From a2272a7e6d0c4fc4e8672594d74e89b293cede7f Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 6 Nov 2023 18:11:58 +0100 Subject: [PATCH 1/8] Update restore --- scripts/restore | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/restore b/scripts/restore index f54bc62..d4f24c7 100755 --- a/scripts/restore +++ b/scripts/restore @@ -39,6 +39,7 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=10 # Define and install dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_use_nodejs # Upgrade NPM ynh_npm install --global npm@6.14.18 From b5e3462c847433ae2f4d5d3e2a6e7ff87b80f3a1 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 6 Nov 2023 20:10:52 +0100 Subject: [PATCH 2/8] cleanup --- scripts/backup | 28 +++++++++---------- scripts/change_url | 2 +- scripts/install | 9 ++++-- scripts/restore | 64 ++++++++++++------------------------------ scripts/upgrade | 69 ++++++++++++++++++---------------------------- 5 files changed, 66 insertions(+), 106 deletions(-) diff --git a/scripts/backup b/scripts/backup index 061d06e..bd7b20f 100755 --- a/scripts/backup +++ b/scripts/backup @@ -22,27 +22,27 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$install_dir" #================================================= -# BACKUP THE NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= +# Backup the nginx configuration ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= - -ynh_backup --src_path="/var/log/$app" - -#================================================= -# BACKUP SYSTEMD -#================================================= - +# Backup the systemd service unit ynh_backup --src_path="/etc/systemd/system/$app.service" +# Backup the logrotate configuration +ynh_backup --src_path="/etc/logrotate.d/$app" + +#================================================= +# BACKUP THE POSTGRESQL DATABASE +#================================================= +ynh_print_info --message="Backing up the PostgreSQL database..." + +ynh_psql_dump_db --database="$db_name" > 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 --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." \ No newline at end of file diff --git a/scripts/change_url b/scripts/change_url index d4c611e..9db32d3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -46,4 +46,4 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression --message="Change of URL completed for $app" --last \ No newline at end of file diff --git a/scripts/install b/scripts/install index da84500..14da4f0 100755 --- a/scripts/install +++ b/scripts/install @@ -83,10 +83,13 @@ ynh_add_systemd_config #================================================= ynh_script_progression --message="Configuring logrotate to manage application logfiles" --weight=1 +mkdir -p "/var/log/$app" +touch "/var/log/$app/$app.log" +chown -R "$app:$app" "/var/log/$app" +chmod -R u=rwX,g=rX,o= "/var/log/$app" + # Use logrotate to manage application logfile(s) -ynh_use_logrotate --specific_user=$app -touch /var/log/$app/$app.log -chown -R $app:www-data /var/log/$app/ +ynh_use_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST diff --git a/scripts/restore b/scripts/restore index d4f24c7..3bea062 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,77 +10,49 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=3 +ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$install_dir" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= -# SPECIFIC RESTORATION +# RESTORE SYSTEM CONFIGURATIONS #================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=10 +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 -# Define and install dependencies -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_use_nodejs - -# Upgrade NPM -ynh_npm install --global npm@6.14.18 - -#================================================= -# RESTORE SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 +yunohost service add $app --description="Jellyseer Service" --log="/var/log/$app/$app.log" mkdir -p "/var/log/$app" -chown -R $app: "/var/log/$app" -ynh_restore_file --origin_path="/var/log/$app" +touch "/var/log/$app/$app.log" +chown -R "$app:$app" "/var/log/$app" +chmod -R u=rwX,g=rX,o= "/var/log/$app" + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= -# INTEGRATE SERVICE IN YUNOHOST +# RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 -yunohost service add $app --log="/var/log/$app/$app.log" - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 - -ynh_exec_warn_less ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="" +ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=nginx --action=reload @@ -88,4 +60,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression --message="Restoration completed for $app" --last \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index 00a2126..878b1ea 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,13 +11,6 @@ source /usr/share/yunohost/helpers upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 - -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" - #================================================= # INSTALL DEPENDENCIES #================================================= @@ -28,14 +21,20 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Upgrade NPM ynh_npm install --global npm@6.14.18 +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + #================================================= # "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) #================================================= -# BUILD APP +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Building app... This may take quiete some time" --weight=30 - -ynh_secure_remove $install_dir/terraforming-mars cd $install_dir ynh_exec_warn_less git clone https://github.com/terraforming-mars/terraforming-mars.git @@ -57,6 +56,19 @@ chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:$app "$install_dir" +#================================================= +# REAPPLY SYSTEM CONFIGURATIONS +#================================================= +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 + +ynh_add_nginx_config + +ynh_add_systemd_config + +yunohost service add $app --description="Jellyseer Service" --log="/var/log/$app/$app.log" + +ynh_use_logrotate --non-append + #================================================= # RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) #================================================= @@ -66,45 +78,18 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" -chmod 600 "$install_dir/.env" +chmod 400 "$install_dir/.env" chown $app:$app "$install_dir/.env" -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." - -# Create a dedicated systemd config -ynh_add_systemd_config - -#================================================= -# GENERIC FINALIZATION -#================================================= -# LOGROTATE -#================================================= -ynh_script_progression --message="Configuring logrotate to manage application logfiles" --weight=1 - -# Use logrotate to manage application logfile(s) -ynh_use_logrotate --specific_user=$app -touch /var/log/$app/$app.log -chown -R $app:www-data /var/log/$app/ - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add $app --log="/var/log/$app/$app.log" - #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_exec_warn_less ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="" +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression --message="Upgrade of $app completed" --last \ No newline at end of file From bfebc43f61aa993404a450e7ef115db2f8197f50 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 6 Nov 2023 20:17:29 +0100 Subject: [PATCH 3/8] Update install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 14da4f0..c62196a 100755 --- a/scripts/install +++ b/scripts/install @@ -96,7 +96,7 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --log="/var/log/$app/$app.log" +yunohost service add $app --description=Jellyseer Service --log=/var/log/$app/$app.log #================================================= # START SYSTEMD SERVICE From ef27f937840fbb51cbc9497ff14d2ed05a27f810 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 6 Nov 2023 20:40:52 +0100 Subject: [PATCH 4/8] fix service name --- conf/systemd.service | 2 +- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index a37151c..674e703 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,5 +1,5 @@ [Unit] -Description=Jellyseer Service +Description=Terraforming-Mars Service Wants=network-online.target After=network-online.target diff --git a/scripts/install b/scripts/install index c62196a..e168d09 100755 --- a/scripts/install +++ b/scripts/install @@ -96,7 +96,7 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description=Jellyseer Service --log=/var/log/$app/$app.log +yunohost service add $app --description="Terraforming-Mars Service" --log=/var/log/$app/$app.log #================================================= # START SYSTEMD SERVICE diff --git a/scripts/restore b/scripts/restore index 3bea062..baa934a 100755 --- a/scripts/restore +++ b/scripts/restore @@ -29,7 +29,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -yunohost service add $app --description="Jellyseer Service" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Terraforming-Mars Service" --log="/var/log/$app/$app.log" mkdir -p "/var/log/$app" touch "/var/log/$app/$app.log" diff --git a/scripts/upgrade b/scripts/upgrade index 878b1ea..4feeb1d 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -65,7 +65,7 @@ ynh_add_nginx_config ynh_add_systemd_config -yunohost service add $app --description="Jellyseer Service" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Terraforming-Mars Service" --log="/var/log/$app/$app.log" ynh_use_logrotate --non-append From 953fd13430a1149e7d6d3f94ad0ff8d0efc4f8d4 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 6 Nov 2023 20:44:03 +0100 Subject: [PATCH 5/8] fix upgrade --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index 4feeb1d..a6b04cd 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -37,6 +37,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app #================================================= cd $install_dir +ynh_secure_remove terraforming-mars ynh_exec_warn_less git clone https://github.com/terraforming-mars/terraforming-mars.git cd $install_dir/terraforming-mars From ee26ec987cdd8b0be977cc145fd590847896bca3 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Fri, 17 Nov 2023 11:53:54 +0100 Subject: [PATCH 6/8] Update _common.sh --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 0a5d1f8..e6f43c4 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,7 +8,7 @@ nodejs_version=16 # Terraforming-mars commit -TM_version="7e36410" +TM_version="38c69c7" #================================================= # PERSONAL HELPERS From f09225eb10e8f6fbb56be540b49b5f734141b167 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Fri, 17 Nov 2023 11:54:16 +0100 Subject: [PATCH 7/8] Update package --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index e2214d8..4531941 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,7 +7,7 @@ name = "Terraforming Mars " description.en = "Open-source online implementation of the great board game Terraforming mars." description.fr = "Implementation en ligne à code source ouvert de l’excellent jeu de plateau Terraforming Mars" -version = "20231103~ynh1" +version = "20231115~ynh1" maintainers = ["Thovi98"] From 20cb29c5abfa27779f9bcdd626b3ee1cdefc40d4 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 17 Nov 2023 10:54:20 +0000 Subject: [PATCH 8/8] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e316374..2495b7d 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in This is an open-source online implementation of the great board game Terraforming mars. It is not affiliated with FryxGames, Asmodee Digital or Steam in any way. -**Shipped version:** 20231103~ynh1 +**Shipped version:** 20231115~ynh1 **Demo:** https://terraforming-mars.herokuapp.com/ diff --git a/README_fr.md b/README_fr.md index ad922d1..765d2be 100644 --- a/README_fr.md +++ b/README_fr.md @@ -18,7 +18,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po Cette application est une implémentation en ligne et open source de l’excellent jeu de plateau Terraforming mars. Elle n’est affiliée à FryxGames, Asmodee Digital ou Steam en aucun cas. -**Version incluse :** 20231103~ynh1 +**Version incluse :** 20231115~ynh1 **Démo :** https://terraforming-mars.herokuapp.com/