mirror of
https://github.com/YunoHost-Apps/zerobin_ynh.git
synced 2024-09-03 18:06:01 +02:00
[fix] is_public boolean && add nginx configuration helper
This commit is contained in:
commit
a48cd99113
5 changed files with 56 additions and 22 deletions
|
@ -14,13 +14,8 @@
|
|||
upgrade=1
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
wrong_user=1
|
||||
wrong_path=1
|
||||
incorrect_path=1
|
||||
corrupt_source=0
|
||||
fail_download_source=0
|
||||
port_already_use=0
|
||||
final_path_already_use=0
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
|
@ -32,3 +27,6 @@
|
|||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
|
@ -16,5 +16,5 @@ location __PATH__ {
|
|||
}
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
# include conf.d/yunohost_panel.conf.inc;
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
|
|
|
@ -180,3 +180,27 @@ ynh_compare_checksum_config () {
|
|||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Normalize the url path syntax
|
||||
# Handle the slash at the beginning of path and its absence at ending
|
||||
# Return a normalized url path
|
||||
#
|
||||
# example: url_path=$(ynh_normalize_url_path $url_path)
|
||||
# ynh_normalize_url_path example -> /example
|
||||
# ynh_normalize_url_path /example -> /example
|
||||
# ynh_normalize_url_path /example/ -> /example
|
||||
# ynh_normalize_url_path / -> /
|
||||
#
|
||||
# usage: ynh_normalize_url_path path_to_normalize
|
||||
# | arg: url_path_to_normalize - URL path to normalize before using it
|
||||
ynh_normalize_url_path () {
|
||||
path_url=$1
|
||||
test -n "$path_url" || ynh_die "ynh_normalize_url_path expect a URL path as first argument and received nothing."
|
||||
if [ "${path_url:0:1}" != "/" ]; then # If the first character is not a /
|
||||
path_url="/$path_url" # Add / at begin of path variable
|
||||
fi
|
||||
if [ "${path_url:${#path_url}-1}" == "/" ] && [ ${#path_url} -gt 1 ]; then # If the last character is a / and that not the only character.
|
||||
path_url="${path_url:0:${#path_url}-1}" # Delete the last character
|
||||
fi
|
||||
echo $path_url
|
||||
}
|
||||
|
|
|
@ -9,19 +9,13 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path=$YNH_APP_ARG_PATH
|
||||
path=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||
|| ynh_die "Path not available: ${domain}${path}"
|
||||
|
||||
# Remove trailing "/" for next commands
|
||||
if [[ ! "$path" == "/" ]]; then
|
||||
path=${path%/}
|
||||
fi
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app"
|
||||
|
||||
# Copy files to the right place
|
||||
final_path=/var/www/$app
|
||||
|
@ -47,10 +41,18 @@ ynh_nginx_config
|
|||
# Create the php-fpm pool config
|
||||
ynh_fpm_config
|
||||
|
||||
<<<<<<< HEAD
|
||||
# If app is public, add url to SSOWat conf as skipped_uris
|
||||
if [[ $is_public -eq 1 ]]; then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
=======
|
||||
# Set ssowat config
|
||||
ynh_app_setting_set $app is_public "$is_public"
|
||||
if [ "$is_public" = "Yes" ];
|
||||
then
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
>>>>>>> ed68227b97ca7aa0f4e0d0f9450df936e867585f
|
||||
fi
|
||||
|
||||
sudo systemctl reload nginx
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
||||
set -eu
|
||||
|
||||
if [ ! -e _common ]; then
|
||||
# Fetch helpers file if not in current directory
|
||||
sudo cp ../settings/scripts/_common ./_common
|
||||
sudo chmod a+rx _common
|
||||
fi
|
||||
source _common
|
||||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -25,8 +31,7 @@ user=$(ynh_app_setting_get $app allowed_users)
|
|||
is_public=$(ynh_app_setting_get $app is_public)
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||
|| ynh_die "Path not available: ${domain}${path}"
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app"
|
||||
|
||||
# Check $final_path
|
||||
final_path="/var/www/${app}"
|
||||
|
@ -52,28 +57,33 @@ if [ -f $phpfpm_ini ]; then
|
|||
ynh_die "The PHP FPM INI configuration already exists at '${phpfpm_ini}'.
|
||||
You should safely delete it before restoring this app."
|
||||
fi
|
||||
# Create dedicated system user for this app
|
||||
ynh_system_user_create $app
|
||||
|
||||
# Restore sources & data
|
||||
sudo cp -a "./sources" $final_path
|
||||
|
||||
# Set permissions
|
||||
sudo chown -R root:root $final_path
|
||||
sudo chown -R www-data:root $final_path/{data,tmp}
|
||||
sudo chown -R $app:root $final_path/{data,tmp}
|
||||
sudo chmod -R 700 $final_path/{data,tmp}
|
||||
|
||||
# Restore nginx configuration files
|
||||
sudo cp -a ./conf/nginx.conf "${nginx_conf}"
|
||||
sudo cp -a ./php-fpm.conf "$phpfpm_conf"
|
||||
sudo cp -a ./php-fpm.ini "$phpfpm_ini"
|
||||
|
||||
# Restore php-fpm configuration files
|
||||
sudo cp -a ./conf/php-fpm.conf "${phpfpm_conf}"
|
||||
sudo cp -a ./conf/php-fpm.ini "${phpfpm_ini}"
|
||||
|
||||
# Set ssowat config
|
||||
if [ "$is_public" = "No" ];
|
||||
if [ "$is_public" = "Yes" ];
|
||||
then
|
||||
ynh_app_setting_delete $app skipped_uris
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
fi
|
||||
|
||||
# Reload service
|
||||
sudo systemctl reload nginx
|
||||
sudo systemctl reload php5-fpm
|
||||
sudo yunohost app ssowatconf
|
Loading…
Reference in a new issue