mirror of
https://github.com/YunoHost-Apps/piwigo_ynh.git
synced 2024-09-03 20:06:03 +02:00
Add progression with ynh_print_info
This commit is contained in:
parent
aec1b4027a
commit
56db279bfb
6 changed files with 83 additions and 0 deletions
|
@ -19,6 +19,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -31,30 +32,35 @@ db_name=$(ynh_app_setting_get $app db_name)
|
|||
#=================================================
|
||||
# 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"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info "Backing up the MySQL database..."
|
||||
|
||||
ynh_mysql_dump_db "$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# BACKUP FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Backing up fail2ban configuration..."
|
||||
|
||||
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
|
||||
|
@ -64,9 +70,15 @@ ynh_backup "/etc/fail2ban/filter.d/$app.conf"
|
|||
#=================================================
|
||||
# BACKUP THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_print_info "Backing up data directory..."
|
||||
|
||||
# The 1 parameter indicates the directory is "big",
|
||||
# so that it won't be backed up before upgrade
|
||||
# This argument has to be the third one.
|
||||
ynh_backup "/home/yunohost.app/${app}/upload" "/home/yunohost.app/${app}/upload" 1
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -24,6 +24,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
@ -58,6 +59,7 @@ fi
|
|||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF FILE
|
||||
#=================================================
|
||||
ynh_print_info "Updating nginx web server configuration..."
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
|
@ -88,6 +90,12 @@ fi
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Change of url completed for $app"
|
||||
|
|
|
@ -31,6 +31,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# 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"
|
||||
|
@ -44,6 +45,7 @@ ynh_webpath_register $app $domain $path_url
|
|||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_print_info "Storing installation settings..."
|
||||
|
||||
ynh_app_setting_set $app domain $domain
|
||||
ynh_app_setting_set $app path $path_url
|
||||
|
@ -56,12 +58,14 @@ ynh_app_setting_set $app language $language
|
|||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Installing dependencies..."
|
||||
|
||||
ynh_install_app_dependencies "$pkg_dependencies"
|
||||
|
||||
#=================================================
|
||||
# CREATE A MYSQL DB
|
||||
#=================================================
|
||||
ynh_print_info "Creating a MySQL database..."
|
||||
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
|
@ -70,6 +74,7 @@ ynh_mysql_setup_db $db_name $db_name
|
|||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_print_info "Setting up source files..."
|
||||
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
|
||||
|
@ -85,6 +90,7 @@ ynh_setup_source "$tmpdir/plugins" log_failed_logins_plugin
|
|||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Configuring system user..."
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create $app
|
||||
|
@ -92,6 +98,7 @@ ynh_system_user_create $app
|
|||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Configuring nginx web server..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
@ -131,6 +138,7 @@ ynh_secure_remove "$tmpdir"
|
|||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Configuring php-fpm..."
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config
|
||||
|
@ -138,6 +146,7 @@ ynh_add_fpm_config
|
|||
#=================================================
|
||||
# SETUP APPLICATION WITH CURL
|
||||
#=================================================
|
||||
ynh_print_info "Installing piwigo with Curl..."
|
||||
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
# Reload SSOwat config
|
||||
|
@ -165,6 +174,7 @@ ynh_local_curl "/install.php?language=$applanguage" "install=true" "dbuser=$db_n
|
|||
#=================================================
|
||||
# CONFIGURE PIWIGO
|
||||
#=================================================
|
||||
ynh_print_info "Configuring piwigo..."
|
||||
|
||||
# Change local config
|
||||
cp ../conf/config.inc.php $final_path/local/config/
|
||||
|
@ -185,6 +195,7 @@ ynh_store_file_checksum "$final_path/local/config/database.inc.php"
|
|||
#=================================================
|
||||
# ADD LDAP PLUGINS
|
||||
#=================================================
|
||||
ynh_print_info "Configuring LDAP plugin..."
|
||||
|
||||
# Configure and activate LDAP plugin
|
||||
ynh_mysql_connect_as $db_name $db_pwd $db_name <<< "INSERT INTO plugins (id,state,version) VALUES ('Ldap_Login','active','1.1');"
|
||||
|
@ -193,6 +204,7 @@ cp ../conf/data.dat $final_path/plugins/Ldap_Login
|
|||
#=================================================
|
||||
# CONFIGURE FAIL2BAN
|
||||
#=================================================
|
||||
ynh_print_info "Configuring fail2ban..."
|
||||
|
||||
# Configure and activate log_failed_logins plugin
|
||||
ynh_mysql_connect_as $db_name $db_pwd $db_name <<< "INSERT INTO plugins (id,state,version) VALUES ('log_failed_logins','active','1.2');"
|
||||
|
@ -208,6 +220,7 @@ ynh_add_fail2ban_config --logpath="/var/log/${app}FailedLogins.log" --failregex=
|
|||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info "Configuring SSOwat..."
|
||||
|
||||
# Protect URIs if private
|
||||
if [ $is_public -eq 0 ]
|
||||
|
@ -219,6 +232,12 @@ fi
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Installation of $app completed"
|
||||
|
|
|
@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -24,6 +25,7 @@ final_path=$(ynh_app_setting_get $app final_path)
|
|||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Removing dependencies"
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
@ -31,6 +33,7 @@ ynh_remove_app_dependencies
|
|||
#=================================================
|
||||
# REMOVE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
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
|
||||
|
@ -38,6 +41,7 @@ ynh_mysql_remove_db $db_name $db_name
|
|||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Removing app main directory"
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove "$final_path"
|
||||
|
@ -45,6 +49,7 @@ 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
|
||||
|
@ -52,6 +57,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
|
||||
|
@ -59,6 +65,7 @@ ynh_remove_fpm_config
|
|||
#=================================================
|
||||
# REMOVE FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Removing fail2ban configuration"
|
||||
|
||||
ynh_remove_fail2ban_config
|
||||
|
||||
|
@ -67,7 +74,13 @@ ynh_remove_fail2ban_config
|
|||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Removing the dedicated system user"
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete $app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Removal of $app completed"
|
||||
|
|
|
@ -19,6 +19,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -31,6 +32,7 @@ db_name=$(ynh_app_setting_get $app db_name)
|
|||
#=================================================
|
||||
# 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}"
|
||||
|
@ -48,12 +50,14 @@ 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"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
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
|
||||
|
@ -62,6 +66,7 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
|||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Recreating the dedicated system user..."
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create $app
|
||||
|
@ -75,6 +80,7 @@ ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
|
|||
#=================================================
|
||||
# RESTORE THE FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Restoring the fail2ban configuration"
|
||||
|
||||
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
|
||||
|
@ -89,6 +95,7 @@ systemctl restart fail2ban
|
|||
#=================================================
|
||||
# RESTORE THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_print_info "Restoring data directory..."
|
||||
|
||||
# The data directory will be restored only if it exists in the backup archive
|
||||
# So only if it was backup previously.
|
||||
|
@ -114,7 +121,13 @@ chown -R $app: /home/yunohost.app/${app}
|
|||
#=================================================
|
||||
# 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"
|
||||
|
|
|
@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -27,6 +28,7 @@ admin_pwd=$(ynh_app_setting_get $app admin_pwd)
|
|||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_print_info "Ensuring downward compatibility..."
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
if [ -z $db_name ]; then
|
||||
|
@ -69,6 +71,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
|
||||
|
@ -91,6 +94,7 @@ path_url=$(ynh_normalize_url_path $path_url)
|
|||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading source files..."
|
||||
|
||||
# Create tmp directory and fetch app inside
|
||||
tmpdir="$(ynh_smart_mktemp --min_size=300)"
|
||||
|
@ -104,6 +108,7 @@ ynh_setup_source "$tmpdir/plugins" log_failed_logins_plugin
|
|||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading nginx web server configuration..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
@ -111,12 +116,14 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading dependencies..."
|
||||
|
||||
ynh_install_app_dependencies "$pkg_dependencies"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Making sure dedicated system user exists..."
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create $app
|
||||
|
@ -124,6 +131,7 @@ ynh_system_user_create $app
|
|||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading php-fpm configuration..."
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config
|
||||
|
@ -167,6 +175,7 @@ ynh_secure_remove "$tmpdir"
|
|||
#=================================================
|
||||
# UPGRADE APPLICATION WITH CURL
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading piwigo with Curl..."
|
||||
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
# Reload SSOwat config
|
||||
|
@ -215,6 +224,7 @@ ynh_store_file_checksum "$final_path/local/config/database.inc.php"
|
|||
#=================================================
|
||||
# ADD LDAP PLUGINS
|
||||
#=================================================
|
||||
ynh_print_info "Configuring LDAP plugin..."
|
||||
|
||||
# Configure and activate LDAP plugin
|
||||
ynh_mysql_connect_as $db_name $db_pwd $db_name <<< "UPDATE plugins SET state='active' WHERE id='Ldap_Login';"
|
||||
|
@ -223,6 +233,7 @@ cp ../conf/data.dat $final_path/plugins/Ldap_Login
|
|||
#=================================================
|
||||
# UPGRADE FAIL2BAN
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading fail2ban..."
|
||||
|
||||
# Configure and activate log_failed_logins plugin
|
||||
ynh_mysql_connect_as $db_name $db_pwd $db_name <<< "INSERT INTO plugins (id,state,version) VALUES ('log_failed_logins','active','1.2');" 2>&1 > /dev/null ||ynh_mysql_connect_as $db_name $db_pwd $db_name <<< "UPDATE plugins SET state='active' WHERE id='log_failed_logins';"
|
||||
|
@ -238,6 +249,7 @@ ynh_add_fail2ban_config --logpath="/var/log/${app}FailedLogins.log" --failregex=
|
|||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading SSOwat configuration..."
|
||||
|
||||
# Protect URIs if private
|
||||
if [ $is_public -eq 0 ]
|
||||
|
@ -249,6 +261,12 @@ fi
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Upgrade of $app completed"
|
||||
|
|
Loading…
Reference in a new issue