1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/redmine_ynh.git synced 2024-09-03 20:16:16 +02:00

Update restore

This commit is contained in:
liberodark 2019-03-22 16:36:55 +01:00 committed by GitHub
parent c0d54efbc5
commit d9f9207e27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,52 +1,100 @@
#!/bin/bash #!/bin/bash
# Note: each files and directories you've saved using the ynh_backup helper #=================================================
# will be located in the current directory, regarding the last argument. # GENERIC START
#=================================================
# Exit on command errors and treat unset variables as an error # IMPORT GENERIC HELPERS
set -eu #=================================================
source _common.sh
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Retrieve old app settings #=================================================
domain=$(ynh_app_setting_get "$app" domain) # MANAGE SCRIPT FAILURE
path_url=$(ynh_app_setting_get "$app" path_url) #=================================================
# Check domain/path availability ynh_clean_setup () {
sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \ #### Remove this function if there's nothing to clean before calling the remove script.
|| ynh_die "Path not available: ${domain}${path_url}" true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Restore sources & data #=================================================
src_path="/var/www/${app}" # LOAD SETTINGS
sudo cp -a ./sources "$src_path" #=================================================
# Restore permissions to app files app=$YNH_APP_INSTANCE_NAME
# you may need to make some file and/or directory writeable by www-data (nginx user)
sudo chown -R root: "$src_path"
### MySQL (remove if not used) ### domain=$(ynh_app_setting_get $app domain)
# If a MySQL database is used: path_url=$(ynh_app_setting_get $app path)
# # Create and restore the database final_path=$(ynh_app_setting_get $app final_path)
# dbname=$app db_name=$(ynh_app_setting_get $app psql_db)
# dbuser=$app db_pwd=$(ynh_app_setting_get $app psqlpwd)
# dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
# ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
# ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql
### MySQL end ###
# Restore NGINX configuration #=================================================
sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" # CHECK IF THE APP CAN BE RESTORED
#=================================================
### PHP (remove if not used) ### ynh_webpath_available $domain $path_url \
# If a dedicated php-fpm process is used: || ynh_die "Path not available: ${domain}${path_url}"
# # Copy PHP-FPM pool configuration and reload the service test ! -d $final_path \
# sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf" || ynh_die "There is already a directory: $final_path "
# sudo service php5-fpm reload
### PHP end ###
# Restart webserver #=================================================
sudo service nginx reload # STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
var_root=/home/yunohost.app/$app
ynh_restore_file "$final_path"
ynh_restore_file "$var_root"
#=================================================
# RESTORE THE psql DATABASE
#=================================================
ynh_psql_test_if_first_run
ynh_psql_create_user $app $db_pwd
ynh_psql_execute_as_root \
"CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $app;"
ynh_psql_execute_file_as_root ./db.sql "$db_name"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
# Create the dedicated user (if not existing)
ynh_system_user_create $app
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chown -R $app: $final_path
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
# Define and install dependencies
ynh_install_app_dependencies postgresql ruby-dev zlib1g-dev libpq-dev
ynh_print_info "Installing Rails & Bunlder..."
gem install rails:5.2.2 bundler:2.0.1
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
systemctl reload nginx