1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/gotify_ynh.git synced 2024-09-03 20:36:26 +02:00

add messages during scripts execution

This commit is contained in:
Clément 2019-03-10 17:11:52 +01:00
parent 0ad402bb26
commit de66cefed0
5 changed files with 43 additions and 12 deletions

View file

@ -13,16 +13,13 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -35,18 +32,21 @@ 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 MYSQL DATABASE
#=================================================
ynh_print_info "Backing up the MySQL database..."
ynh_mysql_dump_db "$db_name" > db.sql
@ -56,3 +56,4 @@ ynh_mysql_dump_db "$db_name" > db.sql
#=================================================
ynh_backup "/etc/systemd/system/$app.service"
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -46,6 +42,7 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_print_info "Validating installation parameters..."
final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
@ -61,6 +58,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
@ -88,6 +86,7 @@ ynh_app_setting_set $app port $port
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_print_info "Creating a MySQL database..."
### Use these lines if you need a database for the application.
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
@ -105,6 +104,7 @@ ynh_mysql_setup_db $db_name $db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Setting up source files..."
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository.
@ -117,6 +117,7 @@ ynh_setup_source "$final_path" $architecture
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Configuring nginx web server..."
### `ynh_add_nginx_config` will use the file conf/nginx.conf
@ -126,6 +127,7 @@ ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Configuring system user..."
# Create a system user
ynh_system_user_create $app
@ -152,6 +154,7 @@ ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_print_info "Create config file..."
### `ynh_replace_string` is used to replace a string in a file.
### (It's compatible with sed regular expressions syntax)
@ -223,6 +226,7 @@ yunohost service add $app
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Configuring SSOwat..."
# Make app public if necessary
# if [ $is_public -eq 1 ]
@ -239,8 +243,10 @@ ynh_app_setting_set $app unprotected_uris "/"
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
systemctl start $app
# yunohost firewall allow --no-upnp TCP $port 2>&1
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
@ -45,6 +46,7 @@ ynh_remove_systemd_config
#=================================================
# 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_user $db_name
@ -52,6 +54,7 @@ ynh_mysql_remove_db $db_user $db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_print_info "Removing app main directory"
# Remove the app directory securely
ynh_secure_remove "$final_path"
@ -59,6 +62,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
@ -100,6 +104,9 @@ ynh_remove_nginx_config
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_print_info "Removing the dedicated system user"
# Delete a system user
ynh_system_user_delete $app
ynh_print_info "Removal of $app completed"

View file

@ -13,16 +13,13 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading settings..."
app=$YNH_APP_INSTANCE_NAME
@ -34,6 +31,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}"
@ -45,18 +43,21 @@ test ! -d $final_path \
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_print_info "Restoring nginx configuration..."
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
@ -65,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
@ -88,6 +90,7 @@ yunohost service add $app
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_print_info "Restoring service..."
ynh_restore_file "/etc/systemd/system/$app.service"
systemctl enable $app.service
@ -95,5 +98,8 @@ systemctl start $app
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
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
@ -28,6 +29,7 @@ password=$(ynh_app_setting_get $app password)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_print_info "Ensuring downward compatibility..."
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
@ -53,6 +55,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
@ -75,6 +78,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" $architecture
@ -82,6 +86,7 @@ ynh_setup_source "$final_path" $architecture
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Upgrading nginx web server configuration..."
# Create a dedicated nginx config
if [ "$path_url" != "/" ]
@ -94,6 +99,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
@ -145,17 +151,22 @@ chown -R $app: $final_path/data
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Upgrading SSOwat configuration..."
ynh_app_setting_set $app unprotected_uris "/"
#=================================================
# RELOAD SERVICE
#=================================================
ynh_print_info "Reloading service..."
systemctl restart $app
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
ynh_print_info "Upgrade of $app completed"