mirror of
https://github.com/YunoHost-Apps/outline_ynh.git
synced 2024-09-03 19:56:12 +02:00
93 lines
3.7 KiB
Bash
Executable file
93 lines
3.7 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
|
source ../settings/scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# CHECK IF DEX IS INSTALLED, IF NOT INSTALL IT
|
|
#=================================================
|
|
ynh_script_progression "Installing Dex if needed..."
|
|
|
|
if ! yunohost app list | grep -q "id: $dex_app"; then
|
|
echo "Dex is not installed. Installing... "
|
|
yunohost tools update
|
|
if yunohost app list | grep -q "$dex_domain$dex_path"; then
|
|
ynh_die "The domain provided for Dex is already used by another app. Please chose another one !"
|
|
fi
|
|
yunohost app install https://github.com/YunoHost-Apps/dex_ynh/tree/ccc5b82dc9762b42abe82dfa0582e6e4bb6175c5 --force --args "domain=$dex_domain&path=$dex_path&oidc_name=$oidc_name&oidc_secret=$oidc_secret&oidc_callback=$oidc_callback"
|
|
fi
|
|
|
|
#=================================================
|
|
# RESTORE THE APP MAIN DIR
|
|
#=================================================
|
|
ynh_script_progression "Restoring the app main directory..."
|
|
|
|
ynh_restore "$install_dir"
|
|
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
|
|
#=================================================
|
|
# RESTORE LOCAL STORAGE
|
|
#=================================================
|
|
ynh_script_progression "Restoring the app local storage..."
|
|
|
|
ynh_restore "/var/lib/outline"
|
|
|
|
chmod -R o-rwx "/var/lib/outline"
|
|
chown -R $app:www-data "/var/lib/outline"
|
|
|
|
#=================================================
|
|
# RESTORE THE POSTGRESQL DATABASE
|
|
#=================================================
|
|
ynh_script_progression "Restoring the PostgreSQL database..."
|
|
|
|
ynh_psql_db_shell < "./db.sql""
|
|
|
|
#=================================================
|
|
# SPECIFIC RESTORATION
|
|
#=================================================
|
|
# REINSTALL DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression "Reinstalling dependencies..."
|
|
|
|
# Install nodejs
|
|
ynh_nodejs_install 2>&1
|
|
|
|
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
ynh_restore "/etc/systemd/system/$app.service"
|
|
systemctl enable $app.service --quiet
|
|
|
|
ynh_restore "/etc/logrotate.d/$app"
|
|
|
|
ynh_restore "/var/log/$app/$app.log"
|
|
|
|
ynh_restore "/etc/cron.d/$app"
|
|
|
|
yunohost service add $app --description="Outline server" --log="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# UPDATING A CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression "Updating the configuration file..."
|
|
|
|
ynh_config_add --template=".env" --destination="$install_dir/.env"
|
|
|
|
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/.env"
|
|
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/.env"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression "Starting $app's systemd service..."
|
|
|
|
ynh_systemctl --service=$app --action="start" --log_path="systemd"
|
|
|
|
ynh_systemctl --service=nginx --action=reload
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression "Restoration completed for $app"
|