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
This commit is contained in:
Éric Gaspar 2024-09-01 17:54:21 +02:00
parent 0a64da4117
commit ead0cbe106
11 changed files with 30 additions and 203 deletions

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://api.github.com/repos/zwave-js/zwave-js-ui/zipball/v8.15.0
SOURCE_SUM=a8aac1fd25000dc6dbdd92c8d91e22bf3ffe1492a914777371f9d6e5299a676d
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true
SOURCE_EXTRACT=true

View file

@ -1,8 +1,3 @@
### Features
Integrate zwave-js-ui natively in Domoticz_ynh.
**Zwave-JS-UI**, also known under previous name ZWaveJS2MQTT, is a replacement for Openzwave. It exposes Z-Wave devices to an MQTT broker in a fully configurable manner.
To work correctly, this app require to install either

View file

@ -1,8 +1,3 @@
### Fonctionnalités
Intègre zwave-js-ui dans domoticz_ynh de façon native.
**Zwave-JS-UI**, aussi connu sous le nom de ZWaveJS2MQTT, est un remplaçant pour Openzwave. Il permet d'exposer les terminaux Z-Wave à un broker MQTT de façon complètement configurable.
Pour fonctionner correctement, cette application nécessite d'avoir installé soit:

View file

@ -18,12 +18,15 @@ code = "https://github.com/zwave-js/zwave-js-ui"
fund = "https://liberapay.com/robertsLando/donate"
[integration]
yunohost = ">= 11.2.18"
yunohost = ">= 11.2.29"
helpers_version = "2.1"
architectures = [ "amd64", "armhf", "arm64" ]
multi_instance = false
ldap = "not_relevant"
sso = "not_relevant"
disk = "350M"
ram.build = "200M"
ram.runtime = "150M"

View file

@ -3,12 +3,14 @@
#=================================================
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
if [[ "$YNH_ARCH" == "armhf" ]] || [[ "$YNH_ARCH" == "arm64" ]]
then
file_exec="zwave-js-ui"
else
file_exec="zwave-js-ui-linux"
fi
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,6 +1,5 @@
#!/bin/bash
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -13,23 +12,13 @@ ynh_print_info "Declaring files to be backed up..."
ynh_backup "$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
# SYSTEM CONFIGURATION
#=================================================
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup "/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup "/etc/systemd/system/$app.service"
#=================================================

View file

@ -1,122 +1,32 @@
#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression "Loading installation settings..."
# Needed for helper "ynh_config_add_nginx"
final_path=$(ynh_app_setting_get --key=final_path)
port=$(ynh_app_setting_get --key=port)
# Add settings here as needed by your application
#db_name=$(ynh_app_setting_get --key=db_name)
#db_user=$db_name
#db_pwd=$(ynh_app_setting_get --key=db_pwd)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression "Backing up the app before changing its URL (may take a while)..."
# Backup the current version of the app
#REMOVEME? ynh_backup_before_upgrade
#REMOVEME? ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_safe_rm "/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
#REMOVEME? ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemctl --service=$app --action="stop"
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression "Updating NGINX web server configuration..."
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different "$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_config_add_nginx
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum "$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
#=================================================
ynh_change_url_nginx_config
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression "Starting $app's systemd service..."
ynh_systemctl --service=$app --action="start"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression "Reloading NGINX web server..."
ynh_systemctl --service=nginx --action=reload
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT

View file

@ -25,40 +25,18 @@ fi
#=================================================
ynh_script_progression "Setting up source files..."
# Download, check integrity, uncompress and patch the source
ynh_setup_source --dest_dir="$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: "$install_dir"
#=================================================
# NGINX CONFIGURATION
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression "Configuring NGINX web server..."
ynh_script_progression "Adding system configurations related to $app..."
# Create a dedicated NGINX config
ynh_config_add_nginx
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression "Configuring $app's systemd service..."
# Create a dedicated systemd config
ynh_config_add_systemd
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression "Configuring log rotation..."
# Use logrotate to manage application logfile(s)
ynh_config_add_logrotate "/var/log/$app/$app.log"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression "Integrating service in YunoHost..."
ynh_config_add_logrotate
yunohost service add $app --description="Zwave integration in domoticz" --log="/var/log/$app/$app.log"
@ -67,7 +45,6 @@ yunohost service add $app --description="Zwave integration in domoticz" --log="/
#=================================================
ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service
ynh_systemctl --service=$app --action="start" --wait_until="Listening on port" -t 30
#=================================================

View file

@ -4,24 +4,24 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression "Removing system configurations related to $app..."
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_hide_warnings yunohost service status $app >/dev/null
then
ynh_script_progression "Removing $app service integration..."
yunohost service remove $app
fi
ynh_script_progression "Removing various system files..."
ynh_config_remove_systemd
ynh_config_remove_logrotate
ynh_config_remove_nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Removal of $app completed"

View file

@ -1,6 +1,5 @@
#!/bin/bash
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -26,9 +25,6 @@ ynh_script_progression "Restoring the app main directory..."
ynh_restore "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: "$install_dir"
ynh_script_progression "Restoring system configurations related to $app..."
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
@ -39,22 +35,16 @@ systemctl enable $app.service --quiet
ynh_restore "/etc/logrotate.d/$app"
mkdir -p /var/log/$app
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app /var/log/$app
yunohost service add $app --description="Zwave integration in domoticz" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
ynh_script_progression "Starting $app's systemd service..."
ynh_script_progression "Reloading NGINX web server and $app's service..."
ynh_systemctl --service=$app --action="start" --wait_until="Listening on port" -t 30
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression "Reloading NGINX web server..."
ynh_systemctl --service=nginx --action=reload
#=================================================

View file

@ -28,48 +28,20 @@ fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression "Upgrading source files..."
# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
if ynh_app_upstream_version_changed
then
ynh_script_progression "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: "$install_dir"
fi
ynh_setup_source --dest_dir="$install_dir"
#=================================================
# NGINX CONFIGURATION
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression "Upgrading NGINX web server configuration..."
ynh_script_progression "Upgrading system configurations related to $app..."
# Create a dedicated NGINX config
ynh_config_add_nginx
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression "Upgrading systemd configuration..."
# Create a dedicated systemd config
ynh_config_add_systemd
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression "Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s)
ynh_config_add_logrotate "/var/log/$app/$app.log"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression "Integrating service in YunoHost..."
ynh_config_add_logrotate
yunohost service add $app --description="Zwave integration in domoticz" --log="/var/log/$app/$app.log"