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

Merge pull request #38 from YunoHost-Apps/convertv2

Move to v2 packaging
This commit is contained in:
Krakinou 2023-02-24 21:20:21 +01:00 committed by GitHub
commit b5b3743f82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 141 additions and 542 deletions

View file

@ -25,20 +25,16 @@ Integrate zwave-js-ui natively in Domoticz_ynh.
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**
- or [Home-Assistant package](https://github.com/YunoHost-Apps/homeassistant_ynh) - [Home-Assistant package](https://github.com/YunoHost-Apps/homeassistant_ynh)
Suivez le [guide d'installation rapide](https://zwave-js.github.io/zwave-js-ui/#/getting-started/quick-start?id=minimum-settings) pour l'intégrer dans l'une ou l'autre de ces applications.
**Shipped version:** 8.8.6~ynh1
## Disclaimers / important information
For now, although the package is fully functional (install, remove, backup, restore...), it is not integrated with domoticz and mosquitto package, this means that all settings needs to be done manually from inside the app. For now, although the package is fully functional (install, remove, backup, restore...), it is not integrated with domoticz and mosquitto package, this means that all settings needs to be done manually from inside the app.
During install, the whole app need to be recompile using yarn, this lead to long installation time. Also, a temporary swap file will be created if less than 2Gb of memory (RAM+Swap) are available : Be sure to have enough space on disk. During install, the whole app need to be recompile using yarn, this lead to long installation time. Also, a temporary swap file will be created if less than 2Gb of memory (RAM+Swap) are available : Be sure to have enough space on disk.
**Shipped version:** 8.8.6~ynh2
## Documentation and resources ## Documentation and resources
* Official app website: <https://zwave-js.github.io/zwave-js-ui/#/> * Official app website: <https://zwave-js.github.io/zwave-js-ui/#/>

View file

@ -27,18 +27,12 @@ Pour fonctionner correctement, cette application nécessite d'avoir installé so
- 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)
Follow the [quick start instruction](https://zwave-js.github.io/zwave-js-ui/#/getting-started/quick-start?id=minimum-settings) to set up the integration with one or the other.
**Version incluse :** 8.8.6~ynh1
## Avertissements / informations importantes
Pour l'instant, bien que le package fonctionne (installation, désinstallation, sauvegarde, restauration...), il n'est pas intégré avec domoticz et mosquitto, les paramétrages doivent être fait manuellement depuis l'application. Pour l'instant, bien que le package fonctionne (installation, désinstallation, sauvegarde, restauration...), il n'est pas intégré avec domoticz et mosquitto, les paramétrages doivent être fait manuellement depuis l'application.
Pendant l'installation, la totalité de l'application doit être recompilé en utilisant yarn : cela amène à des temps d'installation très long. Un fichier de swap temporaire sera créé si moins de 2Go de mémoire sont disponibles (RAM + swap): Assurez vous d'avoir suffisament d'espace disque. Pendant l'installation, la totalité de l'application doit être recompilé en utilisant yarn : cela amène à des temps d'installation très long. Un fichier de swap temporaire sera créé si moins de 2Go de mémoire sont disponibles (RAM + swap): Assurez vous d'avoir suffisament d'espace disque.
**Version incluse :** 8.8.6~ynh2
## Documentations et ressources ## Documentations et ressources
* Site officiel de lapp : <https://zwave-js.github.io/zwave-js-ui/#/> * Site officiel de lapp : <https://zwave-js.github.io/zwave-js-ui/#/>

View file

@ -1,26 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
path="/path"
is_public=0
port="8091"
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=1c9098b5570b86489d2d089ee093cb839c1a90f2
backup_restore=1
multi_instance=0
port_already_use=1
change_url=1
;;; Options
Email=misterl56@hotmail.com
Notification=none
;;; Upgrade options
; commit=1c9098b5570b86489d2d089ee093cb839c1a90f2
name=Initial version
manifest_arg=domain=DOMAIN&path=PATH&is_public=1&language=fr&admin=USER&password=pass&port=666&

View file

@ -8,7 +8,7 @@ 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 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__" #Environment="__YNH_NODE_LOAD_PATH__"
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=env __YNH_NODE_LOAD_PATH__ yarn start ExecStart=env __YNH_NODE_LOAD_PATH__ yarn start
StandardOutput=append:/var/log/__APP__/__APP__.log StandardOutput=append:/var/log/__APP__/__APP__.log
StandardError=inherit StandardError=inherit
@ -45,3 +45,4 @@ CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -7,6 +7,10 @@ Integrate zwave-js-ui natively in Domoticz_ynh.
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**
- or [Home-Assistant package](https://github.com/YunoHost-Apps/homeassistant_ynh) - [Home-Assistant package](https://github.com/YunoHost-Apps/homeassistant_ynh)
Suivez le [guide d'installation rapide](https://zwave-js.github.io/zwave-js-ui/#/getting-started/quick-start?id=minimum-settings) pour l'intégrer dans l'une ou l'autre de ces applications.
For now, although the package is fully functional (install, remove, backup, restore...), it is not integrated with domoticz and mosquitto package, this means that all settings needs to be done manually from inside the app.
During install, the whole app need to be recompile using yarn, this lead to long installation time. Also, a temporary swap file will be created if less than 2Gb of memory (RAM+Swap) are available : Be sure to have enough space on disk.

View file

@ -9,4 +9,7 @@ Pour fonctionner correctement, cette application nécessite d'avoir installé so
- 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)
Follow the [quick start instruction](https://zwave-js.github.io/zwave-js-ui/#/getting-started/quick-start?id=minimum-settings) to set up the integration with one or the other.
Pour l'instant, bien que le package fonctionne (installation, désinstallation, sauvegarde, restauration...), il n'est pas intégré avec domoticz et mosquitto, les paramétrages doivent être fait manuellement depuis l'application.
Pendant l'installation, la totalité de l'application doit être recompilé en utilisant yarn : cela amène à des temps d'installation très long. Un fichier de swap temporaire sera créé si moins de 2Go de mémoire sont disponibles (RAM + swap): Assurez vous d'avoir suffisament d'espace disque.

View file

@ -1,7 +0,0 @@
For now, although the package is fully functional (install, remove, backup, restore...), it is not integrated with domoticz and mosquitto package, this means that all settings needs to be done manually from inside the app.
During install, the whole app need to be recompile using yarn, this lead to long installation time. Also, a temporary swap file will be created if less than 2Gb of memory (RAM+Swap) are available : Be sure to have enough space on disk.

View file

@ -1,6 +0,0 @@
Pour l'instant, bien que le package fonctionne (installation, désinstallation, sauvegarde, restauration...), il n'est pas intégré avec domoticz et mosquitto, les paramétrages doivent être fait manuellement depuis l'application.
Pendant l'installation, la totalité de l'application doit être recompilé en utilisant yarn : cela amène à des temps d'installation très long. Un fichier de swap temporaire sera créé si moins de 2Go de mémoire sont disponibles (RAM + swap): Assurez vous d'avoir suffisament d'espace disque.

1
doc/POST_INSTALL.md Normal file
View file

@ -0,0 +1 @@
Follow the [quick start guide](https://zwave-js.github.io/zwave-js-ui/#/getting-started/quick-start?id=minimum-settings) to integrate Zwave-JS-UI in home Assistant or Domotizc.

1
doc/POST_INSTALL_fr.md Normal file
View file

@ -0,0 +1 @@
Suivez le [guide d'installation rapide](https://zwave-js.github.io/zwave-js-ui/#/getting-started/quick-start?id=minimum-settings) pour intégrer Zwave-JS-UI avec Home Assistant ou Domoticz.

6
doc/PRE_INSTALL.md Normal file
View file

@ -0,0 +1,6 @@
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)

6
doc/PRE_INSTALL_fr.md Normal file
View file

@ -0,0 +1,6 @@
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)

View file

@ -1,53 +0,0 @@
{
"name": "Zwave-JS-UI",
"id": "zwave-js-ui",
"packaging_format": 1,
"description": {
"en": "Full featured Z-Wave Control Panel and MQTT Gateway integrated with domoticz",
"fr": "Panneau de controle Z-Wave et MQTT intégré avec Domoticz"
},
"version": "8.8.6~ynh1",
"url": "https://github.com/zwave-js/zwave-js-ui",
"upstream": {
"license": "MIT",
"website": "https://zwave-js.github.io/zwave-js-ui/#/",
"admindoc": "https://zwave-js.github.io/zwave-js-ui/#/",
"userdoc": "https://www.domoticz.com/wiki/Zwave-JS-UI",
"code": "https://github.com/zwave-js/zwave-js-ui"
},
"license": "MIT",
"maintainer": {
"name": "Krakinou",
"email": "misterl56@hotmail.com"
},
"requirements": {
"yunohost": ">= 11.0.0"
},
"multi_instance": false,
"services": [
"domoticz"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/zwavejsui",
"default": "/zwavejsui"
},
{
"name": "is_public",
"type": "boolean",
"default": false,
"help": {
"en": "If set public, anyone can access the app without login in yunohost, you activate password protected login from within the app",
"fr": "Si publique, N'importe qui peut accéder à l'application sans se connecter à yunohost, vous pouvez cependant activer une connection par mot de passe depuis l'application"
}
}
]
}
}

53
manifest.toml Normal file
View file

@ -0,0 +1,53 @@
packaging_format = 2
id = "zwave-js-ui"
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.8.6~ynh2"
maintainers = ["Krakinou"]
[upstream]
license = "MIT"
website = "https://zwave-js.github.io/zwave-js-ui/#/"
admindoc = "https://zwave-js.github.io/zwave-js-ui/#/"
userdoc = "https://www.domoticz.com/wiki/Zwave-JS-UI"
code = "https://github.com/zwave-js/zwave-js-ui"
fund = "https://liberapay.com/robertsLando/donate"
[integration]
yunohost = ">= 11.1.11"
architectures = "all"
multi_instance = false
ldap = "not_relevant"
sso = "not_relevant"
disk = "650M"
ram.build = "2G"
ram.runtime = "50M"
[install]
[install.domain]
type = "domain"
[install.path]
type = "path"
default = "/zwavejsui"
[install.init_main_permission]
help.en = "If set public, anyone can access the app without login in YunoHost, you activate password protected login from within the app"
help.fr = "Si publique, N'importe qui peut accéder à l'application sans se connecter à YunoHost, vous pouvez cependant activer une connection par mot de passe depuis l'application"
type = "group"
default = "all_users"
[resources]
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.ports]
main.default = 8091

View file

@ -10,43 +10,16 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
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
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
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)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
ynh_print_info --message="Declaring files to be backed up..." 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 # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
@ -54,13 +27,6 @@ ynh_backup --src_path="$final_path"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
#ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
#ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#================================================= #=================================================

View file

@ -9,50 +9,11 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
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
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=4
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
#================================================= #=================================================
# 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="Adding swap if needed for compiling..." 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
@ -66,24 +27,12 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then
fi fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port
port=$(ynh_find_port --port=8091)
ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." --weight=1 ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user usermod -d $install_dir $app
ynh_system_user_create --username=$app --home_dir="$final_path"
if grep dialout -q < /etc/group; then if grep dialout -q < /etc/group; then
usermod -a -G dialout "$app" usermod -a -G dialout "$app"
@ -99,7 +48,7 @@ fi
#================================================= #=================================================
# INSTALL EXTRA DEPENDENCIES # INSTALL EXTRA DEPENDENCIES
#================================================= #=================================================
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
@ -110,20 +59,19 @@ ynh_exec_warn_less $ynh_npm install ---global yarn
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=8 ynh_script_progression --message="Setting up source files..." --weight=8
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$install_dir"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app: "$final_path" 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 "$final_path" 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
@ -142,17 +90,16 @@ pushd "$final_path"
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 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app: "$final_path" chown -R $app: "$install_dir"
#================================================= #=================================================
# REMOVE ADDITIONNAL SWAP # REMOVE ADDITIONNAL SWAP
#================================================= #=================================================
ynh_script_progression --message="Remove additionnal swap..." --weight=2
if [ $swap_needed > 0 ]; then if [ $swap_needed > 0 ]; then
ynh_script_progression --message="Remove additionnal swap..." --weight=2
ynh_del_swap ynh_del_swap
fi fi
#================================================= #=================================================
@ -163,38 +110,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# ADD A CONFIGURATION
#=================================================
#ynh_script_progression --message="Adding a configuration file..." --weight=1
### You can add specific configuration files.
###
### Typically, put your template conf file in ../conf/your_config_file
### The template may contain strings such as __FOO__ or __FOO_BAR__,
### which will automatically be replaced by the values of $foo and $foo_bar
###
### ynh_add_config will also keep track of the config file's checksum,
### which later during upgrade may allow to automatically backup the config file
### if it's found that the file was manually modified
###
### Check the documentation of `ynh_add_config` for more info.
######ynh_add_config --template="some_config_file" --destination="$final_path/some_config_file"
# FIXME: this should be handled by the core in the future
# You may need to use chmod 600 instead of 400,
# for example if the app is expected to be able to modify its own config
#######chmod 400 "$final_path/some_config_file"
#######chown $app:$app "$final_path/some_config_file"
### For more complex cases where you want to replace stuff using regexes,
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
### When doing so, you also need to manually call ynh_store_file_checksum
###
### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/some_config_file"
### ynh_store_file_checksum --file="$final_path/some_config_file"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
@ -203,27 +118,6 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=2
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
### Use these lines only if the app installation needs to be finalized through
### web forms. We generally don't want to ask the final user,
### so we're going to use curl to automatically fill the fields and submit the
### forms.
# Set the app as temporarily public for curl call
#####ynh_script_progression --message="Configuring SSOwat..." --weight=1
# Making the app public for curl
#####ynh_permission_update --permission="main" --add="visitors"
# Installation with curl
#####ynh_script_progression --message="Finalizing installation..." --weight=1
#####ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
# Remove the public access
####ynh_permission_update --permission="main" --remove="visitors"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
@ -249,34 +143,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --line_match="Listening on port" -t 30 --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --line_match="Listening on port" -t 30 --log_path="/var/log/$app/$app.log"
#=================================================
# SETUP FAIL2BAN
#=================================================
#ynh_script_progression --message="Configuring Fail2Ban..." --weight=1
# Create a dedicated Fail2Ban config
#ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=5
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -9,17 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
@ -33,85 +22,23 @@ then
yunohost service remove $app yunohost service remove $app
fi fi
#================================================= ynh_script_progression --message="Removing various system files..." --weight=1
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
ynh_remove_nodejs ynh_remove_nodejs
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE ADDITIONNAL SWAP
#=================================================
#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
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
#=================================================
#ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=1
# Remove the dedicated Fail2Ban config
#ynh_remove_fail2ban_config
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..." --weight=1
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=7
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression --message="Removal of $app completed" --last

View file

@ -10,46 +10,12 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
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
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
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)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
if grep dialout -q < /etc/group; then if grep dialout -q < /etc/group; then
usermod -a -G dialout "$app" usermod -a -G dialout "$app"
fi fi
@ -63,7 +29,7 @@ fi
#================================================= #=================================================
# INSTALL EXTRA DEPENDENCIES # INSTALL EXTRA DEPENDENCIES
#================================================= #=================================================
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
@ -74,7 +40,7 @@ ynh_exec_warn_less $ynh_npm install ---global yarn
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
# FIXME: this should be managed by the core in the future # FIXME: this should be managed by the core in the future
# Here, as a packager, you may have to tweak the ownerhsip/permissions # Here, as a packager, you may have to tweak the ownerhsip/permissions
@ -82,53 +48,22 @@ ynh_restore_file --origin_path="$final_path"
# files in some cases. # files in some cases.
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - # 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. # this will be treated as a security issue.
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app: "$final_path" chown -R $app: "$install_dir"
#================================================= ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
# RESTORE FAIL2BAN CONFIGURATION
#=================================================
#ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=1
#ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
#ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
#ynh_systemd_action --action=restart --service_name=fail2ban
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# RESTORE THE LOG FILE DIRECTORY
#=================================================
mkdir -p /var/log/$app mkdir -p /var/log/$app
chown -R $app:$app /var/log/$app chown -R $app:$app /var/log/$app
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Zwave integration in domoticz" --log="/var/log/$app/$app.log" yunohost service add $app --description="Zwave integration in domoticz" --log="/var/log/$app/$app.log"
#================================================= #=================================================

View file

@ -9,38 +9,12 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
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)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
upgrade_type=$(ynh_check_app_version_changed) 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)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -59,17 +33,19 @@ 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
ynh_script_progression --message="Adding swap if needed for compiling..." if [ "$upgrade_type" == "UPGRADE_APP" ]; then
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
#================================================= #=================================================
@ -77,9 +53,6 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
if grep dialout -q < /etc/group; then if grep dialout -q < /etc/group; then
usermod -a -G dialout "$app" usermod -a -G dialout "$app"
fi fi
@ -93,7 +66,7 @@ fi
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
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
@ -108,14 +81,14 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$install_dir"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app: "$final_path" chown -R $app: "$install_dir"
ynh_script_progression --message="Building from sources..." --weight=15 ynh_script_progression --message="Building from sources..." --weight=15
pushd "$final_path" 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
@ -134,22 +107,22 @@ then
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 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app: "$final_path" chown -R $app: "$install_dir"
fi fi
#================================================= #=================================================
# REMOVE ADDITIONNAL SWAP # REMOVE ADDITIONNAL SWAP
#================================================= #=================================================
ynh_script_progression --message="Remove additionnal swap..." --weight=2 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_del_swap ynh_del_swap
fi
fi fi
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -158,37 +131,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# ...
#=================================================
#=================================================
# UPDATE A CONFIG FILE
#=================================================
#ynh_script_progression --message="Updating a configuration file..." --weight=1
### Same as during install
###
### The file will automatically be backed-up if it's found to be manually modified (because
### ynh_add_config keeps track of the file's checksum)
#ynh_add_config --template="some_config_file" --destination="$final_path/some_config_file"
# FIXME: this should be handled by the core in the future
# You may need to use chmod 600 instead of 400,
# for example if the app is expected to be able to modify its own config
#chmod 400 "$final_path/some_config_file"
#chown $app:$app "$final_path/some_config_file"
### For more complex cases where you want to replace stuff using regexes,
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
### When doing so, you also need to manually call ynh_store_file_checksum
###
### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/some_config_file"
### ynh_store_file_checksum --file="$final_path/some_config_file"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
@ -221,21 +163,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --line_match="Listening on port" -t 30 --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --line_match="Listening on port" -t 30 --log_path="/var/log/$app/$app.log"
#=================================================
# UPGRADE FAIL2BAN
#=================================================
#ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1
# Create a dedicated Fail2Ban config
#ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

5
tests.toml Normal file
View file

@ -0,0 +1,5 @@
test_format = 1.0
[default]
test_upgrade_from.e4968ad.name = "Upgrade from 8.8.6~ynh1"
test_upgrade_from.9164618.name = "Upgrade from 8.8.5~ynh1"