Browse Source
Complete refactoring
Complete refactoring
* Refactoring * Fix typos and code spacing * Change user grouppull/17/head
committed by
JimboJoe
9 changed files with 870 additions and 285 deletions
-
24check_process
-
14conf/nginx.conf
-
387conf/php-fpm.conf
-
10manifest.json
-
64scripts/backup
-
204scripts/install
-
95scripts/remove
-
162scripts/restore
-
195scripts/upgrade
@ -1,31 +1,55 @@ |
|||||
#!/bin/bash |
#!/bin/bash |
||||
|
|
||||
# Exit on command errors and treat unset variables as an error |
|
||||
|
#================================================= |
||||
|
# GENERIC START |
||||
|
#================================================= |
||||
|
# MANAGE SCRIPT FAILURE |
||||
|
#================================================= |
||||
|
|
||||
|
# Exit on command errors and treat access to unset variables as an error |
||||
set -eu |
set -eu |
||||
|
|
||||
# Get multi-instances specific variables |
|
||||
|
#================================================= |
||||
|
# IMPORT GENERIC HELPERS |
||||
|
#================================================= |
||||
|
|
||||
|
source /usr/share/yunohost/helpers |
||||
|
|
||||
|
#================================================= |
||||
|
# LOAD SETTINGS |
||||
|
#================================================= |
||||
|
|
||||
app=$YNH_APP_INSTANCE_NAME |
app=$YNH_APP_INSTANCE_NAME |
||||
|
|
||||
# Source app helpers |
|
||||
. /usr/share/yunohost/helpers |
|
||||
|
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) |
||||
|
with_mysql=$(ynh_app_setting_get $app with_mysql) |
||||
|
|
||||
|
#================================================= |
||||
|
# STANDARD BACKUP STEPS |
||||
|
#================================================= |
||||
|
# BACKUP THE APP MAIN DIR |
||||
|
#================================================= |
||||
|
|
||||
|
ynh_backup "$final_path" |
||||
|
|
||||
|
#================================================= |
||||
|
# BACKUP THE NGINX CONFIGURATION |
||||
|
#================================================= |
||||
|
|
||||
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" |
||||
|
|
||||
# Retrieve app settings |
|
||||
domain=$(ynh_app_setting_get "$app" domain) |
|
||||
path=$(ynh_app_setting_get "$app" path) |
|
||||
with_mysql=$(ynh_app_setting_get "$app" with_mysql) |
|
||||
|
#================================================= |
||||
|
# BACKUP THE PHP-FPM CONFIGURATION |
||||
|
#================================================= |
||||
|
|
||||
# Copy the app files |
|
||||
DESTDIR="/var/www/${app}" |
|
||||
ynh_backup "$DESTDIR" "sources" 1 |
|
||||
|
ynh_backup "/etc/php5/fpm/pool.d/$app.conf" |
||||
|
|
||||
# Copy the conf files |
|
||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "conf/nginx.conf" |
|
||||
ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "conf/php-fpm.conf" |
|
||||
|
#================================================= |
||||
|
# BACKUP THE MYSQL DATABASE |
||||
|
#================================================= |
||||
|
|
||||
# Dump the database |
|
||||
if [[ $with_mysql -eq 1 ]]; then |
|
||||
dbname=$app |
|
||||
dbuser=$app |
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd) |
|
||||
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql |
|
||||
|
if [ $with_mysql -eq 1 ]; then |
||||
|
ynh_mysql_dump_db "$db_name" > db.sql |
||||
fi |
fi |
||||
@ -1,40 +1,71 @@ |
|||||
#!/bin/bash |
#!/bin/bash |
||||
|
|
||||
# Get multi-instances specific variables |
|
||||
|
#================================================= |
||||
|
# GENERIC START |
||||
|
#================================================= |
||||
|
# IMPORT GENERIC HELPERS |
||||
|
#================================================= |
||||
|
|
||||
|
source /usr/share/yunohost/helpers |
||||
|
|
||||
|
#================================================= |
||||
|
# LOAD SETTINGS |
||||
|
#================================================= |
||||
|
|
||||
app=$YNH_APP_INSTANCE_NAME |
app=$YNH_APP_INSTANCE_NAME |
||||
app_nb=$YNH_APP_INSTANCE_NUMBER |
|
||||
|
|
||||
# Source app helpers |
|
||||
. /usr/share/yunohost/helpers |
|
||||
|
|
||||
# Retrieve app settings |
|
||||
domain=$(ynh_app_setting_get "$app" domain) |
|
||||
with_mysql=$(ynh_app_setting_get "$app" with_mysql) |
|
||||
user=$(ynh_app_setting_get "$app" user) |
|
||||
|
|
||||
# Drop MySQL database and user as needed |
|
||||
if [[ $with_mysql -eq 1 ]]; then |
|
||||
dbname=$app |
|
||||
dbuser=$app |
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd) |
|
||||
ynh_mysql_drop_db $dbname || true |
|
||||
ynh_mysql_drop_user $dbuser || true |
|
||||
|
|
||||
|
domain=$(ynh_app_setting_get $app domain) |
||||
|
with_mysql=$(ynh_app_setting_get $app with_mysql) |
||||
|
user=$(ynh_app_setting_get $app user) |
||||
|
db_name=$(ynh_app_setting_get $app db_name) |
||||
|
final_path=$(ynh_app_setting_get $app final_path) |
||||
|
|
||||
|
#================================================= |
||||
|
# STANDARD REMOVE |
||||
|
#================================================= |
||||
|
# REMOVE THE MYSQL DATABASE |
||||
|
#================================================= |
||||
|
|
||||
|
if [ $with_mysql -eq 1 ]; then |
||||
|
# Remove a database if it exists, along with the associated user |
||||
|
ynh_mysql_remove_db $db_name $db_name |
||||
fi |
fi |
||||
|
|
||||
# Delete app directory and configurations |
|
||||
sudo rm -rf "/var/www/${app}" |
|
||||
sudo rm -f "/etc/php5/fpm/pool.d/${app}.conf" |
|
||||
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf" |
|
||||
|
#================================================= |
||||
|
# REMOVE APP MAIN DIR |
||||
|
#================================================= |
||||
|
|
||||
|
# Remove the app directory securely |
||||
|
ynh_secure_remove "$final_path" |
||||
|
|
||||
|
#================================================= |
||||
|
# REMOVE NGINX CONFIGURATION |
||||
|
#================================================= |
||||
|
|
||||
|
# Remove the dedicated nginx config |
||||
|
ynh_remove_nginx_config |
||||
|
|
||||
|
#================================================= |
||||
|
# REMOVE PHP-FPM CONFIGURATION |
||||
|
#================================================= |
||||
|
|
||||
|
# Remove the dedicated php-fpm config |
||||
|
ynh_remove_fpm_config |
||||
|
|
||||
|
#================================================= |
||||
|
# SPECIFIC REMOVE |
||||
|
#================================================= |
||||
|
# REMOVE THE CUSTOM SSH CONFIG |
||||
|
#================================================= |
||||
|
|
||||
# Remove custom SSH configuration |
|
||||
sudo sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config |
|
||||
|
sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config |
||||
|
systemctl reload ssh |
||||
|
|
||||
# Reload services |
|
||||
sudo systemctl restart php5-fpm || true |
|
||||
sudo systemctl reload nginx || true |
|
||||
sudo systemctl reload ssh |
|
||||
|
#================================================= |
||||
|
# GENERIC FINALIZATION |
||||
|
#================================================= |
||||
|
# REMOVE DEDICATED USER |
||||
|
#================================================= |
||||
|
|
||||
# Remove the user account |
|
||||
id "$user" >/dev/null 2>&1 \ |
|
||||
&& sudo deluser --quiet --force "$user" >/dev/null \ |
|
||||
|| true |
|
||||
|
# Delete an user |
||||
|
ynh_system_user_delete $user |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue