mirror of
https://github.com/YunoHost-Apps/jirafeau_ynh.git
synced 2024-09-03 19:35:53 +02:00
Normalization from example_ynh
This commit is contained in:
parent
54a4857ec7
commit
5807306b09
9 changed files with 144 additions and 161 deletions
|
@ -31,9 +31,9 @@ Jirafeau is a web site permitting to upload a file in a simple way and give an u
|
||||||
|
|
||||||
#### Supported architectures
|
#### Supported architectures
|
||||||
|
|
||||||
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/jirafeau%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/jirafeau/)
|
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/jirafeau%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/jirafeau/)
|
||||||
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/jirafeau%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/jirafeau/)
|
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/jirafeau%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/jirafeau/)
|
||||||
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/jirafeau%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/jirafeau/)
|
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/jirafeau%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/jirafeau/)
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ Jirafeau is a web site permitting to upload a file in a simple way and give an u
|
||||||
|
|
||||||
* Report a bug: https://github.com/YunoHost-Apps/jirafeau_ynh/issues
|
* Report a bug: https://github.com/YunoHost-Apps/jirafeau_ynh/issues
|
||||||
* Jirafeau website: https://gitlab.com/mojo42/Jirafeau
|
* Jirafeau website: https://gitlab.com/mojo42/Jirafeau
|
||||||
|
* Upstream app repository: https://gitlab.com/mojo42/Jirafeau
|
||||||
* YunoHost website: https://yunohost.org/
|
* YunoHost website: https://yunohost.org/
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -20,16 +20,7 @@
|
||||||
port_already_use=0
|
port_already_use=0
|
||||||
change_url=1
|
change_url=1
|
||||||
;;; Levels
|
;;; Levels
|
||||||
Level 1=auto
|
|
||||||
Level 2=auto
|
|
||||||
Level 3=auto
|
|
||||||
Level 4=na
|
|
||||||
Level 5=auto
|
Level 5=auto
|
||||||
Level 6=auto
|
|
||||||
Level 7=auto
|
|
||||||
Level 8=0
|
|
||||||
Level 9=0
|
|
||||||
Level 10=0
|
|
||||||
;;; Options
|
;;; Options
|
||||||
Email=
|
Email=
|
||||||
Notification=none
|
Notification=none
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"email": "julien.malik@paraiso.me"
|
"email": "julien.malik@paraiso.me"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 3.2.0"
|
"yunohost": ">= 3.5.0"
|
||||||
},
|
},
|
||||||
"multi_instance": false,
|
"multi_instance": false,
|
||||||
"services": [
|
"services": [
|
||||||
|
|
|
@ -17,48 +17,45 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD BACKUP STEPS
|
# STANDARD BACKUP STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP OF THE MAIN DIR OF THE APP
|
# BACKUP OF THE MAIN DIR OF THE APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Backing up the main app directory..."
|
ynh_script_progression --message="Backing up the main app directory..."
|
||||||
|
|
||||||
ynh_backup "$final_path"
|
ynh_backup --src_path="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP OF THE DATA DIR
|
# BACKUP OF THE DATA DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Backing up data directory..."
|
ynh_script_progression --message="Backing up data directory..."
|
||||||
|
|
||||||
# The 1 parameter indicates the directory is "big",
|
ynh_backup --src_path="/home/yunohost.app/$app" --is_big
|
||||||
# so that it won't be backed up before upgrade
|
|
||||||
# This argument has to be the third one.
|
|
||||||
ynh_backup "/home/yunohost.app/$app" "/home/yunohost.app/$app" 1
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP OF THE NGINX CONFIGURATION
|
# BACKUP OF THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Backing up nginx web server configuration..."
|
ynh_script_progression --message="Backing up nginx web server configuration..."
|
||||||
|
|
||||||
ynh_backup "/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 OF THE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Backing up php-fpm configuration..."
|
ynh_script_progression --message="Backing up php-fpm configuration..."
|
||||||
|
|
||||||
ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
|
ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
|
||||||
|
|
|
@ -24,18 +24,9 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK PATHS SYNTAX
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
test -n "$old_path" || old_path="/"
|
|
||||||
test -n "$new_path" || new_path="/"
|
|
||||||
new_path=$(ynh_normalize_url_path $new_path)
|
|
||||||
old_path=$(ynh_normalize_url_path $old_path)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||||
|
@ -58,7 +49,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Updating nginx web server configuration..."
|
ynh_script_progression --message="Updating nginx web server configuration..." --weight=2
|
||||||
|
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
|
|
||||||
|
@ -66,7 +57,7 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
if [ $change_path -eq 1 ]
|
if [ $change_path -eq 1 ]
|
||||||
then
|
then
|
||||||
# Make a backup of the original nginx config file if modified
|
# Make a backup of the original nginx config file if modified
|
||||||
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||||
# Set global variables for nginx helper
|
# Set global variables for nginx helper
|
||||||
domain="$old_domain"
|
domain="$old_domain"
|
||||||
path_url="$new_path"
|
path_url="$new_path"
|
||||||
|
@ -78,10 +69,10 @@ fi
|
||||||
if [ $change_domain -eq 1 ]
|
if [ $change_domain -eq 1 ]
|
||||||
then
|
then
|
||||||
# Delete file checksum for the old conf file location
|
# Delete file checksum for the old conf file location
|
||||||
ynh_delete_file_checksum "$nginx_conf_path"
|
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||||
# Store file checksum for the new config file location
|
# Store file checksum for the new config file location
|
||||||
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -89,19 +80,19 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Change domain name in parameters.yml
|
# Change domain name in parameters.yml
|
||||||
ynh_replace_string "\$cfg['web_root'] = .*" "\$cfg['web_root'] = 'https://' . '$new_domain' . '${new_path%/}' . '/';" "$final_path/lib/config.local.php"
|
ynh_replace_string --match_string="\$cfg['web_root'] = .*" --replace_string="\$cfg['web_root'] = 'https://' . '$new_domain' . '${new_path%/}' . '/';" --target_file="$final_path/lib/config.local.php"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Reloading nginx web server..."
|
ynh_script_progression --message="Reloading nginx web server..."
|
||||||
|
|
||||||
systemctl reload nginx
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info "Change of url completed for $app"
|
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||||
|
|
|
@ -31,41 +31,39 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Validating installation parameters..."
|
ynh_script_progression --message="Validating installation parameters..."
|
||||||
|
|
||||||
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 "This path already contains a folder"
|
||||||
|
|
||||||
# Normalize the url path syntax
|
|
||||||
path_url=$(ynh_normalize_url_path $path_url)
|
|
||||||
|
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
ynh_webpath_register $app $domain $path_url
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Storing installation settings..."
|
ynh_script_progression --message="Storing installation settings..."
|
||||||
|
|
||||||
ynh_app_setting_set $app domain $domain
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set $app path $path_url
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
ynh_app_setting_set $app admin $admin_user
|
ynh_app_setting_set --app=$app --key=admin --value=$admin_user
|
||||||
ynh_app_setting_set $app is_public $is_public
|
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Setting up source files..."
|
ynh_script_progression --message="Setting up source files..." --weight=3
|
||||||
|
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
ynh_setup_source --dest_dir="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "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
|
||||||
|
@ -73,15 +71,15 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Configuring system user..."
|
ynh_script_progression --message="Configuring system user..." --weight=2
|
||||||
|
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create $app
|
ynh_system_user_create --username=$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP-FPM CONFIGURATION
|
# PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Configuring php-fpm..."
|
ynh_script_progression --message="Configuring php-fpm..." --weight=2
|
||||||
|
|
||||||
# Create a dedicated php-fpm config
|
# Create a dedicated php-fpm config
|
||||||
ynh_add_fpm_config
|
ynh_add_fpm_config
|
||||||
|
@ -98,32 +96,32 @@ cp "../conf/config.local.php" "$jirafeauconfigfile"
|
||||||
# Set and save upload password, allowing an empty one
|
# Set and save upload password, allowing an empty one
|
||||||
if [ -z "$upload_password" ]
|
if [ -z "$upload_password" ]
|
||||||
then
|
then
|
||||||
ynh_replace_string "__YNH_UPLOAD_PASSWORD__" "" "$jirafeauconfigfile"
|
ynh_replace_string --match_string="__YNH_UPLOAD_PASSWORD__" --replace_string="" --target_file="$jirafeauconfigfile"
|
||||||
ynh_app_setting_set $app upload_password ""
|
ynh_app_setting_set --app=$app --key=upload_password --value=""
|
||||||
else
|
else
|
||||||
ynh_replace_string "__YNH_UPLOAD_PASSWORD__" "'$upload_password'" "$jirafeauconfigfile"
|
ynh_replace_string --match_string="__YNH_UPLOAD_PASSWORD__" --replace_string="'$upload_password'" --target_file="$jirafeauconfigfile"
|
||||||
ynh_app_setting_set $app upload_password "$upload_password"
|
ynh_app_setting_set --app=$app --key=upload_password --value="$upload_password"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE JIRAFEAU
|
# CONFIGURE JIRAFEAU
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Configuring jirafeau..."
|
ynh_script_progression --message="Configuring jirafeau..."
|
||||||
|
|
||||||
var_root=/home/yunohost.app/$app
|
var_root=/home/yunohost.app/$app
|
||||||
|
|
||||||
ynh_replace_string "__YNH_DOMAIN__" "$domain" "$jirafeauconfigfile"
|
ynh_replace_string --match_string="__YNH_DOMAIN__" --replace_string="$domain" --target_file="$jirafeauconfigfile"
|
||||||
if [ "$path_url" = "/" ]
|
if [ "$path_url" = "/" ]
|
||||||
then
|
then
|
||||||
ynh_replace_string "__YNH_WWW_PATH__" "" "$jirafeauconfigfile"
|
ynh_replace_string --match_string="__YNH_WWW_PATH__" --replace_string="" --target_file="$jirafeauconfigfile"
|
||||||
else
|
else
|
||||||
ynh_replace_string "__YNH_WWW_PATH__" "$path_url" "$jirafeauconfigfile"
|
ynh_replace_string --match_string="__YNH_WWW_PATH__" --replace_string="$path_url" --target_file="$jirafeauconfigfile"
|
||||||
fi
|
fi
|
||||||
ynh_replace_string "__YNH_VAR_ROOT__" "$var_root" "$jirafeauconfigfile"
|
ynh_replace_string --match_string="__YNH_VAR_ROOT__" --replace_string="$var_root" --target_file="$jirafeauconfigfile"
|
||||||
ynh_replace_string "__YNH_ADMIN_USER__" "$admin_user" "$jirafeauconfigfile"
|
ynh_replace_string --match_string="__YNH_ADMIN_USER__" --replace_string="$admin_user" --target_file="$jirafeauconfigfile"
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
# Calculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum "$jirafeauconfigfile"
|
ynh_store_file_checksum --file="$jirafeauconfigfile"
|
||||||
|
|
||||||
# Remove the install.php
|
# Remove the install.php
|
||||||
rm $final_path/install.php
|
rm $final_path/install.php
|
||||||
|
@ -143,25 +141,25 @@ chmod -R 700 $var_root
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Configuring SSOwat..."
|
ynh_script_progression --message="Configuring SSOwat..."
|
||||||
|
|
||||||
ynh_app_setting_set $app unprotected_uris "/"
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||||
if [ $is_public -eq 0 ]
|
if [ $is_public -eq 0 ]
|
||||||
then
|
then
|
||||||
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
||||||
[ "$path_url" = "/" ] && path_url=""
|
[ "$path_url" = "/" ] && path_url=""
|
||||||
ynh_app_setting_set $app protected_regex "$domain_regex$path_url/$","$domain_regex$path_url/admin.php.*$"
|
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/$","$domain_regex$path_url/admin.php.*$"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Reloading nginx web server..."
|
ynh_script_progression --message="Reloading nginx web server..."
|
||||||
|
|
||||||
systemctl reload nginx
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info "Installation of $app completed"
|
ynh_script_progression --message="Installation of $app completed" --last
|
||||||
|
|
|
@ -12,27 +12,27 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE MAIN DIR OF THE APP
|
# REMOVE THE MAIN DIR OF THE APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Removing app main directory"
|
ynh_script_progression --message="Removing app main directory..."
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove "$final_path"
|
ynh_secure_remove --file="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE NGINX CONFIGURATION
|
# REMOVE THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "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
|
||||||
|
@ -40,7 +40,7 @@ ynh_remove_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE PHP-FPM CONFIGURATION
|
# REMOVE THE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Removing php-fpm configuration"
|
ynh_script_progression --message="Removing php-fpm configuration..." --weight=2
|
||||||
|
|
||||||
# Remove the dedicated php-fpm config
|
# Remove the dedicated php-fpm config
|
||||||
ynh_remove_fpm_config
|
ynh_remove_fpm_config
|
||||||
|
@ -50,22 +50,22 @@ ynh_remove_fpm_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE DATA DIRECTORY
|
# REMOVE THE DATA DIRECTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Removing data directory"
|
ynh_script_progression --message="Removing data directory..."
|
||||||
|
|
||||||
ynh_secure_remove "/home/yunohost.app/$app"
|
ynh_secure_remove --file="/home/yunohost.app/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Removing the dedicated system user"
|
ynh_script_progression --message="Removing the dedicated system user..."
|
||||||
|
|
||||||
# Delete a system user
|
# Delete a system user
|
||||||
ynh_system_user_delete $app
|
ynh_system_user_delete --username=$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info "Removal of $app completed"
|
ynh_script_progression --message="Removal of $app completed" --last
|
||||||
|
|
|
@ -17,24 +17,24 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Loading settings..."
|
ynh_script_progression --message="Loading settings..." --weight=2
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get $app path)
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Validating restoration parameters..."
|
ynh_script_progression --message="Validating restoration parameters..."
|
||||||
|
|
||||||
ynh_webpath_available $domain $path_url \
|
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||||
test ! -d $final_path \
|
test ! -d $final_path \
|
||||||
|| ynh_die "There is already a directory: $final_path "
|
|| ynh_die --message="There is already a directory: $final_path "
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORE STEPS
|
# STANDARD RESTORE STEPS
|
||||||
|
@ -42,52 +42,47 @@ test ! -d $final_path \
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Restoring the app main directory..."
|
ynh_script_progression --message="Restoring the app main directory..."
|
||||||
|
|
||||||
ynh_restore_file "$final_path"
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Recreating the dedicated system user..."
|
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create $app
|
ynh_system_user_create --username=$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PHP-FPM CONFIGURATION
|
# RESTORE THE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORE
|
# SPECIFIC RESTORE
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE DATA OF JIRAFEAU
|
# RESTORE THE DATA OF JIRAFEAU
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Restoring the data directory..."
|
ynh_script_progression --message="Restoring the data directory..." --weight=2
|
||||||
|
|
||||||
datadir="/home/yunohost.app/$app"
|
datadir="/home/yunohost.app/$app"
|
||||||
|
|
||||||
# The data directory will be restored only if it exists in the backup archive
|
# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup.
|
||||||
# So only if it was backup previously.
|
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
||||||
if [ -d "$YNH_BACKUP_DIR/apps/$app/backup$datadir" ]
|
|
||||||
then
|
|
||||||
ynh_restore_file "$datadir"
|
|
||||||
else
|
|
||||||
# Create app folders
|
|
||||||
mkdir -p "$datadir"/{files,links,async,block}
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# RESTORE USER RIGHTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# Create app folders
|
||||||
|
mkdir -p "$datadir"/{files,links,async,block}
|
||||||
chown -R $app:root /home/yunohost.app/$app
|
chown -R $app:root /home/yunohost.app/$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -95,13 +90,13 @@ chown -R $app:root /home/yunohost.app/$app
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND PHP-FPM
|
# RELOAD NGINX AND PHP-FPM
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Reloading nginx web server and php-fpm..."
|
ynh_script_progression --message="Reloading nginx web server and php-fpm..."
|
||||||
|
|
||||||
systemctl reload php7.0-fpm
|
ynh_systemd_action --service_name=php7.0-fpm --action=reload
|
||||||
systemctl reload nginx
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info "Restoration completed for $app"
|
ynh_script_progression --message="Restoration completed for $app" --last
|
||||||
|
|
|
@ -12,41 +12,47 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get $app path)
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
admin_user=$(ynh_app_setting_get $app admin_user)
|
admin_user=$(ynh_app_setting_get --app=$app --key=admin_user)
|
||||||
upload_password=$(ynh_app_setting_get $app upload_password)
|
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
is_public=$(ynh_app_setting_get $app is_public)
|
upload_password=$(ynh_app_setting_get --app=$app --key=upload_password)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK VERSION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Ensuring downward compatibility..."
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||||
|
|
||||||
# Fix is_public as a boolean value
|
# Fix is_public as a boolean value
|
||||||
if [ "$is_public" = "Yes" ]; then
|
if [ "$is_public" = "Yes" ]; then
|
||||||
ynh_app_setting_set $app is_public 1
|
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||||
is_public=1
|
is_public=1
|
||||||
elif [ "$is_public" = "No" ]; then
|
elif [ "$is_public" = "No" ]; then
|
||||||
ynh_app_setting_set $app is_public 0
|
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||||
is_public=0
|
is_public=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If final_path doesn't exist, create it
|
# If final_path doesn't exist, create it
|
||||||
if [ -z $final_path ]; then
|
if [ -z "$final_path" ]; then
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Backing up the app before upgrading (may take a while)..."
|
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
|
||||||
|
@ -62,22 +68,26 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Normalize the URL path syntax
|
# Normalize the URL path syntax
|
||||||
path_url=$(ynh_normalize_url_path $path_url)
|
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Upgrading source files..."
|
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
ynh_setup_source "$final_path"
|
then
|
||||||
|
ynh_script_progression --message="Upgrading source files..." --weight=2
|
||||||
|
|
||||||
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
ynh_setup_source --dest_dir="$final_path"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Upgrading nginx web server configuration..."
|
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
@ -85,15 +95,15 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Making sure dedicated system user exists..."
|
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 $app
|
ynh_system_user_create --username=$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP-FPM CONFIGURATION
|
# PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Upgrading php-fpm configuration..."
|
ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=2
|
||||||
|
|
||||||
# Create a dedicated php-fpm config
|
# Create a dedicated php-fpm config
|
||||||
ynh_add_fpm_config
|
ynh_add_fpm_config
|
||||||
|
@ -106,39 +116,39 @@ ynh_add_fpm_config
|
||||||
|
|
||||||
jirafeauconfigfile="$final_path/lib/config.local.php"
|
jirafeauconfigfile="$final_path/lib/config.local.php"
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different "$final_path/lib/config.local.php"
|
ynh_backup_if_checksum_is_different --file="$final_path/lib/config.local.php"
|
||||||
|
|
||||||
cp "../conf/config.local.php" "$final_path/lib/config.local.php"
|
cp "../conf/config.local.php" "$final_path/lib/config.local.php"
|
||||||
|
|
||||||
# Set and save upload password, allowing an empty one
|
# Set and save upload password, allowing an empty one
|
||||||
if [ -z "$upload_password" ]
|
if [ -z "$upload_password" ]
|
||||||
then
|
then
|
||||||
ynh_replace_string "__YNH_UPLOAD_PASSWORD__" "" "$jirafeauconfigfile"
|
ynh_replace_string --match_string="__YNH_UPLOAD_PASSWORD__" --replace_string="" --target_file="$jirafeauconfigfile"
|
||||||
ynh_app_setting_set $app upload_password ""
|
ynh_app_setting_set --app=$app --key=upload_password --value=""
|
||||||
else
|
else
|
||||||
ynh_replace_string "__YNH_UPLOAD_PASSWORD__" "'$upload_password'" "$jirafeauconfigfile"
|
ynh_replace_string --match_string="__YNH_UPLOAD_PASSWORD__" --replace_string="'$upload_password'" --target_file="$jirafeauconfigfile"
|
||||||
ynh_app_setting_set $app upload_password "$upload_password"
|
ynh_app_setting_set --app=$app --key=upload_password --value="$upload_password"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE JIRAFEAU
|
# CONFIGURE JIRAFEAU
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Upgrading jirafeau configuration..."
|
ynh_script_progression --message="Upgrading jirafeau configuration..."
|
||||||
|
|
||||||
var_root=/home/yunohost.app/$app
|
var_root=/home/yunohost.app/$app
|
||||||
|
|
||||||
ynh_replace_string "__YNH_DOMAIN__" "$domain" "$jirafeauconfigfile"
|
ynh_replace_string --match_string="__YNH_DOMAIN__" --replace_string="$domain" --target_file="$jirafeauconfigfile"
|
||||||
if [ "$path_url" = "/" ]
|
if [ "$path_url" = "/" ]
|
||||||
then
|
then
|
||||||
ynh_replace_string "__YNH_WWW_PATH__" "" "$jirafeauconfigfile"
|
ynh_replace_string --match_string="__YNH_WWW_PATH__" --replace_string="" --target_file="$jirafeauconfigfile"
|
||||||
else
|
else
|
||||||
ynh_replace_string "__YNH_WWW_PATH__" "$path_url" "$jirafeauconfigfile"
|
ynh_replace_string --match_string="__YNH_WWW_PATH__" --replace_string="$path_url" --target_file="$jirafeauconfigfile"
|
||||||
fi
|
fi
|
||||||
ynh_replace_string "__YNH_VAR_ROOT__" "$var_root" "$jirafeauconfigfile"
|
ynh_replace_string --match_string="__YNH_VAR_ROOT__" --replace_string="$var_root" --target_file="$jirafeauconfigfile"
|
||||||
ynh_replace_string "__YNH_ADMIN_USER__" "$admin_user" "$jirafeauconfigfile"
|
ynh_replace_string --match_string="__YNH_ADMIN_USER__" --replace_string="$admin_user" --target_file="$jirafeauconfigfile"
|
||||||
|
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
ynh_store_file_checksum "$jirafeauconfigfile"
|
ynh_store_file_checksum --file="$jirafeauconfigfile"
|
||||||
|
|
||||||
# Remove the install.php
|
# Remove the install.php
|
||||||
rm $final_path/install.php
|
rm $final_path/install.php
|
||||||
|
@ -158,25 +168,25 @@ chmod -R 700 $var_root
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Upgrading SSOwat configuration..."
|
ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=2
|
||||||
|
|
||||||
ynh_app_setting_set $app unprotected_uris "/"
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||||
if [ $is_public -eq 0 ]
|
if [ $is_public -eq 0 ]
|
||||||
then
|
then
|
||||||
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
||||||
[ "$path_url" = "/" ] && path_url=""
|
[ "$path_url" = "/" ] && path_url=""
|
||||||
ynh_app_setting_set $app protected_regex "$domain_regex$path_url/$","$domain_regex$path_url/admin.php.*$"
|
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/$","$domain_regex$path_url/admin.php.*$"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Reloading nginx web server..."
|
ynh_script_progression --message="Reloading nginx web server..."
|
||||||
|
|
||||||
systemctl reload nginx
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info "Upgrade of $app completed"
|
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||||
|
|
Loading…
Reference in a new issue