Commit 955b328d authored by Spctrl's avatar Spctrl

small fixes

parent 4e000781
......@@ -106,7 +106,7 @@ cat $final_path/pleroma/config/setup_db.psql | grep "<%= .* %>" && ynh_die "$fin
# CREATE A POSTGRESQL DATABASE
#=================================================
# Fail installation if database already exists.
! su - postgres -c "psql -lqt" | cut -d \| -f 1 | grep -ws pleroma_dev || ynh_die 'The database pleroma_dev already exists'
! su - postgres -c "psql -lqt" | cut -d \| -f 1 | grep -ws $db_name || ynh_die 'The database $db_name already exists'
chmod +x $final_path/pleroma/config/setup_db.psql
su - postgres -c "psql -f $final_path/pleroma/config/setup_db.psql"
......@@ -123,7 +123,7 @@ su - $app -c "cd $final_path/pleroma;mix local.rebar --force;mix local.hex --for
if ! [ $is_public -eq 1 ]
then
ynh_replace_string " registrations_open: true," " registrations_open: false," "$final_path/pleroma/config/prod.secret.exs"
ynh_replace_string " registrations_open: true" " registrations_open: false" "$final_path/pleroma/config/prod.secret.exs"
fi
#=================================================
......@@ -132,7 +132,7 @@ fi
# the tasks fails, so I have to set the the pasword for the postgresql DB-user first.
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
su - $app -c "cd $final_path/pleroma; MIX_ENV=prod mix local.hex --force; MIX_ENV=prod mix register_user $admin_user $admin_user $admin_mail "Admin of this instance" $admin_password; MIX_ENV=prod mix set_moderator $admin_user true;"
su - $app -c "cd $final_path/pleroma; MIX_ENV=prod mix local.hex --force; MIX_ENV=prod mix register_user $admin_user $admin_user $admin_mail 'Moderator of this instance' $admin_password; MIX_ENV=prod mix set_moderator $admin_user true;"
#=================================================
# NGINX CONFIGURATION
......
......@@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
final_path=$(ynh_app_setting_get $app final_path)
port=$(ynh_app_setting_get $app port)
db_name=$(ynh_app_setting_get $app db_name)
#=================================================
# STANDARD REMOVE
......@@ -27,7 +28,7 @@ port=$(ynh_app_setting_get $app port)
# Remove the dedicated systemd config
ynh_remove_systemd_config
systemctl disable pleroma
systemctl disable $app
rm /etc/systemd/system/$app.service
rm /etc/systemd/system/$app.service.d
rm /usr/lib/systemd/system/$app.service
......@@ -49,20 +50,20 @@ fi
# TODO: I wrote this in a script an ran that, but it failed and I don't know why, so I 'fixed' it like this.
su - postgres -c "
touch drop_$app_db.psql
> drop_$app_db.psql
echo 'SELECT pg_terminate_backend(pg_stat_activity.pid)' >> drop_$app_db.psql
echo FROM pg_stat_activity >> drop_$app_db.psql
echo WHERE pg_stat_activity.datname = \'pleroma_dev\' >> drop_$app_db.psql
echo ' AND pid <> pg_backend_pid();' >> drop_$app_db.psql
echo 'REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM pleroma;' >> drop_$app_db.psql
echo 'REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public FROM pleroma;' >> drop_$app_db.psql
echo 'REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public FROM pleroma;' >> drop_$app_db.psql
echo 'REVOKE ALL PRIVILEGES ON SCHEMA public FROM pleroma;' >> drop_$app_db.psql
echo 'DROP DATABASE IF EXISTS pleroma_dev;' >> drop_$app_db.psql
echo 'DROP USER pleroma;' >> drop_$app_db.psql
psql -f drop_$app_db.psql
rm drop_$app_db.psql
touch drop_$db_name.psql
> drop_$db_name.psql
echo 'SELECT pg_terminate_backend(pg_stat_activity.pid)' >> drop_$db_name.psql
echo FROM pg_stat_activity >> drop_$db_name.psql
echo WHERE pg_stat_activity.datname = \'$db_name\' >> drop_$db_name.psql
echo ' AND pid <> pg_backend_pid();' >> drop_$db_name.psql
echo 'REVOKE ALL PRIVILEGES ON ALL TABLES IN db_name public FROM $app;' >> drop_$db_name.psql
echo 'REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public FROM $app;' >> drop_$db_name.psql
echo 'REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public FROM $app;' >> drop_$db_name.psql
echo 'REVOKE ALL PRIVILEGES ON SCHEMA public FROM $app;' >> drop_$db_name.psql
echo 'DROP DATABASE IF EXISTS $db_name;' >> drop_$db_name.psql
echo 'DROP USER $app;' >> drop_$db_name.psql
psql -f drop_$db_name.psql
rm drop_$db_name.psql
"
#=================================================
......
......@@ -30,8 +30,7 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
#db_name=$(ynh_app_setting_get $app db_name)
db_name=pleroma_dev
db_name=$(ynh_app_setting_get $app db_name)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
......@@ -77,7 +76,7 @@ chown -R $app: $final_path
# RESTORE THE POSTGRESQL DATABASE
#=================================================
! su - postgres -c "psql -lqt" | cut -d \| -f 1 | grep -ws pleroma_dev || ynh_die "The database $db_name already exists"
! su - postgres -c "psql -lqt" | cut -d \| -f 1 | grep -ws $db_name || ynh_die "The database $db_name already exists"
chown postgres $final_path/backup
su - postgres -c "psql -f $final_path/pleroma/config/setup_db.psql"
su - postgres -c "psql $db_name < $final_path/backup/$db_name.sql"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment