Misc cleaning

This commit is contained in:
Alexandre Aubin 2019-05-15 18:42:44 +02:00
parent 650d69514d
commit 5a76baaf61
5 changed files with 22 additions and 88 deletions

View file

@ -6,12 +6,6 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# if [ ! -e _common.sh ]; then
# Get the _common.sh file if it's not in the current directory
# cp ../settings/scripts/_common.sh ./_common.sh
# chmod a+rx _common.sh
# fi
# source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -25,21 +19,9 @@ ynh_abort_if_errors
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
# This is a multi-instance app, meaning it can be installed several times independently
# The id of the app as stated in the manifest is available as $YNH_APP_ID
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
# The app instance name is available as $YNH_APP_INSTANCE_NAME
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
# The app instance name is probably what you are interested the most, since this is
# guaranteed to be unique. This is a good unique identifier to define installation path,
# db names, ...
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments # Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
# Copy the conf files # Copy the conf files
mkdir -p ./conf ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf"
cp -a "/etc/nginx/conf.d/${domain}.d/${app}.conf" ./conf/nginx.conf

View file

@ -6,7 +6,6 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -20,19 +19,8 @@ ynh_abort_if_errors
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
# This is a multi-instance app, meaning it can be installed several times independently
# The id of the app as stated in the manifest is available as $YNH_APP_ID
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
# The app instance name is available as $YNH_APP_INSTANCE_NAME
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
# The app instance name is probably what you are interested the most, since this is
# guaranteed to be unique. This is a good unique identifier to define installation path,
# db names, ...
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments # Retrieve arguments
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
redirect_type=$YNH_APP_ARG_REDIRECT_TYPE redirect_type=$YNH_APP_ARG_REDIRECT_TYPE
@ -49,6 +37,10 @@ url_regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=
ynh_app_setting_set $app redirect_type "$redirect_type" ynh_app_setting_set $app redirect_type "$redirect_type"
ynh_app_setting_set $app redirect_path "$redirect_path" ynh_app_setting_set $app redirect_path "$redirect_path"
#=================================================
# CONFIGURE NGINX
#=================================================
# Nginx configuration # Nginx configuration
for FILE in $(ls ../conf/nginx-*.conf) for FILE in $(ls ../conf/nginx-*.conf)
do do
@ -69,7 +61,7 @@ then
fi fi
#================================================= #=================================================
# SETUP SSOWAT # CONFIGURE SSOWAT
#================================================= #=================================================
# Make app public if necessary # Make app public if necessary
@ -80,4 +72,4 @@ then
fi fi
# Reload Nginx and regenerate SSOwat conf # Reload Nginx and regenerate SSOwat conf
service nginx reload systemctl reload nginx

View file

@ -6,30 +6,18 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
# This is a multi-instance app, meaning it can be installed several times independently
# The id of the app as stated in the manifest is available as $YNH_APP_ID
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
# The app instance name is available as $YNH_APP_INSTANCE_NAME
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
# The app instance name is probably what you are interested the most, since this is
# guaranteed to be unique. This is a good unique identifier to define installation path,
# db names, ...
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments # Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
# Remove configuration files # Remove configuration files
ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf
# Restart services # Restart services
service nginx reload systemctl reload nginx

View file

@ -6,12 +6,6 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# if [ ! -e _common.sh ]; then
# Get the _common.sh file if it's not in the current directory
# cp ../settings/scripts/_common.sh ./_common.sh
# chmod a+rx _common.sh
# fi
# source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -25,19 +19,8 @@ ynh_abort_if_errors
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
# This is a multi-instance app, meaning it can be installed several times independently
# The id of the app as stated in the manifest is available as $YNH_APP_ID
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
# The app instance name is available as $YNH_APP_INSTANCE_NAME
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
# The app instance name is probably what you are interested the most, since this is
# guaranteed to be unique. This is a good unique identifier to define installation path,
# db names, ...
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments # Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get "$app" domain)
path_url=$(ynh_app_setting_get "$app" path) path_url=$(ynh_app_setting_get "$app" path)
redirect_type=$(ynh_app_setting_get "$app" redirect_type) redirect_type=$(ynh_app_setting_get "$app" redirect_type)
@ -52,10 +35,10 @@ NGINX_CONF="/etc/nginx/conf.d/${domain}.d/${app}.conf"
[[ -f $NGINX_CONF ]] && ynh_die "The NGINX configuration already exists at '${NGINX_CONF}'. You should safely delete it before restoring this app." [[ -f $NGINX_CONF ]] && ynh_die "The NGINX configuration already exists at '${NGINX_CONF}'. You should safely delete it before restoring this app."
# Restore configuration files # Restore configuration files
cp -a ./conf/nginx.conf "$NGINX_CONF" ynh_restore_file "$NGINX_CONF"
#================================================= #=================================================
# SETUP SSOWAT # CONFIGURE SSOWAT
#================================================= #=================================================
# Make app public if necessary # Make app public if necessary
@ -66,4 +49,4 @@ then
fi fi
# Reload Nginx and regenerate SSOwat conf # Reload Nginx and regenerate SSOwat conf
service nginx reload systemctl reload nginx

View file

@ -7,29 +7,14 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
# This is a multi-instance app, meaning it can be installed several times independently
# The id of the app as stated in the manifest is available as $YNH_APP_ID
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
# The app instance name is available as $YNH_APP_INSTANCE_NAME
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
# The app instance name is probably what you are interested the most, since this is
# guaranteed to be unique. This is a good unique identifier to define installation path,
# db names, ...
app=$YNH_APP_INSTANCE_NAME
# Source app helpers
. /usr/share/yunohost/helpers
# Retrieve arguments # Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get "$app" domain)
path_url=$(ynh_app_setting_get "$app" path) path_url=$(ynh_app_setting_get "$app" path)
redirect_type=$(ynh_app_setting_get "$app" redirect_type) redirect_type=$(ynh_app_setting_get "$app" redirect_type)
@ -98,6 +83,10 @@ ynh_abort_if_errors
url_regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]' url_regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'
[[ ! $redirect_path =~ $url_regex ]] && ynh_die "Invalid destination: $redirect_path" 1 [[ ! $redirect_path =~ $url_regex ]] && ynh_die "Invalid destination: $redirect_path" 1
#=================================================
# CONFIGURE NGINX
#=================================================
# Nginx configuration # Nginx configuration
for FILE in $(ls ../conf/nginx-*.conf) for FILE in $(ls ../conf/nginx-*.conf)
do do
@ -118,7 +107,7 @@ then
fi fi
#================================================= #=================================================
# SETUP SSOWAT # CONFIGURE SSOWAT
#================================================= #=================================================
# Make app public if necessary # Make app public if necessary
@ -129,4 +118,4 @@ then
fi fi
# Reload Nginx and regenerate SSOwat conf # Reload Nginx and regenerate SSOwat conf
service nginx reload systemctl reload nginx