diff --git a/conf/cron.conf b/conf/cron.conf index 26ed754..5cd4ef8 100755 --- a/conf/cron.conf +++ b/conf/cron.conf @@ -1,2 +1,2 @@ # Run poller periodically to update Osada -*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ __INSTALL_DIR__/Zotlabs/Daemon/Master.php Cron > /dev/null 2>&1 +*/10 * * * * __APP__ /usr/bin/php__PHP_VERSION__ __INSTALL_DIR__/Zotlabs/Daemon/Master.php Cron > /dev/null 2>&1 diff --git a/conf/htconfig.sample.php b/conf/htconfig.sample.php index e53f862..623658d 100644 --- a/conf/htconfig.sample.php +++ b/conf/htconfig.sample.php @@ -70,7 +70,7 @@ App::$config['system']['admin_email'] = '__EMAIL__'; // Location of PHP command line processor -App::$config['system']['php_path'] = 'php__PHPVERSION__'; +App::$config['system']['php_path'] = 'php__PHP_VERSION__'; // Configure how we communicate with directory servers. diff --git a/conf/nginx.conf b/conf/nginx.conf index e79b406..cc760f2 100755 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -18,7 +18,7 @@ location __PATH__/ { location ~* \.php$ { try_files $uri =404; - fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock; fastcgi_index index.php; include fastcgi_params; diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 14511d1..01205bf 100755 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -1,7 +1,7 @@ ; Start a new pool named 'www'. ; the variable $pool can be used in any directive and will be replaced by the ; pool name ('www' here) -[__NAMETOCHANGE__] +[__APP__] ; Per pool prefix ; It only applies on the following directives: @@ -20,8 +20,8 @@ ; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. -user = __USER__ -group = __USER__ +user = __APP__ +group = __APP__ ; The address on which to accept FastCGI requests. ; Valid syntaxes are: @@ -33,7 +33,7 @@ group = __USER__ ; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php/php__PHP_VERSION__-fpm-__APP__.sock ; Set listen(2) backlog. ; Default Value: 511 (-1 on FreeBSD and OpenBSD) @@ -320,7 +320,7 @@ pm.max_requests = 500 ; The log file for slow requests ; Default Value: not set ; Note: slowlog is mandatory if request_slowlog_timeout is set -slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log +slowlog = /var/log/nginx/__APP__.slow.log ; The timeout for serving a single request after which a PHP backtrace will be ; dumped to the 'slowlog' file. A value of '0s' means 'off'. diff --git a/manifest.toml b/manifest.toml index 490b5d7..b079b51 100644 --- a/manifest.toml +++ b/manifest.toml @@ -17,7 +17,8 @@ website = "http://zotlabs.com/osada/" code = "https://codeberg.org/zot-archive/osada" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = true ldap = true @@ -52,6 +53,7 @@ ram.runtime = "200M" [resources.system_user] [resources.install_dir] + group = "www-data:r-x" [resources.permissions] main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..3d7f008 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,17 +1,5 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index d9da129..c633258 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,44 +1,35 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf" #================================================= # BACKUP FAIL2BAN CONFIGURATION #================================================= -ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" -ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" +ynh_backup "/etc/fail2ban/jail.d/$app.conf" +ynh_backup "/etc/fail2ban/filter.d/$app.conf" #================================================= # SPECIFIC BACKUP @@ -46,22 +37,22 @@ ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" # BACKUP LOGROTATE #================================================= -ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup "/etc/logrotate.d/$app" #================================================= # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/cron.d/$app" +ynh_backup "/etc/cron.d/$app" #================================================= # BACKUP THE DATABASE #================================================= -ynh_psql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_db > db.sql #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index a9df042..cbbdb8c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -14,22 +14,22 @@ source /usr/share/yunohost/helpers #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # SPECIFIC MODIFICATIONS #================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 +ynh_script_progression "Updating configuration..." -ynh_add_config --template="htconfig.sample.php" --destination="$install_dir/.htconfig.php" +ynh_config_add --template="htconfig.sample.php" --destination="$install_dir/.htconfig.php" -chmod 600 "$install_dir/.htconfig.php" -chown "$app:$app" "$install_dir/.htconfig.php" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 600 "$install_dir/.htconfig.php" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/.htconfig.php" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 26d508a..0c325b2 100755 --- a/scripts/install +++ b/scripts/install @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -17,14 +11,14 @@ email=$(ynh_user_get_info --username=$admin --key=mail) upload="256M" random_string="$(ynh_string_random --length=48)" -ynh_app_setting_set --app=$app --key=email --value=$email -ynh_app_setting_set --app=$app --key=upload --value=$upload -ynh_app_setting_set --app=$app --key=random_string --value=$random_string +ynh_app_setting_set --key=email --value=$email +ynh_app_setting_set --key=upload --value=$upload +ynh_app_setting_set --key=random_string --value=$random_string #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression "Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" @@ -34,52 +28,52 @@ touch "$install_dir/php.log" mkdir -p "$install_dir/store" mkdir -p "$install_dir/cache/smarty3" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" chmod -R 775 $install_dir/store $install_dir/cache #================================================= # PROVISION DATABASE #================================================= -ynh_script_progression --message="Provisionning database..." +ynh_script_progression "Provisionning database..." -ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < "$install_dir/install/schema_postgres.sql" +ynh_psql_db_shell < "$install_dir/install/schema_postgres.sql" #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression "Adding $app's configuration..." -ynh_add_config --template="htconfig.sample.php" --destination="$install_dir/.htconfig.php" +ynh_config_add --template="htconfig.sample.php" --destination="$install_dir/.htconfig.php" -chmod 600 "$install_dir/.htconfig.php" -chown $app:$app "$install_dir/.htconfig.php" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 600 "$install_dir/.htconfig.php" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/.htconfig.php" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated PHP-FPM config -ynh_add_fpm_config +ynh_config_add_phpfpm # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Use logrotate to manage application logfile(s) -ynh_use_logrotate "$install_dir/php.log" +ynh_config_add_logrotate "$install_dir/php.log" # Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" --max_retry="5" +ynh_config_add_fail2ban --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" # Set up cron job -ynh_add_config --template="cron.conf" --destination="/etc/cron.d/$app" -chown root: "/etc/cron.d/$app" -chmod 644 "/etc/cron.d/$app" +ynh_config_add --template="cron.conf" --destination="/etc/cron.d/$app" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 1b94130..0cb7a95 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,36 +1,30 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression "Loading installation settings..." #REMOVEME? app=$YNH_APP_INSTANCE_NAME -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? domain=$(ynh_app_setting_get --key=domain) +#REMOVEME? db_name=$(ynh_app_setting_get --key=db_name) #REMOVEME? db_user=$db_name -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --key=install_dir) +#REMOVEME? database=$(ynh_app_setting_get --key=database) #================================================= # STANDARD REMOVE #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing logrotate configuration..." +ynh_script_progression "Removing logrotate configuration..." # Remove the app-specific logrotate config -ynh_remove_logrotate +ynh_config_remove_logrotate #================================================= # REMOVE THE DATABASE @@ -39,59 +33,57 @@ ynh_remove_logrotate #================================================= # REMOVE APP MAIN DIR #================================================= -#REMOVEME? ynh_script_progression --message="Removing app main directory..." +#REMOVEME? ynh_script_progression "Removing app main directory..." # Remove the app directory securely -#REMOVEME? ynh_secure_remove --file="$install_dir" +#REMOVEME? ynh_safe_rm "$install_dir" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." +ynh_script_progression "Removing NGINX web server configuration..." # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Removing PHP-FPM configuration..." +ynh_script_progression "Removing PHP-FPM configuration..." # Remove the dedicated PHP-FPM config -ynh_remove_fpm_config +ynh_config_remove_phpfpm #================================================= # REMOVE DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." +#REMOVEME? ynh_script_progression "Removing dependencies..." # Remove metapackage and its dependencies -#REMOVEME? ynh_remove_app_dependencies +#REMOVEME? ynh_apt_remove_dependencies #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= -ynh_script_progression --message="Removing Fail2Ban configuration..." +ynh_script_progression "Removing Fail2Ban configuration..." # Remove the dedicated Fail2Ban config -ynh_remove_fail2ban_config +ynh_config_remove_fail2ban #================================================= # SPECIFIC REMOVE #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." +ynh_script_progression "Removing various files..." # Remove a cron file -ynh_secure_remove --file="/etc/cron.d/$app" +ynh_safe_rm "/etc/cron.d/$app" -#================================================= -# GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= -#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." +#REMOVEME? ynh_script_progression "Removing the dedicated system user..." # Delete a system user #REMOVEME? ynh_system_user_delete --username=$app @@ -100,4 +92,4 @@ ynh_secure_remove --file="/etc/cron.d/$app" # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index cedb7ea..7a76dcf 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -13,87 +7,83 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression "Loading installation settings..." #REMOVEME? app=$YNH_APP_INSTANCE_NAME -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? domain=$(ynh_app_setting_get --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --key=path) +#REMOVEME? admin=$(ynh_app_setting_get --key=admin) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --key=install_dir) +#REMOVEME? db_name=$(ynh_app_setting_get --key=db_name) #REMOVEME? db_user=$db_name -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database) +#REMOVEME? php_version=$(ynh_app_setting_get --key=php_version) +#REMOVEME? database=$(ynh_app_setting_get --key=database) #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" - -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +ynh_restore "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # RESTORE FAIL2BAN CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the Fail2Ban configuration..." +ynh_script_progression "Restoring the Fail2Ban configuration..." -ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" -ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" -ynh_systemd_action --action=restart --service_name=fail2ban +ynh_restore "/etc/fail2ban/jail.d/$app.conf" +ynh_restore "/etc/fail2ban/filter.d/$app.conf" +ynh_systemctl --action=restart --service=fail2ban #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the PHP-FPM configuration..." +ynh_script_progression "Restoring the PHP-FPM configuration..." -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf" #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." +ynh_script_progression "Restoring the NGINX web server configuration..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE DATABASE #================================================= -#REMOVEME? ynh_script_progression --message="Restoring the MySQL database..." - -ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" +#REMOVEME? ynh_script_progression "Restoring the MySQL database..." +ynh_psql_db_shell " < "./db.sql"" #================================================= # RESTORE VARIOUS FILES #================================================= -ynh_script_progression --message="Restoring various files..." +ynh_script_progression "Restoring various files..." -ynh_restore_file --origin_path="/etc/cron.d/$app" +ynh_restore "/etc/cron.d/$app" #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." +ynh_script_progression "Restoring the logrotate configuration..." -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_restore "/etc/logrotate.d/$app" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." +ynh_script_progression "Reloading NGINX web server and PHP-FPM..." -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=php$php_version-fpm --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index b5962ba..357fcdb 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,102 +1,92 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression "Loading installation settings..." #REMOVEME? app=$YNH_APP_INSTANCE_NAME -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? domain=$(ynh_app_setting_get --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --key=path) +#REMOVEME? admin=$(ynh_app_setting_get --key=admin) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --key=install_dir) +#REMOVEME? db_name=$(ynh_app_setting_get --key=db_name) #REMOVEME? db_user=$db_name -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -#REMOVEME? database=$(ynh_app_setting_get --app=$app --key=database) -#REMOVEME? upload=$(ynh_app_setting_get --app=$app --key=upload) -#REMOVEME? random_string=$(ynh_app_setting_get --app=$app --key=random_string) +#REMOVEME? php_version=$(ynh_app_setting_get --key=php_version) +#REMOVEME? database=$(ynh_app_setting_get --key=database) +#REMOVEME? upload=$(ynh_app_setting_get --key=upload) +#REMOVEME? random_string=$(ynh_app_setting_get --key=random_string) email=$(ynh_user_get_info --username=$admin --key=mail) -#================================================= -# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." +ynh_script_progression "Ensuring downward compatibility..." # # Switch $database to "mysql" or "postgresql" # if [[ $database == "1" ]] 2>/dev/null; then # database="mysql" -# ynh_app_setting_set --app=$app --key=database --value=$database +# ynh_app_setting_set --key=database --value=$database # elif [[ $database == "2" ]] 2>/dev/null; then # database="postgresql" -# ynh_app_setting_set --app=$app --key=database --value=$database +# ynh_app_setting_set --key=database --value=$database # fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." +ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="store/ .htconfig.php php.log" +ynh_setup_source --dest_dir="$install_dir" --full_replace --keep="store/ .htconfig.php php.log" ynh_setup_source --dest_dir="$install_dir/addon" --source_id="app_addons" mkdir -p "$install_dir/store" mkdir -p "$install_dir/cache/smarty3" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" chmod -R 775 $install_dir/store $install_dir/cache -#================================================= -# SPECIFIC UPGRADE #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 +ynh_script_progression "Updating configuration..." -ynh_add_config --template="htconfig.sample.php" --destination="$install_dir/.htconfig.php" +ynh_config_add --template="htconfig.sample.php" --destination="$install_dir/.htconfig.php" -chmod 600 "$install_dir/.htconfig.php" -chown $app:$app "$install_dir/.htconfig.php" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 600 "$install_dir/.htconfig.php" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/.htconfig.php" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." # Create a dedicated PHP-FPM config -ynh_add_fpm_config +ynh_config_add_phpfpm # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append +ynh_config_add_logrotate # Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" --max_retry="5" +ynh_config_add_fail2ban --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP .*$" # Set up cron job -ynh_add_config --template="cron.conf" --destination="/etc/cron.d/$app" -chown root: "/etc/cron.d/$app" -chmod 644 "/etc/cron.d/$app" +ynh_config_add --template="cron.conf" --destination="/etc/cron.d/$app" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" +ynh_script_progression "Upgrade of $app completed"