From 537391524bce7958c63f09f1065ee7c77a997c98 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 2 Jul 2022 19:06:02 +0200 Subject: [PATCH] Apply last example_ynh --- check_process | 12 ++++--- conf/nginx.conf | 6 +--- conf/systemd.service | 2 +- manifest.json | 25 +++++++------ scripts/_common.sh | 19 ---------- scripts/backup | 6 ---- scripts/change_url | 3 +- scripts/install | 28 ++++----------- scripts/remove | 31 ++++++++-------- scripts/restore | 21 +++++------ scripts/upgrade | 58 ++++++------------------------ sources/extra_files/app/.gitignore | 2 -- sources/patches/.gitignore | 2 -- 13 files changed, 63 insertions(+), 152 deletions(-) delete mode 100644 sources/extra_files/app/.gitignore delete mode 100644 sources/patches/.gitignore diff --git a/check_process b/check_process index bfdd5c8..2736616 100644 --- a/check_process +++ b/check_process @@ -1,13 +1,9 @@ ;; Test complet ; Manifest domain="domain.tld" - path="/path" - admin="john" - language="fr" is_public=1 - password="1Strong-Password" ssb_admin_id="@5Pt3dKy2HTJ0mWuS78oIiklIX0gBz6BTfEnXsbvke9c=.ed25519" - port="666" + password="1Strong-Password" ; Checks pkg_linter=1 setup_sub_dir=0 @@ -16,6 +12,12 @@ setup_private=1 setup_public=1 upgrade=1 + # 2.0.6~ynh3 + upgrade=1 from_commit=c759c5f400660031676a0f92d5c5ffcc68bd6da9 backup_restore=1 multi_instance=1 + port_already_use=0 change_url=1 +;;; Options +Email= +Notification=none diff --git a/conf/nginx.conf b/conf/nginx.conf index da0252d..a0b8a31 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,10 +1,6 @@ +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - proxy_set_header Accept-Encoding ""; try_files $uri @proxy; diff --git a/conf/systemd.service b/conf/systemd.service index 2456797..8973d36 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,7 +6,7 @@ After=network.target Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__DATADIR__ +WorkingDirectory=__FINALPATH__/ ExecStart=__FINALPATH__/server -repo __DATADIR__/ -lishttp localhost:__PORT__ -https-domain __DOMAIN__ -lismux :__SSBPORT__ -aliases-as-subdomains false StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit diff --git a/manifest.json b/manifest.json index 4399451..26185ee 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "Secure Scuttlebutt room server implemented in Go" }, - "version": "2.0.6~ynh3", + "version": "2.0.6~ynh4", "url": "https://github.com/ssb-ngi-pointer/go-ssb-room", "upstream": { "license": "free", @@ -21,18 +21,25 @@ "email": "max@mfowler.info" }, "requirements": { - "yunohost": ">= 4.1.7" + "yunohost": ">= 4.3.0" }, "multi_instance": true, "services": [ "nginx" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", - "type": "domain", - "example": "example.com" + "type": "domain" + }, + { + "name": "is_public", + "type": "boolean", + "default": true, + "help": { + "en": "If false, ssbroom will only be usable by yunohost users." + } }, { "name": "ssb_admin_id", @@ -45,14 +52,6 @@ }, "example": "@5Pt3dKy2HTJ0mWuS78oIiklIX0gBz6BTfEnXsbvke9c=.ed25519" }, - { - "name": "is_public", - "type": "boolean", - "default": true, - "help": { - "en": "If false, ssbroom will only be usable by yunohost users." - } - }, { "name": "password", "type": "password", diff --git a/scripts/_common.sh b/scripts/_common.sh index 24254a6..e3a9683 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -20,22 +20,3 @@ description="Secure Scuttlebutt room server implemented in Go" #================================================= # FUTURE OFFICIAL HELPERS #================================================= - - -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 -} \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index 01326c1..67278fd 100755 --- a/scripts/backup +++ b/scripts/backup @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script @@ -37,11 +36,6 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= ynh_print_info --message="Declaring files to be backed up..." -### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs -### to be backuped and not an actual copy of any file. The actual backup that -### creates and fill the archive with the files happens in the core after this -### script is called. Hence ynh_backups calls takes basically 0 seconds to run. - #================================================= # BACKUP THE APP MAIN DIR #================================================= diff --git a/scripts/change_url b/scripts/change_url index ac0de97..f6b8b78 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -37,6 +37,7 @@ ynh_script_progression --message="Backing up the app before changing its URL (ma # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" @@ -110,7 +111,7 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="event=serving" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index 6814af3..74411c8 100755 --- a/scripts/install +++ b/scripts/install @@ -14,8 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -29,7 +28,7 @@ path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC ssb_admin_id=$YNH_APP_ARG_SSB_ADMIN_ID password=$YNH_APP_ARG_PASSWORD -architecture=$(ynh_detect_arch) + app=$YNH_APP_INSTANCE_NAME #================================================= @@ -93,9 +92,8 @@ ynh_script_progression --message="Setting up source files..." --weight=1 ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" +ynh_setup_source --dest_dir="$final_path" --source_id="$YNH_ARCH" -# permissions chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" @@ -105,7 +103,7 @@ chown -R $app:www-data "$final_path" #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=1 -# add nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -118,7 +116,6 @@ ynh_app_setting_set --app=$app --key=datadir --value=$datadir mkdir -p $datadir -# permissions chmod 750 "$datadir" chmod -R o-rwx "$datadir" chown -R $app:www-data "$datadir" @@ -127,6 +124,7 @@ chown -R $app:www-data "$datadir" # CREATE FIRST ADMIN USER #================================================= ynh_script_progression --message="Creating first ssbroom admin user" --weight=1 + ynh_exec_as $app /usr/bin/expect<