From 8ec548cbfb8f713752dafab28c7c4fc8e3615c9e Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 19 Feb 2021 16:04:53 +0100 Subject: [PATCH] Fix --- scripts/backup | 8 -------- scripts/install | 46 ++++++++++++++++++---------------------------- scripts/remove | 26 -------------------------- scripts/restore | 16 ---------------- scripts/upgrade | 23 +++++++---------------- 5 files changed, 25 insertions(+), 94 deletions(-) diff --git a/scripts/backup b/scripts/backup index 94a5224..11f1bbb 100755 --- a/scripts/backup +++ b/scripts/backup @@ -46,14 +46,6 @@ ynh_backup --src_path="$final_path" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= - -#ynh_backup --src_path="/etc/logrotate.d/$app" - #================================================= # BACKUP SYSTEMD #================================================= diff --git a/scripts/install b/scripts/install index ebd3bea..72887e7 100755 --- a/scripts/install +++ b/scripts/install @@ -66,16 +66,6 @@ ynh_script_progression --message="Finding an available port..." --weight=3 port=$(ynh_find_port --port=8443) ynh_app_setting_set --app=$app --key=port --value=$port -# Open the port -# ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -#ynh_script_progression --message="Installing dependencies..." --time --weight=1 - -#ynh_install_app_dependencies $pkg_dependencies - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -121,20 +111,28 @@ public_ip4="$(curl ip.yunohost.org)" || true # Create a dedicated systemd config ynh_add_systemd_config --others_var="public_ip4" +#================================================= +# CREAT GROUPS FILE +#================================================= + +# Define app's groups directory +groups="$final_path/groups" +# Create groups folders +mkdir -p "$groups" + #================================================= # MODIFY A CONFIG FILE #================================================= -#ynh_add_config --template="../conf/passwd" --destination="$final_path/data/passwd" -#ynh_add_config --template="../conf/groupname.json" --destination="$final_path/groups/$group_name.json" +#cp ../conf/passwd $final_path/data/passwd +#ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/data/passwd" +#ynh_replace_string --match_string="__PASSWORD__" --replace_string="$password" --target_file="$final_path/data/passwd" +ynh_add_config --template="../conf/passwd" --destination="$final_path/data/passwd" -cp ../conf/passwd $final_path/data/passwd -ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/data/passwd" -ynh_replace_string --match_string="__PASSWORD__" --replace_string="$password" --target_file="$final_path/data/passwd" - -mv ../conf/groupname.json $final_path/groups/$group_name.json -ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/groups/$group_name.json" -ynh_replace_string --match_string="__PASSWORD__" --replace_string="$password" --target_file="$final_path/groups/$group_name.json" +#mv ../conf/groupname.json $final_path/groups/$group_name.json +#ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/groups/$group_name.json" +#ynh_replace_string --match_string="__PASSWORD__" --replace_string="$password" --target_file="$final_path/groups/$group_name.json" +ynh_add_config --template="../conf/groupname.json" --destination="$final_path/groups/$group_name.json" #================================================= # STORE THE CONFIG FILE CHECKSUM @@ -154,14 +152,6 @@ ynh_store_file_checksum --file="$final_path/groups/$group_name.json" chown -R $app: $final_path chmod -R 755 $final_path -#================================================= -# SETUP LOGROTATE -#================================================= -#ynh_script_progression --message="Configuring log rotation..." --weight=1 - -# Use logrotate to manage application logfile(s) -#ynh_use_logrotate - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -185,7 +175,7 @@ ynh_script_progression --message="Configuring permissions..." --weight=2 # Make app public if necessary if [ $is_public -eq 1 ] then - ynh_permission_update --permission "main" --add "visitors" + ynh_permission_update --permission="main" --add="visitors" fi #================================================= diff --git a/scripts/remove b/scripts/remove index a1ec6fb..5855ced 100755 --- a/scripts/remove +++ b/scripts/remove @@ -41,14 +41,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -#ynh_script_progression --message="Removing dependencies..." --time --weight=1 - -# Remove metapackage and its dependencies -#ynh_remove_app_dependencies - #================================================= # REMOVE APP MAIN DIR #================================================= @@ -65,24 +57,6 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -#ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1 - -# Remove the app-specific logrotate config -#ynh_remove_logrotate - -#================================================= -# CLOSE A PORT -#================================================= - -# if yunohost firewall list | grep -q "\- $port$" -# then -# ynh_script_progression --message="Closing port $port..." --time --weight=1 -# ynh_exec_warn_less yunohost firewall disallow TCP $port -# fi - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 89259e7..a67414f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -73,16 +73,6 @@ ynh_system_user_create --username=$app chown -R $app: $final_path chmod -R 755 $final_path -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -#ynh_script_progression --message="Reinstalling dependencies..." --weight=1 - -# Define and install dependencies -#ynh_install_app_dependencies $pkg_dependencies - #================================================= # RESTORE SYSTEMD #================================================= @@ -105,12 +95,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=3 ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log" -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= - -#ynh_restore_file --origin_path="/etc/logrotate.d/$app" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 1b674db..d338247 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -42,6 +42,12 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +# If groups folder doesn't exist, create it +if [ -z "$final_path/groups" ]; then + # Create groups folders + mkdir -p "$final_path/groups" +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -63,7 +69,7 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=3 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -106,13 +112,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -#ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -#ynh_install_app_dependencies $pkg_dependencies - #================================================= # CREATE DEDICATED USER #================================================= @@ -139,14 +138,6 @@ ynh_add_systemd_config chown -R $app: $final_path chmod -R 755 $final_path -#================================================= -# SETUP LOGROTATE -#================================================= -# ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 - -# # Use logrotate to manage app-specific logfile(s) -# ynh_use_logrotate --non-append - #================================================= # INTEGRATE SERVICE IN YUNOHOST #=================================================