From 5a76baaf613d0df3649ce90b800c0c6244c27cfa Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 15 May 2019 18:42:44 +0200 Subject: [PATCH] Misc cleaning --- scripts/backup | 22 ++-------------------- scripts/install | 22 +++++++--------------- scripts/remove | 16 ++-------------- scripts/restore | 25 ++++--------------------- scripts/upgrade | 25 +++++++------------------ 5 files changed, 22 insertions(+), 88 deletions(-) diff --git a/scripts/backup b/scripts/backup index 73bca48..8aa1ce6 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,12 +6,6 @@ # 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 #================================================= @@ -25,21 +19,9 @@ ynh_abort_if_errors # 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 +app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) # Copy the conf files -mkdir -p ./conf -cp -a "/etc/nginx/conf.d/${domain}.d/${app}.conf" ./conf/nginx.conf +ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" diff --git a/scripts/install b/scripts/install index c108ea5..8d3f55e 100644 --- a/scripts/install +++ b/scripts/install @@ -6,7 +6,6 @@ # IMPORT GENERIC HELPERS #================================================= -# source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -20,19 +19,8 @@ ynh_abort_if_errors # 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 +app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH 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_path "$redirect_path" +#================================================= +# CONFIGURE NGINX +#================================================= + # Nginx configuration for FILE in $(ls ../conf/nginx-*.conf) do @@ -69,7 +61,7 @@ then fi #================================================= -# SETUP SSOWAT +# CONFIGURE SSOWAT #================================================= # Make app public if necessary @@ -80,4 +72,4 @@ then fi # Reload Nginx and regenerate SSOwat conf -service nginx reload +systemctl reload nginx diff --git a/scripts/remove b/scripts/remove index 0f596fd..82109e4 100644 --- a/scripts/remove +++ b/scripts/remove @@ -6,30 +6,18 @@ # IMPORT GENERIC HELPERS #================================================= -# source _common.sh source /usr/share/yunohost/helpers #================================================= # 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 +app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) # Remove configuration files ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf # Restart services -service nginx reload +systemctl reload nginx diff --git a/scripts/restore b/scripts/restore index a5fbbe3..0ec55b3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,12 +6,6 @@ # 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 #================================================= @@ -25,19 +19,8 @@ ynh_abort_if_errors # 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 +app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get "$app" domain) path_url=$(ynh_app_setting_get "$app" path) 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." # Restore configuration files -cp -a ./conf/nginx.conf "$NGINX_CONF" +ynh_restore_file "$NGINX_CONF" #================================================= -# SETUP SSOWAT +# CONFIGURE SSOWAT #================================================= # Make app public if necessary @@ -66,4 +49,4 @@ then fi # Reload Nginx and regenerate SSOwat conf -service nginx reload +systemctl reload nginx diff --git a/scripts/upgrade b/scripts/upgrade index d8753ab..280fc98 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,29 +7,14 @@ # IMPORT GENERIC HELPERS #================================================= -# source _common.sh source /usr/share/yunohost/helpers #================================================= # 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 +app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get "$app" domain) path_url=$(ynh_app_setting_get "$app" path) 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\+&@#/%=~_|]' [[ ! $redirect_path =~ $url_regex ]] && ynh_die "Invalid destination: $redirect_path" 1 +#================================================= +# CONFIGURE NGINX +#================================================= + # Nginx configuration for FILE in $(ls ../conf/nginx-*.conf) do @@ -118,7 +107,7 @@ then fi #================================================= -# SETUP SSOWAT +# CONFIGURE SSOWAT #================================================= # Make app public if necessary @@ -129,4 +118,4 @@ then fi # Reload Nginx and regenerate SSOwat conf -service nginx reload +systemctl reload nginx