From bbeab106d5e16a5d48b46d8146edb3ad80c0b379 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sun, 1 Nov 2020 16:49:03 +0100 Subject: [PATCH] Housekeeping --- .project | 2 +- README.md | 13 ------------- manifest.json | 2 +- scripts/backup | 14 +++++++------- scripts/install | 16 +++++++++------- scripts/remove | 15 ++++++++------- scripts/restore | 20 ++++++++++---------- scripts/upgrade | 21 ++++++++++++++------- 8 files changed, 50 insertions(+), 53 deletions(-) diff --git a/.project b/.project index 24d3b92..42dc69a 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - poubelle_ynh + emailpoubelle_ynh diff --git a/README.md b/README.md index 84edbcf..bb240d0 100644 --- a/README.md +++ b/README.md @@ -34,19 +34,6 @@ or sudo yunohost app upgrade emailpoubelle -u https://github.com/Yunohost-Apps/emailpoubelle_ynh/tree/Testing --debug ``` -## TODO : - -- [X] check nginx conf -- [X] insert cron in conf -- [ ] insert symlink for langages in /lang -- [ ] remove new locale on remove -- [ ] Test it ! (and check if that doesn't interfer with postfix and its aliases) -- [X] cron job to remove redirections (`0 */2 * * * /usr/bin/wget -q -t 1 -T 7200 -O /dev/null 'https://domain/poubelle/index.php?act=cron' >/dev/null 2>&1) -- [ ] conflict with SSOWAT + non-public app -- [X] package_check integration -- [ ] Multiinstance -- [ ] LDAP - ## LICENCE Package and software are GPL 3.0 \ No newline at end of file diff --git a/manifest.json b/manifest.json index cf75a72..74892e8 100644 --- a/manifest.json +++ b/manifest.json @@ -7,7 +7,7 @@ "fr": "Créez des adresses email jetables qui redirigent les mails vers votre adresse réelle" }, "url": "https://framagit.org/kepon/emailPoubellePhp/", - "version": "2.0~ynh4", + "version": "2.0~ynh5", "license": "Beerware", "maintainer": { "name": "Krakinou", diff --git a/scripts/backup b/scripts/backup index dbc9b65..d640ec4 100644 --- a/scripts/backup +++ b/scripts/backup @@ -25,7 +25,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -38,35 +38,35 @@ db_name=$(ynh_app_setting_get $app db_name) #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_script_progression --message="Backing up the main app directory..." --time --weight=1 +ynh_script_progression --message="Backing up the main app directory..." ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Backing up nginx web server configuration..." ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Backing up the MySQL database..." --time --weight=1 +ynh_script_progression --message="Backing up the MySQL database..." ynh_mysql_dump_db "$db_name" > db.sql #================================================= # BACKUP THE CRON FILE #================================================= -ynh_script_progression --message="Backing up cron configuration..." --time --weight=1 +ynh_script_progression --message="Backing up cron configuration..." ynh_backup --src_path="/etc/cron.d/$app" #================================================= # BACKUP postfix conf #================================================= -ynh_script_progression --message="Backing up postfix conf configuration..." --time --weight=1 +ynh_script_progression --message="Backing up postfix conf configuration..." ynh_backup "/usr/share/yunohost/hooks/conf_regen/98-postfix_emailpoubelle" @@ -74,4 +74,4 @@ ynh_backup "/usr/share/yunohost/hooks/conf_regen/98-postfix_emailpoubelle" # END OF SCRIPT #================================================= -ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last +ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last diff --git a/scripts/install b/scripts/install index 82b1023..e52c69f 100644 --- a/scripts/install +++ b/scripts/install @@ -18,14 +18,14 @@ admin=$YNH_APP_ARG_ADMIN ynh_print_OFF password=$YNH_APP_ARG_PASSWORD ynh_print_ON -is_public=$5 +is_public=$YNH_APP_ARG_IS_PUBLIC final_path=/var/www/$app db_user=emailPoubelle #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info "Check settings for installation" +ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -43,6 +43,7 @@ ynh_user_exists "$admin" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url @@ -54,7 +55,7 @@ ynh_app_setting_set $app final_path $final_path #================================================= #INSTALL DEPENDENCIES #================================================= -ynh_print_info "Installing dependencies" +ynh_script_progression --message="Installing dependencies..." --weight=15 ynh_install_app_dependencies $pkg_dependencies #install locale (nginx will restart at the end of the install) @@ -68,7 +69,7 @@ locale-gen #INSTALL SOURCES #=============================================== -ynh_print_info "Downloading sources to $final_path" +ynh_script_progression --message="Setting up source files..." --weight=5 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" cp ../conf/index_source.php $final_path/www/index.php @@ -83,7 +84,7 @@ ln -s $final_path/www/template-exemple $final_path/template-exemple #=============================================== #SETTINGS & DATABASE #=============================================== -ynh_print_info "Setting database & settings" +ynh_script_progression --message="Setting database & settings..." #generating random password for database ynh_print_OFF @@ -117,7 +118,7 @@ ynh_print_ON #setting postfix to use virtual aliases file # Add postfix configuration hook and regen postfix conf cp -R ../sources/hooks/conf_regen/98-postfix_emailpoubelle /usr/share/yunohost/hooks/conf_regen/ -yunohost service regen-conf postfix +yunohost tools regen-conf postfix #create the virtual aliases file touch $final_path/var/virtual @@ -135,6 +136,7 @@ chown root:root /etc/cron.d/$app chmod 644 /etc/cron.d/$app # Create a dedicated nginx config +ynh_script_progression --message="Configuring nginx web server..." --weight=2 ynh_add_nginx_config #================================================= @@ -154,4 +156,4 @@ fi ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=postfix --action=reload service php* reload - +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index f8fa531..590b955 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -26,7 +26,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE THE MYSQL DATABASE #================================================= -ynh_print_info --message="Removing the MySQL database" +ynh_script_progression --message="Removing the MySQL database..." # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name @@ -36,7 +36,7 @@ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_print_info --message="Removing dependencies" +ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -45,7 +45,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info --message="Removing app main directory" +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -54,7 +54,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Removing nginx web server configuration" +ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -65,7 +65,7 @@ ynh_remove_nginx_config #================================================= # REMOVE THE CRON FILE #================================================= - +ynh_script_progression --message="Removing cron job and aliases..." ynh_secure_remove --file="/etc/cron.d/$app" #================================================= @@ -86,7 +86,8 @@ ynh_secure_remove "/usr/share/yunohost/hooks/conf_regen/98-postfix_emailpoubelle # REMOVE DEDICATED USER #================================================= -yunohost service regen-conf postfix +yunohost tools regen-conf postfix ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=postfix --action=reload +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 6932804..68cfa32 100644 --- a/scripts/restore +++ b/scripts/restore @@ -25,7 +25,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --time --weight=1 +ynh_script_progression --message="Loading settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -38,7 +38,7 @@ admin=$(ynh_app_setting_get $app admin) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 +ynh_script_progression --message="Validating restoration parameters..." --weight=1 ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" @@ -59,14 +59,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 +ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file "$final_path" #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1 +ynh_script_progression --message="Restoring the MySQL database..." --weight=1 db_pwd=$(ynh_app_setting_get $app mysqlpwd) ynh_mysql_setup_db $db_name $db_name $db_pwd @@ -77,7 +77,7 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 +ynh_script_progression --message="Reinstalling dependencies..." --weight=15 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -91,10 +91,10 @@ locale-gen #================================================= # RESTORE POSTFIX ALIASES #================================================= -ynh_script_progression --message="Restore Postfix aliases..." --time --weight=1 +ynh_script_progression --message="Restore Postfix aliases..." --weight=10 ynh_restore_file "/usr/share/yunohost/hooks/conf_regen/98-postfix_emailpoubelle" -yunohost service regen-conf postfix +yunohost tools regen-conf postfix #create an alias for deleted junk adresses if ! grep -q "devnull:/dev/null" /etc/aliases ; then @@ -106,7 +106,7 @@ fi #================================================= # RESTORE THE CRON FILE #================================================= -ynh_script_progression --message="Reinstall cron job" --time --weight=1 +ynh_script_progression --message="Reinstall cron job" --weight=1 ynh_restore_file "/etc/cron.d/$app" @@ -115,7 +115,7 @@ ynh_restore_file "/etc/cron.d/$app" #================================================= # RELOAD NGINX & ALIASES #================================================= -ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server and php-fpm..." --weight=1 postmap $final_path/var/virtual ynh_systemd_action --service_name=php7.0-fpm --action=restart @@ -126,4 +126,4 @@ ynh_systemd_action --service_name=postfix --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --time --last \ No newline at end of file +ynh_script_progression --message="Restoration completed for $app" --last \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index ba6eef7..ac92353 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= - +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) @@ -37,7 +37,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= - +ynh_script_progression --message="Ensuring downward compatibility..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then ynh_app_setting_set --app=$app --key=is_public --value=1 @@ -63,7 +63,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= - +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { @@ -129,7 +129,7 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading nginx web server configuration..." ynh_backup_if_checksum_is_different "/etc/nginx/conf.d/$domain.d/$app.conf" @@ -139,7 +139,7 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_print_info "Installing dependencies" +ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= @@ -159,7 +159,7 @@ fi #INSTALL SOURCES #=============================================== -ynh_print_info "Downloading sources to $final_path" +ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" cp ../conf/index_source.php $final_path/www/index.php @@ -182,7 +182,7 @@ fi # Add postfix configuration hook and regen postfix conf cp -R ../sources/hooks/conf_regen/98-postfix_emailpoubelle /usr/share/yunohost/hooks/conf_regen/ mv /etc/postfix/main.cf /etc/postfix/main.cf.emailpoubelle.bak -yunohost service regen-conf postfix -f +yunohost tools regen-conf postfix -f #================================================= # SECURE FILES AND DIRECTORIES @@ -195,7 +195,14 @@ chown root:root /etc/cron.d/$app #================================================= # RELOAD SERVICES #================================================= +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=php7.0-fpm --action=restart + +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload + +ynh_script_progression --message="Reloading postfix..." ynh_systemd_action --service_name=postfix --action=reload +ynh_script_progression --message="Upgrade of $app completed" --last +