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

Add progression with ynh_print_info

This commit is contained in:
Maniack Crudelis 2019-03-03 18:13:57 +01:00
parent 1112b12b1d
commit 63a640c5de
5 changed files with 77 additions and 0 deletions

View file

@ -19,6 +19,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -31,23 +32,33 @@ db_name=$(ynh_app_setting_get $app db_name)
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Backing up the main app directory..."
ynh_backup "$final_path" ynh_backup "$final_path"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Backing up nginx web server configuration..."
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# BACKUP THE PHP-FPM CONFIGURATION # BACKUP THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Backing up php-fpm configuration..."
ynh_backup "/etc/php5/fpm/pool.d/$app.conf" ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
#================================================= #=================================================
# BACKUP THE MYSQL DATABASE # BACKUP THE MYSQL DATABASE
#================================================= #=================================================
ynh_print_info "Backing up the MySQL database..."
ynh_mysql_dump_db "$db_name" > db.sql ynh_mysql_dump_db "$db_name" > db.sql
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -33,6 +33,7 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_print_info "Validating installation parameters..."
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder" test ! -e "$final_path" || ynh_die "This path already contains a folder"
@ -46,6 +47,7 @@ ynh_webpath_register $app $domain $path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_print_info "Storing installation settings..."
ynh_app_setting_set $app domain $domain ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url ynh_app_setting_set $app path $path_url
@ -57,12 +59,14 @@ ynh_app_setting_set $app with_enigma $with_enigma
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Installing dependencies..."
ynh_install_app_dependencies "$pkg_dependencies" ynh_install_app_dependencies "$pkg_dependencies"
#================================================= #=================================================
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
#================================================= #=================================================
ynh_print_info "Creating a MySQL database..."
db_name=$(ynh_sanitize_dbid $app) db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name ynh_app_setting_set $app db_name $db_name
@ -71,6 +75,7 @@ ynh_mysql_setup_db $db_name $db_name
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_print_info "Setting up source files..."
ynh_app_setting_set $app final_path $final_path ynh_app_setting_set $app final_path $final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
@ -79,6 +84,7 @@ ynh_setup_source "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Configuring nginx web server..."
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
@ -86,6 +92,7 @@ ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Configuring system user..."
# Create a system user # Create a system user
ynh_system_user_create $app ynh_system_user_create $app
@ -93,6 +100,7 @@ ynh_system_user_create $app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Configuring php-fpm..."
# Create a dedicated php-fpm config # Create a dedicated php-fpm config
ynh_add_fpm_config ynh_add_fpm_config
@ -102,6 +110,7 @@ ynh_add_fpm_config
#================================================= #=================================================
# INSTALL AND INITIALIZE COMPOSER # INSTALL AND INITIALIZE COMPOSER
#================================================= #=================================================
ynh_print_info "Installing roundcube with composer..."
# Install composer.json # Install composer.json
cp "$final_path/composer.json-dist" "$final_path/composer.json" cp "$final_path/composer.json-dist" "$final_path/composer.json"
@ -112,6 +121,7 @@ ynh_install_composer
#================================================= #=================================================
# INITIALIZE DATABASE # INITIALIZE DATABASE
#================================================= #=================================================
ynh_print_info "Initializing database..."
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \ ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
< "$final_path/SQL/mysql.initial.sql" < "$final_path/SQL/mysql.initial.sql"
@ -119,6 +129,8 @@ ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
#================================================= #=================================================
# CONFIGURE ROUNDCUBE # CONFIGURE ROUNDCUBE
#================================================= #=================================================
ynh_print_info "Configuring roundcube..."
rc_conf="$final_path/config/config.inc.php" rc_conf="$final_path/config/config.inc.php"
cp ../conf/config.inc.php "$rc_conf" cp ../conf/config.inc.php "$rc_conf"
@ -131,6 +143,7 @@ ynh_replace_string "__DBNAME__" $db_name "$rc_conf"
#================================================= #=================================================
# INSTALL ADDITIONAL PLUGINS # INSTALL ADDITIONAL PLUGINS
#================================================= #=================================================
ynh_print_info "Installing additional plugins..."
# Create logs and temp directories # Create logs and temp directories
mkdir -p "$final_path/"{logs,temp} mkdir -p "$final_path/"{logs,temp}
@ -184,6 +197,7 @@ fi
#================================================= #=================================================
# UPDATE ROUNDCUBE CONFIGURATION # UPDATE ROUNDCUBE CONFIGURATION
#================================================= #=================================================
ynh_print_info "Updating roundcube configuration..."
ynh_replace_string "^\s*// installed plugins" "&\n $installed_plugins" "$rc_conf" ynh_replace_string "^\s*// installed plugins" "&\n $installed_plugins" "$rc_conf"
@ -207,5 +221,12 @@ chown -R $app: "$final_path/"{temp,logs,plugins/enigma/home}
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Installation of $app completed"

View file

@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -24,6 +25,7 @@ final_path=$(ynh_app_setting_get $app final_path)
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Removing dependencies"
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
@ -31,6 +33,7 @@ ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # REMOVE THE MYSQL DATABASE
#================================================= #=================================================
ynh_print_info "Removing the MySQL database"
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db $db_name $db_name ynh_mysql_remove_db $db_name $db_name
@ -38,6 +41,7 @@ ynh_mysql_remove_db $db_name $db_name
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Removing app main directory"
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove "$final_path" ynh_secure_remove "$final_path"
@ -45,6 +49,7 @@ ynh_secure_remove "$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Removing nginx web server configuration"
# Remove the dedicated nginx config # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -52,6 +57,7 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE PHP-FPM CONFIGURATION # REMOVE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Removing php-fpm configuration"
# Remove the dedicated php-fpm config # Remove the dedicated php-fpm config
ynh_remove_fpm_config ynh_remove_fpm_config
@ -61,6 +67,13 @@ ynh_remove_fpm_config
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Removing the dedicated system user"
# Delete a system user # Delete a system user
ynh_system_user_delete $app ynh_system_user_delete $app
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Removal of $app completed"

View file

@ -19,6 +19,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -30,6 +31,7 @@ db_name=$(ynh_app_setting_get $app db_name)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_print_info "Validating restoration parameters..."
ynh_webpath_available $domain $path_url \ ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}" || ynh_die "Path not available: ${domain}${path_url}"
@ -47,12 +49,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Restoring the app main directory..."
ynh_restore_file "$final_path" ynh_restore_file "$final_path"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Recreating the dedicated system user..."
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create $app ynh_system_user_create $app
@ -76,6 +80,7 @@ ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Reinstalling dependencies..."
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies "$pkg_dependencies" ynh_install_app_dependencies "$pkg_dependencies"
@ -83,6 +88,7 @@ ynh_install_app_dependencies "$pkg_dependencies"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
ynh_print_info "Restoring the MySQL database..."
db_pwd=$(ynh_app_setting_get $app mysqlpwd) db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_mysql_setup_db $db_name $db_name $db_pwd ynh_mysql_setup_db $db_name $db_name $db_pwd
@ -93,7 +99,13 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX AND PHP-FPM
#================================================= #=================================================
ynh_print_info "Reloading nginx web server and php-fpm..."
systemctl reload php5-fpm systemctl reload php5-fpm
systemctl reload nginx systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Restoration completed for $app"

View file

@ -15,6 +15,7 @@ source _getopts_fix.sh
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -28,6 +29,7 @@ with_enigma=$(ynh_app_setting_get $app with_enigma)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_print_info "Ensuring downward compatibility..."
# If db_name doesn't exist, create it # If db_name doesn't exist, create it
if [ -z "$db_name" ]; then if [ -z "$db_name" ]; then
@ -66,6 +68,7 @@ fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # 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 # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -88,6 +91,7 @@ path_url=$(ynh_normalize_url_path $path_url)
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_print_info "Upgrading source files..."
# Get the current version of roundcube # Get the current version of roundcube
oldversion=$(grep RCMAIL_VERSION "$final_path/program/include/iniset.php" | cut -d\' -f4) oldversion=$(grep RCMAIL_VERSION "$final_path/program/include/iniset.php" | cut -d\' -f4)
@ -98,6 +102,7 @@ ynh_setup_source "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Upgrading nginx web server configuration..."
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
@ -105,12 +110,14 @@ ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Upgrading dependencies..."
ynh_install_app_dependencies "$pkg_dependencies" ynh_install_app_dependencies "$pkg_dependencies"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Making sure dedicated system user exists..."
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create $app ynh_system_user_create $app
@ -118,6 +125,7 @@ ynh_system_user_create $app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Upgrading php-fpm configuration..."
# Create a dedicated php-fpm config # Create a dedicated php-fpm config
ynh_add_fpm_config ynh_add_fpm_config
@ -127,6 +135,7 @@ ynh_add_fpm_config
#================================================= #=================================================
# CONFIGURE ROUNDCUBE # CONFIGURE ROUNDCUBE
#================================================= #=================================================
ynh_print_info "Reconfiguring roundcube..."
rc_conf="$final_path/config/config.inc.php" rc_conf="$final_path/config/config.inc.php"
@ -144,6 +153,7 @@ ynh_replace_string "__DBNAME__" $db_name "$rc_conf"
#================================================= #=================================================
# UPDATE DEPENDENCIES WITH COMPOSER # UPDATE DEPENDENCIES WITH COMPOSER
#================================================= #=================================================
ynh_print_info "Updating dependencies with composer..."
# Check if dependencies need to be updated with composer # Check if dependencies need to be updated with composer
if [ -f "$final_path/composer.json" ] if [ -f "$final_path/composer.json" ]
@ -159,6 +169,7 @@ fi
#================================================= #=================================================
# UPGRADE ADDITIONAL PLUGINS # UPGRADE ADDITIONAL PLUGINS
#================================================= #=================================================
ynh_print_info "Upgrading additional plugins..."
# Create logs and temp directories # Create logs and temp directories
mkdir -p "$final_path/"{logs,temp} mkdir -p "$final_path/"{logs,temp}
@ -212,6 +223,7 @@ fi
#================================================= #=================================================
# UPDATE ROUNDCUBE CONFIGURATION # UPDATE ROUNDCUBE CONFIGURATION
#================================================= #=================================================
ynh_print_info "Updating roundcube configuration..."
ynh_replace_string "^\s*// installed plugins" "&\n $installed_plugins" "$rc_conf" ynh_replace_string "^\s*// installed plugins" "&\n $installed_plugins" "$rc_conf"
@ -225,6 +237,7 @@ ynh_store_file_checksum "$rc_conf"
#================================================= #=================================================
# UPDATE ROUNDCUBE CORE # UPDATE ROUNDCUBE CORE
#================================================= #=================================================
ynh_print_info "Updating roundcube core..."
( cd "$final_path" ( cd "$final_path"
ynh_exec_warn ./bin/update.sh --version=$oldversion -y) ynh_exec_warn ./bin/update.sh --version=$oldversion -y)
@ -242,5 +255,12 @@ chown -R $app: "$final_path/"{temp,logs,plugins/enigma/home}
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Upgrade of $app completed"