mirror of
https://github.com/YunoHost-Apps/bozon_ynh.git
synced 2024-09-03 18:16:09 +02:00
Update according to new packaging standards & helpers
This commit is contained in:
parent
55fda9d132
commit
8bb48ce8cb
11 changed files with 443 additions and 246 deletions
|
@ -3,11 +3,12 @@
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="domain.tld" (DOMAIN)
|
domain="domain.tld" (DOMAIN)
|
||||||
path="/path" (PATH)
|
path="/path" (PATH)
|
||||||
is_public="Yes" (PUBLIC|public=Yes|private=No)
|
is_public=1 (PUBLIC)
|
||||||
language="en"
|
language="en"
|
||||||
filesize="2G"
|
filesize="2G"
|
||||||
admin="john" (USER)
|
admin="john" (USER)
|
||||||
password="super_secret_password" (PASSWORD)
|
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
|
||||||
|
|
5
conf/app.src
Normal file
5
conf/app.src
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
SOURCE_URL=https://github.com/broncowdd/BoZoN/archive/06f2a665f45e3e8f4c4bf71bf4146e8accb27776.zip
|
||||||
|
SOURCE_SUM=d82dddd968a8cb31e21d1fb3e0518f4b88d92ec95948d652c0c378fce4dc8e65
|
||||||
|
SOURCE_FORMAT=zip
|
||||||
|
|
||||||
|
#sha256sum obtain with shasum -a 256 $SOURCE_URL
|
|
@ -1,6 +1,6 @@
|
||||||
location YNH_EXAMPLE_PATH {
|
location __PATH__ {
|
||||||
# Path to source
|
# Path to source
|
||||||
alias YNH_EXAMPLE_ALIAS/;
|
alias __FINALPATH__/;
|
||||||
if ($scheme = http) {
|
if ($scheme = http) {
|
||||||
rewrite ^ https://$server_name$request_uri? permanent;
|
rewrite ^ https://$server_name$request_uri? permanent;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ location YNH_EXAMPLE_PATH {
|
||||||
add_header X-Permitted-Cross-Domain-Policies none;
|
add_header X-Permitted-Cross-Domain-Policies none;
|
||||||
|
|
||||||
# Set max upload size
|
# Set max upload size
|
||||||
client_max_body_size YNH_FILE_SIZE;
|
client_max_body_size __FILESIZE__;
|
||||||
client_body_timeout 30m;
|
client_body_timeout 30m;
|
||||||
proxy_read_timeout 30m;
|
proxy_read_timeout 30m;
|
||||||
fastcgi_buffers 64 4K;
|
fastcgi_buffers 64 4K;
|
||||||
|
@ -28,7 +28,7 @@ location YNH_EXAMPLE_PATH {
|
||||||
location ~ [^/]\.php(/|$) {
|
location ~ [^/]\.php(/|$) {
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||||
fastcgi_pass unix:/var/run/php5-fpm-YNH_EXAMPLE_APP.sock;
|
fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock;
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
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;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[YNH_EXAMPLE_APP]
|
[__NAME__]
|
||||||
; The address on which to accept FastCGI requests.
|
; The address on which to accept FastCGI requests.
|
||||||
listen = /var/run/php5-fpm-YNH_EXAMPLE_APP.sock
|
listen = /var/run/php5-fpm-__NAME__.sock
|
||||||
|
|
||||||
; Set permissions for unix socket, if one is used.
|
; Set permissions for unix socket, if one is used.
|
||||||
listen.owner = www-data
|
listen.owner = www-data
|
||||||
|
@ -8,8 +8,8 @@ listen.group = www-data
|
||||||
listen.mode = 0600
|
listen.mode = 0600
|
||||||
|
|
||||||
; Unix user/group of processes.
|
; Unix user/group of processes.
|
||||||
user = www-data
|
user = __NAME__
|
||||||
group = www-data
|
group = __NAME__
|
||||||
|
|
||||||
; Choose how the process manager will control the number of child processes.
|
; Choose how the process manager will control the number of child processes.
|
||||||
pm = dynamic
|
pm = dynamic
|
||||||
|
@ -47,7 +47,7 @@ request_terminate_timeout = 1d
|
||||||
request_slowlog_timeout = 5s
|
request_slowlog_timeout = 5s
|
||||||
|
|
||||||
; The log file for slow requests.
|
; The log file for slow requests.
|
||||||
slowlog = /var/log/nginx/YNH_EXAMPLE_APP.slow.log
|
slowlog = /var/log/nginx/__NAME__.slow.log
|
||||||
|
|
||||||
; Set open file descriptor rlimit.
|
; Set open file descriptor rlimit.
|
||||||
rlimit_files = 4096
|
rlimit_files = 4096
|
||||||
|
@ -56,7 +56,7 @@ rlimit_files = 4096
|
||||||
rlimit_core = 0
|
rlimit_core = 0
|
||||||
|
|
||||||
; Chdir to this directory at the start.
|
; Chdir to this directory at the start.
|
||||||
chdir = YNH_EXAMPLE_ALIAS
|
chdir = __FINALPATH__
|
||||||
|
|
||||||
; Redirect worker stdout and stderr into main error log.
|
; Redirect worker stdout and stderr into main error log.
|
||||||
catch_workers_output = yes
|
catch_workers_output = yes
|
||||||
|
@ -65,7 +65,7 @@ catch_workers_output = yes
|
||||||
clear_env = no
|
clear_env = no
|
||||||
|
|
||||||
; Additional php.ini defines, specific to this pool of workers.
|
; Additional php.ini defines, specific to this pool of workers.
|
||||||
php_value[upload_max_filesize] = YNH_FILE_SIZE
|
php_value[upload_max_filesize] = __FILESIZE__
|
||||||
php_value[post_max_size] = YNH_POST_SIZE
|
php_value[post_max_size] = __POSTSIZE__
|
||||||
php_value[default_charset] = UTF-8
|
php_value[default_charset] = UTF-8
|
||||||
php_value[always_populate_raw_post_data] = -1
|
php_value[always_populate_raw_post_data] = -1
|
||||||
|
|
|
@ -8,12 +8,13 @@
|
||||||
},
|
},
|
||||||
"url": "http://bozon.pw",
|
"url": "http://bozon.pw",
|
||||||
"license": "free",
|
"license": "free",
|
||||||
|
"version": "2.4.18",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "ewilly",
|
"name": "ewilly",
|
||||||
"email": "ewilly@neuf.fr"
|
"email": "ewilly@neuf.fr"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 2.4"
|
"yunohost": ">= 2.6.3"
|
||||||
},
|
},
|
||||||
"multi_instance": false,
|
"multi_instance": false,
|
||||||
"services": [
|
"services": [
|
||||||
|
@ -43,12 +44,12 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
|
"type": "boolean",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Should this application be public ? (if not, sharing file with unregistered users still work)",
|
"en": "Should this application be public ? (if not, sharing file with unregistered users 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)"
|
"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)"
|
||||||
},
|
},
|
||||||
"choices": ["Yes", "No"],
|
"default": false
|
||||||
"default": "No"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "language",
|
"name": "language",
|
||||||
|
@ -84,6 +85,15 @@
|
||||||
"fr": "Choisissez un mot de passe administrateur pour BoZoN"
|
"fr": "Choisissez un mot de passe administrateur pour BoZoN"
|
||||||
},
|
},
|
||||||
"example": "super_secret_password"
|
"example": "super_secret_password"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "backup_core_only",
|
||||||
|
"type": "boolean",
|
||||||
|
"ask": {
|
||||||
|
"en": "In a case of backup should I only backup the core of the app ? (your uploaded to BoZoN datas as videos, pictures, documents, etc. will not be backuped)",
|
||||||
|
"fr": "En cas de sauvegarde dois-je seulement sauvegarder le coeur de l'application ? (les fichiers trasnférés dans BoZoN tels que les vidéos, images, documents, etc. ne seront pas sauvegardés)"
|
||||||
|
},
|
||||||
|
"default": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
120
scripts/_common.sh
Normal file
120
scripts/_common.sh
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
#
|
||||||
|
# Common variables & functions
|
||||||
|
#
|
||||||
|
|
||||||
|
# Package dependencies
|
||||||
|
PKG_DEPENDENCIES="php5-curl php5-gd"
|
||||||
|
|
||||||
|
# Check if directory/file already exists (path in argument)
|
||||||
|
myynh_check_path () {
|
||||||
|
[ -z "$1" ] && ynh_die "No argument supplied"
|
||||||
|
[ ! -e "$1" ] || ynh_die "$1 already exists"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create directory only if not already exists (path in argument)
|
||||||
|
myynh_create_dir () {
|
||||||
|
[ -z "$1" ] && ynh_die "No argument supplied"
|
||||||
|
[ -d "$1" ] || sudo mkdir -p "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if enough disk space available on backup storage
|
||||||
|
myynh_check_disk_space () {
|
||||||
|
file_to_analyse=$1
|
||||||
|
backup_size=$(sudo du --summarize "$1" | cut -f1)
|
||||||
|
free_space=$(sudo df --output=avail "/home/yunohost.backup" | sed 1d)
|
||||||
|
if [ $free_space -le $backup_size ]
|
||||||
|
then
|
||||||
|
WARNING echo "Not enough backup disk space for: $1"
|
||||||
|
WARNING echo "Space available: $(HUMAN_SIZE $free_space)"
|
||||||
|
ynh_die "Space needed: $(HUMAN_SIZE $backup_size)"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a dedicated nginx config
|
||||||
|
myynh_add_nginx_config () {
|
||||||
|
ynh_backup_if_checksum_is_different "$nginx_conf" 1
|
||||||
|
sudo cp ../conf/nginx.conf "$nginx_conf"
|
||||||
|
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
||||||
|
# Substitute in a nginx config file only if the variable is not empty
|
||||||
|
if test -n "${path_url:-}"; then
|
||||||
|
ynh_replace_string "__PATH__" "$path_url" "$nginx_conf"
|
||||||
|
fi
|
||||||
|
if test -n "${final_path:-}"; then
|
||||||
|
ynh_replace_string "__FINALPATH__" "$final_path" "$nginx_conf"
|
||||||
|
fi
|
||||||
|
if test -n "${app:-}"; then
|
||||||
|
ynh_replace_string "__NAME__" "$app" "$nginx_conf"
|
||||||
|
fi
|
||||||
|
if test -n "${filesize:-}"; then
|
||||||
|
ynh_replace_string "__FILESIZE__" "$filesize" "$nginx_conf"
|
||||||
|
fi
|
||||||
|
ynh_store_file_checksum "$nginx_conf"
|
||||||
|
sudo systemctl reload nginx
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove the dedicated nginx config
|
||||||
|
myynh_remove_nginx_config () {
|
||||||
|
ynh_secure_remove "$nginx_conf"
|
||||||
|
sudo systemctl reload nginx
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a dedicated php-fpm config
|
||||||
|
myynh_add_fpm_config () {
|
||||||
|
ynh_backup_if_checksum_is_different "$phpfpm_conf" 1
|
||||||
|
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
|
||||||
|
postsize=${filesize%?}.1${filesize: -1}
|
||||||
|
ynh_replace_string "__FINALPATH__" "$final_path" "$phpfpm_conf"
|
||||||
|
ynh_replace_string "__NAME__" "$app" "$phpfpm_conf"
|
||||||
|
ynh_replace_string "__FILESIZE__" "$filesize" "$phpfpm_conf"
|
||||||
|
ynh_replace_string "__POSTSIZE__" "$postsize" "$phpfpm_conf"
|
||||||
|
sudo chown root: "$phpfpm_conf"
|
||||||
|
ynh_store_file_checksum "$phpfpm_conf"
|
||||||
|
sudo systemctl reload php5-fpm
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove the dedicated php-fpm config
|
||||||
|
myynh_remove_fpm_config () {
|
||||||
|
ynh_secure_remove "$phpfpm_conf"
|
||||||
|
sudo systemctl restart php5-fpm
|
||||||
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# FUTURE YUNOHOST HELPERS - TO BE REMOVED LATER
|
||||||
|
#=================================================
|
||||||
|
# Restore a previous backup if the upgrade process failed
|
||||||
|
ynh_backup_after_failed_upgrade () {
|
||||||
|
echo "Upgrade failed." >&2
|
||||||
|
app_bck=${app//_/-} # Replace all '_' by '-'
|
||||||
|
# Check if a existing backup can be found before remove and restore the application.
|
||||||
|
if sudo yunohost backup list | grep -q $app_bck-upg$backup_number; then
|
||||||
|
# Remove the application then restore it
|
||||||
|
sudo yunohost app remove $app
|
||||||
|
# Restore the backup if the upgrade failed
|
||||||
|
sudo yunohost backup restore --ignore-system $app_bck-upg$backup_number --apps $app --force
|
||||||
|
ynh_die "The app was restored to the way it was before the failed upgrade."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Make a backup in case of failed upgrade
|
||||||
|
ynh_backup_before_upgrade () {
|
||||||
|
backup_number=1
|
||||||
|
old_backup_number=2
|
||||||
|
app_bck=${app//_/-} # Replace all '_' by '-'
|
||||||
|
# Check if a backup already exist with the prefix 1.
|
||||||
|
if sudo yunohost backup list | grep -q $app_bck-upg1; then
|
||||||
|
# Prefix become 2 to preserve the previous backup
|
||||||
|
backup_number=2
|
||||||
|
old_backup_number=1
|
||||||
|
fi
|
||||||
|
# Create another backup
|
||||||
|
sudo yunohost backup create --ignore-system --apps $app --name $app_bck-upg$backup_number
|
||||||
|
if [ "$?" -eq 0 ]; then
|
||||||
|
# If the backup succedded, remove the previous backup
|
||||||
|
if sudo yunohost backup list | grep -q $app_bck-upg$old_backup_number; then
|
||||||
|
# Remove the previous backup only if it exists
|
||||||
|
sudo yunohost backup delete $app_bck-upg$old_backup_number > /dev/null
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
ynh_die "Backup failed, the upgrade process was aborted."
|
||||||
|
fi
|
||||||
|
}
|
|
@ -1,25 +1,44 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# to test the functionnality :
|
||||||
|
# yunohost backup create -n "bozon-test" --ignore-system --apps bozon
|
||||||
|
# yunohost backup delete bozon-test
|
||||||
|
|
||||||
# Exit on command errors and treat unset variables as an error
|
if [ ! -e _common.sh ]; then
|
||||||
set -eu
|
# Get the _common.sh file if it's not in the current directory
|
||||||
|
sudo cp ../settings/scripts/_common.sh ./_common.sh
|
||||||
# Source YunoHost helpers
|
sudo chmod a+rx _common.sh
|
||||||
|
fi
|
||||||
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# manage script failure
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# retrieve arguments
|
# retrieve arguments
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
parent_path=/var/www
|
final_path="/var/www/$app"
|
||||||
final_path="$parent_path"/"$app"
|
data_path="/home/yunohost.app/$app"
|
||||||
data_path=/home/yunohost.app/"$app"
|
nginx_conf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
phpfpm_conf="/etc/php5/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
# backup sources & data
|
# backup source & conf files
|
||||||
ynh_backup "$final_path" "www"
|
if [ -e "$final_path" ]; then
|
||||||
ynh_backup "$data_path" "data"
|
myynh_check_disk_space "$final_path"
|
||||||
|
ynh_backup "$final_path" "source"
|
||||||
|
fi
|
||||||
|
[ -e "$nginx_conf" ] && ynh_backup "$nginx_conf" "nginx.conf"
|
||||||
|
[ -e "$phpfpm_conf" ] && ynh_backup "$phpfpm_conf" "php-fpm.conf"
|
||||||
|
|
||||||
# backup Nginx and php-fpm
|
# backup data
|
||||||
mkdir ./conf
|
if [ -e "$data_path" ]; then
|
||||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "conf/nginx.conf"
|
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only)
|
||||||
ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "conf/php-fpm.conf"
|
if [ $backup_core_only -eq 0 ]; then
|
||||||
|
myynh_check_disk_space "$data_path"
|
||||||
|
ynh_backup "$data_path" "data" 1
|
||||||
|
else
|
||||||
|
echo "Data dir will not be saved, because backup_core_only is set to true." >&2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
164
scripts/install
164
scripts/install
|
@ -1,132 +1,114 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Exit on command errors and treat unset variables as an error
|
source _common.sh
|
||||||
set -eu
|
|
||||||
|
|
||||||
# Source YunoHost helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# manage script failure
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# retrieve arguments
|
# retrieve arguments
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path=$YNH_APP_ARG_PATH
|
path_url=$YNH_APP_ARG_PATH
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
language=$YNH_APP_ARG_LANGUAGE
|
language=$YNH_APP_ARG_LANGUAGE
|
||||||
filesize=$YNH_APP_ARG_FILESIZE
|
filesize=$YNH_APP_ARG_FILESIZE
|
||||||
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
|
||||||
|
|
||||||
# chech if / is present at start and not at end
|
|
||||||
if [ "${path:0:1}" != "/" ] && [ ${#path} -gt 0 ]; then
|
|
||||||
# first char is not / && path not empty => add / at start
|
|
||||||
path="/$path"
|
|
||||||
fi
|
|
||||||
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then
|
|
||||||
# last char is / && path is gretter than /
|
|
||||||
path="${path:0:${#path}-1}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
parent_path=/var/www
|
final_path="/var/www/$app"
|
||||||
final_path="$parent_path"/"$app"
|
data_path="/home/yunohost.app/$app"
|
||||||
data_path=/home/yunohost.app/"$app"
|
bozon_conf="$final_path/config.php"
|
||||||
|
nginx_conf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
phpfpm_conf="/etc/php5/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
# check domain/path availability
|
# check domain/path availability
|
||||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" || ynh_die "The path ${domain}${path} is not available for app installation."
|
path_url=$(ynh_normalize_url_path "$path_url")
|
||||||
|
ynh_webpath_available "$domain" "$path_url"
|
||||||
|
ynh_webpath_register "$app" "$domain" "$path_url"
|
||||||
|
myynh_check_path "$final_path"
|
||||||
|
|
||||||
# check that admin user is an existing account
|
# check that admin user is an existing account
|
||||||
ynh_user_exists "$admin" || ynh_die "The chosen admin user does not exist."
|
ynh_user_exists "$admin"
|
||||||
|
|
||||||
# add required packages
|
# add required packages
|
||||||
ynh_package_is_installed "php5-curl" || ynh_package_install "php5-curl"
|
ynh_install_app_dependencies "$PKG_DEPENDENCIES"
|
||||||
ynh_package_is_installed "php5-gd" || ynh_package_install "php5-gd"
|
|
||||||
|
|
||||||
# retrieve upstream_version version of bozon
|
|
||||||
upstream_version=$(cat ../conf/upstream_version)
|
|
||||||
|
|
||||||
# save app settings
|
# save app settings
|
||||||
ynh_app_setting_set "$app" admin_user "$admin"
|
|
||||||
ynh_app_setting_set "$app" is_public "$is_public"
|
|
||||||
ynh_app_setting_set "$app" domain "$domain"
|
ynh_app_setting_set "$app" domain "$domain"
|
||||||
ynh_app_setting_set "$app" path "$path"
|
ynh_app_setting_set "$app" path "$path_url"
|
||||||
|
ynh_app_setting_set "$app" is_public $is_public
|
||||||
ynh_app_setting_set "$app" filesize "$filesize"
|
ynh_app_setting_set "$app" filesize "$filesize"
|
||||||
|
ynh_app_setting_set "$app" language "$language"
|
||||||
|
ynh_app_setting_set "$app" admin_user "$admin"
|
||||||
|
ynh_app_setting_set "$app" backup_core_only $backup_core_only
|
||||||
|
|
||||||
# download upstream_version version of bozon
|
# create a dedicated system user
|
||||||
wget -nc --quiet https://github.com/broncowdd/BoZoN/archive/"$upstream_version".zip -P /tmp
|
ynh_system_user_create "$app"
|
||||||
sudo unzip -oq /tmp/"$upstream_version".zip -d /tmp
|
|
||||||
sudo mv /tmp/BoZoN-"$upstream_version" "$parent_path"/"$app"
|
|
||||||
|
|
||||||
# copy files to final folder and set permissions
|
# download & unpack bozon
|
||||||
sudo find "$final_path" -type f -name ".htaccess" | xargs sudo rm
|
TMPDIR=$(mktemp -d)
|
||||||
sudo chown -R root: "$final_path"
|
ynh_setup_source "$TMPDIR"
|
||||||
sudo find "$final_path" -type f | xargs sudo chmod 644
|
|
||||||
sudo find "$final_path" -type d | xargs sudo chmod 755
|
# clean & copy files needed to final folder
|
||||||
|
sudo find "$TMPDIR" -type f -name ".htaccess" | xargs sudo rm
|
||||||
|
sudo find "$TMPDIR" -type f -name ".htaccess" | xargs sudo rm
|
||||||
|
if [ -e "$TMPDIR/.gitignore" ]; then
|
||||||
|
for f in $(sudo cat "$TMPDIR/.gitignore") ; do
|
||||||
|
[ -e "$TMPDIR$f" ] && sudo rm -R "$TMPDIR$f"
|
||||||
|
done
|
||||||
|
sudo rm "$TMPDIR/.gitignore"
|
||||||
|
fi
|
||||||
|
sudo mv "$TMPDIR" "$final_path"
|
||||||
|
|
||||||
# configure config file
|
# configure config file
|
||||||
sudo sed -i "s@languageuage='en';@languageuage='${language}';@g" "$final_path"/config.php
|
ynh_replace_string "default_language='en'" "default_language='$language'" "$bozon_conf"
|
||||||
|
ynh_store_file_checksum "$bozon_conf"
|
||||||
|
|
||||||
# create data folders
|
# create private & data folders
|
||||||
sudo mkdir -p "$final_path"/private
|
myynh_create_dir "$final_path/private"
|
||||||
sudo mkdir -p "$data_path"/uploads
|
myynh_create_dir "$data_path/uploads"
|
||||||
sudo ln -s "$data_path"/uploads "$final_path"/uploads
|
myynh_create_dir "$data_path/thumbs"
|
||||||
sudo mkdir -p "$data_path"/thumbs
|
sudo ln -s "$data_path/uploads" "$final_path/uploads"
|
||||||
sudo ln -s "$data_path"/thumbs "$final_path"/thumbs
|
sudo ln -s "$data_path/thumbs" "$final_path/thumbs"
|
||||||
sudo chown -R www-data: "$final_path"/private
|
|
||||||
sudo chown -R www-data: "$data_path"/uploads
|
# set permissions
|
||||||
sudo chown -R www-data: "$data_path"/thumbs
|
sudo find "$final_path" -type f | xargs sudo chmod 0640
|
||||||
|
sudo find "$final_path" -type d | xargs sudo chmod 0750
|
||||||
|
sudo find "$data_path" -type d | xargs sudo chmod 0750
|
||||||
|
sudo chown -R "$app": "$final_path/private"
|
||||||
|
sudo chown -R "$app": "$data_path/uploads"
|
||||||
|
sudo chown -R "$app": "$data_path/thumbs"
|
||||||
|
|
||||||
# configure nginx settings
|
# configure nginx settings
|
||||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
myynh_add_nginx_config
|
||||||
sed -i "s@YNH_EXAMPLE_PATH@${path}@g" ../conf/nginx.conf
|
|
||||||
sed -i "s@YNH_EXAMPLE_ALIAS@${final_path}@g" ../conf/nginx.conf
|
|
||||||
sed -i "s@YNH_EXAMPLE_APP@${app}@g" ../conf/nginx.conf
|
|
||||||
sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/nginx.conf
|
|
||||||
sudo cp ../conf/nginx.conf "$nginx_conf"
|
|
||||||
|
|
||||||
# copy and set php-fpm configuration
|
# copy and set php-fpm configuration
|
||||||
postsize=${filesize%?}.1${filesize: -1}
|
myynh_add_fpm_config
|
||||||
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
|
||||||
sed -i "s@YNH_EXAMPLE_APP@${app}@g" ../conf/php-fpm.conf
|
|
||||||
sed -i "s@YNH_EXAMPLE_ALIAS@${final_path}@g" ../conf/php-fpm.conf
|
|
||||||
sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/php-fpm.conf
|
|
||||||
sed -i "s@YNH_POST_SIZE@${postsize}@g" ../conf/php-fpm.conf
|
|
||||||
## copy final and set permissions
|
|
||||||
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
|
|
||||||
sudo chown root: "$phpfpm_conf"
|
|
||||||
sudo chmod 644 "$phpfpm_conf"
|
|
||||||
|
|
||||||
# restart services
|
# set temporary public access for curl call
|
||||||
sudo service php5-fpm restart || true
|
|
||||||
sudo service nginx reload || true
|
|
||||||
|
|
||||||
# set temporary public access
|
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
# add alias line in hosts file
|
# fill the superadmin creation form (helper ynh_local_curl doesn't work due to --data vs --data-urlencode ?)
|
||||||
echo "127.0.0.1 $domain # $app" | sudo tee -a /etc/hosts
|
curl --silent --show-error -kL -H "Host: $domain" --resolve $domain:443:127.0.0.1 https://localhost"$path_url"/ > /dev/null 2>&1
|
||||||
|
sleep 1
|
||||||
# fill the superadmin creation form
|
curl --silent --show-error -kL -H "Host: $domain" --resolve $domain:443:127.0.0.1 -X POST \
|
||||||
curl_path=$([ "$path" == "/" ] || echo "$path")
|
--data-urlencode creation="1" \
|
||||||
curl -k https://"$domain""$curl_path"/ > /dev/null 2>&1
|
--data-urlencode login="$admin" \
|
||||||
sleep 1 && curl -kX POST \
|
--data-urlencode pass="$password" \
|
||||||
--data-urlencode creation="1" \
|
--data-urlencode confirm="$password" \
|
||||||
--data-urlencode login="$admin" \
|
https://localhost"$path_url"/index.php?p=login > /dev/null 2>&1
|
||||||
--data-urlencode pass="$password" \
|
|
||||||
--data-urlencode confirm="$password" \
|
|
||||||
https://"$domain""$curl_path"/index.php?p=login > /dev/null 2>&1
|
|
||||||
|
|
||||||
# remove alias line from hosts file
|
|
||||||
sudo sed -i "/# $app/d" /etc/hosts
|
|
||||||
|
|
||||||
# if app is private, remove url to SSOWat conf from skipped_uris
|
# if app is private, remove url to SSOWat conf from skipped_uris
|
||||||
if [ "$is_public" = "No" ];
|
if [ $is_public -eq 0 ]
|
||||||
then
|
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" == "/" ] || echo "$path" | 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=.*$"
|
||||||
ynh_app_setting_set "$app" protected_regex "$regexList"
|
ynh_app_setting_set "$app" protected_regex "$regexList"
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,33 +1,50 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# to test the functionnality :
|
||||||
|
# yunohost app remove bozon
|
||||||
|
|
||||||
# Exit on command errors and treat unset variables as an error
|
if [ ! -e _common.sh ]; then
|
||||||
set -u
|
# Get the _common.sh file if it's not in the current directory
|
||||||
|
sudo cp ../settings/scripts/_common.sh ./_common.sh
|
||||||
# Source YunoHost helpers
|
sudo chmod a+rx _common.sh
|
||||||
|
fi
|
||||||
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#retrieve arguments
|
# manage script failure
|
||||||
|
set -u
|
||||||
|
|
||||||
|
# retrieve arguments
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get "${app}" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
|
||||||
if [ -e "/var/www/${app}" ]; then
|
# definie useful vars
|
||||||
echo "Delete app"
|
final_path="/var/www/$app"
|
||||||
sudo rm -rf /var/www/${app}
|
data_path="/home/yunohost.app/$app"
|
||||||
fi
|
nginx_conf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
if [ -e "/etc/nginx/conf.d/${domain}.d/${app}.conf" ]; then
|
phpfpm_conf="/etc/php5/fpm/pool.d/$app.conf"
|
||||||
echo "Delete Nginx config"
|
|
||||||
sudo rm -f /etc/nginx/conf.d/${domain}.d/${app}.conf
|
# create a full backup (core+datas) if app installed
|
||||||
fi
|
if [ $(sudo yunohost app list -i -f "$app" | wc -l) -gt 1 ]; then
|
||||||
if [ -e "/etc/php5/fpm/pool.d/${app}.conf" ]; then
|
ynh_app_setting_set "$app" backup_core_only 0
|
||||||
echo "Delete fpm config"
|
app_bck=${app//_/-}
|
||||||
sudo rm -f /etc/php5/fpm/pool.d/${app}.conf
|
sudo yunohost backup create --ignore-system --apps "$app" --name "${app_bck}_$(date '+%Y%m%d-%H%M%S')"
|
||||||
fi
|
echo "BoZon fully backuped." >&2
|
||||||
if [ -e "/home/yunohost.app/${app}" ]; then
|
|
||||||
echo "Delete datas"
|
|
||||||
sudo rm -rf /home/yunohost.app/${app}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restart services
|
# remove metapackage and its dependencies
|
||||||
sudo service php5-fpm restart || true
|
ynh_remove_app_dependencies
|
||||||
sudo service nginx reload || true
|
|
||||||
sudo yunohost app ssowatconf
|
# remove the app directory securely
|
||||||
|
ynh_secure_remove "$final_path"
|
||||||
|
|
||||||
|
# remove the dedicated nginx config
|
||||||
|
myynh_remove_nginx_config
|
||||||
|
|
||||||
|
# remove the dedicated php-fpm config
|
||||||
|
myynh_remove_fpm_config
|
||||||
|
|
||||||
|
# remove a directory securely
|
||||||
|
ynh_secure_remove "$data_path"
|
||||||
|
|
||||||
|
# delete a system user
|
||||||
|
ynh_system_user_delete "$app"
|
||||||
|
|
101
scripts/restore
101
scripts/restore
|
@ -1,64 +1,67 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# to test the functionnality :
|
||||||
|
# yunohost backup create -n "bozon-test" --ignore-system --apps bozon
|
||||||
|
# yunohost app remove bozon
|
||||||
|
# yunohost backup restore "bozon-test"
|
||||||
|
|
||||||
# Exit on command errors and treat unset variables as an error
|
if [ ! -e _common.sh ]; then
|
||||||
set -eu
|
# Fetch helpers file if not in current directory
|
||||||
|
sudo cp ../settings/scripts/_common.sh ./_common.sh
|
||||||
# Source YunoHost helpers
|
sudo chmod a+rx _common.sh
|
||||||
|
fi
|
||||||
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#retrieve arguments
|
# manage script failure
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
# retrieve arguments
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
path=$(ynh_app_setting_get "$app" path)
|
path_url=$(ynh_app_setting_get "$app" path)
|
||||||
|
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only)
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
parent_path=/var/www
|
final_path="/var/www/$app"
|
||||||
final_path="$parent_path"/"$app"
|
data_path="/home/yunohost.app/$app"
|
||||||
data_path=/home/yunohost.app/"$app"
|
nginx_conf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
phpfpm_conf="/etc/php5/fpm/pool.d/$app}.conf"
|
||||||
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
|
||||||
|
|
||||||
# check domain/path availability with app helper
|
# check domain/path availability
|
||||||
sudo yunohost app checkurl $domain$path -a $app \
|
ynh_webpath_available "$domain" "$path_url"
|
||||||
|| ynh_die "The path ${domain}${path} is not available for app installation."
|
ynh_webpath_register "$app" "$domain" "$path_url"
|
||||||
|
myynh_check_path "$final_path"
|
||||||
# check directories availability
|
|
||||||
[[ -d $final_path ]] && ynh_die \
|
|
||||||
"The path '${final_path}' already exists.
|
|
||||||
You should safely delete it before restoring this app."
|
|
||||||
[[ -d $data_path ]] && ynh_die \
|
|
||||||
"The path '${data_path}' already exists.
|
|
||||||
You should safely delete it before restoring this app."
|
|
||||||
|
|
||||||
# check configuration files
|
|
||||||
[[ -f $nginx_conf ]] && ynh_die \
|
|
||||||
"The NGINX configuration already exists at '${nginx_conf}'.
|
|
||||||
You should safely delete it before restoring this app."
|
|
||||||
[[ -f $phpfpm_conf ]] && ynh_die \
|
|
||||||
"The PHP FPM configuration already exists at '${phpfpm_conf}'.
|
|
||||||
You should safely delete it before restoring this app."
|
|
||||||
|
|
||||||
# add required packages
|
# add required packages
|
||||||
ynh_package_is_installed "php5-curl" || ynh_package_install "php5-curl"
|
ynh_install_app_dependencies "$PKG_DEPENDENCIES"
|
||||||
ynh_package_is_installed "php5-gd" || ynh_package_install "php5-gd"
|
|
||||||
|
|
||||||
# restore sources & data
|
# create a dedicated system user
|
||||||
sudo cp -a ./www "$final_path"
|
ynh_system_user_create "$app"
|
||||||
sudo mkdir -p "$data_path"
|
|
||||||
sudo cp -a ./data/. "$data_path"
|
|
||||||
|
|
||||||
# restore permissions
|
# restore sconf files
|
||||||
sudo chown -R root: "$final_path"
|
ynh_restore_file "$nginx_conf"
|
||||||
sudo find "$final_path" -type f | xargs sudo chmod 644
|
ynh_restore_file "$phpfpm_conf"
|
||||||
sudo find "$final_path" -type d | xargs sudo chmod 755
|
|
||||||
sudo chown -R www-data: "$final_path"/private
|
|
||||||
sudo chown -R www-data: "$data_path"/uploads
|
|
||||||
sudo chown -R www-data: "$data_path"/thumbs
|
|
||||||
|
|
||||||
# restore Nginx & php-fpm
|
# restore source & their permissions
|
||||||
sudo cp -a ./conf/nginx.conf "$nginx_conf"
|
ynh_restore_file "$final_path"
|
||||||
sudo cp -a ./conf/php-fpm.conf "$phpfpm_conf"
|
sudo chown -R "$app": "$final_path"
|
||||||
|
sudo chmod 755 "$final_path"
|
||||||
|
|
||||||
# Restart services
|
# restore data & their permissions only if there is no data
|
||||||
sudo service php5-fpm restart || true
|
if [ ! -d "$data_path" ]; then
|
||||||
sudo service nginx restart || true
|
if [ $backup_core_only -eq 0 ]; then
|
||||||
|
ynh_restore_file "$data_path"
|
||||||
|
sudo chown -R "$app": "$data_path"
|
||||||
|
else
|
||||||
|
myynh_create_dir "$data_path/uploads"
|
||||||
|
sudo chown -R "$app": "$data_path/uploads"
|
||||||
|
myynh_create_dir "$data_path/thumbs"
|
||||||
|
sudo chown -R "$app": "$data_path/thumbs"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "$data_path already exists and will not be overwritten" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# restart services
|
||||||
|
sudo systemctl reload php5-fpm
|
||||||
|
sudo systemctl reload nginx
|
||||||
|
|
142
scripts/upgrade
142
scripts/upgrade
|
@ -1,66 +1,106 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Exit on command errors and treat unset variables as an error
|
source _common.sh
|
||||||
set -eu
|
|
||||||
|
|
||||||
# Source YunoHost helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# manage script failure
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# retrieve arguments
|
# retrieve arguments
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
path=$(ynh_app_setting_get "$app" path)
|
path_url=$(ynh_app_setting_get "$app" path)
|
||||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||||
filesize=$(ynh_app_setting_get "$app" filesize)
|
filesize=$(ynh_app_setting_get "$app" filesize)
|
||||||
|
language=$(ynh_app_setting_get "$app" language)
|
||||||
|
admin_user=$(ynh_app_setting_get "$app" admin_user)
|
||||||
|
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only)
|
||||||
|
|
||||||
# definie useful vars
|
# definie useful vars
|
||||||
parent_path=/var/www
|
final_path="/var/www/$app"
|
||||||
data_path=/home/yunohost.app/"$app"
|
data_path="/home/yunohost.app/$app"
|
||||||
final_path=$parent_path/"$app"
|
bozon_conf="$final_path/config.php"
|
||||||
if [ -z "$filesize" ]
|
nginx_conf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
then # in old script filesize was not saved as an setting
|
phpfpm_conf="/etc/php5/fpm/pool.d/$app.conf"
|
||||||
filesize=$(cat /etc/nginx/conf.d/"$domain".d/"$app".conf | grep -Po 'client_max_body_size \K.*(?=;)')
|
|
||||||
|
# use prior backup and restore on error only if backup feature exists on installed instance
|
||||||
|
if [ -f "/etc/yunohost/apps/$app/scripts/backup" ] ; then
|
||||||
|
ynh_backup_before_upgrade # Backup the current version of the app
|
||||||
|
ynh_clean_setup () {
|
||||||
|
ynh_backup_after_failed_upgrade
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# retrieve & save real/right value if argument was not saved as a app setting in a previous realease
|
||||||
|
if [ -z "$filesize" ]; then # in old script filesize was not saved as a setting
|
||||||
|
filesize=$(cat "$nginx_conf" | grep -Po "client_max_body_size \K.*?(?=;)")
|
||||||
ynh_app_setting_set "$app" filesize "$filesize"
|
ynh_app_setting_set "$app" filesize "$filesize"
|
||||||
fi
|
fi
|
||||||
|
if [ -z "$language" ]; then # in old script language was not saved as a setting
|
||||||
# download upstream_version version of bozon
|
language=$(cat "$bozon_conf" | grep -Po "default_language='\K.*?(?=')")
|
||||||
upstream_version=$(cat ../conf/upstream_version)
|
ynh_app_setting_set "$app" language "$language"
|
||||||
wget -nc --quiet https://github.com/broncowdd/BoZoN/archive/"$upstream_version".zip -P /tmp
|
fi
|
||||||
sudo unzip -oq /tmp/"$upstream_version".zip -d /tmp
|
if [ "$is_public" = "Yes" ]; then # in old script is_public was not a boolean
|
||||||
sudo rsync -avz --exclude="config.php" --exclude=".htaccess" /tmp/BoZoN-"$upstream_version"/* "$final_path"
|
ynh_app_setting_set "$app" is_public 1
|
||||||
|
is_public=1
|
||||||
# configure nginx settings
|
elif [ "$is_public" = "No" ]; then
|
||||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
ynh_app_setting_set "$app" is_public 0
|
||||||
sed -i "s@YNH_EXAMPLE_PATH@${path}@g" ../conf/nginx.conf
|
is_public=0
|
||||||
sed -i "s@YNH_EXAMPLE_ALIAS@${final_path}@g" ../conf/nginx.conf
|
fi
|
||||||
sed -i "s@YNH_EXAMPLE_APP@${app}@g" ../conf/nginx.conf
|
if [ -z "$backup_core_only" ]; then # in old script backup_core_only was not a setting
|
||||||
sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/nginx.conf
|
ynh_app_setting_set "$app" backup_core_only 1
|
||||||
sudo cp ../conf/nginx.conf "$nginx_conf"
|
|
||||||
|
|
||||||
# copy and set php-fpm configuration
|
|
||||||
postsize=${filesize%?}.1${filesize: -1}
|
|
||||||
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
|
||||||
sed -i "s@YNH_EXAMPLE_APP@${app}@g" ../conf/php-fpm.conf
|
|
||||||
sed -i "s@YNH_EXAMPLE_ALIAS@${final_path}@g" ../conf/php-fpm.conf
|
|
||||||
sed -i "s@YNH_FILE_SIZE@${filesize}@g" ../conf/php-fpm.conf
|
|
||||||
sudo sed -i "s@YNH_POST_SIZE@${postsize}@g" ../conf/php-fpm.conf
|
|
||||||
## copy final and set permissions
|
|
||||||
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
|
|
||||||
sudo chown root: "$phpfpm_conf"
|
|
||||||
sudo chmod 644 "$phpfpm_conf"
|
|
||||||
|
|
||||||
# if app is private, remove url to SSOWat conf from skipped_uris
|
|
||||||
if [ "$is_public" = "No" ];
|
|
||||||
then
|
|
||||||
ynh_app_setting_delete "$app" unprotected_uris
|
|
||||||
# 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=$(echo "$path" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
|
||||||
regexList="${domainluaregex}${pathluaregex}/index.php%?f=.+$","${domainluaregex}${pathluaregex}/index.php%?zipfolder=.+$","${domainluaregex}${pathluaregex}/private/temp/.+%.zip$","${domainluaregex}${pathluaregex}/core/js/.*$","${domainluaregex}${pathluaregex}/templates/.*$"
|
|
||||||
ynh_app_setting_set "$app" unprotected_regex "$regexList"
|
|
||||||
sudo yunohost app ssowatconf
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restart services
|
# add required packages
|
||||||
sudo service php5-fpm restart || true
|
ynh_install_app_dependencies "$PKG_DEPENDENCIES"
|
||||||
sudo service nginx reload || true
|
|
||||||
|
# create a dedicated system user
|
||||||
|
ynh_system_user_create "$app"
|
||||||
|
|
||||||
|
# download & unpack bozon
|
||||||
|
TMPDIR=$(mktemp -d)
|
||||||
|
ynh_setup_source "$TMPDIR"
|
||||||
|
|
||||||
|
# clean & copy files needed to final folder
|
||||||
|
sudo find "$TMPDIR" -type f -name ".htaccess" | xargs sudo rm
|
||||||
|
if [ -e "$TMPDIR/.gitignore" ]; then
|
||||||
|
for f in $(sudo cat "$TMPDIR/.gitignore") ; do
|
||||||
|
[ -e "$TMPDIR$f" ] && sudo rm -R "$TMPDIR$f"
|
||||||
|
done
|
||||||
|
sudo rm "$TMPDIR/.gitignore"
|
||||||
|
fi
|
||||||
|
[ -e "$TMPDIR/config.php" ] && sudo rm "$TMPDIR/config.php"
|
||||||
|
sudo cp -a "$TMPDIR/." "$final_path"
|
||||||
|
sudo rm -R "$TMPDIR"
|
||||||
|
|
||||||
|
# set permissions
|
||||||
|
sudo find "$final_path" -type f | xargs sudo chmod 0640
|
||||||
|
sudo find "$final_path" -type d | xargs sudo chmod 0750
|
||||||
|
sudo find "$data_path" -type f | xargs sudo chmod 0640
|
||||||
|
sudo find "$data_path" -type d | xargs sudo chmod 0750
|
||||||
|
sudo chown -R "$app": "$final_path/private"
|
||||||
|
sudo chown -R "$app": "$data_path/uploads"
|
||||||
|
sudo chown -R "$app": "$data_path/thumbs"
|
||||||
|
|
||||||
|
# configure nginx settings
|
||||||
|
myynh_add_nginx_config
|
||||||
|
|
||||||
|
# copy and set php-fpm configuration
|
||||||
|
myynh_add_fpm_config
|
||||||
|
|
||||||
|
# if app is private, remove url to SSOWat conf from skipped_uris
|
||||||
|
if [ $is_public -eq 0 ]
|
||||||
|
then
|
||||||
|
ynh_app_setting_delete "$app" unprotected_regex # in old script unprotected_regex was used in place of protected_regex
|
||||||
|
# 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" protected_regex "$regexList"
|
||||||
|
else
|
||||||
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||||
|
fi
|
||||||
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
|
# Purge php sessions stored in /var/lib/php5/sessions
|
||||||
|
[ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean
|
||||||
|
|
Loading…
Add table
Reference in a new issue