1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/emailpoubelle_ynh.git synced 2024-09-03 18:26:29 +02:00

Merge pull request #13 from YunoHost-Apps/Testing

Housekeeping
This commit is contained in:
Krakinou 2020-11-01 16:53:20 +01:00 committed by GitHub
commit 1e457ce1d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 50 additions and 53 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>poubelle_ynh</name> <name>emailpoubelle_ynh</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>

View file

@ -34,19 +34,6 @@ or
sudo yunohost app upgrade emailpoubelle -u https://github.com/Yunohost-Apps/emailpoubelle_ynh/tree/Testing --debug 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 ## LICENCE
Package and software are GPL 3.0 Package and software are GPL 3.0

View file

@ -7,7 +7,7 @@
"fr": "Créez des adresses email jetables qui redirigent les mails vers votre adresse réelle" "fr": "Créez des adresses email jetables qui redirigent les mails vers votre adresse réelle"
}, },
"url": "https://framagit.org/kepon/emailPoubellePhp/", "url": "https://framagit.org/kepon/emailPoubellePhp/",
"version": "2.0~ynh4", "version": "2.0~ynh5",
"license": "Beerware", "license": "Beerware",
"maintainer": { "maintainer": {
"name": "Krakinou", "name": "Krakinou",

View file

@ -25,7 +25,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1 ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -38,35 +38,35 @@ db_name=$(ynh_app_setting_get $app db_name)
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # 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" ynh_backup --src_path="$final_path"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # 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" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# BACKUP THE MYSQL DATABASE # 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 ynh_mysql_dump_db "$db_name" > db.sql
#================================================= #=================================================
# BACKUP THE CRON FILE # 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" ynh_backup --src_path="/etc/cron.d/$app"
#================================================= #=================================================
# BACKUP postfix conf # 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" 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 # 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

View file

@ -18,14 +18,14 @@ admin=$YNH_APP_ARG_ADMIN
ynh_print_OFF ynh_print_OFF
password=$YNH_APP_ARG_PASSWORD password=$YNH_APP_ARG_PASSWORD
ynh_print_ON ynh_print_ON
is_public=$5 is_public=$YNH_APP_ARG_IS_PUBLIC
final_path=/var/www/$app final_path=/var/www/$app
db_user=emailPoubelle db_user=emailPoubelle
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # 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 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"
@ -43,6 +43,7 @@ ynh_user_exists "$admin"
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # 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 domain $domain
ynh_app_setting_set $app path $path_url ynh_app_setting_set $app path $path_url
@ -54,7 +55,7 @@ ynh_app_setting_set $app final_path $final_path
#================================================= #=================================================
#INSTALL DEPENDENCIES #INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Installing dependencies" ynh_script_progression --message="Installing dependencies..." --weight=15
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#install locale (nginx will restart at the end of the install) #install locale (nginx will restart at the end of the install)
@ -68,7 +69,7 @@ locale-gen
#INSTALL SOURCES #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 # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path" ynh_setup_source "$final_path"
cp ../conf/index_source.php $final_path/www/index.php 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 #SETTINGS & DATABASE
#=============================================== #===============================================
ynh_print_info "Setting database & settings" ynh_script_progression --message="Setting database & settings..."
#generating random password for database #generating random password for database
ynh_print_OFF ynh_print_OFF
@ -117,7 +118,7 @@ ynh_print_ON
#setting postfix to use virtual aliases file #setting postfix to use virtual aliases file
# Add postfix configuration hook and regen postfix conf # Add postfix configuration hook and regen postfix conf
cp -R ../sources/hooks/conf_regen/98-postfix_emailpoubelle /usr/share/yunohost/hooks/conf_regen/ 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 #create the virtual aliases file
touch $final_path/var/virtual touch $final_path/var/virtual
@ -135,6 +136,7 @@ chown root:root /etc/cron.d/$app
chmod 644 /etc/cron.d/$app chmod 644 /etc/cron.d/$app
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_script_progression --message="Configuring nginx web server..." --weight=2
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
@ -154,4 +156,4 @@ fi
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
ynh_systemd_action --service_name=postfix --action=reload ynh_systemd_action --service_name=postfix --action=reload
service php* reload service php* reload
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -26,7 +26,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # 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 # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name 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 # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_print_info --message="Removing dependencies" ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
@ -45,7 +45,7 @@ ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # 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 # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
@ -54,7 +54,7 @@ ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # 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 # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -65,7 +65,7 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE THE CRON FILE # REMOVE THE CRON FILE
#================================================= #=================================================
ynh_script_progression --message="Removing cron job and aliases..."
ynh_secure_remove --file="/etc/cron.d/$app" 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 # 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=nginx --action=reload
ynh_systemd_action --service_name=postfix --action=reload ynh_systemd_action --service_name=postfix --action=reload
ynh_script_progression --message="Removal of $app completed"

View file

@ -25,7 +25,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." --time --weight=1 ynh_script_progression --message="Loading settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -38,7 +38,7 @@ admin=$(ynh_app_setting_get $app admin)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # 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_webpath_available $domain $path_url \
|| ynh_die "Path not 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 # 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" ynh_restore_file "$final_path"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # 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) 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
@ -77,7 +77,7 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 ynh_script_progression --message="Reinstalling dependencies..." --weight=15
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
@ -91,10 +91,10 @@ locale-gen
#================================================= #=================================================
# RESTORE POSTFIX ALIASES # 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" 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 #create an alias for deleted junk adresses
if ! grep -q "devnull:/dev/null" /etc/aliases ; then if ! grep -q "devnull:/dev/null" /etc/aliases ; then
@ -106,7 +106,7 @@ fi
#================================================= #=================================================
# RESTORE THE CRON FILE # 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" ynh_restore_file "/etc/cron.d/$app"
@ -115,7 +115,7 @@ ynh_restore_file "/etc/cron.d/$app"
#================================================= #=================================================
# RELOAD NGINX & ALIASES # 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 postmap $final_path/var/virtual
ynh_systemd_action --service_name=php7.0-fpm --action=restart 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 # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --time --last ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get $app path)
@ -37,7 +37,7 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# Fix is_public as a boolean value # Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=1 ynh_app_setting_set --app=$app --key=is_public --value=1
@ -63,7 +63,7 @@ fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # 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 # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
@ -129,7 +129,7 @@ path_url=$(ynh_normalize_url_path $path_url)
#================================================= #=================================================
# NGINX CONFIGURATION # 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" ynh_backup_if_checksum_is_different "/etc/nginx/conf.d/$domain.d/$app.conf"
@ -139,7 +139,7 @@ ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Installing dependencies" ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
@ -159,7 +159,7 @@ fi
#INSTALL SOURCES #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 # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path" ynh_setup_source "$final_path"
cp ../conf/index_source.php $final_path/www/index.php cp ../conf/index_source.php $final_path/www/index.php
@ -182,7 +182,7 @@ fi
# Add postfix configuration hook and regen postfix conf # Add postfix configuration hook and regen postfix conf
cp -R ../sources/hooks/conf_regen/98-postfix_emailpoubelle /usr/share/yunohost/hooks/conf_regen/ 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 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 # SECURE FILES AND DIRECTORIES
@ -195,7 +195,14 @@ chown root:root /etc/cron.d/$app
#================================================= #=================================================
# RELOAD SERVICES # RELOAD SERVICES
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=php7.0-fpm --action=restart 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_systemd_action --service_name=nginx --action=reload
ynh_script_progression --message="Reloading postfix..."
ynh_systemd_action --service_name=postfix --action=reload ynh_systemd_action --service_name=postfix --action=reload
ynh_script_progression --message="Upgrade of $app completed" --last