X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;ds=sidebyside;f=buster%2Fsetup_scripts%2Frestore_app.sh;h=817c07d1a062988c597184af43dbb921abf2236e;hb=1051f875935af7ecda03a8164013c8849039d92a;hp=46e958796d8663af8781a903335a6e595e6faf84;hpb=6d9f8977e3cf474d95b8e19a62fab15ecfb676de;p=config
diff --git a/buster/setup_scripts/restore_app.sh b/buster/setup_scripts/restore_app.sh
index 46e9587..817c07d 100755
--- a/buster/setup_scripts/restore_app.sh
+++ b/buster/setup_scripts/restore_app.sh
@@ -6,24 +6,33 @@ if [ "$#" -lt 2 ]; then
echo 'Need two arguments: service name and DB name.'
false
fi
-if [ ! "$1" = "pleroma" ] && [ ! "$1" = "peertube" ]; then
- echo "Need legal service name (pleroma or peertube)."
+if [ ! "$1" = "pleroma_otp" ] && [ ! "$1" = "pleroma_source" ] && [ ! "$1" = "peertube" ]; then
+ echo "Need legal service name (pleroma_otp or pleroma_source or peertube)."
false
fi
app="$1"
db_name="$2"
+service="$1"
+if [ "${app}" = "pleroma_source" ] || [ "${app}" = "pleroma_otp" ]; then
+ service=pleroma
+fi
-service "${app}" stop
+service "${service}" stop
-mv "/home/plom/${app}_backup.tar" /tmp/
+mv "/home/plom/${service}_backup.tar" /tmp/
cd /tmp
-tar xf "${app}_backup.tar"
+tar xf "${service}_backup.tar"
-su postgres -c "pg_restore -c -1 -d ${db_name} ${app}_backup/${db_name}.pgdump"
-rm "${app}_backup/${db_name}.pgdump"
+su postgres -c "pg_restore -c -1 -d ${db_name} ${service}_backup/${db_name}.pgdump"
+rm "${service}_backup/${db_name}.pgdump"
-cd "${app}_backup"
+cd "${service}_backup"
for path in $(find . -type f); do
+ if [ "${app}" = "pleroma_source" ]; then
+ if [ "${path}" = './opt/pleroma/config/prod.secret.exs' ]; then
+ continue # skip file that contains passwords
+ fi
+ fi
target_path=$(echo "${path}" | cut -c2-)
source_path=$(realpath "${path}")
dir=$(dirname "${target_path}")
@@ -32,11 +41,13 @@ for path in $(find . -type f); do
done
# TODO: Horrible hack, improve.
-if [ "${app}" = "pleroma" ]; then
+if [ "${app}" = "pleroma_otp" ]; then
db_pw=$(cat /etc/pleroma/config.exs | grep password | sed 's/[ ]*password\: *//g' | sed 's/,//g' | sed 's/"//g')
elif [ "${app}" = "peertube" ]; then
db_pw=$(cat /var/www/peertube/config/production.yaml | grep password | head -1 | sed "s/[ ]*password\: *//g" | sed "s/'//g")
fi
-su postgres -lc "psql -c \"ALTER USER ${app} WITH PASSWORD '${db_pw}';\""
+if [ "${app}" = "pleroma_otp" ] || [ "${app}" = "peertube" ]; then
+ su postgres -lc "psql -c \"ALTER USER ${service} WITH PASSWORD '${db_pw}';\""
+fi
-service "${app}" stop
+service "${service}" start