From 1740efd0a317a6d4c5c860d38bb4a04c9e5f71fe Mon Sep 17 00:00:00 2001 From: dragondaddy Date: Sun, 12 Nov 2023 15:19:06 +0100 Subject: [PATCH] Rework of scripts More scripts rework Can't even remember why I'm doing this Oopsie wrong filename wrong filename, again! Give up the ynh_setup_source strategy --- manifest.toml | 13 +------------ scripts/backup | 3 ++- scripts/install | 11 ++++++----- scripts/remove | 3 +++ scripts/restore | 15 +++++++++++---- scripts/upgrade | 4 ++-- 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/manifest.toml b/manifest.toml index e08b34f..294d095 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Streams" description.en = "Open source fediverse server" description.fr = "Serveur fediverse open source" -version = "23.11.11~ynh1" +version = "23.11.12~ynh1" maintainers = ["Papa Dragon"] @@ -37,17 +37,6 @@ ram.runtime = "50M" type = "user" [resources] -<<<<<<< HEAD - [resources.sources] - [resources.sources.main] - url = "https://codeberg.org/streams/streams/archive/8fb92b522b8bff562b350070b57954a998875e58.tar.gz" - sha256 = "b06cb71508cdb166002b41d08a9385bac2bfd9ddb3301116a8cdf9b3bc026275" - - [resources.sources.addons] - url = "https://codeberg.org/streams/streams-addons/archive/39b1c5af9f2b1c639b6438ac85b0ea85273fc201.tar.gz" - sha256 = "5885665bf3dfbe843387184543be17b6b2061b807a57c1d6962548af80794f75" -======= ->>>>>>> d73fcb5 (Switch from tarball download to git clone for the install) [resources.ports] diff --git a/scripts/backup b/scripts/backup index 9d780ff..c06af88 100644 --- a/scripts/backup +++ b/scripts/backup @@ -49,10 +49,11 @@ ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= -# BACKUP VARIOUS FILES +# BACKUP CRON JOBS #================================================= ynh_backup --src_path="/etc/cron.d/$app" +ynh_backup --src_path="/$data_dir" #================================================= # BACKUP THE DATABASE diff --git a/scripts/install b/scripts/install index 1fa3713..003e705 100755 --- a/scripts/install +++ b/scripts/install @@ -79,6 +79,11 @@ ynh_script_progression --message="Pulling in external libraries with Composer... ynh_install_composer --workdir="$install_dir" chown -R $app:www-data "$install_dir" +#================================================= +# ADDONS +#================================================= +ynh_script_progression --message="Installing addons..." + pushd $install_dir ynh_exec_as $app git config pull.rebase false ynh_exec_as $app util/add_addon_repo https://codeberg.org/streams/streams-addons.git zaddons @@ -102,17 +107,13 @@ ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_add_config --template="../conf/htconfig.sample.php" --destination="$install_dir/.htconfig.php" -# addon ldap config -#ynh_script_progression --message="Push LDAP configuration to .htconfig.php..." - -#cat ../conf/ldap_conf.php >> $install_dir/.htconfig.php ynh_store_file_checksum --file=$install_dir/.htconfig.php chmod 600 "$install_dir/.htconfig.php" chown $app:$app "$install_dir/.htconfig.php" #================================================= -# SET CRON JOB +# SET CRON JOBS #================================================= ynh_script_progression --message="Setuping cron job..." --weight=1 diff --git a/scripts/remove b/scripts/remove index 8101afc..e230ab7 100755 --- a/scripts/remove +++ b/scripts/remove @@ -29,6 +29,9 @@ ynh_remove_fail2ban_config # Remove a cron file ynh_secure_remove --file="/etc/cron.d/$app" +# Remove daily updates logfile +ynh_secure_remove --file="$data_dir/daily-updates.log" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 0c7de08..9724b92 100644 --- a/scripts/restore +++ b/scripts/restore @@ -38,12 +38,15 @@ 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_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - +#================================================= +# RESTORE CRON JOBS +#================================================= ynh_restore_file --origin_path="/etc/cron.d/$app" +ynh_restore_file --origin_path="$data_dir" +#================================================= +# RESTORE LOGROTATE +#================================================= ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= @@ -53,6 +56,10 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index fbb37d4..aca9fd9 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -57,7 +57,7 @@ then # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" --keep="store/ .htconfig.php php.log" - ynh_setup_source --dest_dir="$install_dir/addon" --source_id="addons" + fi mkdir -p "$install_dir/store" @@ -115,7 +115,7 @@ chmod 644 "/etc/cron.d/$app" ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append +ynh_use_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"