5 if [ "$#" -lt 2 ]; then
6 echo 'Need two arguments: service name and DB name.'
9 if [ ! "$1" = "pleroma_otp" ] && [ ! "$1" = "pleroma_sourc" ] && [ ! "$1" = "peertube" ]; then
10 echo "Need legal service name (pleroma_otp or pleroma_source or peertube)."
18 mv "/home/plom/${app}_backup.tar" /tmp/
20 tar xf "${app}_backup.tar"
22 su postgres -c "pg_restore -c -1 -d ${db_name} ${app}_backup/${db_name}.pgdump"
23 rm "${app}_backup/${db_name}.pgdump"
26 for path in $(find . -type f); do
27 if [ "${app}" = "pleroma_source" ]; then
28 if [ "${path}" = '/opt/pleroma/config/prod.secret.exs' ]; then
29 continue # skip file that contains passwords
32 target_path=$(echo "${path}" | cut -c2-)
33 source_path=$(realpath "${path}")
34 dir=$(dirname "${target_path}")
36 cp -a "${source_path}" "${target_path}"
39 # TODO: Horrible hack, improve.
40 if [ "${app}" = "pleroma_otp" ]; then
41 db_pw=$(cat /etc/pleroma/config.exs | grep password | sed 's/[ ]*password\: *//g' | sed 's/,//g' | sed 's/"//g')
42 elif [ "${app}" = "peertube" ]; then
43 db_pw=$(cat /var/www/peertube/config/production.yaml | grep password | head -1 | sed "s/[ ]*password\: *//g" | sed "s/'//g")
45 su postgres -lc "psql -c \"ALTER USER ${app} WITH PASSWORD '${db_pw}';\""
47 service "${app}" start