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

Add progression with ynh_print_info

This commit is contained in:
Maniack Crudelis 2019-02-17 20:58:14 +01:00
parent 24158eb8d0
commit 086dfd2fe1
5 changed files with 71 additions and 0 deletions

View file

@ -19,6 +19,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -31,23 +32,33 @@ 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
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -29,6 +29,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"
@ -42,6 +43,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
@ -52,6 +54,7 @@ ynh_app_setting_set $app admin $admin
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_print_info "Creating a MySQL database..."
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
@ -73,6 +76,7 @@ fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Setting up source files..."
ynh_app_setting_set $app final_path $final_path
# Download, check integrity, uncompress and patch the source from app.src
@ -81,6 +85,7 @@ ynh_setup_source "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Configuring nginx web server..."
# Create a dedicated nginx config
ynh_add_nginx_config
@ -88,6 +93,7 @@ ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Configuring system user..."
# Create a system user
ynh_system_user_create $app
@ -95,6 +101,7 @@ ynh_system_user_create $app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Configuring php-fpm..."
# Create a dedicated php-fpm config
ynh_add_fpm_config
@ -104,6 +111,7 @@ ynh_add_fpm_config
#=================================================
# POPULATE THE DATABASE
#=================================================
ynh_print_info "Filling database..."
ynh_replace_string "__YNH_PMA_USER__" "$db_name" ../conf/create_db.sql
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
@ -115,6 +123,7 @@ ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
#=================================================
# CONFIGURE PHPMYADMIN
#=================================================
ynh_print_info "Configuring phpmyadmin..."
ynh_replace_string "__YNH_PMA_ADMIN_USER__" "$db_admin_user" ../conf/config.inc.php
ynh_replace_string "__YNH_PMA_ADMIN_PASSWORD__" "$db_admin_pwd" ../conf/config.inc.php
@ -129,6 +138,7 @@ ynh_store_file_checksum "$final_path/config.inc.php"
#=================================================
# INSTALL DEPENDENCIES WITH COMPOSER
#=================================================
ynh_print_info "Installing dependencies with Composer..."
# Set permissions for initialization
chown -R $app: "$final_path"
@ -168,6 +178,7 @@ chown $app: $final_path/tmp
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Configuring SSOwat..."
# Restrict access to admin only
yunohost app addaccess --users=$admin $app
@ -175,5 +186,12 @@ yunohost app addaccess --users=$admin $app
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
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
#=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -25,6 +26,7 @@ db_admin_user=$(ynh_app_setting_get $app db_admin_user)
#=================================================
# 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
@ -35,6 +37,7 @@ ynh_mysql_drop_user $db_admin_user
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_print_info "Removing app main directory"
# Remove the app directory securely
ynh_secure_remove "$final_path"
@ -42,6 +45,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
@ -49,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
@ -58,6 +63,13 @@ ynh_remove_fpm_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"

View file

@ -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
@ -72,6 +76,7 @@ fi
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_print_info "Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create $app
@ -96,6 +101,13 @@ ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
#=================================================
# 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

@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -26,6 +27,7 @@ db_admin_pwd=$(ynh_app_setting_get $app db_admin_pwd)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_print_info "Ensuring downward compatibility..."
# If db_name doesn't exist, create it
if [ -z $db_name ]; then
@ -65,6 +67,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
@ -87,6 +90,7 @@ path_url=$(ynh_normalize_url_path $path_url)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
@ -94,6 +98,7 @@ ynh_setup_source "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Upgrading nginx web server configuration..."
# Create a dedicated nginx config
ynh_add_nginx_config
@ -101,6 +106,7 @@ ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create $app
@ -108,6 +114,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
@ -117,6 +124,7 @@ ynh_add_fpm_config
#=================================================
# UPGRADE THE DATABASE
#=================================================
ynh_print_info "Upgrading database..."
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
# Handle upgrade from a version before latest version
@ -137,6 +145,7 @@ ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
#=================================================
# CONFIGURE PHPMYADMIN
#=================================================
ynh_print_info "Reconfiguring phpmyadmin..."
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$final_path/config.inc.php"
@ -154,6 +163,7 @@ ynh_store_file_checksum "$final_path/config.inc.php"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_print_info "Upgrading dependencies with Composer..."
# Set permissions for initialization
chown -R $app: "$final_path"
@ -193,6 +203,7 @@ chown -R $app: $final_path/tmp
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Upgrading SSOwat configuration..."
# Restrict access to admin only
yunohost app addaccess --users=$admin $app
@ -200,5 +211,12 @@ yunohost app addaccess --users=$admin $app
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Upgrade of $app completed"