mirror of
https://github.com/YunoHost-Apps/bozon_ynh.git
synced 2024-09-03 18:16:09 +02:00
Apply example_ynh
This commit is contained in:
parent
b4189f578d
commit
77d417a6a8
17 changed files with 384 additions and 340 deletions
|
@ -1,20 +1,17 @@
|
||||||
;; Test complet (bozon=sans bdd)
|
;; Test complet (bozon=sans bdd)
|
||||||
auto_remove=1
|
auto_remove=1
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="domain.tld" (DOMAIN)
|
domain="domain.tld"
|
||||||
path="/path" (PATH)
|
path="/path"
|
||||||
is_public=1
|
is_public=1
|
||||||
language="fr"
|
admin="john"
|
||||||
filesize="2G"
|
password="super_secret_password"
|
||||||
admin="john" (USER)
|
|
||||||
password="super_secret_password" (PASSWORD)
|
|
||||||
backup_core_only=1
|
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=1
|
setup_sub_dir=1
|
||||||
setup_root=1
|
setup_root=1
|
||||||
setup_nourl=0
|
setup_nourl=0
|
||||||
setup_private=0
|
setup_private=1
|
||||||
setup_public=1
|
setup_public=1
|
||||||
upgrade=1
|
upgrade=1
|
||||||
upgrade=1 from_commit=03e787291ba1104f195fdeb5103071b9546b4ad5
|
upgrade=1 from_commit=03e787291ba1104f195fdeb5103071b9546b4ad5
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
SOURCE_URL=https://github.com/broncowdd/BoZoN/archive/ce0265e0dd13bc1e3cbbf0d96b846f65d1a17173.zip
|
SOURCE_URL=https://github.com/broncowdd/BoZoN/archive/ce0265e0dd13bc1e3cbbf0d96b846f65d1a17173.zip
|
||||||
SOURCE_SUM=42e8e81771cb3489297a75138a69cf83c82edc3e6ea5988b8d436254ac502b1b
|
SOURCE_SUM=42e8e81771cb3489297a75138a69cf83c82edc3e6ea5988b8d436254ac502b1b
|
||||||
|
SOURCE_SUM_PRG=sha256sum
|
||||||
SOURCE_FORMAT=zip
|
SOURCE_FORMAT=zip
|
||||||
|
SOURCE_IN_SUBDIR=true
|
||||||
#sha256sum obtain with shasum -a 256 $SOURCE_URL
|
SOURCE_FILENAME=
|
||||||
|
SOURCE_EXTRACT=true
|
||||||
|
|
125
conf/nginx.conf
125
conf/nginx.conf
|
@ -1,67 +1,64 @@
|
||||||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||||
location __PATH__/ {
|
location __PATH__/ {
|
||||||
# Path to source
|
|
||||||
alias __FINALPATH__/;
|
# Path to source
|
||||||
|
alias __FINALPATH__/;
|
||||||
# Force usage of https
|
|
||||||
if ($scheme = http) {
|
# Add headers to serve security related headers
|
||||||
rewrite ^ https://$server_name$request_uri? permanent;
|
more_set_headers "Strict-Transport-Security: max-age=15768000; includeSubDomains; preload;";
|
||||||
}
|
more_set_headers "X-Content-Type-Options: nosniff";
|
||||||
|
more_set_headers "X-XSS-Protection: 1; mode=block";
|
||||||
# Add headers to serve security related headers
|
more_set_headers "X-Robots-Tag: none";
|
||||||
more_set_headers "Strict-Transport-Security: max-age=15768000; includeSubDomains; preload;";
|
more_set_headers "X-Download-Options: noopen";
|
||||||
more_set_headers "X-Content-Type-Options: nosniff";
|
more_set_headers "X-Permitted-Cross-Domain-Policies: none";
|
||||||
more_set_headers "X-XSS-Protection: 1; mode=block";
|
more_set_headers "Referrer-Policy: no-referrer";
|
||||||
more_set_headers "X-Robots-Tag: none";
|
|
||||||
more_set_headers "X-Download-Options: noopen";
|
# Set max upload size
|
||||||
more_set_headers "X-Permitted-Cross-Domain-Policies: none";
|
client_max_body_size 10G;
|
||||||
more_set_headers "Referrer-Policy: no-referrer";
|
fastcgi_buffers 64 4K;
|
||||||
|
client_body_timeout 60m;
|
||||||
# Set max upload size
|
proxy_read_timeout 60m;
|
||||||
client_max_body_size 10G;
|
|
||||||
fastcgi_buffers 64 4K;
|
# Disable gzip to avoid the removal of the ETag header
|
||||||
client_body_timeout 60m;
|
gzip off;
|
||||||
proxy_read_timeout 60m;
|
|
||||||
|
index index.php;
|
||||||
# Disable gzip to avoid the removal of the ETag header
|
|
||||||
gzip off;
|
try_files $uri $uri/ index.php;
|
||||||
|
location ~ [^/]\.php(/|$) {
|
||||||
index index.php;
|
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||||
try_files $uri $uri/ index.php;
|
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
|
||||||
|
|
||||||
location ~ [^/]\.php(/|$) {
|
fastcgi_index index.php;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
fastcgi_param REMOTE_USER $remote_user;
|
||||||
fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
fastcgi_index index.php;
|
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||||
fastcgi_param REMOTE_USER $remote_user;
|
fastcgi_param HTTPS on;
|
||||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
fastcgi_param modHeadersAvailable true;
|
||||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
fastcgi_intercept_errors on;
|
||||||
fastcgi_param HTTPS on;
|
fastcgi_read_timeout 60m;
|
||||||
fastcgi_param modHeadersAvailable true;
|
fastcgi_send_timeout 60m;
|
||||||
fastcgi_intercept_errors on;
|
}
|
||||||
fastcgi_read_timeout 60m;
|
|
||||||
fastcgi_send_timeout 60m;
|
location ^~ __PATH__/(uploads|thumbs){
|
||||||
}
|
deny all;
|
||||||
|
}
|
||||||
location ^~ __PATH__/(uploads|thumbs){
|
|
||||||
deny all;
|
location ^~ __PATH__/private {
|
||||||
}
|
deny all;
|
||||||
|
location ~* __PATH__/private/temp/.*\.zip$ {
|
||||||
location ^~ __PATH__/private {
|
allow all;
|
||||||
deny all;
|
}
|
||||||
location ~* __PATH__/private/temp/.*\.zip$ {
|
}
|
||||||
allow all;
|
|
||||||
}
|
location ^~ __PATH__/core {
|
||||||
}
|
deny all;
|
||||||
|
location ~* __PATH__/core/.*\.js$ {
|
||||||
location ^~ __PATH__/core {
|
allow all;
|
||||||
deny all;
|
}
|
||||||
location ~* __PATH__/core/.*\.js$ {
|
}
|
||||||
allow all;
|
|
||||||
}
|
# Include SSOWAT user panel.
|
||||||
}
|
include conf.d/yunohost_panel.conf.inc;
|
||||||
|
|
||||||
# Include SSOWAT user panel.
|
|
||||||
include conf.d/yunohost_panel.conf.inc;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ group = __USER__
|
||||||
; (IPv6 and IPv4-mapped) on a specific port;
|
; (IPv6 and IPv4-mapped) on a 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/php/php7.0-fpm-__NAMETOCHANGE__.sock
|
listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock
|
||||||
|
|
||||||
; Set listen(2) backlog.
|
; Set listen(2) backlog.
|
||||||
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
|
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
|
||||||
|
|
0
doc/.gitkeep
Normal file
0
doc/.gitkeep
Normal file
1
doc/DESCRIPTION.md
Normal file
1
doc/DESCRIPTION.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
BoZoN is a minimalist Drag & drop file sharing app.
|
0
doc/DISCLAIMER.md
Normal file
0
doc/DISCLAIMER.md
Normal file
0
doc/screenshots/.gitkeep
Normal file
0
doc/screenshots/.gitkeep
Normal file
Before Width: | Height: | Size: 240 KiB After Width: | Height: | Size: 240 KiB |
|
@ -6,77 +6,49 @@
|
||||||
"en": "Minimalist Drag & drop file sharing app",
|
"en": "Minimalist Drag & drop file sharing app",
|
||||||
"fr": "Application minimaliste de partage de fichiers"
|
"fr": "Application minimaliste de partage de fichiers"
|
||||||
},
|
},
|
||||||
"url": "https://github.com/broncowdd/BoZoN",
|
|
||||||
"license": "AGPL-3.0",
|
|
||||||
"version": "2.4.18~ynh1",
|
"version": "2.4.18~ynh1",
|
||||||
|
"url": "https://github.com/broncowdd/BoZoN",
|
||||||
|
"upstream": {
|
||||||
|
"license": "AGPL-3.0",
|
||||||
|
"code": "https://github.com/broncowdd/BoZoN"
|
||||||
|
},
|
||||||
|
"license": "AGPL-3.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "ewilly",
|
"name": "ewilly",
|
||||||
"email": "ewilly@neuf.fr"
|
"email": "ewilly@neuf.fr"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 3.8.1"
|
"yunohost": ">= 4.3.0"
|
||||||
},
|
},
|
||||||
"multi_instance": false,
|
"multi_instance": false,
|
||||||
"services": [
|
"services": [
|
||||||
"nginx",
|
"nginx",
|
||||||
"php7.0-fpm"
|
"php7.3-fpm"
|
||||||
],
|
],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install" : [
|
"install": [
|
||||||
{
|
{
|
||||||
"name": "domain",
|
"name": "domain",
|
||||||
"type": "domain",
|
"type": "domain"
|
||||||
"ask": {
|
|
||||||
"en": "Choose a domain for BoZoN",
|
|
||||||
"fr": "Choisissez un domaine pour BoZoN"
|
|
||||||
},
|
|
||||||
"example": "domain.org"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "path",
|
"name": "path",
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"ask": {
|
|
||||||
"en": "Choose a path for BoZoN",
|
|
||||||
"fr": "Choisissez un chemin pour BoZoN"
|
|
||||||
},
|
|
||||||
"example": "/bozon",
|
"example": "/bozon",
|
||||||
"default": "/bozon"
|
"default": "/bozon"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"ask": {
|
|
||||||
"en": "Should this application be public? (if not, sharing file with unregistered users will still work)",
|
|
||||||
"fr": "Est-ce que cette application doit être visible publiquement ? (dans le cas contraire, le partage de fichiers avec des utilisateurs externes fonctionnera tout de même)"
|
|
||||||
},
|
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "admin",
|
"name": "admin",
|
||||||
"type": "user",
|
"type": "user"
|
||||||
"ask": {
|
|
||||||
"en": "Choose an admin user for BoZoN",
|
|
||||||
"fr": "Choisissez un administrateur pour BoZoN"
|
|
||||||
},
|
|
||||||
"example": "homer"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "password",
|
"name": "password",
|
||||||
"type": "password",
|
"type": "password"
|
||||||
"ask": {
|
|
||||||
"en": "Choose an admin password for BoZoN",
|
|
||||||
"fr": "Choisissez un mot de passe administrateur pour BoZoN"
|
|
||||||
},
|
|
||||||
"example": "super_secret_password"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "backup_core_only",
|
|
||||||
"type": "boolean",
|
|
||||||
"ask": {
|
|
||||||
"en": "When backing up, should only the core of the app be backed up? (uploaded files to BoZoN such as videos, pictures, documents, etc. will not be backed up)",
|
|
||||||
"fr": "En cas de sauvegarde, doit-être uniquement sauvegardé le cœur de l'application ? (les fichiers transférés dans BoZoN tels que les vidéos, images, documents, etc. ne seront pas sauvegardés)"
|
|
||||||
},
|
|
||||||
"default": true
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
pkg_dependencies="php-zip php-curl php-gd"
|
pkg_dependencies="php$YNH_DEFAULT_PHP_VERSION-zip php$YNH_DEFAULT_PHP_VERSION-curl php$YNH_DEFAULT_PHP_VERSION-gd"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Check if directory/file already exists (path in argument)
|
# Check if directory/file already exists (path in argument)
|
||||||
myynh_check_path () {
|
myynh_check_path () {
|
||||||
[ -z "$1" ] && ynh_die --message="No argument supplied"
|
[ -z "$1" ] && ynh_die --message="No argument supplied"
|
||||||
|
@ -31,12 +32,12 @@ myynh_clean_source () {
|
||||||
myynh_set_permissions () {
|
myynh_set_permissions () {
|
||||||
[ $(find "$final_path" -type f | wc -l) -gt 0 ] && find "$final_path" -type f | xargs chmod 0644
|
[ $(find "$final_path" -type f | wc -l) -gt 0 ] && find "$final_path" -type f | xargs chmod 0644
|
||||||
[ $(find "$final_path" -type d | wc -l) -gt 0 ] && find "$final_path" -type d | xargs chmod 0755
|
[ $(find "$final_path" -type d | wc -l) -gt 0 ] && find "$final_path" -type d | xargs chmod 0755
|
||||||
[ $(find "$data_path" -type f | wc -l) -gt 0 ] && find "$data_path" -type f | xargs chmod 0644
|
[ $(find "$datadir" -type f | wc -l) -gt 0 ] && find "$datadir" -type f | xargs chmod 0644
|
||||||
[ $(find "$data_path" -type d | wc -l) -gt 0 ] && find "$data_path" -type d | xargs chmod 0755
|
[ $(find "$datadir" -type d | wc -l) -gt 0 ] && find "$datadir" -type d | xargs chmod 0755
|
||||||
chown -R root:"$app" "$final_path"
|
chown -R root:"$app" "$final_path"
|
||||||
chown -R "$app": "$final_path/private"
|
chown -R "$app": "$final_path/private"
|
||||||
chown -R "$app": "$data_path"
|
chown -R "$app": "$datadir"
|
||||||
chown root: "$data_path"
|
chown root: "$datadir"
|
||||||
}
|
}
|
||||||
|
|
||||||
#Convert --data to --data-urlencode before ynh_local_curl
|
#Convert --data to --data-urlencode before ynh_local_curl
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# to test the functionnality :
|
|
||||||
# yunohost backup create -n "bozon-test" --apps bozon
|
|
||||||
# yunohost backup delete bozon-test
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
|
||||||
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -21,44 +18,48 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_print_info --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
|
||||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD BACKUP STEPS
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Declaring files to be backed up..."
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the main app directory..."
|
|
||||||
if [ -e "$final_path" ]; then
|
ynh_backup --src_path="$final_path"
|
||||||
ynh_backup --src_path="$final_path"
|
|
||||||
fi
|
#=================================================
|
||||||
|
# BACKUP THE DATA DIR
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="$datadir" --is_big
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up nginx web server configuration..."
|
|
||||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE PHP-FPM CONFIGURATION
|
# BACKUP THE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up php-fpm configuration..."
|
|
||||||
ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
|
|
||||||
|
|
||||||
##=================================================
|
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
# SPECIFIC BACKUP
|
# SPECIFIC BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE DATA DIRECTORY
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up data directory..."
|
|
||||||
if [ -e "$data_path" ]; then
|
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||||
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only)
|
|
||||||
if [ $backup_core_only -eq 0 ]; then
|
|
||||||
ynh_backup --src_path="$data_path" --is_big
|
|
||||||
else
|
|
||||||
echo "Data dir will not be saved, because backup_core_only is set to true." >&2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
|
@ -12,34 +12,36 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
old_domain=$YNH_APP_OLD_DOMAIN
|
old_domain=$YNH_APP_OLD_DOMAIN
|
||||||
new_domain=$YNH_APP_NEW_DOMAIN
|
|
||||||
old_path=$YNH_APP_OLD_PATH
|
old_path=$YNH_APP_OLD_PATH
|
||||||
|
|
||||||
|
new_domain=$YNH_APP_NEW_DOMAIN
|
||||||
new_path=$YNH_APP_NEW_PATH
|
new_path=$YNH_APP_NEW_PATH
|
||||||
|
|
||||||
# definie useful vars
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
old_nginx_conf="/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
|
||||||
new_nginx_conf="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
|
||||||
new_path=$(ynh_normalize_url_path --path_url="$new_path")
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
# Needed for helper "ynh_add_nginx_config"
|
# Needed for helper "ynh_add_nginx_config"
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1
|
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
|
||||||
# backup the current version of the app
|
|
||||||
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
# remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
ynh_clean_check_starting
|
||||||
|
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
# restore it if the upgrade fails
|
|
||||||
|
# Restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
|
@ -48,12 +50,16 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
change_domain=0
|
change_domain=0
|
||||||
if [ "$old_domain" != "$new_domain" ]; then
|
if [ "$old_domain" != "$new_domain" ]
|
||||||
|
then
|
||||||
change_domain=1
|
change_domain=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
change_path=0
|
change_path=0
|
||||||
if [ "$old_path" != "$new_path" ]; then
|
if [ "$old_path" != "$new_path" ]
|
||||||
|
then
|
||||||
change_path=1
|
change_path=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -62,42 +68,42 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1
|
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
||||||
|
|
||||||
# Change the path in the nginx config file
|
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
if [ $change_path -eq 1 ]; then
|
|
||||||
# Make a backup of the original nginx config file if modified
|
# Change the path in the NGINX config file
|
||||||
ynh_backup_if_checksum_is_different --file="$old_nginx_conf"
|
if [ $change_path -eq 1 ]
|
||||||
# Set global variables for nginx helper
|
then
|
||||||
|
# Make a backup of the original NGINX config file if modified
|
||||||
|
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||||
|
# Set global variables for NGINX helper
|
||||||
domain="$old_domain"
|
domain="$old_domain"
|
||||||
path_url="$new_path"
|
path_url="$new_path"
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
if [ "$path_url" != "/" ]; then
|
|
||||||
ynh_replace_string --match_string="^#sub_path_only" --replace_string="" --target_file="$old_nginx_conf"
|
|
||||||
fi
|
|
||||||
# Store file checksum for the new config file location
|
|
||||||
ynh_store_file_checksum --file="$old_nginx_conf"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for nginx
|
# Change the domain for NGINX
|
||||||
if [ $change_domain -eq 1 ]; then
|
if [ $change_domain -eq 1 ]
|
||||||
|
then
|
||||||
# Delete file checksum for the old conf file location
|
# Delete file checksum for the old conf file location
|
||||||
ynh_delete_file_checksum --file="$old_nginx_conf"
|
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||||
mv "$old_nginx_conf" "$new_nginx_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 --file="$new_nginx_conf"
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Change of URL completed for $app" --time --last
|
|
||||||
|
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||||
|
|
109
scripts/install
109
scripts/install
|
@ -18,27 +18,28 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url=$YNH_APP_ARG_PATH
|
path_url=$YNH_APP_ARG_PATH
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
password=$YNH_APP_ARG_PASSWORD
|
password=$YNH_APP_ARG_PASSWORD
|
||||||
backup_core_only=$YNH_APP_ARG_BACKUP_CORE_ONLY
|
|
||||||
|
|
||||||
# definie useful vars
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
final_path="/var/www/$app"
|
|
||||||
data_path="/home/yunohost.app/$app"
|
|
||||||
path_url=$(ynh_normalize_url_path --path_url="$path_url")
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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..."
|
ynh_script_progression --message="Validating installation parameters..."
|
||||||
## check domain/path availability
|
|
||||||
|
final_path=/var/www/$app
|
||||||
|
datadir="/home/yunohost.app/$app"
|
||||||
|
path_url=$(ynh_normalize_url_path --path_url="$path_url")
|
||||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||||
## register (book) web path
|
|
||||||
ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url"
|
# Register (book) web path
|
||||||
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||||
|
|
||||||
## check that admin user is an existing account
|
## check that admin user is an existing account
|
||||||
ynh_user_exists --username="$admin"
|
ynh_user_exists --username="$admin"
|
||||||
|
|
||||||
|
@ -46,12 +47,12 @@ ynh_user_exists --username="$admin"
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Storing installation settings..."
|
ynh_script_progression --message="Storing installation settings..."
|
||||||
ynh_app_setting_set --app="$app" --key=domain --value="$domain"
|
|
||||||
ynh_app_setting_set --app="$app" --key=path --value="$path_url"
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set --app="$app" --key=admin_user --value="$admin"
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
ynh_app_setting_set --app="$app" --key=backup_core_only --value=$backup_core_only
|
ynh_app_setting_set --app=$app --key=admin_user --value=$admin
|
||||||
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
|
ynh_app_setting_set --app=$app --key=final_path --value="$final_path"
|
||||||
ynh_app_setting_set --app="$app" --key=data_path --value="$data_path"
|
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
|
@ -59,59 +60,91 @@ ynh_app_setting_set --app="$app" --key=data_path --value="$data_path"
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..." --weight=3
|
ynh_script_progression --message="Installing dependencies..." --weight=3
|
||||||
ynh_install_app_dependencies "$pkg_dependencies"
|
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring system user..."
|
ynh_script_progression --message="Configuring system user..."
|
||||||
ynh_system_user_create --username="$app"
|
|
||||||
|
# Create a system user
|
||||||
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setting up source files..." --weight=3
|
ynh_script_progression --message="Setting up source files..." --weight=3
|
||||||
|
|
||||||
## download source
|
## download source
|
||||||
tmpdir=$(mktemp -d)
|
tmpdir=$(mktemp -d)
|
||||||
ynh_setup_source --dest_dir="$tmpdir"
|
ynh_setup_source --dest_dir="$tmpdir"
|
||||||
## clean & copy files needed to final folder
|
## clean & copy files needed to final folder
|
||||||
myynh_clean_source
|
myynh_clean_source
|
||||||
mv "$tmpdir" "$final_path"
|
mv "$tmpdir" "$final_path"
|
||||||
## create private & data folders
|
|
||||||
myynh_create_dir "$final_path/private"
|
chmod 750 "$final_path"
|
||||||
myynh_create_dir "$data_path/uploads"
|
chmod -R o-rwx "$final_path"
|
||||||
myynh_create_dir "$data_path/thumbs"
|
chown -R $app:www-data "$final_path"
|
||||||
ln -s "$data_path/uploads" "$final_path/uploads"
|
|
||||||
ln -s "$data_path/thumbs" "$final_path/thumbs"
|
#=================================================
|
||||||
## set permissions
|
# PHP-FPM CONFIGURATION
|
||||||
myynh_set_permissions
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring PHP-FPM..."
|
||||||
|
|
||||||
|
# Create a dedicated PHP-FPM config
|
||||||
|
ynh_add_fpm_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring nginx web server..."
|
ynh_script_progression --message="Configuring NGINX web server..."
|
||||||
|
|
||||||
if [ "$path_url" != "/" ]; then
|
if [ "$path_url" != "/" ]; then
|
||||||
ynh_replace_string --match_string="^#sub_path_only" --replace_string="" --target_file="../conf/nginx.conf"
|
ynh_replace_string --match_string="^#sub_path_only" --replace_string="" --target_file="../conf/nginx.conf"
|
||||||
fi
|
fi
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP-FPM CONFIGURATION
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring php-fpm..."
|
# CREATE DATA DIRECTORY
|
||||||
ynh_add_fpm_config
|
#=================================================
|
||||||
|
ynh_script_progression --message="Creating a data directory..."
|
||||||
|
|
||||||
|
datadir=/home/yunohost.app/$app
|
||||||
|
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
||||||
|
|
||||||
|
mkdir -p $datadir
|
||||||
|
|
||||||
|
chmod 750 "$datadir"
|
||||||
|
chmod -R o-rwx "$datadir"
|
||||||
|
chown -R $app:www-data "$datadir"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ADD A CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Adding a configuration file..."
|
||||||
|
|
||||||
|
## create private & data folders
|
||||||
|
myynh_create_dir "$final_path/private"
|
||||||
|
myynh_create_dir "$datadir/uploads"
|
||||||
|
myynh_create_dir "$datadir/thumbs"
|
||||||
|
ln -s "$datadir/uploads" "$final_path/uploads"
|
||||||
|
ln -s "$datadir/thumbs" "$final_path/thumbs"
|
||||||
|
## set permissions
|
||||||
|
myynh_set_permissions
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP APPLICATION WITH CURL
|
# SETUP APPLICATION WITH CURL
|
||||||
#=================================================
|
#=================================================
|
||||||
# create admin user in bozon
|
|
||||||
ynh_script_progression --message="Configuring admin user in BoZon..." --weight=2
|
ynh_script_progression --message="Configuring admin user in BoZon..." --weight=2
|
||||||
## set the app as temporarily public for curl call
|
|
||||||
|
|
||||||
## reload SSOwat config
|
# Set the app as temporarily public for curl call
|
||||||
yunohost app ssowatconf
|
ynh_script_progression --message="Configuring SSOwat..."
|
||||||
## reload Nginx
|
# Making the app public for curl
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_permission_update --permission="main" --add="visitors"
|
||||||
|
|
||||||
## fill the superadmin creation form (helper ynh_local_curl doesn't work due to --data vs --data-urlencode ?)
|
## fill the superadmin creation form (helper ynh_local_curl doesn't work due to --data vs --data-urlencode ?)
|
||||||
admin_url="/index.php?p=login"
|
admin_url="/index.php?p=login"
|
||||||
admin=$(myynh_urlencode $admin)
|
admin=$(myynh_urlencode $admin)
|
||||||
|
@ -126,21 +159,23 @@ ynh_print_ON
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring SSOwat..."
|
ynh_script_progression --message="Configuring SSOwat..."
|
||||||
|
|
||||||
if [ $is_public -eq 0 ]; then
|
if [ $is_public -eq 0 ]; then
|
||||||
# escape magic chars in vars (lua magic chars are ().%+-*?[^$ according to https://www.lua.org/pil/20.2.html)
|
# escape magic chars in vars (lua magic chars are ().%+-*?[^$ according to https://www.lua.org/pil/20.2.html)
|
||||||
domainluaregex=$(echo "$domain" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
domainluaregex=$(echo "$domain" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
||||||
pathluaregex=$([ "$path_url" == "/" ] || echo "$path_url" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
pathluaregex=$([ "$path_url" == "/" ] || echo "$path_url" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
||||||
regexList="${domainluaregex}${pathluaregex}/index%.php$","${domainluaregex}${pathluaregex}/index%.php%?p=.*$"
|
regexList="${domainluaregex}${pathluaregex}/index%.php$","${domainluaregex}${pathluaregex}/index%.php%?p=.*$"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading nginx web server..."
|
ynh_script_progression --message="Reloading NGINX web server..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of $app completed" --last
|
ynh_script_progression --message="Installation of $app completed" --last
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# to test the functionnality :
|
|
||||||
# yunohost app remove bozon
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -14,41 +13,57 @@ source /usr/share/yunohost/helpers
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
|
||||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
#=================================================
|
|
||||||
# REMOVE DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing dependencies..." --weight=1
|
|
||||||
ynh_remove_app_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||||
|
|
||||||
|
# Remove the app directory securely
|
||||||
ynh_secure_remove --file="$final_path"
|
ynh_secure_remove --file="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE DATA DIR
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Remove the data directory if --purge option is used
|
||||||
|
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
|
||||||
|
then
|
||||||
|
ynh_script_progression --message="Removing app data directory..."
|
||||||
|
ynh_secure_remove --file="$datadir"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing nginx web server configuration..." --weight=1
|
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||||
|
|
||||||
|
# Remove the dedicated NGINX config
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE PHP-FPM CONFIGURATION
|
# REMOVE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing php-fpm configuration..." --weight=1
|
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1
|
||||||
|
|
||||||
|
# Remove the dedicated PHP-FPM config
|
||||||
ynh_remove_fpm_config
|
ynh_remove_fpm_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC REMOVE
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_secure_remove --file="$data_path"
|
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||||
|
|
||||||
|
# Remove metapackage and its dependencies
|
||||||
|
ynh_remove_app_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
@ -56,9 +71,12 @@ ynh_secure_remove --file="$data_path"
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||||
ynh_system_user_delete --username="$app"
|
|
||||||
|
# Delete a system user
|
||||||
|
ynh_system_user_delete --username=$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed" --last
|
ynh_script_progression --message="Removal of $app completed" --last
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# to test the functionnality :
|
|
||||||
# yunohost backup create -n "bozon-test" --apps bozon
|
|
||||||
# yunohost app remove bozon
|
|
||||||
# yunohost backup restore "bozon-test"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC START
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
|
||||||
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -23,43 +20,55 @@ ynh_abort_if_errors
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
|
||||||
path_url=$(ynh_app_setting_get --app="$app" --key=path)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
backup_core_only=$(ynh_app_setting_get --app="$app" --key=backup_core_only)
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||||
ynh_webpath_available --domain="$domain" --path_url="$path_url" || ynh_die --message="Path not available: ${domain}${path_url}"
|
|
||||||
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path"
|
test ! -d $final_path \
|
||||||
|
|| ynh_die --message="There is already a directory: $final_path "
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORATION STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
# RECREATE THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||||
|
|
||||||
|
# Create the dedicated user (if not existing)
|
||||||
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$final_path"
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
#=================================================
|
chmod 750 "$final_path"
|
||||||
# RECREATE THE DEDICATED USER
|
chmod -R o-rwx "$final_path"
|
||||||
#=================================================
|
chown -R $app:www-data "$final_path"
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
|
||||||
ynh_system_user_create --username="$app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PHP-FPM CONFIGURATION
|
# RESTORE THE DATA DIRECTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf"
|
ynh_script_progression --message="Restoring the data directory..."
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
||||||
|
|
||||||
|
mkdir -p $datadir
|
||||||
|
|
||||||
|
chmod 750 "$datadir"
|
||||||
|
chmod -R o-rwx "$datadir"
|
||||||
|
chown -R $app:www-data "$datadir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
|
@ -67,22 +76,23 @@ ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
||||||
|
|
||||||
|
# Define and install dependencies
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE DATA DIR
|
# RESTORE THE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the data directory..." --weight=2
|
ynh_script_progression --message="Restoring the PHP-FPM configuration..."
|
||||||
if [ ! -d "$data_path" ]; then
|
|
||||||
if [ $backup_core_only -eq 0 ]; then
|
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||||
ynh_restore_file --origin_path="$data_path"
|
|
||||||
else
|
#=================================================
|
||||||
myynh_create_dir "$data_path/uploads"
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
myynh_create_dir "$data_path/thumbs"
|
#=================================================
|
||||||
fi
|
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||||
else
|
|
||||||
echo "$data_path already exists and will not be overwritten" >&2
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# RESTORE USER RIGHTS
|
||||||
|
@ -94,12 +104,13 @@ myynh_set_permissions
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND PHP-FPM
|
# RELOAD NGINX AND PHP-FPM
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading nginx web server and php-fpm..." --weight=1
|
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
|
||||||
ynh_systemd_action --service_name=php7.0-fpm --action=reload
|
|
||||||
|
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoration completed for $app" --last
|
|
||||||
|
|
||||||
|
ynh_script_progression --message="Restoration completed for $app" --last
|
||||||
|
|
141
scripts/upgrade
141
scripts/upgrade
|
@ -1,11 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC STARTING
|
# GENERIC START
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
set -eu
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -13,29 +13,15 @@ source /usr/share/yunohost/helpers
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
|
||||||
path_url=$(ynh_app_setting_get --app="$app" --key=path)
|
|
||||||
is_public=$(ynh_app_setting_get --app="$app" --key=is_public)
|
|
||||||
admin_user=$(ynh_app_setting_get --app="$app" --key=admin_user)
|
|
||||||
backup_core_only=$(ynh_app_setting_get --app="$app" --key=backup_core_only)
|
|
||||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
|
||||||
data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
|
|
||||||
|
|
||||||
#=================================================
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
|
||||||
#=================================================
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
# If final_path doesn't exist, create it
|
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||||
if [ -z "$final_path" ]; then
|
admin_user=$(ynh_app_setting_get --app=$app --key=admin_user)
|
||||||
final_path="/var/www/$app"
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
|
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
||||||
fi
|
|
||||||
# If data_path doesn't exist, create it
|
|
||||||
if [ -z "$data_path" ]; then
|
|
||||||
data_path="/home/yunohost.app/$app"
|
|
||||||
ynh_app_setting_set --app="$app" --key=data_path --value="$data_path"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
|
@ -46,31 +32,56 @@ upgrade_type=$(ynh_check_app_version_changed)
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
|
||||||
if [ -f "/etc/yunohost/apps/$app/scripts/backup" ]; then
|
|
||||||
ynh_backup_before_upgrade # Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_clean_setup () {
|
ynh_backup_before_upgrade
|
||||||
ynh_restore_upgradebackup
|
ynh_clean_setup () {
|
||||||
}
|
ynh_clean_check_starting
|
||||||
fi
|
# Restore it if the upgrade fails
|
||||||
|
ynh_restore_upgradebackup
|
||||||
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Migrate legacy permissions to new system
|
# STANDARD UPGRADE STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
if ynh_legacy_permissions_exists
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
then
|
#=================================================
|
||||||
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||||
|
|
||||||
|
# Cleaning legacy permissions
|
||||||
|
if ynh_legacy_permissions_exists; then
|
||||||
ynh_legacy_permissions_delete_all
|
ynh_legacy_permissions_delete_all
|
||||||
|
|
||||||
ynh_app_setting_delete --app=$app --key=is_public
|
ynh_app_setting_delete --app=$app --key=is_public
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If final_path doesn't exist, create it
|
||||||
|
if [ -z "$final_path" ]; then
|
||||||
|
final_path="/var/www/$app"
|
||||||
|
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
|
||||||
|
fi
|
||||||
|
# If datadir doesn't exist, create it
|
||||||
|
if [ -z "$datadir" ]; then
|
||||||
|
datadir="/home/yunohost.app/$app"
|
||||||
|
ynh_app_setting_set --app="$app" --key=datadir --value="$datadir"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||||
|
|
||||||
|
# Create a dedicated user (if not existing)
|
||||||
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]; then
|
|
||||||
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
|
then
|
||||||
# download & unpack bozon
|
# download & unpack bozon
|
||||||
ynh_script_progression --message="Setting up source files..." --weight=2
|
ynh_script_progression --message="Setting up source files..." --weight=2
|
||||||
## download source
|
## download source
|
||||||
|
@ -81,68 +92,60 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]; then
|
||||||
[ -e "$tmpdir/config.php" ] && ynh_secure_remove "$tmpdir/config.php"
|
[ -e "$tmpdir/config.php" ] && ynh_secure_remove "$tmpdir/config.php"
|
||||||
cp -a "$tmpdir/." "$final_path"
|
cp -a "$tmpdir/." "$final_path"
|
||||||
ynh_secure_remove "$tmpdir"
|
ynh_secure_remove "$tmpdir"
|
||||||
## set permissions
|
|
||||||
myynh_set_permissions
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
## set permissions
|
||||||
|
myynh_set_permissions
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
||||||
|
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PHP-FPM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading PHP-FPM configuration..."
|
||||||
|
|
||||||
|
# Create a dedicated PHP-FPM config
|
||||||
|
ynh_add_fpm_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading nginx web server configuration..."
|
ynh_script_progression --message="Upgrading nginx web server configuration..."
|
||||||
|
|
||||||
if [ "$path_url" != "/" ]; then
|
if [ "$path_url" != "/" ]; then
|
||||||
ynh_replace_string --match_string="^#sub_path_only" --replace_string="" --target_file="../conf/nginx.conf"
|
ynh_replace_string --match_string="^#sub_path_only" --replace_string="" --target_file="../conf/nginx.conf"
|
||||||
fi
|
fi
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE DEPENDENCIES
|
# SPECIFIC UPGRADE
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
|
||||||
ynh_system_user_create --username="$app"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# PHP-FPM CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading php-fpm configuration..."
|
|
||||||
ynh_add_fpm_config
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP SSOWAT
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading SSOwat configuration..."
|
|
||||||
if [ $is_public -eq 0 ]; then
|
|
||||||
# escape magic chars in vars (lua magic chars are ().%+-*?[^$ according to https://www.lua.org/pil/20.2.html)
|
|
||||||
domainluaregex=$(echo "$domain" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
|
||||||
pathluaregex=$([ "$path_url" == "/" ] || echo "$path_url" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
|
||||||
regexList="${domainluaregex}${pathluaregex}/index%.php$","${domainluaregex}${pathluaregex}/index%.php%?p=.*$"
|
|
||||||
ynh_app_setting_set --app="$app" --key=protected_regex --value="$regexList"
|
|
||||||
else
|
|
||||||
ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CLEAN PHP SESSIONS STORED IN /var/lib/phpx/sessions
|
# CLEAN PHP SESSIONS STORED IN /var/lib/phpx/sessions
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Cleaning php sessions stored..."
|
ynh_script_progression --message="Cleaning php sessions stored..."
|
||||||
|
|
||||||
if [ -d "/usr/lib/php5" ]; then
|
if [ -d "/usr/lib/php5" ]; then
|
||||||
[ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean
|
[ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean
|
||||||
elif [ -d "/usr/lib/php" ]; then
|
elif [ -d "/usr/lib/php" ]; then
|
||||||
[ -x /usr/lib/php/sessionclean ] && /usr/lib/php/sessionclean
|
[ -x /usr/lib/php/sessionclean ] && /usr/lib/php/sessionclean
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading nginx web server..."
|
ynh_script_progression --message="Reloading NGINX web server..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||||
|
|
Loading…
Reference in a new issue