Quellcode durchsuchen

moved initialize_couchdb into _common.sh

and replaced it in install and upgrade by a function call
Chris Vogel vor 1 Jahr
Ursprung
Commit
e1ec0e97e1
4 geänderte Dateien mit 19 neuen und 47 gelöschten Zeilen
  1. 16 0
      scripts/_common.sh
  2. 0 25
      scripts/change_url
  3. 2 11
      scripts/install
  4. 1 11
      scripts/upgrade

+ 16 - 0
scripts/_common.sh

@@ -120,6 +120,22 @@ flohmarkt_ynh_up_inst_couchdb() {
           --package="couchdb"
           --package="couchdb"
 }
 }
 
 
+# (re)initialise database during install and upgrade
+flohmarkt_ynh_initialize_couchdb() {
+    # run in a sub shell to not source the venv activate to the rest of the script
+    (
+        set +o nounset
+        source "$flohmarkt_venv_dir/bin/activate"
+        set -o nounset
+        # change directory to where flohmarkt.conf is located
+        cd $flohmarkt_app_dir
+        # initialize_couchdb seems to re-try on connect problems endlessly blocking the yunohost api
+        # give it 45 seconds to finish and then fail
+        # https://codeberg.org/ChriChri/flohmarkt_ynh/issues/13
+        timeout 45 python3 initialize_couchdb.py $password_couchdb_admin
+    )
+}
+
 flohmarkt_ynh_dump_couchdb() {
 flohmarkt_ynh_dump_couchdb() {
   ../settings/scripts/couchdb-dump/couchdb-dump.sh -b -H 127.0.0.1 -d "${app}" \
   ../settings/scripts/couchdb-dump/couchdb-dump.sh -b -H 127.0.0.1 -d "${app}" \
     -q -u admin -p "${password_couchdb_admin}" -f "${YNH_CWD}/${app}.json"
     -q -u admin -p "${password_couchdb_admin}" -f "${YNH_CWD}/${app}.json"

+ 0 - 25
scripts/change_url

@@ -1,25 +0,0 @@
-#!/bin/bash
-
-#=================================================
-# GENERIC STARTING
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
-source _common.sh
-source /usr/share/yunohost/helpers
-
-#=================================================
-# STANDARD MODIFICATIONS
-#=================================================
-# MODIFY URL IN NGINX CONF
-#=================================================
-ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
-
-ynh_change_url_nginx_config
-
-#=================================================
-# END OF SCRIPT
-#=================================================
-
-ynh_script_progression --message="Change of URL completed for $app" --last

+ 2 - 11
scripts/install

@@ -17,7 +17,7 @@ then
 fi
 fi
 
 
 # INITIALIZE AND STORE SETTINGS
 # INITIALIZE AND STORE SETTINGS
-# todo: do we need to store the password un-encrypted somewhere on the system?
+# TODO: do we need to store the password un-encrypted somewhere on the system?
 # → there's no way to get the admin password later if sometimes in the future deleting
 # → there's no way to get the admin password later if sometimes in the future deleting
 #   the app will delete its specific database only (instead of the whole couchdb server as
 #   the app will delete its specific database only (instead of the whole couchdb server as
 #   of now in the earliest versions of the integration).
 #   of now in the earliest versions of the integration).
@@ -76,16 +76,7 @@ ynh_add_config --template="../conf/flohmarkt.conf" --destination="$flohmarkt_app
 # setup couchdb
 # setup couchdb
 ynh_script_progression --message="Setup couchdb database and user for flohmarkt..." --weight=2
 ynh_script_progression --message="Setup couchdb database and user for flohmarkt..." --weight=2
 flohmarkt_ynh_check_old_couchdb
 flohmarkt_ynh_check_old_couchdb
-(
-    set +o nounset
-    source "$flohmarkt_venv_dir/bin/activate"
-    set -o nounset
-    cd "$flohmarkt_app_dir"
-    # initialize_couchdb seems to re-try on connect problems endlessly blocking the yunohost api
-    # give it 45 seconds to finish and then fail
-    # https://codeberg.org/ChriChri/flohmarkt_ynh/issues/13
-    timeout 45 python3 initialize_couchdb.py $password_couchdb_admin
-)
+flohmarkt_ynh_initialize_couchdb
 
 
 # SETUP LOGROTATE
 # SETUP LOGROTATE
 ynh_script_progression --message="Configuring log rotation..." --weight=2
 ynh_script_progression --message="Configuring log rotation..." --weight=2

+ 1 - 11
scripts/upgrade

@@ -59,17 +59,7 @@ ynh_script_progression --message="Upgrading flohmarkt configuration..." --weight
 ynh_add_config --template="../conf/flohmarkt.conf" --destination="$flohmarkt_app_dir/flohmarkt.conf"
 ynh_add_config --template="../conf/flohmarkt.conf" --destination="$flohmarkt_app_dir/flohmarkt.conf"
 
 
 ynh_script_progression --message="Upgrading flohmarkt couchdb..." --weight=10
 ynh_script_progression --message="Upgrading flohmarkt couchdb..." --weight=10
-# run initialize_couchdb.py
-(
-    set +o nounset
-    source "$flohmarkt_venv_dir/bin/activate"
-    set -o nounset
-    cd "$flohmarkt_app_dir"
-    # initialize_couchdb seems to re-try on connect problems endlessly blocking the yunohost api
-    # give it 45 seconds to finish and then fail
-    # https://codeberg.org/ChriChri/flohmarkt_ynh/issues/13
-    timeout 45 python3 initialize_couchdb.py $password_couchdb_admin $password_couchdb_flohmarkt
-)
+flohmarkt_ynh_initialize_couchdb
 
 
 # set file permissions for install dir
 # set file permissions for install dir
 flohmarkt_ynh_set_permission
 flohmarkt_ynh_set_permission