1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/zwave-js-ui_ynh.git synced 2024-09-03 18:06:00 +02:00

Use already compiled sources

This commit is contained in:
Krakinou 2023-05-07 15:08:57 +02:00
parent 7077cfeda1
commit a70f97d5ed
10 changed files with 118 additions and 202 deletions

View file

@ -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

View file

@ -6,10 +6,8 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__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__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=env __YNH_NODE_LOAD_PATH__ yarn start ExecStart=__INSTALL_DIR__/__FILE_EXEC__
StandardOutput=append:/var/log/__APP__/__APP__.log StandardOutput=append:/var/log/__APP__/__APP__.log
StandardError=inherit StandardError=inherit

View file

@ -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 To work correctly, this app require to install either
- [domoticz package](https://github.com/YunoHost-Apps/domoticz_ynh) with **mqtt broker Mosquitto** - [domoticz package](https://github.com/YunoHost-Apps/domoticz_ynh) with **mqtt broker Mosquitto**
- [Home-Assistant package](https://github.com/YunoHost-Apps/homeassistant_ynh) - [Home-Assistant package](https://github.com/YunoHost-Apps/homeassistant_ynh)

View file

@ -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: 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 [domoticz](https://github.com/YunoHost-Apps/domoticz_ynh) avec le **broker MQTT mosquitto**
- le package [Home-Assistant](https://github.com/YunoHost-Apps/homeassistant_ynh) - le package [Home-Assistant](https://github.com/YunoHost-Apps/homeassistant_ynh)

View file

@ -5,7 +5,7 @@ name = "Zwave-JS-UI"
description.en = "Full featured Z-Wave Control Panel and MQTT Gateway integrated with domoticz" 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" 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"] maintainers = ["Krakinou"]
@ -18,13 +18,13 @@ code = "https://github.com/zwave-js/zwave-js-ui"
fund = "https://liberapay.com/robertsLando/donate" fund = "https://liberapay.com/robertsLando/donate"
[integration] [integration]
yunohost = ">= 11.1.11" yunohost = ">= 11.1.18"
architectures = "all" architectures = "arm64 armhf amd64"
multi_instance = false multi_instance = false
ldap = "not_relevant" ldap = "not_relevant"
sso = "not_relevant" sso = "not_relevant"
disk = "650M" disk = "350M"
ram.build = "2G" ram.build = "100M"
ram.runtime = "100M" ram.runtime = "100M"
[install] [install]
@ -42,6 +42,22 @@ ram.runtime = "100M"
default = "all_users" default = "all_users"
[resources] [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.system_user]
[resources.install_dir] [resources.install_dir]

View file

@ -3,8 +3,6 @@
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
MEMORY_NEEDED="2048"
NODEJS_VERSION=18
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
@ -14,99 +12,6 @@ NODEJS_VERSION=18
# EXPERIMENTAL HELPERS # 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 # FUTURE OFFICIAL HELPERS
#================================================= #=================================================

View file

@ -9,23 +9,30 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers 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 # ADD SWAP IF NEEDED
#================================================= #=================================================
#https://github.com/zwave-js/zwave-js-ui/issues/2699 #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) #total_memory=$(ynh_get_ram --total)
swap_needed=0 #swap_needed=0
if [ $total_memory -lt $MEMORY_NEEDED ]; then #if [ $total_memory -lt $MEMORY_NEEDED ]; then
# Need a minimum of 2Go of memory # Need a minimum of 2Go of memory
swap_needed=$(($MEMORY_NEEDED - $total_memory)) # swap_needed=$(($MEMORY_NEEDED - $total_memory))
ynh_script_progression --message="Adding $swap_needed Mo to swap..." # ynh_script_progression --message="Adding $swap_needed Mo to swap..."
SD_CARD_CAN_SWAP=1 # SD_CARD_CAN_SWAP=1
ynh_add_swap --size=$swap_needed # ynh_add_swap --size=$swap_needed
fi #fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -50,58 +57,60 @@ fi
#================================================= #=================================================
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=15 #REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=15
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION #ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_use_nodejs #ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install ---global yarn #ynh_exec_warn_less $ynh_npm install ---global yarn
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=8 ynh_script_progression --message="Setting up source files..." --weight=8
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source
ynh_setup_source --dest_dir="$install_dir" ynh_setup_source --dest_dir="$install_dir"
chmod 750 "$install_dir" chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir" chmod -R o-rwx "$install_dir"
chown -R $app: "$install_dir" chown -R $app: "$install_dir"
#================================================= #=================================================
# BUILD FROM SOURCE # BUILD FROM SOURCE
#================================================= #=================================================
ynh_script_progression --message="Building from sources..." --weight=1 #ynh_script_progression --message="Building from sources..." --weight=1
pushd "$install_dir" #pushd "$install_dir"
ynh_script_progression --message="Fetching Yarn dependencies... This can be very long, be patient !" --weight=40 # 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 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 workspaces focus --production
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --network-timeout 1000000000 # 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. # #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 # #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/3996
#https://github.com/yarnpkg/berry/issues/5065 # #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_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_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_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 # ynh_script_progression --message="Building Yarn dependencies... This can be very long, be patient !" --weight=30
#https://geeklearning.io/angular-aot-webpack-memory-trick/ ##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_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_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_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean 2>&1
popd #popd
chmod 750 "$install_dir" #chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir" #chmod -R o-rwx "$install_dir"
chown -R $app: "$install_dir" #chown -R $app: "$install_dir"
#================================================= #=================================================
# REMOVE ADDITIONNAL SWAP # REMOVE ADDITIONNAL SWAP
#================================================= #=================================================
if [ $swap_needed > 0 ]; then #if [ $swap_needed > 0 ]; then
ynh_script_progression --message="Remove additionnal swap..." --weight=2 # ynh_script_progression --message="Remove additionnal swap..." --weight=2
ynh_del_swap # ynh_del_swap
fi #fi
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================

View file

@ -28,13 +28,13 @@ ynh_remove_systemd_config
ynh_remove_logrotate 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 #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 #if [ -e /swap_$app ]; then
ynh_script_progression --message="Remove additionnal swap..." --weight=2 # ynh_script_progression --message="Remove additionnal swap..." --weight=2
ynh_del_swap # ynh_del_swap
fi #fi
ynh_remove_nginx_config ynh_remove_nginx_config

View file

@ -31,9 +31,9 @@ fi
#================================================= #=================================================
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=15 #REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=15
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION #ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_use_nodejs #ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install ---global yarn #ynh_exec_warn_less $ynh_npm install ---global yarn
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR

View file

@ -33,20 +33,20 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
# ADD SWAP IF NEEDED # ADD SWAP IF NEEDED
#================================================= #=================================================
#https://github.com/zwave-js/zwave-js-ui/issues/2699 #https://github.com/zwave-js/zwave-js-ui/issues/2699
if [ "$upgrade_type" == "UPGRADE_APP" ]; then #if [ "$upgrade_type" == "UPGRADE_APP" ]; then
ynh_script_progression --message="Checking for RAM..." # ynh_script_progression --message="Checking for RAM..."
total_memory=$(ynh_get_ram --total) # total_memory=$(ynh_get_ram --total)
swap_needed=0 # swap_needed=0
if [ $total_memory -lt $MEMORY_NEEDED ]; then # if [ $total_memory -lt $MEMORY_NEEDED ]; then
# Need a minimum of 2Go of memory # # Need a minimum of 2Go of memory
swap_needed=$(($MEMORY_NEEDED - $total_memory)) # swap_needed=$(($MEMORY_NEEDED - $total_memory))
ynh_script_progression --message="Adding $swap_needed Mo to swap..." # ynh_script_progression --message="Adding $swap_needed Mo to swap..."
SD_CARD_CAN_SWAP=1 # SD_CARD_CAN_SWAP=1
ynh_add_swap --size=$swap_needed # ynh_add_swap --size=$swap_needed
fi # fi
fi #fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -68,9 +68,9 @@ fi
#================================================= #=================================================
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 #REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION #ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_use_nodejs #ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install ---global yarn #ynh_exec_warn_less $ynh_npm install ---global yarn
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -87,41 +87,41 @@ then
chmod -R o-rwx "$install_dir" chmod -R o-rwx "$install_dir"
chown -R $app: "$install_dir" chown -R $app: "$install_dir"
ynh_script_progression --message="Building from sources..." --weight=15 # ynh_script_progression --message="Building from sources..." --weight=15
pushd "$install_dir" # pushd "$install_dir"
ynh_script_progression --message="Fetching Yarn dependencies... This can be very long, be patient !" --weight=18 # 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 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 workspaces focus --production
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --network-timeout 1000000000 # 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. #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 #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/3996
#https://github.com/yarnpkg/berry/issues/5065 #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_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_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_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_script_progression --message="Building Yarn dependencies... This can be very long, be patient !" --weight=18
#https://geeklearning.io/angular-aot-webpack-memory-trick/ #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_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_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_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean 2>&1
popd # 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"
#
fi fi
#================================================= #=================================================
# REMOVE ADDITIONNAL SWAP # REMOVE ADDITIONNAL SWAP
#================================================= #=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]; then #if [ "$upgrade_type" == "UPGRADE_APP" ]; then
if [ $swap_needed > 0 ]; then # if [ $swap_needed > 0 ]; then
ynh_script_progression --message="Remove additionnal swap..." --weight=2 # ynh_script_progression --message="Remove additionnal swap..." --weight=2
ynh_del_swap # ynh_del_swap
fi # fi
fi #fi
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION