From a70f97d5ed4dd5601dcec494d4695502dfb64755 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sun, 7 May 2023 15:08:57 +0200 Subject: [PATCH] Use already compiled sources --- conf/app.src | 6 --- conf/systemd.service | 4 +- doc/PRE_INSTALL.md | 3 -- doc/PRE_INSTALL_fr.md | 3 -- manifest.toml | 26 +++++++++--- scripts/_common.sh | 95 ------------------------------------------- scripts/install | 89 ++++++++++++++++++++++------------------ scripts/remove | 10 ++--- scripts/restore | 6 +-- scripts/upgrade | 78 +++++++++++++++++------------------ 10 files changed, 118 insertions(+), 202 deletions(-) delete mode 100644 conf/app.src diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 8da8495..0000000 --- a/conf/app.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://api.github.com/repos/zwave-js/zwave-js-ui/zipball/v8.14.1 -SOURCE_SUM=9a6a4c66dc915e207e3bcb7957b55409d2487081d4ffd5bf8de3e9ec2df03503 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_EXTRACT=true diff --git a/conf/systemd.service b/conf/systemd.service index 68e74fc..81cec7d 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,10 +6,8 @@ After=network.target Type=simple User=__APP__ Group=__APP__ -#Environment not working, don't know why, have to add env command to ExecStart, if you know a better way, don't hesitate to make a PR -#Environment="__YNH_NODE_LOAD_PATH__" WorkingDirectory=__INSTALL_DIR__/ -ExecStart=env __YNH_NODE_LOAD_PATH__ yarn start +ExecStart=__INSTALL_DIR__/__FILE_EXEC__ StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md index 6f15d96..2869682 100644 --- a/doc/PRE_INSTALL.md +++ b/doc/PRE_INSTALL.md @@ -1,6 +1,3 @@ -Beware! -A temporary swap file will be created during install if less than 2Gb of memory (RAM+Swap) are available : Be sure to have enough space on disk! - To work correctly, this app require to install either - [domoticz package](https://github.com/YunoHost-Apps/domoticz_ynh) with **mqtt broker Mosquitto** - [Home-Assistant package](https://github.com/YunoHost-Apps/homeassistant_ynh) \ No newline at end of file diff --git a/doc/PRE_INSTALL_fr.md b/doc/PRE_INSTALL_fr.md index 37dd1b3..e26d48b 100644 --- a/doc/PRE_INSTALL_fr.md +++ b/doc/PRE_INSTALL_fr.md @@ -1,6 +1,3 @@ -Attention! -Un fichier de swap temporaire sera créé durant l'installation si moins de 2Go de mémoire (RAM+Swap) sont disponibles : Assurez vous d'avoir assez d'espace disque! - Pour fonctionner correctement, cette application nécessite d'avoir installé soit: - le package [domoticz](https://github.com/YunoHost-Apps/domoticz_ynh) avec le **broker MQTT mosquitto** - le package [Home-Assistant](https://github.com/YunoHost-Apps/homeassistant_ynh) \ No newline at end of file diff --git a/manifest.toml b/manifest.toml index b213c30..6a1e3b9 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Zwave-JS-UI" description.en = "Full featured Z-Wave Control Panel and MQTT Gateway integrated with domoticz" description.fr = "Panneau de controle Z-Wave et MQTT intégré avec Domoticz" -version = "8.14.1~ynh1" +version = "8.15.0~ynh2" maintainers = ["Krakinou"] @@ -18,13 +18,13 @@ code = "https://github.com/zwave-js/zwave-js-ui" fund = "https://liberapay.com/robertsLando/donate" [integration] -yunohost = ">= 11.1.11" -architectures = "all" +yunohost = ">= 11.1.18" +architectures = "arm64 armhf amd64" multi_instance = false ldap = "not_relevant" sso = "not_relevant" -disk = "650M" -ram.build = "2G" +disk = "350M" +ram.build = "100M" ram.runtime = "100M" [install] @@ -42,6 +42,22 @@ ram.runtime = "100M" default = "all_users" [resources] + [resources.sources.main] + arm64.url = "https://github.com/zwave-js/zwave-js-ui/releases/download/v8.15.0/zwave-js-ui-v8.15.0-linux-arm64.zip" + arm64.sha256 = "092c538cb865d1591fc2c46cc08ad7aff57847ac14f396067e9e1339f4d5b344" + armhf.url = "https://github.com/zwave-js/zwave-js-ui/releases/download/v8.15.0/zwave-js-ui-v8.15.0-linux-armv7.zip" + armhf.sha256 = "6fddd163a8158e8d8ff42a604cc563b77d6893ad698c3a70ed4c43dc8444b6ae" + amd64.url = "https://github.com/zwave-js/zwave-js-ui/releases/download/v8.15.0/zwave-js-ui-v8.15.0-linux.zip" + amd64.sha256 = "a479b01abcd1d597806918e0b2d31466306cca7c8a87af1dc9e3fcc08750dc1c" + format="zip" + in_subdir=false + extract=true + + autoupdate.strategy = "latest_github_release" + + autoupdate.asset.arm64 = "*-arm64.zip" + autoupdate.asset.amd64 = "*-linux.zip" + autoupdate.asset.armhf = "*-armv7.zip" [resources.system_user] [resources.install_dir] diff --git a/scripts/_common.sh b/scripts/_common.sh index 972675b..69c72c9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,8 +3,6 @@ #================================================= # COMMON VARIABLES #================================================= -MEMORY_NEEDED="2048" -NODEJS_VERSION=18 #================================================= # PERSONAL HELPERS @@ -14,99 +12,6 @@ NODEJS_VERSION=18 # EXPERIMENTAL HELPERS #================================================= -# 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 - e -lse - return 1 - fi -} - #================================================= # FUTURE OFFICIAL HELPERS #================================================= \ No newline at end of file diff --git a/scripts/install b/scripts/install index 4f9c527..ac957fd 100755 --- a/scripts/install +++ b/scripts/install @@ -9,23 +9,30 @@ source _common.sh source /usr/share/yunohost/helpers + +if [[ "$YNH_ARCH" == "armhf" ]] || [[ "$YNH_ARCH" == "arm64" ]] +then + file_exec="zwave-js-ui" +else + file_exec="zwave-js-ui-linux" +fi #================================================= # ADD SWAP IF NEEDED #================================================= #https://github.com/zwave-js/zwave-js-ui/issues/2699 -ynh_script_progression --message="Checking for RAM..." +#ynh_script_progression --message="Checking for RAM..." -total_memory=$(ynh_get_ram --total) -swap_needed=0 +#total_memory=$(ynh_get_ram --total) +#swap_needed=0 -if [ $total_memory -lt $MEMORY_NEEDED ]; then +#if [ $total_memory -lt $MEMORY_NEEDED ]; then # Need a minimum of 2Go of memory - swap_needed=$(($MEMORY_NEEDED - $total_memory)) - ynh_script_progression --message="Adding $swap_needed Mo to swap..." - SD_CARD_CAN_SWAP=1 - ynh_add_swap --size=$swap_needed +# swap_needed=$(($MEMORY_NEEDED - $total_memory)) +# ynh_script_progression --message="Adding $swap_needed Mo to swap..." +# SD_CARD_CAN_SWAP=1 +# ynh_add_swap --size=$swap_needed -fi +#fi #================================================= # CREATE DEDICATED USER @@ -50,58 +57,60 @@ fi #================================================= #REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=15 -ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -ynh_use_nodejs -ynh_exec_warn_less $ynh_npm install ---global yarn +#ynh_install_nodejs --nodejs_version=$NODEJS_VERSION +#ynh_use_nodejs +#ynh_exec_warn_less $ynh_npm install ---global yarn #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=8 -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" +# Download, check integrity, uncompress and patch the source +ynh_setup_source --dest_dir="$install_dir" chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app: "$install_dir" + + #================================================= # BUILD FROM SOURCE #================================================= -ynh_script_progression --message="Building from sources..." --weight=1 +#ynh_script_progression --message="Building from sources..." --weight=1 -pushd "$install_dir" - ynh_script_progression --message="Fetching Yarn dependencies... This can be very long, be patient !" --weight=40 - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn plugin import workspace-tools - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn workspaces focus --production - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --network-timeout 1000000000 - #On slow/low memory system, yarn silently fails with a 0 return code and nothing seems to be doable about that so far. - #relaunching yarn install seems to do the trick for raspberry at least as it resumes from where it fails - #https://github.com/yarnpkg/berry/issues/3996 - #https://github.com/yarnpkg/berry/issues/5065 - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --network-timeout 1000000000 - ynh_script_progression --message="Cleaning cache... " --weight=3 - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean 2>&1 - ynh_script_progression --message="Building Yarn dependencies... This can be very long, be patient !" --weight=30 - #https://geeklearning.io/angular-aot-webpack-memory-trick/ - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_OPTIONS=--max-old-space-size=2048 yarn run build - ynh_script_progression --message="Cleaning cache... " --weight=3 - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean 2>&1 -popd +#pushd "$install_dir" +# ynh_script_progression --message="Fetching Yarn dependencies... This can be very long, be patient !" --weight=40 +# ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn plugin import workspace-tools +# ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn workspaces focus --production +# ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --network-timeout 1000000000 +# #On slow/low memory system, yarn silently fails with a 0 return code and nothing seems to be doable about that so far. +# #relaunching yarn install seems to do the trick for raspberry at least as it resumes from where it fails +# #https://github.com/yarnpkg/berry/issues/3996 +# #https://github.com/yarnpkg/berry/issues/5065 +# ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --network-timeout 1000000000 +# ynh_script_progression --message="Cleaning cache... " --weight=3 +# ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean 2>&1 + # ynh_script_progression --message="Building Yarn dependencies... This can be very long, be patient !" --weight=30 + ##https://geeklearning.io/angular-aot-webpack-memory-trick/ +# ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_OPTIONS=--max-old-space-size=2048 yarn run build +# ynh_script_progression --message="Cleaning cache... " --weight=3 +# ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean 2>&1 +#popd -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app: "$install_dir" +#chmod 750 "$install_dir" +#chmod -R o-rwx "$install_dir" +#chown -R $app: "$install_dir" #================================================= # REMOVE ADDITIONNAL SWAP #================================================= -if [ $swap_needed > 0 ]; then - ynh_script_progression --message="Remove additionnal swap..." --weight=2 - ynh_del_swap -fi +#if [ $swap_needed > 0 ]; then +# ynh_script_progression --message="Remove additionnal swap..." --weight=2 +# ynh_del_swap +#fi #================================================= # NGINX CONFIGURATION #================================================= diff --git a/scripts/remove b/scripts/remove index 79780d6..aec5c7b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -28,13 +28,13 @@ ynh_remove_systemd_config ynh_remove_logrotate -ynh_remove_nodejs +#ynh_remove_nodejs #In case install or upgrade went wrong, remove script is launched, so we need to ensure additional swap is deleted -if [ -e /swap_$app ]; then - ynh_script_progression --message="Remove additionnal swap..." --weight=2 - ynh_del_swap -fi +#if [ -e /swap_$app ]; then +# ynh_script_progression --message="Remove additionnal swap..." --weight=2 +# ynh_del_swap +#fi ynh_remove_nginx_config diff --git a/scripts/restore b/scripts/restore index 055d5ac..0293402 100755 --- a/scripts/restore +++ b/scripts/restore @@ -31,9 +31,9 @@ fi #================================================= #REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=15 -ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -ynh_use_nodejs -ynh_exec_warn_less $ynh_npm install ---global yarn +#ynh_install_nodejs --nodejs_version=$NODEJS_VERSION +#ynh_use_nodejs +#ynh_exec_warn_less $ynh_npm install ---global yarn #================================================= # RESTORE THE APP MAIN DIR diff --git a/scripts/upgrade b/scripts/upgrade index fe9ba89..03f571f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -33,20 +33,20 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app # ADD SWAP IF NEEDED #================================================= #https://github.com/zwave-js/zwave-js-ui/issues/2699 -if [ "$upgrade_type" == "UPGRADE_APP" ]; then - ynh_script_progression --message="Checking for RAM..." +#if [ "$upgrade_type" == "UPGRADE_APP" ]; then +# ynh_script_progression --message="Checking for RAM..." - total_memory=$(ynh_get_ram --total) - swap_needed=0 +# total_memory=$(ynh_get_ram --total) +# swap_needed=0 - if [ $total_memory -lt $MEMORY_NEEDED ]; then - # Need a minimum of 2Go of memory - swap_needed=$(($MEMORY_NEEDED - $total_memory)) - ynh_script_progression --message="Adding $swap_needed Mo to swap..." - SD_CARD_CAN_SWAP=1 - ynh_add_swap --size=$swap_needed - fi -fi +# if [ $total_memory -lt $MEMORY_NEEDED ]; then +# # Need a minimum of 2Go of memory +# swap_needed=$(($MEMORY_NEEDED - $total_memory)) +# ynh_script_progression --message="Adding $swap_needed Mo to swap..." +# SD_CARD_CAN_SWAP=1 +# ynh_add_swap --size=$swap_needed +# fi +#fi #================================================= # CREATE DEDICATED USER @@ -68,9 +68,9 @@ fi #================================================= #REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 -ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -ynh_use_nodejs -ynh_exec_warn_less $ynh_npm install ---global yarn +#ynh_install_nodejs --nodejs_version=$NODEJS_VERSION +#ynh_use_nodejs +#ynh_exec_warn_less $ynh_npm install ---global yarn #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -87,41 +87,41 @@ then chmod -R o-rwx "$install_dir" chown -R $app: "$install_dir" - ynh_script_progression --message="Building from sources..." --weight=15 - pushd "$install_dir" - ynh_script_progression --message="Fetching Yarn dependencies... This can be very long, be patient !" --weight=18 - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn plugin import workspace-tools - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn workspaces focus --production - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --network-timeout 1000000000 +# ynh_script_progression --message="Building from sources..." --weight=15 +# pushd "$install_dir" +# ynh_script_progression --message="Fetching Yarn dependencies... This can be very long, be patient !" --weight=18 +# ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn plugin import workspace-tools +# ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn workspaces focus --production +# ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --network-timeout 1000000000 #On slow/low memory system, yarn silently fails with a 0 return code and nothing seems to be doable about that so far. #relaunching yarn install seems to do the trick for raspberry at least as it resumes from where it fails #https://github.com/yarnpkg/berry/issues/3996 #https://github.com/yarnpkg/berry/issues/5065 - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --network-timeout 1000000000 - ynh_script_progression --message="Cleaning cache... " --weight=3 - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean 2>&1 - ynh_script_progression --message="Building Yarn dependencies... This can be very long, be patient !" --weight=18 +# ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --network-timeout 1000000000 +# ynh_script_progression --message="Cleaning cache... " --weight=3 +# ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean 2>&1 + # ynh_script_progression --message="Building Yarn dependencies... This can be very long, be patient !" --weight=18 #https://geeklearning.io/angular-aot-webpack-memory-trick/ - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_OPTIONS=--max-old-space-size=2048 yarn run build - ynh_script_progression --message="Cleaning cache... " --weight=3 - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean 2>&1 - popd - - chmod 750 "$install_dir" - chmod -R o-rwx "$install_dir" - chown -R $app: "$install_dir" +# ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_OPTIONS=--max-old-space-size=2048 yarn run build +# ynh_script_progression --message="Cleaning cache... " --weight=3 +# ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean 2>&1 +# popd +# chmod 750 "$install_dir" +# chmod -R o-rwx "$install_dir" +# chown -R $app: "$install_dir" +# fi #================================================= # REMOVE ADDITIONNAL SWAP #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ]; then - if [ $swap_needed > 0 ]; then - ynh_script_progression --message="Remove additionnal swap..." --weight=2 - ynh_del_swap - fi -fi +#if [ "$upgrade_type" == "UPGRADE_APP" ]; then +# if [ $swap_needed > 0 ]; then +# ynh_script_progression --message="Remove additionnal swap..." --weight=2 +# ynh_del_swap +# fi +#fi #================================================= # NGINX CONFIGURATION