From ebddc0839ac647f55bb60e9d4066ce7cd7c352c3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 23 Jun 2022 04:25:14 +0200 Subject: [PATCH 1/5] Apply example_ynh --- check_process | 9 ------ conf/nginx.conf | 2 +- manifest.json | 2 +- scripts/backup | 17 +---------- scripts/change_url | 3 +- scripts/install | 6 ++-- scripts/remove | 8 ++--- scripts/restore | 48 +++++++++++------------------- scripts/upgrade | 23 +++++++------- sources/extra_files/app/.gitignore | 2 -- sources/patches/.gitignore | 2 -- 11 files changed, 37 insertions(+), 85 deletions(-) delete mode 100644 sources/extra_files/app/.gitignore delete mode 100644 sources/patches/.gitignore diff --git a/check_process b/check_process index fc45223..f04085b 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,3 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. - ;; Test complet ; Manifest domain="domain.tld" @@ -25,7 +20,3 @@ ;;; Options Email= Notification=none -;;; Upgrade options - ; commit=CommitHash - name=Name and date of the commit. - manifest_arg=domain=DOMAIN&path=PATH&is_public=1&language=fr&admin=USER&password=pass&port=666& diff --git a/conf/nginx.conf b/conf/nginx.conf index db7eaef..a0a5ba3 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -11,4 +11,4 @@ location __PATH__/ { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; -} \ No newline at end of file +} diff --git a/manifest.json b/manifest.json index a38eb29..c270519 100644 --- a/manifest.json +++ b/manifest.json @@ -28,7 +28,7 @@ "nginx" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", "type": "domain" diff --git a/scripts/backup b/scripts/backup index 444217b..2ea94c3 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 @@ -28,9 +27,9 @@ ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME +final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) @@ -44,11 +43,6 @@ password=$(ynh_app_setting_get --app=$app --key=password) #================================================= 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 #================================================= @@ -76,12 +70,6 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/logrotate.d/$app" -#================================================= -# BACKUP LOGS -#================================================= - -ynh_backup --src_path="/var/log/$app/$app.log" - #================================================= # BACKUP SYSTEMD #================================================= @@ -93,9 +81,6 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= ynh_print_info --message="Backing up the MySQL database..." -### (However, things like MySQL dumps *do* take some time to run, though the -### copy of the generated dump to the archive still happens later) - ynh_mysql_dump_db --database="$db_name" > db.sql #================================================= diff --git a/scripts/change_url b/scripts/change_url index 2ecbf05..c7def58 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -46,6 +46,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" @@ -112,8 +113,8 @@ fi #================================================= # SPECIFIC MODIFICATIONS #================================================= - ynh_script_progression --message="Updating the configuration file..." --weight=1 + domain=$new_domain path_url=$new_path diff --git a/scripts/install b/scripts/install index 72d1298..5be16f5 100755 --- a/scripts/install +++ b/scripts/install @@ -16,8 +16,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 @@ -43,7 +42,6 @@ fi #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= - ynh_script_progression --message="Validating installation parameters..." --time --weight=1 final_path=/var/www/$app @@ -188,13 +186,13 @@ chmod 750 "$datadir" chmod -R o-rwx "$datadir" chown -R $app:www-data "$datadir" - #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --time --weight=1 ynh_add_config --template="options.yml" --destination="$final_path/build/config/options.yml" + chmod 400 "$final_path/build/config/options.yml" chown $app:$app "$final_path/build/config/options.yml" diff --git a/scripts/remove b/scripts/remove index 9a55410..a9be8ec 100755 --- a/scripts/remove +++ b/scripts/remove @@ -18,15 +18,11 @@ ynh_script_progression --message="Loading installation settings..." --time --wei app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) +port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -language_key=$(ynh_app_setting_get --app=$app --key=language) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) datadir=$(ynh_app_setting_get --app=$app --key=datadir) -port=$(ynh_app_setting_get --app=$app --key=port) -password=$(ynh_app_setting_get --app=$app --key=password) #================================================= # STANDARD REMOVE diff --git a/scripts/restore b/scripts/restore index 9c420a5..b0f2d9f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -16,8 +16,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 @@ -50,13 +49,6 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --time --weight=1 - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -72,12 +64,6 @@ ynh_script_progression --message="Restoring the app main directory..." --time -- ynh_restore_file --origin_path="$final_path" -# FIXME: this should be managed by the core in the future -# Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access -# files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - -# this will be treated as a security issue. chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" @@ -106,6 +92,22 @@ ynh_script_progression --message="Reinstalling dependencies..." --time --weight= # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." --time --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE MYSQL DATABASE +#================================================= +ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1 + +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql + #================================================= # ADD SWAP IF NEEDED #================================================= @@ -122,15 +124,6 @@ fi ynh_script_progression --message="Adding $swap_needed Mo to swap..." ynh_add_swap --size=$swap_needed -#================================================= -# RESTORE THE MYSQL DATABASE -#================================================= -ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1 - -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql - #================================================= # RESTORE SYSTEMD #================================================= @@ -146,13 +139,6 @@ ynh_script_progression --message="Restoring the logrotate configuration..." --ti ynh_restore_file --origin_path="/etc/logrotate.d/$app" -#================================================= -# RESTORE THE LOGS -#================================================= -ynh_script_progression --message="Restoring the logs..." --weight=1 - -ynh_restore_file --origin_path="/var/log/$app/$app.log" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 7f2e5f9..531c2a1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -32,6 +32,7 @@ password=$(ynh_app_setting_get --app=$app --key=password) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -43,6 +44,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # Restore it if the upgrade fails ynh_restore_upgradebackup } @@ -85,16 +87,17 @@ then popd fi -# FIXME: this should be managed by the core in the future -# Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access -# files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - -# this will be treated as a security issue. chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # NGINX CONFIGURATION #================================================= @@ -104,12 +107,7 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - ynh_add_nginx_config #================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - +# SPECIFIC UPGRADE #================================================= # ADD SWAP IF NEEDED #================================================= @@ -168,6 +166,7 @@ chown -R $app:www-data "$datadir" ynh_script_progression --message="Updating a configuration file..." --time --weight=1 ynh_add_config --template="options.yml" --destination="$final_path/build/config/options.yml" + chmod 400 "$final_path/build/config/options.yml" chown $app:$app "$final_path/build/config/options.yml" diff --git a/sources/extra_files/app/.gitignore b/sources/extra_files/app/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/extra_files/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/patches/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] From 4fd77c449ce2d6c62147e339ba5c0913610d6c97 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 23 Jun 2022 14:38:23 +0200 Subject: [PATCH 2/5] First docker --- conf/docker-image-extract.src | 7 ++++ conf/systemd.service | 2 +- scripts/_common.sh | 5 ++- scripts/install | 69 +++++++++++++++-------------------- 4 files changed, 40 insertions(+), 43 deletions(-) create mode 100644 conf/docker-image-extract.src diff --git a/conf/docker-image-extract.src b/conf/docker-image-extract.src new file mode 100644 index 0000000..64fe1a1 --- /dev/null +++ b/conf/docker-image-extract.src @@ -0,0 +1,7 @@ +SOURCE_URL=https://codeload.github.com/jjlin/docker-image-extract/tar.gz/a9e455e44bbbfba897bf3342d9661b182cee67a9 +SOURCE_SUM=9eb0c734e83a3fd7102fc7209af4977024ec467fbc819782491af47295675f67 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.gz +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= +SOURCE_EXTRACT=true diff --git a/conf/systemd.service b/conf/systemd.service index 33cf560..d2e014b 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/build/bin/photoprism --config-path __FINALPATH__/build/config/ --trace start +ExecStart=__FINALPATH__/live/bin/photoprism --config-path __FINALPATH__/live/config/ --trace start StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit diff --git a/scripts/_common.sh b/scripts/_common.sh index 8d7a790..8adb48f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,13 +5,14 @@ #================================================= # Tag name of the installed version -PHOTOPRISM_VERSION="220617-0402b8d3" +PHOTOPRISM_VERSION="220617-bullseye" MEMORY_NEEDED="3000" NODEJS_VERSION=14 GO_VERSION="1.18" -pkg_dependencies="libc6-dev libssl-dev libxft-dev libhdf5-serial-dev libpng-dev libheif-examples librsvg2-bin libx264-dev libx265-dev libnss3 libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev libzmq3-dev" +#pkg_dependencies="libc6-dev libssl-dev libxft-dev libhdf5-serial-dev libpng-dev libheif-examples librsvg2-bin libx264-dev libx265-dev libnss3 libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev libzmq3-dev" +pkg_dependencies="" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index 5be16f5..31ad3cd 100755 --- a/scripts/install +++ b/scripts/install @@ -79,10 +79,10 @@ ynh_script_progression --message="Installing dependencies..." --time --weight=1 ynh_install_app_dependencies $pkg_dependencies # Install nodejs -ynh_install_nodejs --nodejs_version=$NODEJS_VERSION 2>&1 +#ynh_install_nodejs --nodejs_version=$NODEJS_VERSION 2>&1 # Install go -ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION +#ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION #================================================= # ADD SWAP IF NEEDED @@ -125,17 +125,7 @@ ynh_script_progression --message="Setting up source files..." --time --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" - -# I need to use git clone instead of ynh_setup_source - -pushd "/var/www/" - git clone https://github.com/photoprism/photoprism -popd - -pushd "$final_path" - git checkout "$PHOTOPRISM_VERSION" 2>&1 -popd +ynh_setup_source --dest_dir="$final_path/build/" --source_id="docker-image-extract" chmod 750 "$final_path" chmod -R o-rwx "$final_path" @@ -149,28 +139,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --time --weig # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# BUILD PHOTOPRISM -#================================================= -ynh_script_progression --message="Building Photoprism..." --time --weight=1 - -pushd "$final_path" - # Setup go exe and environnement - ynh_use_go - export GOPATH="$final_path/go" - export GOCACHE="$final_path/go/.cache" - export GOBIN=$GOPATH/bin - # Setup tensorflow library - ./scripts/dist/install-tensorflow.sh - # Setup node environment - export NODE_OPTIONS=--max_old_space_size=1024 - # Build server from source - ynh_use_nodejs - env "$ynh_node_load_PATH" npm install -g npm - env "$ynh_node_load_PATH" make dep-tensorflow dep-js dep-go build-js install DESTDIR=$final_path/build 2>&1 - ynh_secure_remove --file="$final_path/go" -popd - #================================================= # CREATE DATA DIRECTORY #================================================= @@ -179,8 +147,29 @@ ynh_script_progression --message="Creating a data directory..." --time --weight= datadir=/home/yunohost.app/$app ynh_app_setting_set --app=$app --key=datadir --value=$datadir -mkdir -p "$datadir/assets/" -rsync -a "$final_path/build/assets/" "$datadir/assets/" +mkdir -p "$datadir" +#rsync -a "$final_path/build/assets/" "$datadir/assets/" + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + +#================================================= +# MAKE INSTALL +#================================================= +ynh_script_progression --message="Making install..." + +# Install photoprism +pushd $final_path/build + ./docker-image-extract photoprism/photoprism:$PHOTOPRISM_VERSION +popd +mv -f "$final_path/build/output/opt/photoprism/" "$final_path/live/" +mv -f "$final_path/live/assets/" "$datadir/assets/" +ynh_secure_remove --file="$final_path/build" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" chmod 750 "$datadir" chmod -R o-rwx "$datadir" @@ -191,10 +180,10 @@ chown -R $app:www-data "$datadir" #================================================= ynh_script_progression --message="Adding a configuration file..." --time --weight=1 -ynh_add_config --template="options.yml" --destination="$final_path/build/config/options.yml" +ynh_add_config --template="../conf/options.yml" --destination="$final_path/live/config/options.yml" -chmod 400 "$final_path/build/config/options.yml" -chown $app:$app "$final_path/build/config/options.yml" +chmod 400 "$final_path/live/config/options.yml" +chown $app:$app "$final_path/live/config/options.yml" #================================================= # SETUP SYSTEMD From 2a997cece08c31239da59257194e56cc45a9dd87 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 24 Jun 2022 02:37:54 +0200 Subject: [PATCH 3/5] more docker stuff --- conf/nginx.conf | 14 +-- scripts/_common.sh | 5 - scripts/backup | 6 - scripts/change_url | 17 +-- scripts/install | 61 +++------- scripts/remove | 4 - scripts/restore | 26 +---- scripts/upgrade | 81 ++++++-------- scripts/ynh_add_swap | 93 ---------------- scripts/ynh_install_go | 247 ----------------------------------------- 10 files changed, 70 insertions(+), 484 deletions(-) delete mode 100644 scripts/ynh_add_swap delete mode 100644 scripts/ynh_install_go diff --git a/conf/nginx.conf b/conf/nginx.conf index a0a5ba3..a5537e8 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,12 +1,12 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - proxy_pass http://127.0.0.1:__PORT__; - proxy_redirect off; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Host $server_name; + proxy_pass http://127.0.0.1:__PORT__; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $server_name; client_max_body_size 500M; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; diff --git a/scripts/_common.sh b/scripts/_common.sh index 8adb48f..5260975 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,13 +4,8 @@ # COMMON VARIABLES #================================================= -# Tag name of the installed version PHOTOPRISM_VERSION="220617-bullseye" -MEMORY_NEEDED="3000" -NODEJS_VERSION=14 -GO_VERSION="1.18" - #pkg_dependencies="libc6-dev libssl-dev libxft-dev libhdf5-serial-dev libpng-dev libheif-examples librsvg2-bin libx264-dev libx265-dev libnss3 libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev libzmq3-dev" pkg_dependencies="" diff --git a/scripts/backup b/scripts/backup index 2ea94c3..bcc70c1 100755 --- a/scripts/backup +++ b/scripts/backup @@ -29,14 +29,8 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -language_key=$(ynh_app_setting_get --app=$app --key=language) datadir=$(ynh_app_setting_get --app=$app --key=datadir) -port=$(ynh_app_setting_get --app=$app --key=port) -password=$(ynh_app_setting_get --app=$app --key=password) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP diff --git a/scripts/change_url b/scripts/change_url index c7def58..c09f018 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -33,7 +33,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -language_key=$(ynh_app_setting_get --app=$app --key=language) +language_key=$(ynh_app_setting_get --app=$app --key=language_key) datadir=$(ynh_app_setting_get --app=$app --key=datadir) port=$(ynh_app_setting_get --app=$app --key=port) password=$(ynh_app_setting_get --app=$app --key=password) @@ -113,17 +113,17 @@ fi #================================================= # SPECIFIC MODIFICATIONS #================================================= -ynh_script_progression --message="Updating the configuration file..." --weight=1 +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." --weight=1 domain=$new_domain path_url=$new_path -ynh_secure_remove --file="$final_path/build/config/options.yml" -ynh_add_config --template="options.yml" --destination="$final_path/build/config/options.yml" -chmod 400 "$final_path/build/config/options.yml" -chown $app:$app "$final_path/build/config/options.yml" +ynh_add_config --template="options.yml" --destination="$final_path/live/config/options.yml" -#================================================= +chmod 400 "$final_path/live/config/options.yml" +chown $app:$app "$final_path/live/config/options.yml" #================================================= # GENERIC FINALISATION @@ -132,7 +132,8 @@ chown $app:$app "$final_path/build/config/options.yml" #================================================= ynh_script_progression --message="Starting a systemd service..." --time --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +# Start a systemd service +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="http: starting web server at" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index 31ad3cd..4d7c8aa 100755 --- a/scripts/install +++ b/scripts/install @@ -7,8 +7,6 @@ #================================================= source _common.sh -source ynh_install_go -source ynh_add_swap source /usr/share/yunohost/helpers #================================================= @@ -57,7 +55,7 @@ ynh_script_progression --message="Storing installation settings..." --time --wei ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=language --value=$language_key +ynh_app_setting_set --app=$app --key=language_key --value=$language_key ynh_app_setting_set --app=$app --key=password --value=$password #================================================= @@ -68,7 +66,7 @@ ynh_app_setting_set --app=$app --key=password --value=$password ynh_script_progression --message="Finding an available port..." --time --weight=1 # Find an available port -port=$(ynh_find_port --port=2342) +port=$(ynh_find_port --port=8095) ynh_app_setting_set --app=$app --key=port --value=$port #================================================= @@ -78,28 +76,6 @@ ynh_script_progression --message="Installing dependencies..." --time --weight=1 ynh_install_app_dependencies $pkg_dependencies -# Install nodejs -#ynh_install_nodejs --nodejs_version=$NODEJS_VERSION 2>&1 - -# Install go -#ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION - -#================================================= -# ADD SWAP IF NEEDED -#================================================= -ynh_script_progression --message="Adding swap is needed..." - -total_memory=$(ynh_get_ram --total) -swap_needed=0 - -if [ $total_memory -lt $MEMORY_NEEDED ]; then - # Need a minimum of 2.5Go of memory - swap_needed=$(($MEMORY_NEEDED - $total_memory)) -fi - -ynh_script_progression --message="Adding $swap_needed Mo to swap..." -ynh_add_swap --size=$swap_needed - #================================================= # CREATE DEDICATED USER #================================================= @@ -140,20 +116,7 @@ ynh_script_progression --message="Configuring NGINX web server..." --time --weig ynh_add_nginx_config #================================================= -# CREATE DATA DIRECTORY -#================================================= -ynh_script_progression --message="Creating a data directory..." --time --weight=1 - -datadir=/home/yunohost.app/$app -ynh_app_setting_set --app=$app --key=datadir --value=$datadir - -mkdir -p "$datadir" -#rsync -a "$final_path/build/assets/" "$datadir/assets/" - -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" - +# SPECIFIC SETUP #================================================= # MAKE INSTALL #================================================= @@ -163,14 +126,26 @@ ynh_script_progression --message="Making install..." pushd $final_path/build ./docker-image-extract photoprism/photoprism:$PHOTOPRISM_VERSION popd -mv -f "$final_path/build/output/opt/photoprism/" "$final_path/live/" -mv -f "$final_path/live/assets/" "$datadir/assets/" +mkdir -p "$final_path/live/" +rsync -a "$final_path/build/output/opt/photoprism/" "$final_path/live/" ynh_secure_remove --file="$final_path/build" chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" +#================================================= +# CREATE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Creating a data directory..." --time --weight=1 + +datadir=/home/yunohost.app/$app +ynh_app_setting_set --app=$app --key=datadir --value=$datadir + +mkdir -p $datadir +rsync -a "$final_path/live/assets/" "$datadir/assets/" +ynh_secure_remove --file="$final_path/live/assets/" + chmod 750 "$datadir" chmod -R o-rwx "$datadir" chown -R $app:www-data "$datadir" @@ -216,7 +191,7 @@ yunohost service add $app --description="AI-Powered Photos App for the Decentral ynh_script_progression --message="Starting a systemd service..." --time --weight=1 # Start a systemd service -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="http: starting web server at" #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index a9be8ec..b4c79e2 100755 --- a/scripts/remove +++ b/scripts/remove @@ -7,7 +7,6 @@ #================================================= source _common.sh -source ynh_add_swap source /usr/share/yunohost/helpers #================================================= @@ -119,9 +118,6 @@ ynh_secure_remove --file="/etc/cron.d/$app" # Remove the log files ynh_secure_remove --file="/var/log/$app" -# Remove swap -ynh_del_swap - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index b0f2d9f..f1c8e3e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -8,7 +8,6 @@ # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh -source ../settings/scripts/ynh_add_swap source /usr/share/yunohost/helpers #================================================= @@ -33,11 +32,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -language_key=$(ynh_app_setting_get --app=$app --key=language) datadir=$(ynh_app_setting_get --app=$app --key=datadir) -port=$(ynh_app_setting_get --app=$app --key=port) -password=$(ynh_app_setting_get --app=$app --key=password) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -75,8 +70,7 @@ ynh_script_progression --message="Restoring the data directory..." --time --weig ynh_restore_file --origin_path="$datadir" --not_mandatory -mkdir -p "$datadir/assets/" -rsync -a "$final_path/build/assets/" "$datadir/assets/" +mkdir -p $datadir chmod 750 "$datadir" chmod -R o-rwx "$datadir" @@ -108,22 +102,6 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql -#================================================= -# ADD SWAP IF NEEDED -#================================================= -ynh_script_progression --message="Adding swap is needed..." - -total_memory=$(ynh_get_ram --total) -swap_needed=0 - -if [ $total_memory -lt $MEMORY_NEEDED ]; then - # Need a minimum of 2.5Go of memory - swap_needed=$(($MEMORY_NEEDED - $total_memory)) -fi - -ynh_script_progression --message="Adding $swap_needed Mo to swap..." -ynh_add_swap --size=$swap_needed - #================================================= # RESTORE SYSTEMD #================================================= @@ -151,7 +129,7 @@ yunohost service add $app --description="AI-Powered Photos App for the Decentral #================================================= ynh_script_progression --message="Starting a systemd service..." --time --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="http: starting web server at" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 531c2a1..248805a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,8 +7,6 @@ #================================================= source _common.sh -source ynh_install_go -source ynh_add_swap source /usr/share/yunohost/helpers #================================================= @@ -24,7 +22,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -language_key=$(ynh_app_setting_get --app=$app --key=language) +language_key=$(ynh_app_setting_get --app=$app --key=language_key) datadir=$(ynh_app_setting_get --app=$app --key=datadir) port=$(ynh_app_setting_get --app=$app --key=port) password=$(ynh_app_setting_get --app=$app --key=password) @@ -65,6 +63,13 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 +# If language_key doesn't exist, create it +if [ -z "$language_key" ]; then + language_key=$(ynh_app_setting_get --app=$app --key=language) + ynh_app_setting_set --app=$app --key=language_key --value=$language_key + ynh_app_setting_delete --app=$app --key=language +fi + #================================================= # CREATE DEDICATED USER #================================================= @@ -81,10 +86,8 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --time --weight=1 - pushd "$final_path" - git fetch origin - git checkout "$PHOTOPRISM_VERSION" 2>&1 - popd + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path/build/" --source_id="docker-image-extract" fi chmod 750 "$final_path" @@ -109,52 +112,36 @@ ynh_add_nginx_config #================================================= # SPECIFIC UPGRADE #================================================= -# ADD SWAP IF NEEDED +# MAKE INSTALL #================================================= -ynh_script_progression --message="Adding swap is needed..." +ynh_script_progression --message="Making install..." --time --weight=1 -total_memory=$(ynh_get_ram --total) -swap_needed=0 - -if [ $total_memory -lt $MEMORY_NEEDED ]; then - # Need a minimum of 2.5Go of memory - swap_needed=$(($MEMORY_NEEDED - $total_memory)) +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + # Install photoprism + pushd $final_path/build + ./docker-image-extract photoprism/photoprism:$PHOTOPRISM_VERSION + popd + mkdir -p "$final_path/live/" + rsync -a "$final_path/build/output/opt/photoprism/" "$final_path/live/" + ynh_secure_remove --file="$final_path/build" fi -ynh_script_progression --message="Adding $swap_needed Mo to swap..." -ynh_add_swap --size=$swap_needed - - -#================================================= -# BUILD PHOTOPRISM -#================================================= -ynh_script_progression --message="Building Photoprism..." --time --weight=1 - -pushd "$final_path" - # Setup go exe and environnement - ynh_use_go - export GOPATH="$final_path/go" - export GOCACHE="$final_path/go/.cache" - export GOBIN=$GOPATH/bin - # Setup tensorflow library - ./scripts/dist/install-tensorflow.sh - # Remove the former build file - ynh_secure_remove --file="$final_path/build" - # Setup node environment - export NODE_OPTIONS=--max_old_space_size=1024 - # Build server from source - ynh_use_nodejs - env "$ynh_node_load_PATH" npm install -g npm - env "$ynh_node_load_PATH" make dep-tensorflow dep-js dep-go build-js install DESTDIR=$final_path/build 2>&1 - ynh_secure_remove --file="$final_path/go" -popd +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" #================================================= # UPDATE DATA DIRECTORY #================================================= ynh_script_progression --message="Updating data directory..." --time --weight=1 -rsync -a "$final_path/build/assets/" "$datadir/assets/" +mkdir -p $datadir +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + rsync -a "$final_path/live/assets/" "$datadir/assets/" + ynh_secure_remove --file="$final_path/live/assets/" +fi chmod 750 "$datadir" chmod -R o-rwx "$datadir" @@ -165,10 +152,10 @@ chown -R $app:www-data "$datadir" #================================================= ynh_script_progression --message="Updating a configuration file..." --time --weight=1 -ynh_add_config --template="options.yml" --destination="$final_path/build/config/options.yml" +ynh_add_config --template="../conf/options.yml" --destination="$final_path/live/config/options.yml" -chmod 400 "$final_path/build/config/options.yml" -chown $app:$app "$final_path/build/config/options.yml" +chmod 400 "$final_path/live/config/options.yml" +chown $app:$app "$final_path/live/config/options.yml" #================================================= # SETUP SYSTEMD @@ -200,7 +187,7 @@ yunohost service add $app --description="AI-Powered Photos App for the Decentral #================================================= ynh_script_progression --message="Starting a systemd service..." --time --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="http: starting web server at" #================================================= # RELOAD NGINX diff --git a/scripts/ynh_add_swap b/scripts/ynh_add_swap deleted file mode 100644 index 2fd2d8c..0000000 --- a/scripts/ynh_add_swap +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash - -# Add swap -# -# usage: ynh_add_swap --size=SWAP in Mb -# | arg: -s, --size= - Amount of SWAP to add in Mb. -ynh_add_swap () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [s]=size= ) - local size - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - local swap_max_size=$(( $size * 1024 )) - - local free_space=$(df --output=avail / | sed 1d) - # Because we don't want to fill the disk with a swap file, divide by 2 the available space. - local usable_space=$(( $free_space / 2 )) - - SD_CARD_CAN_SWAP=${SD_CARD_CAN_SWAP:-0} - - # Swap on SD card only if it's is specified - if ynh_is_main_device_a_sd_card && [ "$SD_CARD_CAN_SWAP" == "0" ] - then - ynh_print_warn --message="The main mountpoint of your system '/' is on an SD card, swap will not be added to prevent some damage of this one, but that can cause troubles for the app $app. If you still want activate the swap, you can relaunch the command preceded by 'SD_CARD_CAN_SWAP=1'" - return - fi - - # Compare the available space with the size of the swap. - # And set a acceptable size from the request - if [ $usable_space -ge $swap_max_size ] - then - local swap_size=$swap_max_size - elif [ $usable_space -ge $(( $swap_max_size / 2 )) ] - then - local swap_size=$(( $swap_max_size / 2 )) - elif [ $usable_space -ge $(( $swap_max_size / 3 )) ] - then - local swap_size=$(( $swap_max_size / 3 )) - elif [ $usable_space -ge $(( $swap_max_size / 4 )) ] - then - local swap_size=$(( $swap_max_size / 4 )) - else - echo "Not enough space left for a swap file" >&2 - local swap_size=0 - fi - - # If there's enough space for a swap, and no existing swap here - if [ $swap_size -ne 0 ] && [ ! -e /swap_$app ] - then - # Preallocate space for the swap file, fallocate may sometime not be used, use dd instead in this case - if ! fallocate -l ${swap_size}K /swap_$app - then - dd if=/dev/zero of=/swap_$app bs=1024 count=${swap_size} - fi - chmod 0600 /swap_$app - # Create the swap - mkswap /swap_$app - # And activate it - swapon /swap_$app - # Then add an entry in fstab to load this swap at each boot. - echo -e "/swap_$app swap swap defaults 0 0 #Swap added by $app" >> /etc/fstab - fi -} - -ynh_del_swap () { - # If there a swap at this place - if [ -e /swap_$app ] - then - # Clean the fstab - sed -i "/#Swap added by $app/d" /etc/fstab - # Desactive the swap file - swapoff /swap_$app - # And remove it - rm /swap_$app - fi -} - -# Check if the device of the main mountpoint "/" is an SD card -# -# [internal] -# -# return 0 if it's an SD card, else 1 -ynh_is_main_device_a_sd_card () { - local main_device=$(lsblk --output PKNAME --noheadings $(findmnt / --nofsroot --uniq --output source --noheadings --first-only)) - - if echo $main_device | grep --quiet "mmc" && [ $(tail -n1 /sys/block/$main_device/queue/rotational) == "0" ] - then - return 0 - else - return 1 - fi -} \ No newline at end of file diff --git a/scripts/ynh_install_go b/scripts/ynh_install_go deleted file mode 100644 index 2952214..0000000 --- a/scripts/ynh_install_go +++ /dev/null @@ -1,247 +0,0 @@ -#!/bin/bash - -ynh_go_try_bash_extension() { - if [ -x src/configure ]; then - src/configure && make -C src || { - ynh_print_info --message="Optional bash extension failed to build, but things will still work normally." - } - fi -} - -goenv_install_dir="/opt/goenv" -go_version_path="$goenv_install_dir/versions" -# goenv_ROOT is the directory of goenv, it needs to be loaded as a environment variable. -export GOENV_ROOT="$goenv_install_dir" - -# Load the version of Go for an app, and set variables. -# -# ynh_use_go has to be used in any app scripts before using Go for the first time. -# This helper will provide alias and variables to use in your scripts. -# -# To use gem or Go, use the alias `ynh_gem` and `ynh_go` -# Those alias will use the correct version installed for the app -# For example: use `ynh_gem install` instead of `gem install` -# -# With `sudo` or `ynh_exec_as`, use instead the fallback variables `$ynh_gem` and `$ynh_go` -# And propagate $PATH to sudo with $ynh_go_load_path -# Exemple: `ynh_exec_as $app $ynh_go_load_path $ynh_gem install` -# -# $PATH contains the path of the requested version of Go. -# However, $PATH is duplicated into $go_path to outlast any manipulation of $PATH -# You can use the variable `$ynh_go_load_path` to quickly load your Go version -# in $PATH for an usage into a separate script. -# Exemple: $ynh_go_load_path $final_path/script_that_use_gem.sh` -# -# -# Finally, to start a Go service with the correct version, 2 solutions -# Either the app is dependent of Go or gem, but does not called it directly. -# In such situation, you need to load PATH -# `Environment="__YNH_GO_LOAD_PATH__"` -# `ExecStart=__FINALPATH__/my_app` -# You will replace __YNH_GO_LOAD_PATH__ with $ynh_go_load_path -# -# Or Go start the app directly, then you don't need to load the PATH variable -# `ExecStart=__YNH_GO__ my_app run` -# You will replace __YNH_GO__ with $ynh_go -# -# -# one other variable is also available -# - $go_path: The absolute path to Go binaries for the chosen version. -# -# usage: ynh_use_go -# -# Requires YunoHost version 3.2.2 or higher. -ynh_use_go () { - go_version=$(ynh_app_setting_get --app=$app --key=go_version) - - # Get the absolute path of this version of Go - go_path="$go_version_path/$go_version/bin" - - # Allow alias to be used into bash script - shopt -s expand_aliases - - # Create an alias for the specific version of Go and a variable as fallback - ynh_go="$go_path/go" - alias ynh_go="$ynh_go" - - # Load the path of this version of Go in $PATH - if [[ :$PATH: != *":$go_path"* ]]; then - PATH="$go_path:$PATH" - fi - # Create an alias to easily load the PATH - ynh_go_load_path="PATH=$PATH" - - # Sets the local application-specific Go version - pushd $final_path - $goenv_install_dir/bin/goenv local $go_version - popd -} - -# Install a specific version of Go -# -# ynh_install_go will install the version of Go provided as argument by using goenv. -# -# This helper creates a /etc/profile.d/goenv.sh that configures PATH environment for goenv -# for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin) -# -# Don't forget to execute go-dependent command in a login environment -# (e.g. sudo --login option) -# When not possible (e.g. in systemd service definition), please use direct path -# to goenv shims (e.g. $goenv_ROOT/shims/bundle) -# -# usage: ynh_install_go --go_version=go_version -# | arg: -v, --go_version= - Version of go to install. -# -# Requires YunoHost version 3.2.2 or higher. -ynh_install_go () { - # Declare an array to define the options of this helper. - local legacy_args=v - local -A args_array=( [v]=go_version= ) - local go_version - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - # Load goenv path in PATH - local CLEAR_PATH="$goenv_install_dir/bin:$PATH" - - # Remove /usr/local/bin in PATH in case of Go prior installation - PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@') - - # Move an existing Go binary, to avoid to block goenv - test -x /usr/bin/go && mv /usr/bin/go /usr/bin/go_goenv - - # Install or update goenv - goenv="$(command -v goenv $goenv_install_dir/bin/goenv | head -1)" - if [ -n "$goenv" ]; then - ynh_print_info --message="goenv already seems installed in \`$goenv'." - pushd "${goenv%/*/*}" - if git remote -v 2>/dev/null | grep "https://github.com/syndbg/goenv.git"; then - echo "Trying to update with git..." - git pull -q --tags origin master - cd .. - ynh_go_try_bash_extension - fi - popd - else - ynh_print_info --message="Installing goenv with git..." - mkdir -p $goenv_install_dir - pushd $goenv_install_dir - git init -q - git remote add -f -t master origin https://github.com/syndbg/goenv.git > /dev/null 2>&1 - git checkout -q -b master origin/master - ynh_go_try_bash_extension - goenv=$goenv_install_dir/bin/goenv - popd - fi - - goenv_latest="$(command -v "$goenv_install_dir"/plugins/*/bin/goenv-latest goenv-latest | head -1)" - if [ -n "$goenv_latest" ]; then - ynh_print_info --message="\`goenv latest' command already available in \`$goenv_latest'." - pushd "${goenv_latest%/*/*}" - if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then - ynh_print_info --message="Trying to update xxenv-latest with git..." - git pull -q origin master - fi - popd - else - ynh_print_info --message="Installing xxenv-latest with git..." - mkdir -p "${goenv_install_dir}/plugins" - git clone -q https://github.com/momo-lab/xxenv-latest.git "${goenv_install_dir}/plugins/xxenv-latest" - fi - - # Enable caching - mkdir -p "${goenv_install_dir}/cache" - - # Create shims directory if needed - mkdir -p "${goenv_install_dir}/shims" - - # Restore /usr/local/bin in PATH - PATH=$CLEAR_PATH - - # And replace the old Go binary - test -x /usr/bin/go_goenv && mv /usr/bin/go_goenv /usr/bin/go - - # Install the requested version of Go - local final_go_version=$(goenv latest --print $go_version) - ynh_print_info --message="Installation of Go-$final_go_version" - goenv install --skip-existing $final_go_version - - # Store go_version into the config of this app - ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=go_version --value=$final_go_version - - # Cleanup Go versions - ynh_cleanup_go - - # Set environment for Go users - echo "#goenv -export GOENV_ROOT=$goenv_install_dir -export PATH=\"$goenv_install_dir/bin:$PATH\" -eval \"\$(goenv init -)\" -#goenv" > /etc/profile.d/goenv.sh - - # Load the environment - eval "$(goenv init -)" -} - -# Remove the version of Go used by the app. -# -# This helper will also cleanup Go versions -# -# usage: ynh_remove_go -ynh_remove_go () { - local go_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=go_version) - - # Load goenv path in PATH - local CLEAR_PATH="$goenv_install_dir/bin:$PATH" - - # Remove /usr/local/bin in PATH in case of Go prior installation - PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@') - - # Remove the line for this app - ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=go_version - - # Cleanup Go versions - ynh_cleanup_go -} - -# Remove no more needed versions of Go used by the app. -# -# This helper will check what Go version are no more required, -# and uninstall them -# If no app uses Go, goenv will be also removed. -# -# usage: ynh_cleanup_go -ynh_cleanup_go () { - - # List required Go versions - local installed_apps=$(yunohost app list --output-as json --quiet | jq -r .apps[].id) - local required_go_versions="" - for installed_app in $installed_apps - do - local installed_app_go_version=$(ynh_app_setting_get --app=$installed_app --key="go_version") - if [[ $installed_app_go_version ]] - then - required_go_versions="${installed_app_go_version}\n${required_go_versions}" - fi - done - - # Remove no more needed Go versions - local installed_go_versions=$(goenv versions --bare --skip-aliases | grep -Ev '/') - for installed_go_version in $installed_go_versions - do - if ! `echo ${required_go_versions} | grep "${installed_go_version}" 1>/dev/null 2>&1` - then - ynh_print_info --message="Removing of Go-$installed_go_version" - $goenv_install_dir/bin/goenv uninstall --force $installed_go_version - fi - done - - # If none Go version is required - if [[ ! $required_go_versions ]] - then - # Remove goenv environment configuration - ynh_print_info --message="Removing of goenv" - ynh_secure_remove --file="$goenv_install_dir" - ynh_secure_remove --file="/etc/profile.d/goenv.sh" - fi -} \ No newline at end of file From 83295324de5d1ee31a695815cf93ba1cf71d1ad0 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 24 Jun 2022 04:00:32 +0200 Subject: [PATCH 4/5] remove time --- scripts/change_url | 16 ++++++++-------- scripts/install | 34 +++++++++++++++++----------------- scripts/remove | 26 +++++++++++++------------- scripts/restore | 28 ++++++++++++++-------------- scripts/upgrade | 34 +++++++++++++++++----------------- 5 files changed, 69 insertions(+), 69 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index c09f018..bd34f42 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -41,7 +41,7 @@ password=$(ynh_app_setting_get --app=$app --key=password) #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1 +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -77,14 +77,14 @@ fi #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1 +ynh_script_progression --message="Updating NGINX web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -115,7 +115,7 @@ fi #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 +ynh_script_progression --message="Updating a configuration file..." domain=$new_domain path_url=$new_path @@ -130,7 +130,7 @@ chown $app:$app "$final_path/live/config/options.yml" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +ynh_script_progression --message="Starting a systemd service..." # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="http: starting web server at" @@ -138,7 +138,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -146,4 +146,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --time --last +ynh_script_progression --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 4d7c8aa..a20ae08 100755 --- a/scripts/install +++ b/scripts/install @@ -40,7 +40,7 @@ fi #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --time --weight=1 +ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -51,7 +51,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --time --weight=1 +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url @@ -63,7 +63,7 @@ ynh_app_setting_set --app=$app --key=password --value=$password #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Finding an available port..." --time --weight=1 +ynh_script_progression --message="Finding an available port..." # Find an available port port=$(ynh_find_port --port=8095) @@ -72,14 +72,14 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --time --weight=1 +ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --time --weight=1 +ynh_script_progression --message="Configuring system user..." # Create a system user ynh_system_user_create --username=$app --home_dir="$final_path" @@ -87,7 +87,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # CREATE A MYSQL DATABASE #================================================= -ynh_script_progression --message="Creating a MySQL database..." --time --weight=1 +ynh_script_progression --message="Creating a MySQL database..." db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name @@ -97,7 +97,7 @@ ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --time --weight=1 +ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src @@ -110,7 +110,7 @@ chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --time --weight=1 +ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config @@ -137,7 +137,7 @@ chown -R $app:$app "$final_path" #================================================= # CREATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Creating a data directory..." --time --weight=1 +ynh_script_progression --message="Creating a data directory..." datadir=/home/yunohost.app/$app ynh_app_setting_set --app=$app --key=datadir --value=$datadir @@ -153,7 +153,7 @@ chown -R $app:www-data "$datadir" #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --time --weight=1 +ynh_script_progression --message="Adding a configuration file..." ynh_add_config --template="../conf/options.yml" --destination="$final_path/live/config/options.yml" @@ -163,7 +163,7 @@ chown $app:$app "$final_path/live/config/options.yml" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." --time --weight=1 +ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config @@ -173,7 +173,7 @@ ynh_add_systemd_config #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." --time --weight=1 +ynh_script_progression --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -181,14 +181,14 @@ ynh_use_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description="AI-Powered Photos App for the Decentralized Web" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +ynh_script_progression --message="Starting a systemd service..." # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="http: starting web server at" @@ -196,7 +196,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." --time --weight=1 +ynh_script_progression --message="Configuring permissions..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -209,7 +209,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -217,4 +217,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --time --last +ynh_script_progression --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index b4c79e2..2940537 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -32,14 +32,14 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service integration..." --time --weight=1 + ynh_script_progression --message="Removing $app service integration..." yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config @@ -47,7 +47,7 @@ ynh_remove_systemd_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1 +ynh_script_progression --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate @@ -55,7 +55,7 @@ ynh_remove_logrotate #================================================= # REMOVE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Removing the MySQL database..." --time --weight=1 +ynh_script_progression --message="Removing the MySQL database..." # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name @@ -63,7 +63,7 @@ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --time --weight=1 +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -75,14 +75,14 @@ ynh_secure_remove --file="$final_path" # Remove the data directory if --purge option is used if [ "${YNH_APP_PURGE:-0}" -eq 1 ] then - ynh_script_progression --message="Removing app data directory..." --time --weight=1 + ynh_script_progression --message="Removing app data directory..." ynh_secure_remove --file="$datadir" fi #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --time --weight=1 +ynh_script_progression --message="Removing NGINX web server configuration..." # Remove the dedicated NGINX config ynh_remove_nginx_config @@ -90,7 +90,7 @@ ynh_remove_nginx_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --time --weight=1 +ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -101,7 +101,7 @@ ynh_remove_app_dependencies if yunohost firewall list | grep -q "\- $port$" then - ynh_script_progression --message="Closing port $port..." --time --weight=1 + ynh_script_progression --message="Closing port $port..." ynh_exec_warn_less yunohost firewall disallow TCP $port fi @@ -110,7 +110,7 @@ fi #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." --time --weight=1 +ynh_script_progression --message="Removing various files..." # Remove a cron file ynh_secure_remove --file="/etc/cron.d/$app" @@ -123,7 +123,7 @@ ynh_secure_remove --file="/var/log/$app" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 +ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user ynh_system_user_delete --username=$app @@ -132,4 +132,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --time --last +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index f1c8e3e..2701f8b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -37,7 +37,7 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 +ynh_script_progression --message="Validating restoration parameters..." test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " @@ -47,7 +47,7 @@ test ! -d $final_path \ #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 +ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" @@ -55,7 +55,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" @@ -66,7 +66,7 @@ chown -R $app:www-data "$final_path" #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." --time --weight=1 +ynh_script_progression --message="Restoring the data directory..." ynh_restore_file --origin_path="$datadir" --not_mandatory @@ -81,7 +81,7 @@ chown -R $app:www-data "$datadir" #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 +ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -89,14 +89,14 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --time --weight=1 +ynh_script_progression --message="Restoring the NGINX web server configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1 +ynh_script_progression --message="Restoring the MySQL database..." db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd @@ -105,7 +105,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./ #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1 +ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet @@ -113,21 +113,21 @@ systemctl enable $app.service --quiet #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --time --weight=1 +ynh_script_progression --message="Restoring the logrotate configuration..." ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description="AI-Powered Photos App for the Decentralized Web" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="http: starting web server at" @@ -136,7 +136,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -144,4 +144,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --time --last +ynh_script_progression --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 248805a..1e244b6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -37,7 +37,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -54,14 +54,14 @@ ynh_abort_if_errors #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 +ynh_script_progression --message="Ensuring downward compatibility..." # If language_key doesn't exist, create it if [ -z "$language_key" ]; then @@ -73,7 +73,7 @@ fi #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 +ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" @@ -84,7 +84,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --time --weight=1 + ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path/build/" --source_id="docker-image-extract" @@ -97,14 +97,14 @@ chown -R $app:www-data "$final_path" #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 +ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated NGINX config ynh_add_nginx_config @@ -114,7 +114,7 @@ ynh_add_nginx_config #================================================= # MAKE INSTALL #================================================= -ynh_script_progression --message="Making install..." --time --weight=1 +ynh_script_progression --message="Making install..." if [ "$upgrade_type" == "UPGRADE_APP" ] then @@ -134,7 +134,7 @@ chown -R $app:$app "$final_path" #================================================= # UPDATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Updating data directory..." --time --weight=1 +ynh_script_progression --message="Updating data directory..." mkdir -p $datadir if [ "$upgrade_type" == "UPGRADE_APP" ] @@ -150,7 +150,7 @@ chown -R $app:www-data "$datadir" #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." --time --weight=1 +ynh_script_progression --message="Updating a configuration file..." ynh_add_config --template="../conf/options.yml" --destination="$final_path/live/config/options.yml" @@ -160,7 +160,7 @@ chown $app:$app "$final_path/live/config/options.yml" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_add_systemd_config @@ -170,7 +170,7 @@ ynh_add_systemd_config #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading logrotate configuration..." # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append @@ -178,21 +178,21 @@ ynh_use_logrotate --non-append #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description="AI-Powered Photos App for the Decentralized Web" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="http: starting web server at" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -200,4 +200,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --time --last +ynh_script_progression --message="Upgrade of $app completed" From 9a5b0c7c5aa901052a20e18f1b607276bc7d4ca7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 24 Jun 2022 13:44:09 +0200 Subject: [PATCH 5/5] Fix restore --- scripts/remove | 3 --- scripts/restore | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/remove b/scripts/remove index 2940537..59b3537 100755 --- a/scripts/remove +++ b/scripts/remove @@ -112,9 +112,6 @@ fi #================================================= ynh_script_progression --message="Removing various files..." -# Remove a cron file -ynh_secure_remove --file="/etc/cron.d/$app" - # Remove the log files ynh_secure_remove --file="/var/log/$app" diff --git a/scripts/restore b/scripts/restore index 2701f8b..d737481 100755 --- a/scripts/restore +++ b/scripts/restore @@ -115,6 +115,9 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Restoring the logrotate configuration..." +mkdir -p "/var/log/$app" +chown -R $app:$app "/var/log/$app" + ynh_restore_file --origin_path="/etc/logrotate.d/$app" #=================================================