mirror of
https://github.com/YunoHost-Apps/nodebb_ynh.git
synced 2024-09-03 19:46:29 +02:00
Update restore
This commit is contained in:
parent
64c6841849
commit
b9a93eb973
1 changed files with 68 additions and 33 deletions
|
@ -1,20 +1,26 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Exit on command errors and treat unset variables as an error
|
#=================================================
|
||||||
set -eu
|
# GENERIC START
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ ! -e _common.sh ]; then
|
if [ ! -e _common.sh ]; then
|
||||||
# Fetch helpers file if not in current directory
|
# Get the _common.sh file if it's not in the current directory
|
||||||
sudo cp ../settings/scripts/_common.sh ./_common.sh
|
cp ../settings/scripts/_common.sh ./_common.sh
|
||||||
sudo chmod a+rx _common.sh
|
chmod a+rx _common.sh
|
||||||
fi
|
fi
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -23,69 +29,98 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
path_url=$(ynh_app_setting_get $app path)
|
path_url=$(ynh_app_setting_get $app path)
|
||||||
is_public=$(ynh_app_setting_get $app is_public)
|
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
|
db_name=$(ynh_app_setting_get $app db_name)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
yunohost app checkurl "${domain}${path_url}" -a "$app" \
|
ynh_webpath_available $domain $path_url \
|
||||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||||
test ! -d $final_path \
|
test ! -d $final_path \
|
||||||
|| ynh_die "There is already a directory: $final_path "
|
|| ynh_die "There is already a directory: $final_path "
|
||||||
|
|
||||||
CHECK_FINALPATH # Check if destination directory is not already in use
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORE STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE NGINX CONFIGURATION
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo cp -a ./nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE LOGROTATE CONFIGURATION
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo cp -a ./logrotate /etc/logrotate.d/$app
|
ynh_restore_file "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE APP MAIN DIR
|
# RECREATE THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo cp -a ./sources/. $final_path
|
# Create the dedicated user (if not existing)
|
||||||
|
ynh_system_user_create $app
|
||||||
#=================================================
|
|
||||||
# RECREATE OF THE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_system_user_create $app # Recreate the dedicated user, if not existing
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# RESTORE USER RIGHTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo chown -R $app: $final_path
|
# Restore permissions on app files
|
||||||
|
chown -R $app:$app $final_path
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC RESTORATION
|
||||||
|
#=================================================
|
||||||
|
# REINSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
|
||||||
|
echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.6 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
|
||||||
|
sudo apt-get update
|
||||||
|
ynh_install_app_dependencies mongodb-org
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE MYSQL DATABASE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
pushd $final_path
|
||||||
|
datebackup=$(ynh_app_setting_get $app datebackup)
|
||||||
|
mongorestore mongo_backup$datebackup/
|
||||||
|
ynh_secure_remove mongo_backup$datebackup/
|
||||||
|
popd
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
yunohost service add $app --log "/var/log/$app/APP.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL NODEJS
|
# INSTALL NODEJS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_install_nodejs $NODEJS_VERSION
|
ynh_install_nodejs $NODEJS_VERSION
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD CONFIGURATION
|
# RESTORE SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
sudo cp -a ./systemd.service "/etc/systemd/system/$app.service"
|
|
||||||
sudo systemctl enable $app
|
ynh_restore_file "/etc/systemd/system/$app.service"
|
||||||
sudo systemctl daemon-reload
|
systemctl enable $app.service
|
||||||
sudo systemctl start $app
|
systemctl start $app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_restore_file "/etc/logrotate.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX AND PHP-FPM
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo systemctl reload nginx
|
systemctl reload php5-fpm
|
||||||
|
systemctl reload nginx
|
||||||
|
|
Loading…
Add table
Reference in a new issue