Bladeren bron

1st time working backup/restore

:)
Chris Vogel 1 jaar geleden
bovenliggende
commit
935a8e7844
2 gewijzigde bestanden met toevoegingen van 21 en 14 verwijderingen
  1. 15 12
      scripts/_common.sh
  2. 6 2
      scripts/remove

+ 15 - 12
scripts/_common.sh

@@ -99,9 +99,14 @@ flohmarkt_ynh_up_inst_couchdb() {
 }
 
 flohmarkt_ynh_dump_couchdb() {
-  ls -l ../settings/scripts/couchdb-dump/couchdb-dump.sh # debug
   ../settings/scripts/couchdb-dump/couchdb-dump.sh -b -H 127.0.0.1 -d "${app}" \
-    -u admin -p "${password_couchdb_admin}" -f "${YNH_CWD}/${app}.json"
+    -q -u admin -p "${password_couchdb_admin}" -f "${YNH_CWD}/${app}.json"
+}
+
+flohmarkt_ynh_import_couchdb() {
+  ls -l ../settings/scripts/couchdb-dump/couchdb-dump.sh ${YNH_CWD}/${app}.json
+  ../settings/scripts/couchdb-dump/couchdb-dump.sh -r -c -H 127.0.0.1 -d "${app}" \
+    -q -u admin -p "${password_couchdb_admin}" -f "${YNH_CWD}/${app}.json"
 }
 
 flohmarkt_ynh_delete_couchdb_user() {
@@ -116,27 +121,25 @@ flohmarkt_ynh_delete_couchdb_db() {
   curl -s -X DELETE "http://127.0.0.1:5984/${app}" --user "admin:${password_couchdb_admin}"
 }
 
-flohmarkt_ynh_import_couchdb() {
-  ls -l ../settings/scripts/couchdb-dump/couchdb-dump.sh # debug
-  ../settings/scripts/couchdb-dump/couchdb-dump.sh -r -c -H 127.0.0.1 -d "${app}" \
-    -u admin -p "${password_couchdb_admin}" -f "${YNH_CWD}/${app}.json"
-}
-
 flohmarkt_ynh_create_couchdb_user() {
-  curl -X PUT "http://127.0.0.1:5984/_users/org.couchdb.user:${app}" --user "admin:${password_couchdb_admin}"\
+  curl -s -X PUT "http://127.0.0.1:5984/_users/org.couchdb.user:${app}" --user "admin:${password_couchdb_admin}"\
     -H "Accept: application/json" -H "Content-Type: application/json" \
-    -d "\{\"name\": \"${app}\", \"${password_couchdb_flohmarkt}\": \"\", \"roles\": \[\], \"type\": \"user\"\}"
+    -d "{\"name\": \"${app}\", \"password\": \"${password_couchdb_flohmarkt}\", \"roles\": [], \"type\": \"user\"}"
 }
 
 flohmarkt_ynh_couchdb_user_permissions() {
-  curl -X PUT "http://127.0.0.1:5984/${app}/_security" --user "admin:${password_couchdb_admin}"\
+  curl -s -X PUT "http://127.0.0.1:5984/${app}/_security" --user "admin:${password_couchdb_admin}"\
     -H "Accept: application/json" -H "Content-Type: application/json" \
-    -d "\{\"members\":\{\"names\": \[\"${app}\"\],\"roles\": \[\"editor\"\]\}\}"
+    -d "{\"members\":{\"names\": [\"${app}\"],\"roles\": [\"editor\"]}}"
 
 }
 
 flohmarkt_ynh_restore_couchdb() {
   # @@ todo for now we'll make sure dbuser and db do not exist
+  # matrix:
+  # Is there a way to interact with the admin during the scripts/* run?
+  # absolutely not, and it's by design.
+  # at bear minimum if you use the manifest v2 and app helpers, the script should fail.
   flohmarkt_ynh_delete_couchdb_user || true
   flohmarkt_ynh_delete_couchdb_db || true
 

+ 6 - 2
scripts/remove

@@ -31,22 +31,26 @@ fi
 # https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/12
 ynh_script_progression --message="Removing database and database user..." --weight=2
 # remove DB
-flohmarkt_ynh_remove_couchdb
+flohmarkt_ynh_delete_couchdb_db
 # remove DB user for this instance:
-flohmarkt_ynh_delete_dbuser
+flohmarkt_ynh_delete_couchdb_user
 
 # Remove the app-specific logrotate config
+ynh_script_progression --message="Removing logrotate configuration..." --weight=2
 ynh_remove_logrotate
 
 # remove logfiles directory
 # https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/29
 # can only remove a subdir or one file
+ynh_script_progression --message="Removing logfiles..." --weight=2
 ynh_secure_remove --file="${flohmarkt_log_dir}"
 
 # Remove the dedicated NGINX config
+ynh_script_progression --message="Removing nginx configuration..." --weight=2
 ynh_remove_nginx_config
 
 # Remove the dedicated Fail2Ban config
+ynh_script_progression --message="Removing fail2ban configuration..." --weight=2
 ynh_remove_fail2ban_config
 
 # Remove home