1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/garradin_ynh.git synced 2024-09-03 18:36:17 +02:00

Update to version 0.9.5 with the last commit (#16)

* try to update source to 0.9.5

* try to update source to 0.9.5

* refactoring and try to update version

* try to debug

* try to debug

* try to debug

* try to debug

* try to debug

* try to debug

* try to debug

* try to debug

* try to debug

* try to debug

* try to debug

* try to debug

* try to debug

* try to debug

* try to debug

* try to debug

* try to debug

* try to debug

* try update garradin

* try the upgrade without php7.2

* try to debug

* try to debug

* try to debug

* try to debug

* add hooks to copy file config.dist.php in config.local.php with good options

* add hooks to copy file config.dist.php in config.local.php with good options

* try again to correct values

* try again to correct values

* try again to correct values

* change the upgrade file

* change the upgrade file

* try to backup sql for the upgrade

* try to save sqlite bdd since upgarade

* try to save sqlite bdd since upgarade

* try to save sqlite bdd since upgarade

* make the upgrade with backup of the bdd

* syntax error on file backup

* syntax error on file backup

* change the hook post_upgrade

* change the hook post_upgrade

* delete folder hooks and update the scripts install and upgrade

* correct url for backup file config.local.php

* correct url for backup files

* correct url for backup files

* delete the backup of config.local.php because this file must be edited with this upgrade

* delete the backup of config.local.php because this file must be edited with this upgrade

* change the script backup

* change the script backup

* add a missing bracket in script restore

* prepare package_check

* prepare package_check

* delete php.ini not used and add the values (commented) on php_fpm.conf

* delete sudo for bash commands

* remove file script jenkins

* syntax error

* try ro change PATH nginx.conf

* the garrdin must be insstalled on a sub-domain, back to put the correct path

* try to delete slash at the end of PATH in nginx.conf

* change path_url in config.local.php for sripts install and upgrade

* change also the path for change_url

* change also the path for change_url

* change also the path for change_url

* change also the path for change_url

* change also the path for change_url

* change also the path for change_url

* change also the path for change_url

* change also the path for change_url

* try to debug upgrade

* error syntax

* chnage the code in upgrade to look for exist or not file association.bdd

* try to debug update script conditions

* try change install and update to debug scripts

* try to debug update script conditions

* try to debug update script conditions

* try to debug update script conditions

* check_url available for check_package

* try to make better check_packages dependencies

* try to make better check_packages dependencies

* try to make possible install on root path and change url from or to root path

* try to make possible install on root path and change url from or to root path

* try to make possible install on root path and change url from or to root path

* try to make possible install on root path and change url from or to root path

* try to make possible install on root path and change url from or to root path

* try to make possible install on root path and change url from or to root path

* try to make possible install on root path and change url from or to root path

* try to make possible install on root path and change url from or to root path

* try to make possible install on root path and change url from or to root path

* try to make possible install on root path and change url from or to root path

* try to make possible install on root path and change url from or to root path

* try to make possible install on root path and change url from or to root path

* try to make possible install on root path and change url from or to root path

* come back to precedent config por nginx

* just a test to watch if it is possible like this install on root path

* come back to this code, have not found how to install on root path with this version

* but back check_up as origin

* add a search for nginx.conf

* try change nginx.conf and how to add a line on config.local.php

* try change nginx.conf and how to add a line on config.local.php

* try change nginx.conf

* try change nginx.conf

* try change nginx.conf

* change install

* try change nginx.conf

* try change nginx.conf

* try change nginx.conf

* try change nginx.conf

* try change nginx.conf

* try change nginx.conf

* try change nginx.conf

* try change nginx.conf

* try change nginx.conf

* try change nginx.conf

* success, change check_path

* few change to delete blanks

* delete sudo not need on install

* comment ynh_delete_file_checksum in common.sh

* delete ynh_delete_file_checksum in common.sh

* delete sudo on upgrade, no need

* put condition in install and update for config.local.php

* put condition in install and update for config.local.php

* try to save secret key if exist on update

* try to save secret key if exist on update

* try to save secret key if exist on update

* try to save secret key if exist on update

* try to keep secret key script on install

* back to previous version

* try to keep secret key script on install

* try to keep secret key script on install

* try create secret key script on install

* create secret key script on install

* put same lenght for secret key then the example in config.dist.php script for install

* try to debug slash for root directory in install and upgrade

* try to debug slash for root directory in cahnge_url

* try to debug slash for root directory in change_url

* try to debug slash for root directory in change_url

* try to put clean upgrade script

* try to debug change_url script

* try to debug change_url script

* try to debug change_url script

* try to debug change_url script

* try to debug change_url script

* try to debug change_url script

* try to debug change_url script

* try to debug change_url script

* try to debug change_url script

* try to debug change_url script

* try to debug change_url script

* change manifest

* change url debug

* change Readme

* change url debug

* change url debug

* add a line in config.local.php for domain in change_url script

* add a line in config.local.php for domain in change_url script

* add a line in config.local.php for domain in change_url script

* add a lines for doamin in config.local.php in change_url install and upgrade script

* comme back to previous version

* sripts modified, try to resolve change url

* sripts modified, try to resolve change url

* sripts modified, try to resolve change url

* sripts modified, try to resolve change url

* sripts modified, try to resolve change url

* sripts modified, try to resolve change url

* sripts modified, try to resolve change url

* sripts modified, try to resolve change url

* sripts modified, try to resolve change url

* sripts modified, try to resolve change url

* remove file_checksum md5 not needed

* cleaning syntax
This commit is contained in:
Robles Rodolphe 2020-04-11 13:02:18 +02:00 committed by GitHub
parent f1b1b2cb4f
commit b7d2abacc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 338 additions and 226 deletions

View file

@ -18,7 +18,7 @@ site de garradin : http://garradin.eu
- À travers l'interface d'administration - À travers l'interface d'administration
### TODO list : ### TODO list :
- Backup de la base de donnée SQlite (AIDE REQUISE) ? - Permissions de certains fichiers sensibles ?
#### Problèmes / Avertissements : #### Problèmes / Avertissements :
- le système SSO n'est pas implémenté, ni l'installation directe. L'utilisateur admin devra créer son compte avec le formulaire de création de compte qu'il trouvera à la fin de l'installation. Plusieurs raisons m'ont poussé à ne pas implémenter le SSO : - le système SSO n'est pas implémenté, ni l'installation directe. L'utilisateur admin devra créer son compte avec le formulaire de création de compte qu'il trouvera à la fin de l'installation. Plusieurs raisons m'ont poussé à ne pas implémenter le SSO :

View file

@ -1,4 +1,4 @@
;; Test complet ; Test complet
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
path="/path" (PATH) path="/path" (PATH)
@ -15,7 +15,7 @@
multi_instance=1 multi_instance=1
incorrect_path=1 incorrect_path=1
port_already_use=0 port_already_use=0
change_url=0 change_url=1
;;; Levels ;;; Levels
Level 1=auto Level 1=auto
Level 2=auto Level 2=auto

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.2.tar.bz2 SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.5.tar.bz2
SOURCE_SUM=d0a95b0aea2b2001dcd30088f6ebddf65f7a4fce5db2aaa3359c3692b1ded0e9 SOURCE_SUM=48f8d62d8c86b3aef2d090b2a7d04873c9642d6efc451389f58a5d6e89d89612
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.bz2 SOURCE_FORMAT=tar.bz2
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

View file

@ -1,36 +1,25 @@
location __PATH__ { location __PATH__ {
# Path to source # Path to source
alias __FINALPATH__/www/ ; alias __FINALPATH__/www/ ;
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }
# Example PHP configuration (remove if not used) # Example PHP configuration (remove if not used)
index index.php; index index.php /_route.php;
try_files $uri $uri/ index.php /_route.php;
# Common parameter to increase upload size limit in conjuction with dedicated php-fpm file location ~ [^/]\.php(/|$) {
#client_max_body_size 50M;
try_files $uri $uri/ index.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
# If you don't use a dedicated fpm config for your app,
# use a general fpm pool.
# This is to be used INSTEAD of line above
# Don't forget to adjust scripts install/upgrade/remove/backup accordingly
#
#fastcgi_pass unix:/var/run/php5-fpm.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;
} }
# PHP configuration end # PHP configuration end
# Include SSOWAT user panel. # Include SSOWAT user panel.

View file

@ -30,7 +30,7 @@ group = __USER__
; specific port; ; specific port;
; '/path/to/unix/socket' - to listen on a unix socket. ; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory. ; Note: This value is mandatory.
listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock
; Set listen(2) backlog. A value of '-1' means unlimited. ; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: 128 (-1 on FreeBSD and OpenBSD) ; Default Value: 128 (-1 on FreeBSD and OpenBSD)
@ -390,3 +390,14 @@ catch_workers_output = yes
;php_admin_value[error_log] = /var/log/fpm-php.www.log ;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on ;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M ;php_admin_value[memory_limit] = 32M
; Common values to change to increase file upload limit
; php_value[upload_max_filesize] = 50M
; php_value[post_max_size] = 50M
; php_valuemail.add_x_header = Off
; Other common parameters
; php_value[max_execution_time] = 600
; php_value[max_input_time] = 300
; php_value[memory_limit] = 256M
; php_value[short_open_tag] = On

View file

@ -1,10 +0,0 @@
; Common values to change to increase file upload limit
; upload_max_filesize = 50M
; post_max_size = 50M
; mail.add_x_header = Off
; Other common parameters
; max_execution_time = 600
; max_input_time = 300
; memory_limit = 256M
; short_open_tag = On

View file

@ -3,13 +3,13 @@
"id": "garradin", "id": "garradin",
"packaging_format": 1, "packaging_format": 1,
"requirements": { "requirements": {
"yunohost": ">= 2.7.2" "yunohost": ">=3.5.0"
}, },
"description": { "description": {
"en": "Software to manage association", "en": "Software to manage association",
"fr": "Logiciel libre de gestion d'association" "fr": "Logiciel libre de gestion d'association"
}, },
"version": "0.9.2~ynh1", "version": "0.9.5~ynh3",
"url": "http://garradin.eu/a-propos/", "url": "http://garradin.eu/a-propos/",
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
"maintainer": { "maintainer": {
@ -19,7 +19,7 @@
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
"nginx", "nginx",
"php5-fpm" "php7.0-fpm"
], ],
"arguments": { "arguments": {
"install" : [ "install" : [

View file

@ -1,13 +1,10 @@
#!/bin/bash #!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="php7.0-sqlite3"
# ============= FUTURE YUNOHOST HELPER ============= # ============= FUTURE YUNOHOST HELPER =============
# Delete a file checksum from the app settings
#
# $app should be defined when calling this helper
#
# usage: ynh_remove_file_checksum file
# | arg: file - The file for which the checksum will be deleted
ynh_delete_file_checksum () {
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
ynh_app_setting_delete $app $checksum_setting_name
}

View file

@ -6,12 +6,8 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
if [ ! -e _common.sh ]; then #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
# Get the _common.sh file if it's not in the current directory source ../settings/scripts/_common.sh
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -24,40 +20,37 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1
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 THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
ynh_backup "$final_path" ynh_backup --src_path="$final_path"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# BACKUP THE PHP-FPM CONFIGURATION # BACKUP THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Backing up php-fpm configuration..." --time --weight=1
ynh_backup "/etc/php5/fpm/pool.d/$app.conf" ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini"
# Backup directory location for the app from where the script is executed and #=================================================
# which will be compressed afterward # END OF SCRIPT
backup_dir=$YNH_APP_BACKUP_DIR #=================================================
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last
# Backup sources & data
ynh_backup "/var/www/$app" "sources"
# Copy Nginx conf
sudo mkdir -p ./conf
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx.conf"

View file

@ -22,27 +22,33 @@ new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK THE SYNTAX OF THE PATHS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1
test -n "$old_path" || old_path="/" # Needed for helper "ynh_add_nginx_config"
test -n "$new_path" || new_path="/" final_path=$(ynh_app_setting_get --app=$app --key=final_path)
new_path=$(ynh_normalize_url_path $new_path)
old_path=$(ynh_normalize_url_path $old_path) # #=================================================
# # CHECK THE SYNTAX OF THE PATHS
# #=================================================
# 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
#================================================= #=================================================
change_domain=0 change_domain=0
if [ "$old_domain" != "$new_domain" ] if [ "$old_domain" != "$new_domain" ]; then
then
change_domain=1 change_domain=1
fi fi
change_path=0 change_path=0
if [ "$old_path" != "$new_path" ] if [ "$old_path" != "$new_path" ]; then
then
change_path=1 change_path=1
fi fi
@ -51,31 +57,38 @@ fi
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
final_path=/var/www/$app
# Change the path in the nginx config file # Change the path in the nginx config file
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"
# Replace locations starting with old_path # Set global variables for nginx helper
# Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location) domain="$old_domain"
ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? $old_path" "location\1 $new_path" "$nginx_conf_path" path_url="$new_path"
# Replace path in "return" directives # Create a dedicated nginx config
ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path" ynh_add_nginx_config
# Calculate and store the nginx config file checksum fi
ynh_store_file_checksum "$nginx_conf_path"
# change the config.local.conf
if [ $change_path -eq 1 ] && [ "$new_path" == "/" ]; then
ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php"
elif [ $change_path -eq 1 ] && [ "$old_path" == "/" ]; then
ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php"
else [ $change_path -eq 1 ]
ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php"
fi fi
# Change the domain for nginx # Change the domain for nginx
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
#================================================= #=================================================
@ -83,5 +96,15 @@ fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# last configuration
#=================================================
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --time --last

View file

@ -29,6 +29,7 @@ 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_script_progression --message="Validating installation parameters..." --time --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 "This path already contains a folder"
@ -39,59 +40,57 @@ path_url=$(ynh_normalize_url_path $path_url)
# Check web path availability # Check web path availability
ynh_webpath_available $domain $path_url ynh_webpath_available $domain $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_script_progression --message="Storing installation settings..." --time --weight=1
ynh_app_setting_set $app path_url $path_url ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set $app domain $domain ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set $app is_public $is_public ynh_app_setting_set --app=$app --key=is_public --value=$is_public
#================================================= #=================================================
# Install dependency to convert tracks to a readable format for the browser # Install dependency to convert tracks to a readable format for the browser
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --time --weight=1
if [ "$(lsb_release --codename --short)" != "jessie" ] if [ "$(lsb_release --codename --short)" != "jessie" ]
then then
ynh_install_app_dependencies php-sqlite3 ynh_install_app_dependencies $pkg_dependencies
else else
ynh_install_app_dependencies php5-sqlite ynh_die --message="Votre version de Debian n'est pas compatible..." --time --weight=1
fi fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." --time --weight=1
# Create a system user # Create a system user
ynh_system_user_create $app ynh_system_user_create --username=$app
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --time --weight=1
ynh_app_setting_set $app final_path $final_path 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 "$final_path" ynh_setup_source --dest_dir="$final_path"
#=================================================
# Files owned by user app
#=================================================
sudo chown $app:$app $final_path -R
sudo chmod 755 $final_path -R
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring nginx web server..." --time --weight=1
# 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..." --time --weight=1
# Create a dedicated php-fpm config # Create a dedicated php-fpm config
ynh_add_fpm_config ynh_add_fpm_config
@ -99,6 +98,7 @@ ynh_add_fpm_config
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring SSOwat..." --time --weight=1
if [ $is_public -eq 0 ] if [ $is_public -eq 0 ]
then # Remove the public access then # Remove the public access
@ -108,11 +108,40 @@ fi
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
then then
# unprotected_uris allows SSO credentials to be passed anyway. # unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set $app unprotected_uris "/" ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
fi fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
systemctl reload nginx systemctl reload nginx
#=================================================
# MODIFY A CONFIG FILE
#=================================================
# copy config.dist.php creating config.local.php
cp -a $final_path/config.dist.php $final_path/config.local.php
# create a key for the secret key CSFR;
key=$(ynh_string_random --length=50)
# edit config.local.php
ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php"
if [ "$path_url" == "/" ]; then
ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php"
else
ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php"
fi
#=================================================
# Files owned by user app
#=================================================
chown $app:$app $final_path -R
chmod 755 $final_path -R
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --time --last

View file

@ -12,15 +12,17 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1
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)
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." --time --weight=1
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
@ -28,13 +30,15 @@ ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." --time --weight=1
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove "$final_path" ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
# Remove the dedicated nginx config # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -42,6 +46,7 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE PHP-FPM CONFIGURATION # REMOVE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1
# Remove the dedicated php-fpm config # Remove the dedicated php-fpm config
ynh_remove_fpm_config ynh_remove_fpm_config
@ -51,6 +56,13 @@ ynh_remove_fpm_config
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
# Delete a system user # Delete a system user
ynh_system_user_delete $app ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --time --last

View file

@ -6,12 +6,8 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
if [ ! -e _common.sh ]; then #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
# Get the _common.sh file if it's not in the current directory source ../settings/scripts/_common.sh
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -24,16 +20,18 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." --time --weight=1
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)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
ynh_webpath_available $domain $path_url \ ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}" || ynh_die "Path not available: ${domain}${path_url}"
@ -51,15 +49,17 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
ynh_restore_file "$final_path" ynh_restore_file "$final_path"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
# 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 USER RIGHTS # RESTORE USER RIGHTS
@ -71,37 +71,32 @@ chown -R $app:$app $final_path
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION
#================================================= #=================================================
if [ "$(lsb_release --codename --short)" != "jessie" ] ynh_script_progression --message="Restore php-fpm configuration..." --time --weight=1
then
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"
ynh_restore_file "/etc/php/7.0/fpm/conf.d/20-$app.ini"
else
ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini"
fi
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
if [ "$(lsb_release --codename --short)" != "jessie" ] # Define and install dependencies
then ynh_install_app_dependencies $pkg_dependencies
ynh_install_app_dependencies php7.0-sqlite3
else
ynh_install_app_dependencies php5-sqlite
fi
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX AND PHP-FPM
#================================================= #=================================================
if [ "$(lsb_release --codename --short)" != "jessie" ] ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
then
systemctl reload php7.0-fpm ynh_systemd_action --service_name=php7.0-fpm --action=reload
else ynh_systemd_action --service_name=nginx --action=reload
systemctl reload php5-fpm
fi #=================================================
systemctl reload nginx # END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --time --last

View file

@ -12,35 +12,66 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1
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)
is_public=$(ynh_app_setting_get $app is_public) is_public=$(ynh_app_setting_get --app=$app --key=is_public)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) || ynh_die "This path already contains a folder"
#=================================================
# CHECK VERSION
#=================================================
### This helper will compare the version of the currently installed app and the version of the upstream package.
### $upgrade_type can have 2 different values
### - UPGRADE_APP if the upstream app version has changed
### - UPGRADE_PACKAGE if only the YunoHost package has changed
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
# 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
#=================================================
# Backup Data
#=================================================
ynh_script_progression --message="Backing up the data before upgrading (may take a while)..." --time --weight=1
bdd=$final_path/association.sqlite
squelettes=$final_path/www/squelettes
if [ -d "$squelettes" ]; then
cp -ar $squelettes /tmp/squelettes
fi
if [ -e "$bdd" ]; then
cp -a $bdd /tmp/association.sqlite
fi fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -51,80 +82,122 @@ 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
#================================================= # #=================================================
# Install dependency to convert tracks to a readable format for the browser # # CHECK THE PATH
#================================================= # #=================================================
if [ "$(lsb_release --codename --short)" != "jessie" ]
then
ynh_install_app_dependencies php-sqlite3
else
ynh_install_app_dependencies php5-sqlite
fi
#=================================================
# CHECK THE PATH
#=================================================
# Normalize the URL path syntax # Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url) # 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
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Upgrading source files..." --time --weight=1
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
fi
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
# Create a system user
ynh_system_user_create $app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1
# Create a dedicated php-fpm config # Create a dedicated php-fpm config
ynh_add_fpm_config ynh_add_fpm_config
#================================================= #=================================================
# GENERIC FINALIZATION # Change options in file config.dist.php
# and copy in local.dist.php
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES ynh_script_progression --message="final configuration needed..." --time --weight=1
key=$(ynh_string_random --length=50)
cp -a $final_path/config.dist.php $final_path/config.local.php
ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php"
if [ "$path_url" == "/" ]
then
ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php"
else
ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php"
fi
#=======================================================
# backup bdd, squelettes directory and config.local.php
#=======================================================
ynh_script_progression --message="restore data..." --time --weight=1
backup_bdd=/tmp/association.sqlite
backup_squelettes=/tmp/squelettes
if [ -d "$backup_squelettes" ]
then
cp -ar $backup_squelettes $final_path/www/squelettes
fi
if [ -e "$backup_bdd" ]
then
cp -a $backup_bdd $final_path/association.sqlite
fi
#=================================================
# Files owned by user app
#================================================= #=================================================
# Set right permissions for curl installation # Set permissions on app files
chown -R $app:$app $final_path chown $app:$app $final_path -R
chmod 755 $final_path -R
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1
if [ $is_public -eq 0 ]
then # Remove the public access
ynh_app_setting_delete $app skipped_uris
fi
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
then then
# unprotected_uris allows SSO credentials to be passed anyway # unprotected_uris allows SSO credentials to be passed anyway
ynh_app_setting_set $app unprotected_uris "/" ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
fi fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --time --last