mirror of
https://github.com/YunoHost-Apps/zerobin_ynh.git
synced 2024-09-03 18:06:01 +02:00
Various fixes
This commit is contained in:
parent
37ce42d372
commit
ed68227b97
6 changed files with 53 additions and 24 deletions
|
@ -14,13 +14,8 @@
|
||||||
upgrade=1
|
upgrade=1
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=1
|
||||||
wrong_user=1
|
|
||||||
wrong_path=1
|
|
||||||
incorrect_path=1
|
incorrect_path=1
|
||||||
corrupt_source=0
|
|
||||||
fail_download_source=0
|
|
||||||
port_already_use=0
|
port_already_use=0
|
||||||
final_path_already_use=0
|
|
||||||
;;; Levels
|
;;; Levels
|
||||||
Level 1=auto
|
Level 1=auto
|
||||||
Level 2=auto
|
Level 2=auto
|
||||||
|
@ -32,3 +27,6 @@
|
||||||
Level 8=0
|
Level 8=0
|
||||||
Level 9=0
|
Level 9=0
|
||||||
Level 10=0
|
Level 10=0
|
||||||
|
;;; Options
|
||||||
|
Email=
|
||||||
|
Notification=none
|
|
@ -7,7 +7,7 @@ location YNH_WWW_PATH {
|
||||||
try_files $uri $uri/ index.php;
|
try_files $uri $uri/ index.php;
|
||||||
location ~ [^/]\.php(/|$) {
|
location ~ [^/]\.php(/|$) {
|
||||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||||
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
fastcgi_pass unix:/var/run/php5-fpm-YNH_NAME.sock;
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
fastcgi_param REMOTE_USER $remote_user;
|
fastcgi_param REMOTE_USER $remote_user;
|
||||||
|
|
|
@ -145,3 +145,27 @@ ynh_compare_checksum_config () {
|
||||||
fi
|
fi
|
||||||
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
|
# Retrieve arguments
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
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
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
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
|
|
||||||
|
|
||||||
# Copy files to the right place
|
# Copy files to the right place
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
|
@ -44,6 +38,7 @@ sudo chmod 700 $final_path/{data,tmp}
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
||||||
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
||||||
|
sed -i "s@YNH_NAME@$app@g" ../conf/nginx.conf
|
||||||
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
|
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
sudo cp ../conf/nginx.conf $nginxconf
|
sudo cp ../conf/nginx.conf $nginxconf
|
||||||
sudo chown root: $nginxconf
|
sudo chown root: $nginxconf
|
||||||
|
@ -53,9 +48,10 @@ sudo chmod 600 $nginxconf
|
||||||
ynh_fpm_config
|
ynh_fpm_config
|
||||||
|
|
||||||
# Set ssowat config
|
# Set ssowat config
|
||||||
if [ "$is_public" = "No" ];
|
ynh_app_setting_set $app is_public "$is_public"
|
||||||
|
if [ "$is_public" = "Yes" ];
|
||||||
then
|
then
|
||||||
ynh_app_setting_delete $app skipped_uris
|
ynh_app_setting_set $app unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo systemctl reload nginx
|
sudo systemctl reload nginx
|
||||||
|
|
|
@ -3,6 +3,12 @@
|
||||||
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
||||||
set -eu
|
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 app helpers
|
||||||
source /usr/share/yunohost/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)
|
is_public=$(ynh_app_setting_get $app is_public)
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
sudo yunohost app checkurl "${domain}${path}" -a "$app"
|
||||||
|| ynh_die "Path not available: ${domain}${path}"
|
|
||||||
|
|
||||||
# Check $final_path
|
# Check $final_path
|
||||||
final_path="/var/www/${app}"
|
final_path="/var/www/${app}"
|
||||||
|
@ -52,24 +57,29 @@ if [ -f $phpfpm_ini ]; then
|
||||||
ynh_die "The PHP FPM INI configuration already exists at '${phpfpm_ini}'.
|
ynh_die "The PHP FPM INI configuration already exists at '${phpfpm_ini}'.
|
||||||
You should safely delete it before restoring this app."
|
You should safely delete it before restoring this app."
|
||||||
fi
|
fi
|
||||||
|
# Create dedicated system user for this app
|
||||||
|
ynh_system_user_create $app
|
||||||
|
|
||||||
# Restore sources & data
|
# Restore sources & data
|
||||||
sudo cp -a "./sources" $final_path
|
sudo cp -a "./sources" $final_path
|
||||||
|
|
||||||
# Set permissions
|
# Set permissions
|
||||||
sudo chown -R root:root $final_path
|
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}
|
sudo chmod -R 700 $final_path/{data,tmp}
|
||||||
|
|
||||||
# Restore configuration files
|
# Restore configuration files
|
||||||
sudo cp -a ./conf/nginx.conf "${nginx_conf}"
|
sudo cp -a ./conf/nginx.conf "${nginx_conf}"
|
||||||
|
sudo cp -a ./php-fpm.conf "$phpfpm_conf"
|
||||||
|
sudo cp -a ./php-fpm.ini "$phpfpm_ini"
|
||||||
|
|
||||||
# Set ssowat config
|
# Set ssowat config
|
||||||
if [ "$is_public" = "No" ];
|
if [ "$is_public" = "Yes" ];
|
||||||
then
|
then
|
||||||
ynh_app_setting_delete $app skipped_uris
|
ynh_app_setting_set $app unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Reload service
|
# Reload service
|
||||||
sudo systemctl reload nginx
|
sudo systemctl reload nginx
|
||||||
|
sudo systemctl reload php5-fpm
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
|
@ -59,6 +59,7 @@ sudo chmod 700 $final_path/{data,tmp}
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||||
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
||||||
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
||||||
|
sed -i "s@YNH_NAME@$app@g" ../conf/nginx.conf
|
||||||
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
|
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
sudo cp ../conf/nginx.conf $nginxconf
|
sudo cp ../conf/nginx.conf $nginxconf
|
||||||
sudo chown root: $nginxconf
|
sudo chown root: $nginxconf
|
||||||
|
|
Loading…
Reference in a new issue