1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/framagames_ynh.git synced 2024-09-03 18:36:28 +02:00
* Fix some linter warnings
* Add change_url script
This commit is contained in:
Éric Gaspar 2020-11-18 14:29:49 +01:00 committed by GitHub
parent c42343982b
commit 7a61185e8f
12 changed files with 145 additions and 80 deletions

View file

@ -24,8 +24,7 @@ Set of games from Framagames
--- ---
Developer info ## Developer info
----------------
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/framagames_ynh/tree/testing). Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/framagames_ynh/tree/testing).

View file

@ -20,10 +20,8 @@
upgrade=1 from_commit=bd2c87a6fd4212771f9c06e7965598a5ea744ffc upgrade=1 from_commit=bd2c87a6fd4212771f9c06e7965598a5ea744ffc
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
# incorrect_path=1
port_already_use=0 port_already_use=0
change_url=0 change_url=1
;;; Levels ;;; Levels
# If the level 5 (Package linter) is forced to 1. Please add justifications here. # If the level 5 (Package linter) is forced to 1. Please add justifications here.
Level 5=auto Level 5=auto
@ -34,4 +32,3 @@ Notification=none
; commit=CommitHash ; commit=CommitHash
name=Name and date of the commit. name=Name and date of the commit.
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -19,11 +19,11 @@ location __PATH__/ {
fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php; fastcgi_index index.php;
include fastcgi_params; include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user; fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_param SCRIPT_FILENAME $request_filename;
} }
# Include SSOWAT user panel. # Include SSOWAT user panel.

View file

@ -7,7 +7,7 @@ about: Create a report to help us debug, it would be nice to fill the template a
**How to post a meaningful bug report** **How to post a meaningful bug report**
1. *Read this whole template first.* 1. *Read this whole template first.*
2. *Determine if you are on the right place:* 2. *Determine if you are on the right place:*
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!* - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
- *Otherwise, the issue may be due to Framagames itself. Refer to its documentation or repository for help.* - *Otherwise, the issue may be due to Framagames itself. Refer to its documentation or repository for help.*
- *If you have a doubt, post here, we will figure it out together.* - *If you have a doubt, post here, we will figure it out together.*
3. *Delete the italic comments as you write over them below, and remove this guide.* 3. *Delete the italic comments as you write over them below, and remove this guide.*
@ -34,8 +34,8 @@ about: Create a report to help us debug, it would be nice to fill the template a
- *If you used the webadmin, please perform the equivalent command from the CLI first.* - *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:* - *If the error occurs in your browser, explain what you did:*
1. *Go to '...'* 1. *Go to '...'*
2. *Click on '....'* 2. *Click on '...'*
3. *Scroll down to '....'* 3. *Scroll down to '...'*
4. *See error* 4. *See error*
**Expected behavior** **Expected behavior**

View file

@ -6,15 +6,15 @@
"en": "Set of games Framagames from Framasoft", "en": "Set of games Framagames from Framasoft",
"fr": "Ensemble de jeux Framagames venant de Framasoft" "fr": "Ensemble de jeux Framagames venant de Framasoft"
}, },
"version": "1.0~ynh2", "version": "1.0~ynh3",
"url": "https://github.com/YunoHost-Apps/framagames_ynh", "url": "https://framagit.org/framasoft/framagames",
"license": "free", "license": "free",
"maintainer": { "maintainer": {
"name": "polytan02", "name": "polytan02",
"email": "polytan02@mcgva.org" "email": "polytan02@mcgva.org"
}, },
"requirements": { "requirements": {
"yunohost": ">= 3.5" "yunohost": ">= 4.0.0"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
@ -27,8 +27,8 @@
"name": "domain", "name": "domain",
"type": "domain", "type": "domain",
"ask": { "ask": {
"en": "Choose a domain for your framagames", "en": "Choose a domain for your Framagames",
"fr": "Choisissez un domaine pour vos framagames" "fr": "Choisissez un domaine pour vos Framagames"
}, },
"example": "example.com" "example": "example.com"
}, },
@ -36,8 +36,8 @@
"name": "path", "name": "path",
"type": "path", "type": "path",
"ask": { "ask": {
"en": "Choose a path to access your framagames", "en": "Choose a path to access your Framagames",
"fr": "Choisissez un chemin pour acceder a vos framagames" "fr": "Choisissez un chemin pour acceder à vos Framagames"
}, },
"example": "/framagames", "example": "/framagames",
"default": "/framagames" "default": "/framagames"

View file

@ -4,6 +4,8 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
YNH_PHP_VERSION="7.3"
# dependencies used by the app # dependencies used by the app
pkg_dependencies="" pkg_dependencies=""

View file

@ -6,7 +6,6 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -14,10 +13,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================

105
scripts/change_url Normal file
View file

@ -0,0 +1,105 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating nginx web server configuration..." --weight=2
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the nginx config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for nginx helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated nginx config
ynh_add_nginx_config
fi
# Change the domain for nginx
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINXweb server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
@ -63,17 +59,17 @@ ynh_setup_source --dest_dir="$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring nginx web server..." ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated nginx config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring php-fpm..." ynh_script_progression --message="Configuring PHP-FPM..."
# Create a dedicated php-fpm config # Create a dedicated PHP-FPM config
ynh_add_fpm_config ynh_add_fpm_config
#================================================= #=================================================
@ -84,7 +80,7 @@ ynh_add_fpm_config
ynh_script_progression --message="Securing files and directories..." ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files # Set permissions to app files
chmod 775 -R $final_path chmod -R 775 $final_path
chown -hR www-data:www-data $final_path chown -hR www-data:www-data $final_path
#================================================= #=================================================
@ -92,17 +88,18 @@ chown -hR www-data:www-data $final_path
#================================================= #=================================================
ynh_script_progression --message="Configuring SSOwat..." ynh_script_progression --message="Configuring SSOwat..."
# Make app public if necessary # Make app public if necessary or protect it
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
then then
# unprotected_uris allows SSO credentials to be passed anyway. # Everyone can access the app.
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" # The "main" permission is automatically created before the install script.
ynh_permission_update --permission "main" --add "visitors"
fi fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload

View file

@ -32,20 +32,19 @@ 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
#================================================= #=================================================
# REMOVE PHP-FPM CONFIGURATION # REMOVE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing php-fpm configuration..." ynh_script_progression --message="Removing PHP-FPM configuration..."
# Remove the dedicated php-fpm config # Remove the dedicated PHP-FPM config
ynh_remove_fpm_config ynh_remove_fpm_config
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -6,7 +6,6 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -14,10 +13,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
@ -78,7 +73,7 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX AND PHP-FPM
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server and php-fpm..." ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload

View file

@ -68,18 +68,6 @@ ynh_clean_setup () {
# 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
#=================================================
# CHECK THE PATH
#=================================================
# Normalize the URL path syntax
# N.B. : this is for app installations before YunoHost 2.7
# where this value might be something like /foo/ or foo/
# instead of /foo ....
# If nobody installed your app before 2.7, then you may
# safely remove this line
path_url=$(ynh_normalize_url_path --path_url=$path_url)
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -98,17 +86,17 @@ fi
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading nginx web server configuration..." ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated nginx config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading php-fpm configuration..." ynh_script_progression --message="Upgrading PHP-FPM configuration..."
# Create a dedicated php-fpm config # Create a dedicated PHP-FPM config
ynh_add_fpm_config ynh_add_fpm_config
#================================================= #=================================================
@ -119,25 +107,13 @@ ynh_add_fpm_config
ynh_script_progression --message="Securing files and directories..." ynh_script_progression --message="Securing files and directories..."
# Set permissions on app files # Set permissions on app files
chmod 775 -R $final_path chmod -R 775 $final_path
chown -hR www-data:www-data $final_path chown -hR www-data:www-data $final_path
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Upgrading SSOwat configuration..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload