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/ 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/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"] 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 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..e168d09 100755 --- a/scripts/install +++ b/scripts/install @@ -83,17 +83,20 @@ 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 #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --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 f54bc62..baa934a 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,76 +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 - -# 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="Terraforming-Mars 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 @@ -87,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..a6b04cd 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,16 +21,23 @@ 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_secure_remove terraforming-mars ynh_exec_warn_less git clone https://github.com/terraforming-mars/terraforming-mars.git cd $install_dir/terraforming-mars @@ -57,6 +57,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="Terraforming-Mars Service" --log="/var/log/$app/$app.log" + +ynh_use_logrotate --non-append + #================================================= # RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) #================================================= @@ -66,45 +79,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