From b9164a623cc33f764fdc2a9a441a8fe993bc9194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 23 Nov 2021 22:19:40 +0100 Subject: [PATCH] remove arch helper (#68) * remove arch helper --- conf/arm6.src | 6 ------ conf/{arm7.src => armhf.src} | 0 conf/{386.src => i386.src} | 0 conf/nginx.conf | 5 ----- manifest.json | 2 +- scripts/_common.sh | 26 -------------------------- scripts/backup | 6 ++++++ scripts/install | 11 ++++++++++- scripts/remove | 8 ++++++++ scripts/restore | 7 +++++++ scripts/upgrade | 12 +++++++++++- 11 files changed, 43 insertions(+), 40 deletions(-) delete mode 100644 conf/arm6.src rename conf/{arm7.src => armhf.src} (100%) rename conf/{386.src => i386.src} (100%) diff --git a/conf/arm6.src b/conf/arm6.src deleted file mode 100644 index e9f2f0c..0000000 --- a/conf/arm6.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/YunoHost-Apps/galene_ynh/releases/download/v0.4.1/galene_0.4.1_Linux_arm6.tar.gz -SOURCE_SUM=4a017aa340f81494a14414485ffccc53b461b58c2e70bc178f6037c65ddf534c -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_EXTRACT=true diff --git a/conf/arm7.src b/conf/armhf.src similarity index 100% rename from conf/arm7.src rename to conf/armhf.src diff --git a/conf/386.src b/conf/i386.src similarity index 100% rename from conf/386.src rename to conf/i386.src diff --git a/conf/nginx.conf b/conf/nginx.conf index 6a3b9a8..a1d2e03 100755 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,10 +1,5 @@ location / { - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - proxy_pass https://127.0.0.1:__PORT__; proxy_redirect off; proxy_set_header Host $host; diff --git a/manifest.json b/manifest.json index c559c07..9e409b2 100644 --- a/manifest.json +++ b/manifest.json @@ -22,7 +22,7 @@ "email": "" }, "requirements": { - "yunohost": ">= 4.2.8" + "yunohost": ">= 4.3.0" }, "multi_instance": false, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index 28b4f50..944a65e 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -15,29 +15,3 @@ #================================================= # FUTURE OFFICIAL HELPERS #================================================= - -# Check the architecture -# -# example: architecture=$(ynh_detect_arch) -# -# usage: ynh_detect_arch -# -# Requires YunoHost version 2.2.4 or higher. - -ynh_detect_arch(){ - local architecture - if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep aarch64)" ]; then - architecture="arm64" - elif [ -n "$(uname -m | grep 64)" ]; then - architecture="amd64" - elif [ -n "$(uname -m | grep 86)" ]; then - architecture="386" - elif [ -n "$(uname -m | grep armv7)" ]; then - architecture="arm7" - elif [ -n "$(uname -m | grep armv6)" ]; then - architecture="arm6" - else - architecture="unknown" - fi - echo $architecture -} diff --git a/scripts/backup b/scripts/backup index 5d6324e..5f1b0d0 100755 --- a/scripts/backup +++ b/scripts/backup @@ -50,6 +50,12 @@ ynh_backup --src_path="$datadir" --is_big ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# BACKUP LOGROTATE +#================================================= + +ynh_backup --src_path="/etc/logrotate.d/$app" + #================================================= # BACKUP SYSTEMD #================================================= diff --git a/scripts/install b/scripts/install index 2fa779b..32a4599 100755 --- a/scripts/install +++ b/scripts/install @@ -27,7 +27,7 @@ is_public=$YNH_APP_ARG_IS_PUBLIC password=$YNH_APP_ARG_PASSWORD group_name=$YNH_APP_ARG_GROUP_NAME group_description=$YNH_APP_ARG_GROUP_DESCRIPTION -architecture=$(ynh_detect_arch) +architecture=$YNH_ARCH app=$YNH_APP_INSTANCE_NAME @@ -53,6 +53,7 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=password --value=$password ynh_app_setting_set --app=$app --key=group_name --value="$group_name" ynh_app_setting_set --app=$app --key=group_description --value="$group_description" +ynh_app_setting_set --app=$app --key=architecture --value=$architecture #================================================= # STANDARD MODIFICATIONS @@ -149,6 +150,14 @@ ynh_add_systemd_config # Create a group name config ynh_add_config --template="../conf/groupname.json" --destination="$datadir/groups/$group_name.json" +#================================================= +# 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 #================================================= diff --git a/scripts/remove b/scripts/remove index 275a629..89cf791 100755 --- a/scripts/remove +++ b/scripts/remove @@ -43,6 +43,14 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 + +# Remove the app-specific logrotate config +ynh_remove_logrotate + #================================================= # REMOVE APP MAIN DIR #================================================= diff --git a/scripts/restore b/scripts/restore index 9942247..fc6008f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -87,6 +87,13 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f3ea0c9..64675e8 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,7 +24,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) group_name=$(ynh_app_setting_get --app=$app --key=group_name) port=$(ynh_app_setting_get --app=$app --key=port) turn_port=$(ynh_app_setting_get --app=$app --key=turn_port) -architecture=$(ynh_detect_arch) +architecture=$YNH_ARCH if ynh_compare_current_package_version --comparison le --version 0.3.5~ynh3 then @@ -100,6 +100,8 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=2 + # Remove the app directory securely + ynh_secure_remove --file=$final_path ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" #--keep="$final_path/data/config.json" fi @@ -143,6 +145,14 @@ public_ip4="$(curl -s ip.yunohost.org)" || true # Create a dedicated systemd config ynh_add_systemd_config +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + #================================================= # INTEGRATE SERVICE IN YUNOHOST #=================================================