1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jirafeau_ynh.git synced 2024-09-03 19:35:53 +02:00

Apply example_ynh

This commit is contained in:
yalh76 2022-07-28 23:32:49 +02:00
parent 2ad16181db
commit 1373072c77
10 changed files with 186 additions and 193 deletions

View file

@ -2,9 +2,9 @@
; Manifest ; Manifest
domain="domain.tld" domain="domain.tld"
path="/path" path="/path"
is_public=1
admin_user="package_checker" admin_user="package_checker"
upload_password="supersecretpassword" upload_password="supersecretpassword"
is_public=1
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1
@ -14,9 +14,10 @@
setup_public=1 setup_public=1
upgrade=1 upgrade=1
#4.3.0~ynh3 #4.3.0~ynh3
upgrade=1 from_commit=0615fbcfa5b163812657b2f291026bf24b5e0667 upgrade=1 from_commit=0615fbcfa5b163812657b2f291026bf24b5e0667
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
port_already_use=0
change_url=1 change_url=1
;;; Options ;;; Options
Email= Email=
@ -24,4 +25,3 @@ Notification=none
;;; Upgrade options ;;; Upgrade options
; commit=0615fbcfa5b163812657b2f291026bf24b5e0667 ; commit=0615fbcfa5b163812657b2f291026bf24b5e0667
name=Merge pull request #92 name=Merge pull request #92

View file

@ -27,7 +27,7 @@
/* URL of installation, with traling slash (eg. »https://exmaple.com/jirafeau/«) /* URL of installation, with traling slash (eg. »https://exmaple.com/jirafeau/«)
*/ */
$cfg['web_root'] = 'https://' . '__DOMAIN__' . '__PATH__' . '/'; $cfg['web_root'] = 'https://' . '__DOMAIN__' . '__JIRAFEAU_PATH__' . '/';
/* Path to data directory, with trailing slash (eg. »/var/www/data/var_314159265358979323846264« /* Path to data directory, with trailing slash (eg. »/var/www/data/var_314159265358979323846264«
*/ */

View file

@ -1,42 +1,44 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ { location __PATH__/ {
# Path to source # Path to source
alias __FINALPATH__/ ; alias __FINALPATH__/;
client_max_body_size 10G; index index.php;
client_body_timeout 30m;
proxy_read_timeout 30m;
index index.php; client_max_body_size 10G;
try_files $uri $uri/ index.php; client_body_timeout 30m;
proxy_read_timeout 30m;
location ~ ^__PATH__/lib/functions.js.php { try_files $uri $uri/ index.php;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_read_timeout 30m;
fastcgi_send_timeout 30m;
}
location ~ ^__PATH__/lib/.*\.php { location ~ ^__PATH__/lib/functions.js.php {
deny all; fastcgi_split_path_info ^(.+?\.php)(/.*)$;
} fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_read_timeout 30m;
fastcgi_send_timeout 30m;
}
location ~ [^/]\.php(/|$) { location ~ ^__PATH__/lib/.*\.php {
fastcgi_split_path_info ^(.+?\.php)(/.*)$; deny all;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; }
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
# Include SSOWAT user panel. location ~ [^/]\.php(/|$) {
include conf.d/yunohost_panel.conf.inc; fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
} }

View file

@ -1,66 +1,66 @@
{ {
"name": "Jirafeau", "name": "Jirafeau",
"id": "jirafeau", "id": "jirafeau",
"packaging_format": 1, "packaging_format": 1,
"description": { "description": {
"en": "Upload a file in a simple way and give a unique link to it", "en": "Upload a file in a simple way and give a unique link to it",
"fr": "Hébergez simplement un fichier et partagez-le avec un lien unique" "fr": "Hébergez simplement un fichier et partagez-le avec un lien unique"
}, },
"version": "4.4.0~ynh1", "version": "4.4.0~ynh2",
"url": "https://gitlab.com/mojo42/Jirafeau", "url": "https://gitlab.com/mojo42/Jirafeau",
"upstream": { "upstream": {
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"website": "https://gitlab.com/mojo42/Jirafeau", "website": "https://gitlab.com/mojo42/Jirafeau",
"demo": "https://demo.yunohost.org/jirafeau/", "demo": "https://demo.yunohost.org/jirafeau/",
"code": "https://gitlab.com/mojo42/Jirafeau" "code": "https://gitlab.com/mojo42/Jirafeau"
}, },
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"maintainer": { "maintainer": {
"name": "julien", "name": "julien",
"email": "julien.malik@paraiso.me" "email": "julien.malik@paraiso.me"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.3.0" "yunohost": ">= 4.3.0"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [
"nginx", "nginx",
"php7.3-fpm" "php7.3-fpm"
], ],
"arguments": { "arguments": {
"install" : [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain" "type": "domain"
}, },
{ {
"name": "path", "name": "path",
"type": "path", "type": "path",
"example": "/jirafeau", "example": "/jirafeau",
"default": "/jirafeau" "default": "/jirafeau"
}, },
{ {
"name": "admin_user", "name": "is_public",
"type": "user", "type": "boolean",
"ask": { "default": true
"en": "Choose an admin user (will be able to access admin.php page)", },
"fr": "Choisissez l'administrateur (seul autorisé à accéder à la page admin.php)" {
} "name": "admin_user",
}, "type": "user",
{ "ask": {
"name": "upload_password", "en": "Choose an admin user (will be able to access admin.php page)",
"type": "password", "fr": "Choisissez l'administrateur (seul autorisé à accéder à la page admin.php)"
"optional": true, }
"ask": { },
"en": "Set the password granting upload permissions (leave empty to allow anybody to upload). Please avoid using ' (quotes) in the password as it will fail the app...", {
"fr": "Définissez le mot de passe permettant l'accès à l'envoi de fichiers (laissez vide pour autoriser tout le monde). Veuillez éviter d'utiliser ' (guillemets) dans le mot de passe car cela fera échouer l'application..." "name": "upload_password",
} "type": "password",
}, "optional": true,
{ "ask": {
"name": "is_public", "en": "Set the password granting upload permissions (leave empty to allow anybody to upload). Please avoid using ' (quotes) in the password as it will fail the app...",
"type": "boolean", "fr": "Définissez le mot de passe permettant l'accès à l'envoi de fichiers (laissez vide pour autoriser tout le monde). Veuillez éviter d'utiliser ' (guillemets) dans le mot de passe car cela fera échouer l'application..."
"default": true }
} }
] ]
} }
} }

View file

@ -6,6 +6,7 @@
YNH_PHP_VERSION="7.3" YNH_PHP_VERSION="7.3"
# dependencies used by the app
pkg_dependencies="" pkg_dependencies=""
#================================================= #=================================================

View file

@ -1,9 +1,12 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# 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
@ -32,31 +35,31 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
ynh_print_info --message="Declaring files to be backed up..." ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================
# BACKUP OF THE MAIN DIR OF THE APP # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$final_path"
#================================================= #=================================================
# BACKUP OF THE DATA DIR # BACKUP THE DATA DIR
#================================================= #=================================================
ynh_backup --src_path="$datadir" --is_big ynh_backup --src_path="$datadir" --is_big
#================================================= #=================================================
# BACKUP OF THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# BACKUP OF THE PHP-FPM CONFIGURATION # BACKUP THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#================================================= #=================================================
# BACKUP THE CRON FILE # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_backup --src_path="/etc/cron.d/$app" ynh_backup --src_path="/etc/cron.d/$app"
@ -65,4 +68,4 @@ ynh_backup --src_path="/etc/cron.d/$app"
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Backup script completed for Jirafeau. (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)."

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# GENERIC STARTING # GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -22,10 +22,9 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
admin_user=$YNH_APP_ARG_ADMIN_USER admin_user=$YNH_APP_ARG_ADMIN_USER
upload_password=$YNH_APP_ARG_UPLOAD_PASSWORD upload_password=$YNH_APP_ARG_UPLOAD_PASSWORD
is_public=$YNH_APP_ARG_IS_PUBLIC
phpversion=$YNH_PHP_VERSION
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -35,7 +34,7 @@ app=$YNH_APP_INSTANCE_NAME
ynh_script_progression --message="Validating installation parameters..." --weight=1 ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path # Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@ -49,7 +48,10 @@ ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin_user ynh_app_setting_set --app=$app --key=admin --value=$admin_user
ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set --app=$app --key=upload_password --value="$upload_password"
#=================================================
# STANDARD MODIFICATIONS
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
@ -65,8 +67,6 @@ ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user # Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# STANDARD MODIFICATIONS
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -76,10 +76,21 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
# Remove the install.php
ynh_secure_remove --file=$final_path/install.php
chmod 750 "$final_path" chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -88,34 +99,8 @@ 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
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#=================================================
# SET AND SAVE THE UPLOAD PASSWORD
#=================================================
jirafeauconfigfile="$final_path/lib/config.local.php"
cp "../conf/config.local.php" "$jirafeauconfigfile"
# Set and save upload password, allowing an empty one
if [ -z "$upload_password" ]
then
ynh_replace_string --match_string="__UPLOAD_PASSWORD__" --replace_string="" --target_file="$jirafeauconfigfile"
ynh_app_setting_set --app=$app --key=upload_password --value=""
else
ynh_replace_special_string --match_string="__UPLOAD_PASSWORD__" --replace_string="'$upload_password'" --target_file="$jirafeauconfigfile"
ynh_app_setting_set --app=$app --key=upload_password --value="$upload_password"
fi
#================================================= #=================================================
# CREATE DATA DIRECTORY # CREATE DATA DIRECTORY
#================================================= #=================================================
@ -131,28 +116,21 @@ chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir" chown -R $app:www-data "$datadir"
#================================================= #=================================================
# CONFIGURE JIRAFEAU # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring Jirafeau..." --weight=2 ynh_script_progression --message="Adding a configuration file..." --weight=2
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$jirafeauconfigfile"
if [ "$path_url" = "/" ] if [ "$path_url" = "/" ]
then then
ynh_replace_string --match_string="__PATH__" --replace_string="" --target_file="$jirafeauconfigfile" jirafeau_path=""
else else
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$jirafeauconfigfile" jirafeau_path="$path_url"
fi fi
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$jirafeauconfigfile"
ynh_replace_string --match_string="__ADMIN_USER__" --replace_string="$admin_user" --target_file="$jirafeauconfigfile"
# Calculate and store the config file checksum into the app settings ynh_add_config --template="../conf/config.local.php" --destination="$final_path/lib/config.local.php"
ynh_store_file_checksum --file="$jirafeauconfigfile"
# Remove the install.php chmod 400 "$final_path/lib/config.local.php"
ynh_secure_remove --file=$final_path/install.php chown $app:$app "$final_path/lib/config.local.php"
chmod 400 "$jirafeauconfigfile"
chown $app:$app "$jirafeauconfigfile"
#================================================= #=================================================
# SET THE CRON FILE # SET THE CRON FILE
@ -160,9 +138,12 @@ chown $app:$app "$jirafeauconfigfile"
ynh_script_progression --message="Configuring the cron file..." --weight=2 ynh_script_progression --message="Configuring the cron file..." --weight=2
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app" chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app" chmod 644 "/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# GENERIC STARTING # GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -23,7 +23,7 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
# REMOVE THE MAIN DIR OF THE APP # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." --weight=2 ynh_script_progression --message="Removing app main directory..." --weight=2
@ -42,7 +42,7 @@ then
fi fi
#================================================= #=================================================
# REMOVE THE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=2 ynh_script_progression --message="Removing NGINX web server configuration..." --weight=2
@ -50,7 +50,7 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
ynh_remove_nginx_config ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE THE PHP-FPM CONFIGURATION # REMOVE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2 ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2
@ -66,14 +66,17 @@ ynh_script_progression --message="Removing dependencies..." --weight=3
ynh_remove_app_dependencies ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE THE CRON FILE # SPECIFIC REMOVE
#================================================= #=================================================
ynh_script_progression --message="Removing the cron file..." --weight=1 # REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..." --weight=1
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app" ynh_secure_remove --file="/etc/cron.d/$app"
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALIZATION
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================

View file

@ -1,9 +1,12 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# 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
@ -17,7 +20,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." --weight=2 ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -36,14 +39,7 @@ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORE STEPS # STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
@ -55,7 +51,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring $app main directory..." --weight=2 ynh_script_progression --message="Restoring the app main directory..." --weight=2
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
@ -92,16 +88,23 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weig
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#================================================= #=================================================
# RESTORE THE CRON FILE # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the cron file..." --weight=1 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 VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app" ynh_restore_file --origin_path="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app" chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app" chmod 644 "/etc/cron.d/$app"
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX AND PHP-FPM
#================================================= #=================================================

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# GENERIC STARTING # GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -28,23 +28,26 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up Jirafeau before upgrading (may take a while)..." --weight=3 ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
# restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
# 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
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
@ -62,6 +65,15 @@ if [ -z "$datadir" ]; then
ynh_app_setting_set --app=$app --key=datadir --value=$datadir ynh_app_setting_set --app=$app --key=datadir --value=$datadir
fi fi
ynh_permission_update --permission="main" --add="visitors"
if [ $is_public -eq 0 ]
then
domain_regex=$(echo "$domain" | sed 's@-@.@g')
[ "$path_url" = "/" ] && path_url=""
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/$","$domain_regex$path_url/admin.php.*$"
fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
@ -70,8 +82,6 @@ ynh_script_progression --message="Making sure dedicated system user exists..." -
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -92,12 +102,11 @@ chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 ynh_script_progression --message="Upgrading dependencies..." --weight=3
# Create a dedicated NGINX config ynh_install_app_dependencies $pkg_dependencies
ynh_add_nginx_config
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
@ -108,12 +117,15 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2
ynh_add_fpm_config ynh_add_fpm_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=3 ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
ynh_install_app_dependencies $pkg_dependencies # Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#================================================= #=================================================
# SET THE CRON FILE # SET THE CRON FILE
#================================================= #=================================================
@ -124,19 +136,7 @@ chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app" chmod 644 "/etc/cron.d/$app"
#================================================= #=================================================
# SETUP SSOWAT # GENERIC FINALIZATION
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=2
ynh_permission_update --permission="main" --add="visitors"
if [ $is_public -eq 0 ]
then
domain_regex=$(echo "$domain" | sed 's@-@.@g')
[ "$path_url" = "/" ] && path_url=""
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/$","$domain_regex$path_url/admin.php.*$"
fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================