فهرست منبع

Merge branch 'testing' of https://github.com/YunoHost-Apps/flohmarkt_ynh into testing

Éric Gaspar 1 سال پیش
والد
کامیت
27920e6cfc
7فایلهای تغییر یافته به همراه55 افزوده شده و 63 حذف شده
  1. 0 2
      conf/05-flohmarkt.ini
  2. 0 1
      conf/flohmarkt.conf
  3. 2 0
      conf/systemd.service
  4. 36 1
      scripts/_common.sh
  5. 6 18
      scripts/install
  6. 3 22
      scripts/restore
  7. 8 19
      scripts/upgrade

+ 0 - 2
conf/05-flohmarkt.ini

@@ -1,5 +1,3 @@
 [chttpd]
 [chttpd]
 ; prevent non admin users to be able to access the list of all databases
 ; prevent non admin users to be able to access the list of all databases
 admin_only_all_dbs = true
 admin_only_all_dbs = true
-
-; port = __##PORT_COUCHDB__

+ 0 - 1
conf/flohmarkt.conf

@@ -10,7 +10,6 @@ UseHttps = 0
 Host = 127.0.0.1
 Host = 127.0.0.1
 User = __APP__
 User = __APP__
 Password = __PASSWORD_COUCHDB_FLOHMARKT__
 Password = __PASSWORD_COUCHDB_FLOHMARKT__
-# Port = __##PORT_COUCHDB__
 Port = 5984
 Port = 5984
 Database = __APP__
 Database = __APP__
 
 

+ 2 - 0
conf/systemd.service

@@ -9,6 +9,8 @@ Group=__APP__
 WorkingDirectory=__FLOHMARKT_APP_DIR__
 WorkingDirectory=__FLOHMARKT_APP_DIR__
 Environment="VENV_DIR=__FLOHMARKT_VENV_DIR__"
 Environment="VENV_DIR=__FLOHMARKT_VENV_DIR__"
 ExecStart=/bin/bash -c "__FLOHMARKT_VENV_DIR__/bin/uvicorn --host 127.0.0.1 --port __PORT__ flohmarkt.web:start  2>&1 | /usr/bin/ts '%%Y-%%m-%%d %%H:%%M:%%S'"
 ExecStart=/bin/bash -c "__FLOHMARKT_VENV_DIR__/bin/uvicorn --host 127.0.0.1 --port __PORT__ flohmarkt.web:start  2>&1 | /usr/bin/ts '%%Y-%%m-%%d %%H:%%M:%%S'"
+Restart=on-failure
+RestartSec=5s 
 # nicer logfile naming https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/38
 # nicer logfile naming https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/38
 StandardOutput=append:__FLOHMARKT_LOGFILE__
 StandardOutput=append:__FLOHMARKT_LOGFILE__
 StandardError=inherit
 StandardError=inherit

+ 36 - 1
scripts/_common.sh

@@ -53,14 +53,49 @@ flohmarkt_ynh_set_permission() {
   chmod g-w,o-rwx -R "$flohmarkt_install"
   chmod g-w,o-rwx -R "$flohmarkt_install"
 }
 }
 
 
+# start flohmarkt service
 flohmarkt_ynh_start_service() {
 flohmarkt_ynh_start_service() {
   ynh_systemd_action --service_name=$flohmarkt_filename --action="start"  \
   ynh_systemd_action --service_name=$flohmarkt_filename --action="start"  \
     --line_match='INFO: *Application startup complete.' --log_path="$flohmarkt_logfile" \
     --line_match='INFO: *Application startup complete.' --log_path="$flohmarkt_logfile" \
     --timeout=30
     --timeout=30
 }
 }
 
 
+# stop flohmarkt service
 flohmarkt_ynh_stop_service() {
 flohmarkt_ynh_stop_service() {
-  ynh_systemd_action --service_name=$app --action="stop"
+  ynh_systemd_action --service_name=$flohmarkt_filename --action="stop"
+}
+
+# start couchdb and wait for success
+flohmarkt_ynh_start_couchdb() {
+  ynh_systemd_action --service_name=couchdb --action="start" --timeout=30 \
+    --log_path="/var/log/couchdb/couchdb.log" \
+    --line_match='Apache CouchDB has started on http://127.0.0.1'
+}
+
+# stop couchdb
+flohmarkt_ynh_stop_couchdb() {
+  ynh_systemd_action --service_name=couchdb --action="stop" --timeout=30 \
+    --log_path="/var/log/couchdb/couchdb.log" \
+    --line_match='SIGTERM received - shutting down'
+}
+
+# install or upgrade couchdb
+flohmarkt_ynh_up_inst_couchdb() {
+  echo "\
+  couchdb couchdb/mode select standalone
+  couchdb couchdb/mode seen true
+  couchdb couchdb/bindaddress string 127.0.0.1
+  couchdb couchdb/bindaddress seen true
+  couchdb couchdb/cookie string $couchdb_magic_cookie
+  couchdb couchdb/adminpass password $password_couchdb_admin
+  couchdb couchdb/adminpass seen true
+  couchdb couchdb/adminpass_again password $password_couchdb_admin
+  couchdb couchdb/adminpass_again seen true" | debconf-set-selections
+  DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb
+  ynh_install_extra_app_dependencies \
+          --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \
+          --key="https://couchdb.apache.org/repo/keys.asc" \
+          --package="couchdb"
 }
 }
 
 
 # create venv
 # create venv

+ 6 - 18
scripts/install

@@ -33,22 +33,11 @@ ynh_script_progression --message="Installing CouchDB..." --weight=60
 couchdb_magic_cookie=$(ynh_string_random --length=23 --filter='A-Za-z0-9_')
 couchdb_magic_cookie=$(ynh_string_random --length=23 --filter='A-Za-z0-9_')
 ynh_app_setting_set --app=$app --key=couchdb_magic_cookie --value="$couchdb_magic_cookie"
 ynh_app_setting_set --app=$app --key=couchdb_magic_cookie --value="$couchdb_magic_cookie"
 
 
-echo "\
-couchdb couchdb/mode select standalone
-couchdb couchdb/mode seen true
-couchdb couchdb/bindaddress string 127.0.0.1
-couchdb couchdb/bindaddress seen true
-couchdb couchdb/cookie string $couchdb_magic_cookie
-couchdb couchdb/adminpass password $password_couchdb_admin
-couchdb couchdb/adminpass seen true
-couchdb couchdb/adminpass_again password $password_couchdb_admin
-couchdb couchdb/adminpass_again seen true" | debconf-set-selections
-DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb
-
-ynh_install_extra_app_dependencies \
-    --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \
-    --key="https://couchdb.apache.org/repo/keys.asc" \
-    --package="couchdb"
+# update couchdb dpkg
+flohmarkt_ynh_up_inst_couchdb
+
+# stop couchdb
+flohmarkt_ynh_stop_couchdb
 
 
 # add couchdb configuration
 # add couchdb configuration
 ynh_script_progression --message="Adding a configuration file..." --weight=2
 ynh_script_progression --message="Adding a configuration file..." --weight=2
@@ -58,8 +47,7 @@ chown root:couchdb /opt/couchdb/etc/local.d/05-flohmarkt.ini
 chmod 640 /opt/couchdb/etc/local.d/05-flohmarkt.ini
 chmod 640 /opt/couchdb/etc/local.d/05-flohmarkt.ini
 
 
 # restart couchdb to pick up changes
 # restart couchdb to pick up changes
-systemctl restart couchdb
-systemctl status couchdb
+flohmarkt_ynh_start_couchdb
 
 
 # get flohmarkt
 # get flohmarkt
 # suspecting that this deletes all other sources for YNH_APP_ID
 # suspecting that this deletes all other sources for YNH_APP_ID

+ 3 - 22
scripts/restore

@@ -10,26 +10,8 @@ ynh_restore_file --origin_path="/var/lib/couchdb"
 
 
 # reinstall couchdb
 # reinstall couchdb
 ynh_script_progression --message="Reinstalling couchdb..." --weight=40
 ynh_script_progression --message="Reinstalling couchdb..." --weight=40
-
-echo "\
-couchdb couchdb/mode select standalone
-couchdb couchdb/mode seen true
-couchdb couchdb/bindaddress string 127.0.0.1
-couchdb couchdb/bindaddress seen true
-couchdb couchdb/cookie string $couchdb_magic_cookie
-couchdb couchdb/adminpass password $password_couchdb_admin
-couchdb couchdb/adminpass seen true
-couchdb couchdb/adminpass_again password $password_couchdb_admin
-couchdb couchdb/adminpass_again seen true" | debconf-set-selections
-DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb
-
-ynh_install_extra_app_dependencies \
-    --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \
-    --key="https://couchdb.apache.org/repo/keys.asc" \
-    --package="couchdb"
-
-# stop couchdb
-systemctl stop couchdb
+flohmarkt_ynh_up_inst_couchdb
+flohmarkt_ynh_stop_couchdb
 
 
 # add couchdb configuration
 # add couchdb configuration
 ynh_script_progression --message="Adding a configuration file..." --weight=2
 ynh_script_progression --message="Adding a configuration file..." --weight=2
@@ -38,8 +20,7 @@ chown root:couchdb /opt/couchdb/etc/local.d/05-flohmarkt.ini
 chmod 640 /opt/couchdb/etc/local.d/05-flohmarkt.ini
 chmod 640 /opt/couchdb/etc/local.d/05-flohmarkt.ini
 
 
 # start couchdb
 # start couchdb
-systemctl start couchdb
-systemctl status couchdb
+flohmarkt_ynh_start_couchdb
 
 
 # RESTORE THE APP MAIN DIR
 # RESTORE THE APP MAIN DIR
 ynh_script_progression --message="Restoring the app main directory..." --weight=10
 ynh_script_progression --message="Restoring the app main directory..." --weight=10

+ 8 - 19
scripts/upgrade

@@ -17,7 +17,7 @@ ynh_script_progression --message="Stopping flohmarkt and CouchDB..." --weight=5
 # stop flohmarkt
 # stop flohmarkt
 flohmarkt_ynh_stop_service
 flohmarkt_ynh_stop_service
 # stop couchdb
 # stop couchdb
-ynh_systemd_action --service_name=couchdb --action="stop"
+flohmarkt_ynh_stop_couchdb
 
 
 # Upgrade ynh4 → ynh5, change of paths and filenames
 # Upgrade ynh4 → ynh5, change of paths and filenames
 # https://matrix.to/#/!PauySEslPVuJCJCwlZ:matrix.org/$auU_rSL6MACt9wkyFGlCQbO8ivFlU0ztYW74TimZdcM?via=matrix.org&via=aria-net.org&via=sans-nuage.fr
 # https://matrix.to/#/!PauySEslPVuJCJCwlZ:matrix.org/$auU_rSL6MACt9wkyFGlCQbO8ivFlU0ztYW74TimZdcM?via=matrix.org&via=aria-net.org&via=sans-nuage.fr
@@ -30,21 +30,11 @@ fi
 
 
 # upgrade couchdb
 # upgrade couchdb
 ynh_script_progression --message="Upgrading CouchDB..." --weight=50
 ynh_script_progression --message="Upgrading CouchDB..." --weight=50
-echo "\
-couchdb couchdb/mode select standalone
-couchdb couchdb/mode seen true
-couchdb couchdb/bindaddress string 127.0.0.1
-couchdb couchdb/bindaddress seen true
-couchdb couchdb/cookie string $couchdb_magic_cookie
-couchdb couchdb/adminpass password $password_couchdb_admin
-couchdb couchdb/adminpass seen true
-couchdb couchdb/adminpass_again password $password_couchdb_admin
-couchdb couchdb/adminpass_again seen true" | debconf-set-selections
-DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb
-ynh_install_extra_app_dependencies \
-	--repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \
-	--key="https://couchdb.apache.org/repo/keys.asc" \
-	--package="couchdb"
+flohmarkt_ynh_up_inst_couchdb
+
+# stop couchdb
+ynh_script_progression --message="Stop couchdb before updating configuration file..." --weight=1
+flohmarkt_ynh_stop_couchdb
 
 
 # upgrade couchdb config
 # upgrade couchdb config
 ynh_script_progression --message="Updating couchdb configuration file..." --weight=1
 ynh_script_progression --message="Updating couchdb configuration file..." --weight=1
@@ -52,10 +42,9 @@ ynh_add_config --template="../conf/05-flohmarkt.ini" --destination="/opt/couchdb
 chown root:couchdb /opt/couchdb/etc/local.d/05-flohmarkt.ini
 chown root:couchdb /opt/couchdb/etc/local.d/05-flohmarkt.ini
 chmod 640 /opt/couchdb/etc/local.d/05-flohmarkt.ini
 chmod 640 /opt/couchdb/etc/local.d/05-flohmarkt.ini
 
 
-# start couchdb to pick up changes
+# start couchdb
 ynh_script_progression --message="Starting couchdb..." --weight=1
 ynh_script_progression --message="Starting couchdb..." --weight=1
-ynh_systemd_action --service_name=couchdb --action="start"
-systemctl status couchdb
+flohmarkt_ynh_start_couchdb
 
 
 # install upgrade for flohmarkt
 # install upgrade for flohmarkt
 ynh_script_progression --message="Upgrading flohmarkt..." --weight=4
 ynh_script_progression --message="Upgrading flohmarkt..." --weight=4