1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/emailpoubelle_ynh.git synced 2024-09-03 18:26:29 +02:00
This commit is contained in:
ericgaspar 2021-11-10 08:10:36 +01:00
parent 95f7d1b20a
commit 8b8395ab5c
11 changed files with 87 additions and 126 deletions

View file

@ -1,10 +1,10 @@
;; Complete Test ;; Complete Test
# Comment ignored # Comment ignored
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld"
path="/poubelle" (PATH) path="/poubelle"
admin="john" (USER) admin="john"
is_public=1 (PUBLIC|public=1|private=0) is_public=1
password="password" password="password"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
@ -16,9 +16,7 @@
upgrade=1 upgrade=1
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
incorrect_path=1
change_url=1 change_url=1
;;; Options ;;; Options
Email= Email=
Notification=none Notification=none

View file

@ -1 +1 @@
0 */2 * * * www-data cd $final_path/www/; /usr/bin/php index.php > /dev/null 2>&1 0 */2 * * * www-data cd $final_path/www/; /usr/bin/php__PHPVERSION__ index.php > /dev/null

View file

@ -33,7 +33,7 @@ group = __USER__
; (IPv6 and IPv4-mapped) on a specific port; ; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket. ; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory. ; Note: This value is mandatory.
listen = /var/run/php/php__PHPVERSION__-fpm.sock listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock
; Set listen(2) backlog. ; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD) ; Default Value: 511 (-1 on FreeBSD and OpenBSD)

View file

@ -14,7 +14,7 @@
"email": "misterl56@hotmail.com" "email": "misterl56@hotmail.com"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.2.0" "yunohost": ">= 4.2.8"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [
@ -28,8 +28,7 @@
"install" : [ "install" : [
{ {
"name": "domain", "name": "domain",
"type": "domain", "type": "domain"
"example": "domain.org"
}, },
{ {
"name": "path", "name": "path",
@ -40,7 +39,6 @@
{ {
"name": "admin", "name": "admin",
"type": "user", "type": "user",
"example": "homer",
"help": { "help": {
"en": "Admin user can access to the control panel, block and remove all redirection and reset any settings", "en": "Admin user can access to the control panel, block and remove all redirection and reset any settings",
"fr": "L'administrateur peut accéder au panneau de controle, bloquer et supprimer les redirections ainsi que réinitialiser les réglages" "fr": "L'administrateur peut accéder au panneau de controle, bloquer et supprimer les redirections ainsi que réinitialiser les réglages"
@ -48,8 +46,7 @@
}, },
{ {
"name": "password", "name": "password",
"type": "password", "type": "password"
"example": "AveryStrongPassword"
}, },
{ {
"name": "is_public", "name": "is_public",

View file

@ -1,7 +1,8 @@
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
YNH_PHP_VERSION="7.3" YNH_PHP_VERSION="7.3"
extra_php_dependencies="php${YNH_PHP_VERSION}-geoip php${YNH_PHP_VERSION}-cli" extra_php_dependencies="php${YNH_PHP_VERSION}-geoip php${YNH_PHP_VERSION}-cli"
app="emailpoubelle"
lang="fr_FR.UTF-8 en_US.UTF-8 it_IT.UTF-8" lang="fr_FR.UTF-8 en_US.UTF-8 it_IT.UTF-8"

View file

@ -7,11 +7,7 @@
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
#if [ ! -e _common.sh ]; then
# # Get the _common.sh file if it's not in the current directory
# cp ../settings/scripts/_common.sh ./_common.sh
# chmod a+rx _common.sh
#fi
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -64,7 +60,7 @@ ynh_backup --src_path="/etc/cron.d/$app"
# BACKUP postfix conf # BACKUP postfix conf
#================================================= #=================================================
ynh_backup "/usr/share/yunohost/hooks/conf_regen/98-postfix_emailpoubelle" ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/98-postfix_emailpoubelle"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -67,14 +67,10 @@ then
change_path=1 change_path=1
fi fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -100,21 +96,10 @@ then
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi fi
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
#=================================================
#=================================================
# GENERIC FINALISATION
#=================================================
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -122,4 +107,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Change of URL completed for $app" --time --last ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -5,34 +5,38 @@
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
# Retrieve arguments # Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
ynh_print_OFF
password=$YNH_APP_ARG_PASSWORD password=$YNH_APP_ARG_PASSWORD
ynh_print_ON
is_public=$YNH_APP_ARG_IS_PUBLIC 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 # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1 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"
# Check web path availability final_path=/var/www/$app
ynh_webpath_available $domain $path_url test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path # Register (book) web path
ynh_webpath_register $app $domain $path_url ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
# Check user # Check user
ynh_user_exists "$admin" ynh_user_exists "$admin"
@ -42,11 +46,9 @@ ynh_user_exists "$admin"
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set $app domain $domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set $app path $path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set $app admin $admin ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set $app db_name $db_user
ynh_app_setting_set $app final_path $final_path
#================================================= #=================================================
#INSTALL DEPENDENCIES #INSTALL DEPENDENCIES
@ -63,8 +65,8 @@ locale-gen
#================================================= #=================================================
#INSTALL SOURCES #INSTALL SOURCES
#=============================================== #===============================================
ynh_script_progression --message="Setting up source files..." --weight=5 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
@ -117,8 +119,8 @@ chmod 644 /etc/cron.d/$app
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
ynh_script_progression --message="Configuring nginx web server..." --weight=1
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
@ -127,12 +129,13 @@ ynh_add_nginx_config
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated PHP-FPM config # Create a dedicated PHP-FPM config
ynh_add_fpm_config ynh_add_fpm_config --package="$extra_php_dependencies"
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary # Make app public if necessary
if [ "$is_public" -eq 1 ] if [ "$is_public" -eq 1 ]
@ -144,6 +147,8 @@ fi
#================================================= #=================================================
# RELOAD SERVICES # RELOAD SERVICES
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
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_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
@ -151,4 +156,5 @@ ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression --message="Installation of $app completed" --last

View file

@ -21,8 +21,6 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # REMOVE THE MYSQL DATABASE
#================================================= #=================================================
@ -31,17 +29,6 @@ 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
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
@ -50,27 +37,27 @@ 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"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --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
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
#================================================= #=================================================
# REMOVE THE CRON FILE # REMOVE THE CRON FILE
#================================================= #=================================================
ynh_script_progression --message="Removing cron job and aliases..." 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"
#================================================= #=================================================
#removing aliases #removing aliases
#================================================= #=================================================
ynh_replace_string "devnull:/dev/null" "" /etc/aliases ynh_replace_string "devnull:/dev/null" "" /etc/aliases
newaliases newaliases
@ -90,4 +77,8 @@ 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
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" ynh_script_progression --message="Removal of $app completed"

View file

@ -2,16 +2,10 @@
#================================================= #=================================================
# GENERIC START # GENERIC START
#=================================================
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
#if [ ! -e _common.sh ]; then
# # Get the _common.sh file if it's not in the current directory
# cp ../settings/scripts/_common.sh ./_common.sh
# chmod a+rx _common.sh
#fi
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -40,8 +34,6 @@ admin=$(ynh_app_setting_get $app admin)
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --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}"
test ! -d $final_path \ test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path " || ynh_die "There is already a directory: $final_path "
@ -61,7 +53,16 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file "$final_path" ynh_restore_file --origin_path="$final_path"
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=5
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_add_fpm_config --package="$extra_php_dependencies"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
@ -87,7 +88,6 @@ for i in $lang ; do
done done
locale-gen locale-gen
#================================================= #=================================================
# RESTORE POSTFIX ALIASES # RESTORE POSTFIX ALIASES
#================================================= #=================================================

View file

@ -13,31 +13,39 @@ source /usr/share/yunohost/helpers
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation 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)
path_url=$(ynh_app_setting_get $app path) domain=$(ynh_app_setting_get --app=$app --key=domain)
admin=$(ynh_app_setting_get $app admin) path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get $app final_path) admin=$(ynh_app_setting_get --app=$app --key=admin)
db_name=$(ynh_app_setting_get $app db_name) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
### This helper will compare the version of the currently installed app and the version of the upstream package.
### $upgrade_type can have 2 different values
### - UPGRADE_APP if the upstream app version has changed
### - UPGRADE_PACKAGE if only the YunoHost package has changed
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
### Not used yet in this script
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# 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 () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." ynh_script_progression --message="Ensuring downward compatibility..."
# Fix is_public as a boolean value
# 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
@ -51,23 +59,6 @@ if [ -z "$final_path" ]; then
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi 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 () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# Migrate legacy permissions to new system
#=================================================
if ynh_legacy_permissions_exists if ynh_legacy_permissions_exists
then then
ynh_legacy_permissions_delete_all ynh_legacy_permissions_delete_all
@ -75,11 +66,6 @@ then
ynh_app_setting_delete --app=$app --key=is_public ynh_app_setting_delete --app=$app --key=is_public
fi fi
#=================================================
# CHECK THE PATH
#=================================================
# Normalize the URL path syntax
#================================================= #=================================================
#check for matlink's version - DEPRECATED - uninstall & reinstall #check for matlink's version - DEPRECATED - uninstall & reinstall
#================================================= #=================================================
@ -139,6 +125,7 @@ ynh_add_nginx_config
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
@ -157,8 +144,8 @@ fi
#================================================= #=================================================
#INSTALL SOURCES #INSTALL SOURCES
#=============================================== #===============================================
ynh_script_progression --message="Upgrading source files..." 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
@ -190,17 +177,17 @@ yunohost tools regen-conf postfix -f
chown -R www-data:www-data $final_path chown -R www-data:www-data $final_path
chown root:root /etc/cron.d/$app chown root:root /etc/cron.d/$app
#================================================= #=================================================
# RELOAD SERVICES # RELOAD SERVICES
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=php$phpversion-fpm --action=restart ynh_systemd_action --service_name=php$phpversion-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
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression --message="Upgrade of $app completed" --last