1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/coin_ynh.git synced 2024-09-03 18:16:26 +02:00
coin_ynh/scripts/restore

79 lines
2.7 KiB
Text
Raw Normal View History

2017-04-09 11:05:39 +02:00
#!/bin/bash
2022-09-03 00:23:04 +02:00
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
2019-08-23 16:08:03 +02:00
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
2022-03-13 23:43:18 +01:00
# RESTORE THE APP MAIN DIR
2019-08-23 16:08:03 +02:00
#=================================================
2022-09-03 00:23:04 +02:00
ynh_script_progression --message="Restoring the app main directory..." --weight=1
2022-03-13 23:43:18 +01:00
2023-12-16 15:11:09 +01:00
ynh_restore_file --origin_path="$install_dir"
2019-08-23 16:08:03 +02:00
2023-12-16 15:11:09 +01:00
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2022-09-03 00:23:04 +02:00
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2019-08-23 16:08:03 +02:00
2022-09-04 16:11:02 +02:00
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
2019-08-23 16:08:03 +02:00
2022-09-03 00:23:04 +02:00
#=================================================
# PYTHON DEPENDENCIES
#=================================================
2023-12-16 15:11:09 +01:00
ynh_script_progression --message="Reinstalling venv..." --weight=1
2022-09-03 00:23:04 +02:00
2023-12-16 15:11:09 +01:00
ynh_secure_remove --file="${install_dir}/venv"
pushd "$install_dir"
python3 -m venv venv
venv/bin/pip install --upgrade pip
venv/bin/pip install gunicorn
#echo "django-auth-ldap<1.4" >> $install_dir/requirements.txt
venv/bin/pip install -r requirements.txt
2022-09-03 00:23:04 +02:00
popd
2022-09-04 16:11:02 +02:00
#=================================================
2022-03-13 23:43:18 +01:00
# CONFIGURE LOG DIR
2022-09-04 16:11:02 +02:00
#=================================================
2022-03-13 23:43:18 +01:00
mkdir -p /var/log/$app
2023-12-16 15:11:09 +01:00
chown -R $app:www-data /var/log/$app
2019-08-23 16:08:03 +02:00
#=================================================
2023-12-16 15:11:09 +01:00
# RESTORE SYSTEMD
2019-08-23 16:08:03 +02:00
#=================================================
2023-12-16 15:11:09 +01:00
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
2019-08-23 16:08:03 +02:00
2022-03-13 23:43:18 +01:00
yunohost service add $app --description "$app daemon" --log="/var/log/$app/$app.log"
2019-08-23 16:08:03 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2022-09-03 00:23:04 +02:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
2019-08-23 16:08:03 +02:00
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# GENERIC FINALIZATION
#=================================================
2019-08-24 17:35:13 +02:00
# RELOAD NGINX
2019-08-23 16:08:03 +02:00
#=================================================
2022-09-03 00:23:04 +02:00
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
2019-08-23 16:08:03 +02:00
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
2022-09-03 00:23:04 +02:00
ynh_script_progression --message="Restoration completed for $app" --last