mirror of
https://github.com/YunoHost-Apps/zwave-js-ui_ynh.git
synced 2024-09-03 18:06:00 +02:00
Initial Commit to v2 packaging
This commit is contained in:
parent
3b25262979
commit
c471908c1d
16 changed files with 127 additions and 520 deletions
|
@ -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&
|
|
@ -8,7 +8,7 @@ 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=__FINALPATH__/
|
||||
WorkingDirectory=__INSTALL_DIR__/
|
||||
ExecStart=env __YNH_NODE_LOAD_PATH__ yarn start
|
||||
StandardOutput=append:/var/log/__APP__/__APP__.log
|
||||
StandardError=inherit
|
||||
|
@ -45,3 +45,4 @@ CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
|
|||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
|
|
|
@ -5,8 +5,3 @@ 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
|
||||
- [domoticz package](https://github.com/YunoHost-Apps/domoticz_ynh) with **mqtt broker Mosquitto**
|
||||
- or [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.
|
|
@ -5,8 +5,3 @@ 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:
|
||||
- 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)
|
||||
|
||||
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.
|
||||
|
|
1
doc/POST_INSTALL.md
Normal file
1
doc/POST_INSTALL.md
Normal 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
1
doc/POST_INSTALL_fr.md
Normal 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
6
doc/PRE_INSTALL.md
Normal 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**
|
||||
- or [Home-Assistant package](https://github.com/YunoHost-Apps/homeassistant_ynh)
|
6
doc/PRE_INSTALL_fr.md
Normal file
6
doc/PRE_INSTALL_fr.md
Normal 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)
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
55
manifest.toml
Normal file
55
manifest.toml
Normal file
|
@ -0,0 +1,55 @@
|
|||
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" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
|
||||
multi_instance = false
|
||||
ldap = "not_relevant"
|
||||
sso = "not_relevant"
|
||||
disk = "650M"
|
||||
ram.build = "2G"
|
||||
ram.runtime = "50M"
|
||||
|
||||
[install]
|
||||
[install.domain]
|
||||
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||
type = "domain"
|
||||
|
||||
[install.path]
|
||||
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||
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 = false
|
||||
|
||||
[resources]
|
||||
[resources.system_user]
|
||||
|
||||
[resources.install_dir]
|
||||
|
||||
[resources.permissions]
|
||||
main.url = "/"
|
||||
|
||||
[resources.ports]
|
||||
main.default = 8091
|
|
@ -10,43 +10,16 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
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
|
||||
#=================================================
|
||||
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
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# 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"
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
|
|
158
scripts/install
158
scripts/install
|
@ -9,50 +9,11 @@
|
|||
source _common.sh
|
||||
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
|
||||
#=================================================
|
||||
#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)
|
||||
swap_needed=0
|
||||
|
@ -66,24 +27,12 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
|||
|
||||
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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
usermod -d $install_dir $app
|
||||
|
||||
if grep dialout -q < /etc/group; then
|
||||
usermod -a -G dialout "$app"
|
||||
|
@ -99,7 +48,7 @@ fi
|
|||
#=================================================
|
||||
# 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_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_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app: "$final_path"
|
||||
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
|
||||
|
||||
pushd "$final_path"
|
||||
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
|
||||
|
@ -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
|
||||
popd
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app: "$final_path"
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app: "$install_dir"
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE ADDITIONNAL SWAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Remove additionnal swap..." --weight=2
|
||||
|
||||
if [ $swap_needed > 0 ]; then
|
||||
ynh_script_progression --message="Remove additionnal swap..." --weight=2
|
||||
ynh_del_swap
|
||||
fi
|
||||
#=================================================
|
||||
|
@ -163,38 +110,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2
|
|||
# Create a dedicated 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
|
||||
#=================================================
|
||||
|
@ -203,27 +118,6 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=2
|
|||
# Create a dedicated 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
|
||||
#=================================================
|
||||
|
@ -249,34 +143,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|||
# 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"
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
|
|
|
@ -9,17 +9,6 @@
|
|||
source _common.sh
|
||||
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
|
||||
#=================================================
|
||||
|
@ -33,85 +22,23 @@ then
|
|||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
||||
ynh_script_progression --message="Removing various system files..." --weight=1
|
||||
|
||||
# Remove the dedicated 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
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||
|
||||
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
|
||||
if [ -e /swap_$app ]; then
|
||||
ynh_script_progression --message="Remove additionnal swap..." --weight=2
|
||||
ynh_del_swap
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated 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
|
||||
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
|
|
@ -10,46 +10,12 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
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
|
||||
#=================================================
|
||||
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
|
||||
usermod -a -G dialout "$app"
|
||||
fi
|
||||
|
@ -63,7 +29,7 @@ fi
|
|||
#=================================================
|
||||
# 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_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_restore_file --origin_path="$final_path"
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
# FIXME: this should be managed by the core in the future
|
||||
# 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.
|
||||
# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder -
|
||||
# this will be treated as a security issue.
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app: "$final_path"
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app: "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# 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_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
|
||||
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"
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOG FILE DIRECTORY
|
||||
#=================================================
|
||||
mkdir -p /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"
|
||||
|
||||
#=================================================
|
||||
|
|
111
scripts/upgrade
111
scripts/upgrade
|
@ -9,38 +9,12 @@
|
|||
source _common.sh
|
||||
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
|
||||
#=================================================
|
||||
|
||||
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
|
||||
#=================================================
|
||||
|
@ -59,17 +33,19 @@ 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
|
||||
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)
|
||||
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
|
||||
fi
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -77,9 +53,6 @@ fi
|
|||
#=================================================
|
||||
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
|
||||
usermod -a -G dialout "$app"
|
||||
fi
|
||||
|
@ -93,7 +66,7 @@ fi
|
|||
#=================================================
|
||||
# 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_use_nodejs
|
||||
|
@ -108,14 +81,14 @@ then
|
|||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
|
||||
# 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 -R o-rwx "$final_path"
|
||||
chown -R $app: "$final_path"
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app: "$install_dir"
|
||||
|
||||
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_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
|
||||
|
@ -134,22 +107,22 @@ then
|
|||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean 2>&1
|
||||
popd
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app: "$final_path"
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app: "$install_dir"
|
||||
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE ADDITIONNAL SWAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Remove additionnal swap..." --weight=2
|
||||
|
||||
if [ $swap_needed > 0 ]; then
|
||||
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
|
||||
#=================================================
|
||||
|
@ -158,37 +131,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
|
|||
# Create a dedicated 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
|
||||
#=================================================
|
||||
|
@ -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"
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
|
|
5
tests.toml
Normal file
5
tests.toml
Normal 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"
|
Loading…
Reference in a new issue