1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/my_webapp_ynh.git synced 2024-09-03 19:46:26 +02:00

Add progression with ynh_print_info

This commit is contained in:
Maniack Crudelis 2019-02-17 20:55:53 +01:00
parent d5e9add734
commit 8c2f9fa5c7
5 changed files with 67 additions and 0 deletions

View file

@ -18,6 +18,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -31,18 +32,21 @@ with_mysql=$(ynh_app_setting_get $app with_mysql)
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_print_info "Backing up the main app directory..."
ynh_backup "$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_print_info "Backing up nginx web server configuration..."
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Backing up php-fpm configuration..."
ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
@ -51,5 +55,12 @@ ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
#=================================================
if [ $with_mysql -eq 1 ]; then
ynh_print_info "Backing up the MySQL database..."
ynh_mysql_dump_db "$db_name" > db.sql
fi
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -31,6 +31,7 @@ app_nb=$YNH_APP_INSTANCE_NUMBER
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_print_info "Validating installation parameters..."
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
@ -48,6 +49,7 @@ ynh_webpath_register $app $domain $path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_print_info "Storing installation settings..."
user=webapp${app_nb}
ynh_app_setting_set $app domain $domain
@ -65,6 +67,7 @@ ynh_app_setting_set $app final_path $final_path
#=================================================
if [ $with_mysql -eq 1 ]; then
ynh_print_info "Creating a MySQL database..."
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
ynh_mysql_setup_db $db_name $db_name
@ -73,6 +76,7 @@ fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Configuring nginx web server..."
# Create a dedicated nginx config
ynh_add_nginx_config
@ -80,6 +84,7 @@ ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Configuring system user..."
# Create a standard user (not a system user for sftp)
ynh_system_user_exists "$user" || \
@ -92,6 +97,7 @@ chpasswd <<< "${user}:${password}"
#=================================================
# CONFIGURE SSH
#=================================================
ynh_print_info "Configuring ssh..."
# Harden SSH connection for the user
echo "##-> ${app}
@ -146,6 +152,7 @@ chown root: "$final_path"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Configuring SSOwat..."
# Make app public if necessary
if [ $is_public -eq 1 ]
@ -156,5 +163,12 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Installation of $app completed"

View file

@ -11,6 +11,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -27,6 +28,7 @@ final_path=$(ynh_app_setting_get $app final_path)
#=================================================
if [ $with_mysql -eq 1 ]; then
ynh_print_info "Removing the MySQL database"
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db $db_name $db_name
fi
@ -34,6 +36,7 @@ fi
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_print_info "Removing app main directory"
# Remove the app directory securely
ynh_secure_remove "$final_path"
@ -41,6 +44,8 @@ ynh_secure_remove "$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_print_info "Removing nginx web server configuration"
# Remove the dedicated nginx config
ynh_remove_nginx_config
@ -48,6 +53,7 @@ ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Removing php-fpm configuration"
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
@ -57,6 +63,7 @@ ynh_remove_fpm_config
#=================================================
# REMOVE THE CUSTOM SSH CONFIG
#=================================================
ynh_print_info "Removing the custom ssh config"
sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
systemctl reload ssh
@ -66,6 +73,13 @@ systemctl reload ssh
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_print_info "Removing the dedicated system user"
# Delete an user
ynh_system_user_delete $user
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Removal of $app completed"

View file

@ -18,6 +18,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading settings..."
app=$YNH_APP_INSTANCE_NAME
@ -32,6 +33,7 @@ user=$(ynh_app_setting_get $app user)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_print_info "Validating restoration parameters..."
ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}"
@ -49,6 +51,7 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_print_info "Restoring the app main directory..."
ynh_restore_file "$final_path"
@ -57,6 +60,7 @@ ynh_restore_file "$final_path"
#=================================================
if [ $with_mysql -eq 1 ]; then
ynh_print_info "Restoring the mysql database..."
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_mysql_setup_db $db_name $db_name $db_pwd
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
@ -65,6 +69,7 @@ fi
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_print_info "Recreating the dedicated system user..."
# Create a standard user (not a system user for sftp)
ynh_system_user_exists "$user" || \
@ -93,6 +98,7 @@ ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
#=================================================
# CONFIGURE SSH
#=================================================
ynh_print_info "Configuring ssh..."
# Harden SSH connection for the user
echo "##-> ${app}
@ -112,6 +118,13 @@ systemctl reload ssh
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_print_info "Reloading nginx web server and php-fpm..."
systemctl reload php7.0-fpm
systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Restoration completed for $app"

View file

@ -11,6 +11,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -26,6 +27,7 @@ user=$(ynh_app_setting_get $app user)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_print_info "Ensuring downward compatibility..."
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
@ -51,6 +53,7 @@ fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_print_info "Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
@ -78,6 +81,7 @@ modified_config=$(ynh_backup_if_checksum_is_different "/etc/nginx/conf.d/$domain
# Replace nginx config only if it wasn't modified.
if [ -z "$modified_config" ]
then
ynh_print_info "Upgrading nginx web server configuration..."
# Create a dedicated nginx config
ynh_add_nginx_config
fi
@ -85,6 +89,7 @@ fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Making sure dedicated system user exists..."
# Create a standard user (not a system user for sftp)
ynh_system_user_exists "$user" || \
@ -104,6 +109,7 @@ modified_config=$(ynh_backup_if_checksum_is_different "/etc/php5/fpm/pool.d/$app
# Replace nginx config only if it wasn't modified.
if [ -z "$modified_config" ]
then
ynh_print_info "Upgrading php-fpm configuration..."
# Create a dedicated php-fpm config
ynh_replace_string "__USER__" "$user" "../conf/php-fpm.conf"
ynh_add_fpm_config
@ -114,6 +120,7 @@ fi
#=================================================
# CONFIGURE SSH
#=================================================
ynh_print_info "Configuring ssh..."
# Remove the previous config for upgrading it
sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
@ -143,6 +150,7 @@ chown root: "$final_path"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Upgrading SSOwat configuration..."
# Make app public if necessary
if [ $is_public -eq 1 ]
@ -153,5 +161,12 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Upgrade of $app completed"