From 804379d875ba437ebfaa746f2417fa53f9a41e20 Mon Sep 17 00:00:00 2001 From: Hadrien Date: Tue, 2 Nov 2021 08:18:06 +0300 Subject: [PATCH 01/13] gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 783a4ae..52ffdbe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ *.sw[op] +.DS_Store \ No newline at end of file From 8539138446fde0a94db501c0fbd1536ec1cc4f55 Mon Sep 17 00:00:00 2001 From: Hadrien Date: Tue, 2 Nov 2021 08:19:03 +0300 Subject: [PATCH 02/13] use ynh_setup_source also for front end --- conf/dist.src | 7 +++++++ scripts/install | 7 +++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 conf/dist.src diff --git a/conf/dist.src b/conf/dist.src new file mode 100644 index 0000000..331766a --- /dev/null +++ b/conf/dist.src @@ -0,0 +1,7 @@ +SOURCE_URL=https://github.com/louislam/uptime-kuma/releases/download/1.10.0/dist.tar.gz +SOURCE_SUM=f9f41507b427f155cb6a9bbc136ebba87587fd51c6d11e1999e5a66cc4249e6e +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.gz +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME=dist.tar.gz +SOURCE_EXTRACT=true diff --git a/scripts/install b/scripts/install index 2f671e8..15ec1f4 100755 --- a/scripts/install +++ b/scripts/install @@ -166,7 +166,9 @@ 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" +ynh_setup_source --dest_dir="$final_path" --keep=data/ +# Download, check integrity, uncompress and patch the source from dist.src +ynh_setup_source --source_id="dist" --dest_dir="$final_path/dist" # FIXME: this should be managed by the core in the future # Here, as a packager, you may have to tweak the ownerhsip/permissions @@ -212,9 +214,6 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Installing Uptime Kuma dependencies..." --time --weight=7 cd $final_path && ynh_exec_warn_less $ynh_npm install -ynh_script_progression --message="Downloading Uptime Kuma frontend..." --time --weight=1 -ynh_exec_warn_less wget https://github.com/louislam/uptime-kuma/releases/download/1.10.0/dist.tar.gz -ynh_exec_as $app tar -xvf dist.tar.gz --directory=$final_path #================================================= # CREATE DATA DIRECTORY From 8b7e64c3d80beabf0b9e033df6738ba50c5ac7c2 Mon Sep 17 00:00:00 2001 From: Hadrien Date: Tue, 2 Nov 2021 08:19:30 +0300 Subject: [PATCH 03/13] add backup, restore and upgrade scripts + notes on post-install --- README.md | 4 +- README_fr.md | 4 +- doc/DISCLAIMER.md | 4 +- scripts/backup | 6 +- scripts/install | 20 ++- scripts/remove | 4 +- scripts/restore | 42 ++++--- scripts/upgrade | 312 ++++++++++++++++++++++------------------------ 8 files changed, 193 insertions(+), 203 deletions(-) diff --git a/README.md b/README.md index b63cbec..84bd740 100644 --- a/README.md +++ b/README.md @@ -42,10 +42,8 @@ It is a self-hosted monitoring tool like "Uptime Robot". - Requires a full dedicated domain - ARM architecture not supported - This app needs a manual post-install -- No upgrade script in this package -- No restore script in this package -- Backup script is untested in this package - Uses N to install specific nodejs version +- We could pre-configure mail notifications with YunoHost mail server as an improvement. ## Documentation and resources diff --git a/README_fr.md b/README_fr.md index 6ef0802..fc5a413 100644 --- a/README_fr.md +++ b/README_fr.md @@ -40,19 +40,6 @@ It is a self-hosted monitoring tool like "Uptime Robot". - This app needs a manual post-install - Uses N to install specific nodejs version - We could pre-configure mail notifications with YunoHost mail server as an improvement. - ## Documentations et ressources diff --git a/conf/systemd.service b/conf/systemd.service index e12642b..387ffe5 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,5 +1,5 @@ [Unit] -Description=Uptime Kuma +Description=Uptime Kuma, a fancy monitoring tool After=network.target [Service] diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index f54e38b..cabcf9b 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -3,16 +3,3 @@ - This app needs a manual post-install - Uses N to install specific nodejs version - We could pre-configure mail notifications with YunoHost mail server as an improvement. - diff --git a/manifest.json b/manifest.json index a9cc2f4..55d5d24 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "id": "uptime-kuma", "packaging_format": 1, "description": { - "en": " A fancy self-hosted monitoring tool like Uptime-Robot", + "en": "A fancy self-hosted monitoring tool like Uptime-Robot", "fr": "Un joli outil similaire à Uptime-Robot pour vérifier que des sites restent joignables" }, "version": "1.0~ynh1", diff --git a/scripts/install b/scripts/install index 111159f..0035567 100755 --- a/scripts/install +++ b/scripts/install @@ -342,7 +342,7 @@ ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script ### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script -yunohost service add $app --description="Uptime Kuma" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Uptime Kuma, a fancy monitoring tool" --log="/var/log/$app/$app.log" ### Additional options starting with 3.8: ### diff --git a/scripts/upgrade b/scripts/upgrade index a251e6c..32b60d8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -197,7 +197,7 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Uptime Kuma, a fancy monitoring tool" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE From b575e63e6464f29abbaa8dc88106f36af1da17f4 Mon Sep 17 00:00:00 2001 From: Hadrien Date: Tue, 2 Nov 2021 12:23:34 +0300 Subject: [PATCH 09/13] disclaimer backup of node_modules.. --- README.md | 1 + README_fr.md | 1 + doc/DISCLAIMER.md | 1 + 3 files changed, 3 insertions(+) diff --git a/README.md b/README.md index 8f4791a..10c6cb0 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ It is a self-hosted monitoring tool like "Uptime Robot". ## Disclaimers / important information - Requires a full dedicated domain +- node_modules folder is backed up and shouldn't be (600Mo...) - ARM architecture not supported - This app needs a manual post-install - Uses N to install specific nodejs version diff --git a/README_fr.md b/README_fr.md index fc5a413..171c8ea 100644 --- a/README_fr.md +++ b/README_fr.md @@ -36,6 +36,7 @@ It is a self-hosted monitoring tool like "Uptime Robot". ## Avertissements / informations importantes - Requires a full dedicated domain +- node_modules folder is backed up and shouldn't be (600Mo...) - ARM architecture not supported - This app needs a manual post-install - Uses N to install specific nodejs version diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index cabcf9b..1dcb93a 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -1,4 +1,5 @@ - Requires a full dedicated domain +- node_modules folder is backed up and shouldn't be (600Mo...) - ARM architecture not supported - This app needs a manual post-install - Uses N to install specific nodejs version From 2c5a1df64838780eb002b4f28577a0814c36589d Mon Sep 17 00:00:00 2001 From: Hadrien Date: Tue, 2 Nov 2021 12:23:43 +0300 Subject: [PATCH 10/13] notes --- scripts/install | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/install b/scripts/install index 0035567..e97620c 100755 --- a/scripts/install +++ b/scripts/install @@ -301,6 +301,10 @@ ynh_add_systemd_config ### It could be tricky to use CURL since this app uses websocket exclusively. # curl --data-binary '{"jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "1"}' -H "Upgrade:websocket" -H 'content-type: application/json;' http://localhost:9090/jsonrpc +# curl 'wss://uptime-kuma.example.fr/socket.io/?EIO=4&transport=websocket' -H 'Accept: */*' -H 'Sec-WebSocket-Version: 13' -H 'Origin: https://uptime-kuma.example.fr' -H 'Sec-WebSocket-Extensions: permessage-deflate' -H 'Sec-WebSocket-Key: ZziEpfBMcnRSyFryHHsVmA==' -H 'Connection: keep-alive, Upgrade' -H 'Sec-Fetch-Dest: websocket' -H 'Sec-Fetch-Mode: websocket' -H 'Sec-Fetch-Site: same-origin' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'Upgrade: websocket' --data-binary '["setup","admin","password"]' -H 'content-type: application/json;' + +# 421["setup","admin","password"] + ### We could write to its SQLite. Didn't find where the language preferences are though. # password_hashed = $(htpasswd -bnBC 10 "" $password | tr -d ':\n') From 842c9f6807734ad51d2ed5b60557cdd19760ca0e Mon Sep 17 00:00:00 2001 From: Hadrien Date: Tue, 2 Nov 2021 12:24:32 +0300 Subject: [PATCH 11/13] upgrade nginx conf --- scripts/upgrade | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 32b60d8..f592d97 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,6 +20,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) # admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +port=$(ynh_app_setting_get --app=$app --key=port) # language=$(ynh_app_setting_get --app=$app --key=language) # db_name=$(ynh_app_setting_get --app=$app --key=db_name) @@ -114,14 +115,6 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 - -# Create a dedicated NGINX config -ynh_add_nginx_config - #================================================= # INSTALL NODEJS #================================================= @@ -135,6 +128,14 @@ ynh_install_nodejs --nodejs_version=$nodejs_version ynh_use_nodejs +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config + #================================================= # UPGRADE DEPENDENCIES #================================================= From d303c53b1b413f33464a2c48aecc610add9e3943 Mon Sep 17 00:00:00 2001 From: Hadrien Date: Tue, 2 Nov 2021 12:27:10 +0300 Subject: [PATCH 12/13] edit check_process --- check_process | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/check_process b/check_process index fefa192..ffd4471 100644 --- a/check_process +++ b/check_process @@ -6,21 +6,18 @@ ;; Test complet ; Manifest domain="domain.tld" - path="/path" - admin="john" - language="fr" + path="/" is_public=1 - password="1Strong-Password" port="666" ; Checks pkg_linter=1 - setup_sub_dir=1 + setup_sub_dir=0 setup_root=1 setup_nourl=0 setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=CommitHash + upgrade=1 from_commit=20c58daa4be910e554058914633f9a94500bc7e1 backup_restore=1 multi_instance=1 port_already_use=0 @@ -29,6 +26,6 @@ Email= Notification=none ;;; Upgrade options - ; commit=CommitHash - name=Name and date of the commit. - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& + ; commit=20c58daa4be910e554058914633f9a94500bc7e1 + name="Merge pull request #1 from YunoHost-Apps/helper-in-service" + manifest_arg=domain=domain.td&path=/&is_public=1&port=666& From 912e3101924b7c5bcfdbcee5faa97724c5e3bf48 Mon Sep 17 00:00:00 2001 From: Hadrien Date: Tue, 2 Nov 2021 12:38:23 +0300 Subject: [PATCH 13/13] disable datadir --- scripts/backup | 4 ++-- scripts/install | 28 ++++++++++++++-------------- scripts/remove | 14 +++++++------- scripts/restore | 28 ++++++++++++++-------------- scripts/upgrade | 2 +- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/scripts/backup b/scripts/backup index de13821..295a5ff 100755 --- a/scripts/backup +++ b/scripts/backup @@ -32,7 +32,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) # db_name=$(ynh_app_setting_get --app=$app --key=db_name) # phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +# datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -54,7 +54,7 @@ ynh_backup --src_path="$final_path" --is_big # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$datadir" +# ynh_backup --src_path="$datadir" #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/install b/scripts/install index e97620c..5b22be1 100755 --- a/scripts/install +++ b/scripts/install @@ -118,7 +118,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL NODEJS #================================================= -ynh_script_progression --message="Installing NodeJS..." --weight=2 +ynh_script_progression --message="Installing nodejs..." --weight=2 ynh_install_nodejs --nodejs_version=$nodejs_version @@ -218,7 +218,7 @@ cd $final_path && ynh_exec_warn_less $ynh_npm install #================================================= # CREATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Creating a data directory..." --weight=1 +# ynh_script_progression --message="Creating a data directory..." --weight=1 ### Use these lines if you need to create a directory to store "persistent files" for the application. ### Usually this directory is used to store uploaded files or any file that won't be updated during @@ -228,20 +228,20 @@ ynh_script_progression --message="Creating a data directory..." --weight=1 ### - Remove the section "RESTORE THE DATA DIRECTORY" in the restore script ### - As well as the section "REMOVE DATA DIR" in the remove script -datadir=/home/yunohost.app/$app/data -ynh_app_setting_set --app=$app --key=datadir --value=$datadir +# datadir=/home/yunohost.app/$app/data +# ynh_app_setting_set --app=$app --key=datadir --value=$datadir -mkdir -p $datadir +# mkdir -p $datadir -# 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 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" +# # 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 "$datadir" +# chmod -R o-rwx "$datadir" +# chown -R $app:www-data "$datadir" #================================================= # ADD A CONFIGURATION diff --git a/scripts/remove b/scripts/remove index cb5bda9..a4d9909 100755 --- a/scripts/remove +++ b/scripts/remove @@ -21,7 +21,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) # db_name=$(ynh_app_setting_get --app=$app --key=db_name) # db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +# datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # STANDARD REMOVE @@ -87,12 +87,12 @@ ynh_secure_remove --file="$final_path" # REMOVE DATA DIR #================================================= -# 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_secure_remove --file="$datadir" -fi +# # 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_secure_remove --file="$datadir" +# fi #================================================= # REMOVE NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 5049567..05e5d27 100755 --- a/scripts/restore +++ b/scripts/restore @@ -34,7 +34,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 # phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +# datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -81,21 +81,21 @@ chown -R $app:www-data "$final_path" #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." --weight=1 +# ynh_script_progression --message="Restoring the data directory..." --weight=1 -ynh_restore_file --origin_path="$datadir" --not_mandatory +# ynh_restore_file --origin_path="$datadir" --not_mandatory -mkdir -p $datadir +# mkdir -p $datadir -# 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 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" +# # 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 "$datadir" +# chmod -R o-rwx "$datadir" +# chown -R $app:www-data "$datadir" #================================================= # RESTORE FAIL2BAN CONFIGURATION @@ -113,7 +113,7 @@ chown -R $app:www-data "$datadir" #================================================= # INSTALL NODEJS #================================================= -ynh_script_progression --message="Reinstalling NodeJS..." --weight=2 +ynh_script_progression --message="Reinstalling nodejs version..." --weight=2 ynh_install_nodejs --nodejs_version=$nodejs_version diff --git a/scripts/upgrade b/scripts/upgrade index f592d97..26f34cc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -118,7 +118,7 @@ chown -R $app:www-data "$final_path" #================================================= # INSTALL NODEJS #================================================= -ynh_script_progression --message="Upgrading NodeJS..." --weight=2 +ynh_script_progression --message="Upgrading nodejs..." --weight=2 ynh_install_nodejs --nodejs_version=$nodejs_version