From 59aacd614f6737a537152fdbd2175731a3b481df Mon Sep 17 00:00:00 2001 From: Krakinou Date: Mon, 20 Feb 2023 22:22:42 +0100 Subject: [PATCH 01/51] Initial conversion from script --- conf/systemd.service | 25 +++++------ manifest.toml | 72 ++++++++++++++++++++++++++++++ scripts/_common.sh | 6 +-- scripts/backup | 18 ++++---- scripts/install | 94 ++++++++++++++++++++-------------------- scripts/remove | 26 +++++------ scripts/restore | 46 ++++++++++---------- scripts/upgrade | 101 ++++++++++++++++++++++--------------------- 8 files changed, 230 insertions(+), 158 deletions(-) create mode 100644 manifest.toml diff --git a/conf/systemd.service b/conf/systemd.service index 9d04cef..d40db54 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -5,34 +5,33 @@ After=network.target [Service] User=__APP__ Group=__APP__ -ExecStart=__FINALPATH__/domoticz -www __PORT__ -sslwww 0 -log /var/log/__APP__/__APP__.log -loglevel normal,status,error -WorkingDirectory=__FINALPATH__/ +ExecStart=__INSTALL_DIR__/domoticz -www __PORT__ -sslwww 0 -log /var/log/__APP__/__APP__.log -loglevel normal,status,error +WorkingDirectory=__INSTALL_DIR__/ PermissionsStartOnly=true -ExecStartPre=setcap 'cap_net_bind_service=+ep cap_net_raw=+eip' __FINALPATH__/domoticz +ExecStartPre=setcap 'cap_net_bind_service=+ep cap_net_raw=+eip' __INSTALL_DIR__/domoticz Restart=on-failure RestartSec=1m #StandardOutput=null # Sandboxing options to harden security -# Depending on specificities of your service/app, you may need to tweak these -# .. but this should be a good baseline # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html -NoNewPrivileges=yes +# Most of the options are disabled as they prevent domoticz to correctly update +#NoNewPrivileges=yes PrivateTmp=yes #Private device restrict access to device in /dev/, so to any devices like razberry, zigate, etc. #PrivateDevices=yes -RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 -RestrictNamespaces=yes -RestrictRealtime=yes +#RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 +#RestrictNamespaces=yes +#RestrictRealtime=yes #Same : restrict access to devices #DevicePolicy=closed ProtectSystem=full ProtectControlGroups=yes -ProtectKernelModules=yes -ProtectKernelTunables=yes -LockPersonality=yes +#ProtectKernelModules=yes +#ProtectKernelTunables=yes +#LockPersonality=yes #@setuid prevent system call such as ping or other command lines -SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @swap +#SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @swap #SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap # Denying access to capabilities that should not be relevant for webapps diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..27a6209 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,72 @@ +packaging_format = 2 + +id = "domoticz" +name = "Domoticz" +description.en = "Home automation system that lets you monitor and configure miscellaneous devices" +description.fr = "Logiciel de domotique qui vous permet de configurer un grand nombre d'appareils" + +version = "2020.2~ynh8" + +maintainers = ["Krakinou"] + +[upstream] +license = "GPL-3.0-or-later" +website = "https://domoticz.com/" +admindoc = "https://www.domoticz.com/wiki/Main_Page" +userdoc = "https://www.domoticz.com/DomoticzManual.pdf" +code = "https://github.com/domoticz/domoticz" +cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) +fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. + +[integration] +yunohost = ">= 11.0.0" +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 = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. +sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[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 = "/domoticz" + + [install.init_main_permission] + help.fr = "Attention, cette application n'a pas de gestion d'utilisateur par défaut, si vous la mettez public, n importe qui y aura accès!" + help.en = "Beware, there is no user management by default. If it's set as public, anyone will have access!" + type = "group" + default = false + + [install.mqtt_domain] + ask.fr = "Domaine MQTT" + ask.en = "MQTT domain" + help.fr = "Domaine pour le serveur MQTT. Remettez le domaine principal si vous ne souhaitez pas l'utiliser. Lire la documentation pour plus d'informations" + help.en = "MQTT server domain. Set the main domain if you don't wish to use it. See the doc for more info" + type = "domain" + optional = true + +[resources] + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + + [resources.ports] + main.default = 8080 + + [resources.apt] + packages = "libudev-dev, python3-dev, mosquitto, mosquitto-clients, $pkg_dependencies, $add_dep" + + [[resources.apt.extras]] + repo = "deb https://repo.mosquitto.org/debian buster main" + key = "http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" + packages = "#FIXME#$extra_pkg_dependencies \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index abc64c6..b8f6638 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,8 +8,8 @@ #python3-dev required as per https://www.domoticz.com/forum/viewtopic.php?f=65&t=16116&p=119747 #mosquitto and mosquitto-clients are required for mqtt #other dependencies are from standard install script... seems quite useles... -pkg_dependencies="libudev-dev python3-dev" -extra_pkg_dependencies="mosquitto mosquitto-clients" +#REMOVEME? pkg_dependencies="libudev-dev python3-dev" +#REMOVEME? extra_pkg_dependencies="mosquitto mosquitto-clients" default_mqtt_port=1883 default_mqtt_websocket_port=8883 @@ -23,7 +23,7 @@ then else add_dep="libcurl4 libusb-0.1-4" fi; -pkg_dependencies="$pkg_dependencies $add_dep" +#REMOVEME? pkg_dependencies="$pkg_dependencies $add_dep" lowercase(){ echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/" diff --git a/scripts/backup b/scripts/backup index ff2c423..0c62fca 100755 --- a/scripts/backup +++ b/scripts/backup @@ -14,22 +14,22 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting -} +#} # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +#REMOVEME? ynh_print_info --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) -mqtt_domain=$(ynh_app_setting_get --app=$app --key=mqtt_domain) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? mqtt_domain=$(ynh_app_setting_get --app=$app --key=mqtt_domain) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -40,7 +40,7 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/install b/scripts/install index 23e8a5f..6e83340 100755 --- a/scripts/install +++ b/scripts/install @@ -13,42 +13,42 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting -} +#} # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? 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" -mqtt_domain="$YNH_APP_ARG_MQTT_DOMAIN" +#REMOVEME? domain="$YNH_APP_ARG_DOMAIN" +#REMOVEME? path="$YNH_APP_ARG_PATH" +#REMOVEME? is_public="$YNH_APP_ARG_IS_PUBLIC" +#REMOVEME? mqtt_domain="$YNH_APP_ARG_MQTT_DOMAIN" -app="$YNH_APP_INSTANCE_NAME" +#REMOVEME? app="$YNH_APP_INSTANCE_NAME" #Set dedicated variables -if [ "$path_url" == "/" ]; then +if [ "$path" == "/" ]; then api_path=/api_/"$app" else - api_path=/api_"$path_url" + api_path=/api_"$path" fi #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." +#REMOVEME? ynh_script_progression --message="Validating installation parameters..." -final_path=/opt/yunohost/"$app" -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +#REMOVEME? install_dir=/opt/yunohost/"$app" +#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" # Register (book) web path -ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url" +#REMOVEME? ynh_webpath_register --app="$app" --domain="$domain" --path="$path" #impossible de booker plusieurs webpath #if [ ! -z $mqtt_domain ]; then -# ynh_webpath_register --app=mqtt_$app --domain=$mqtt_domain --path_url="/" +#REMOVEME? # ynh_webpath_register --app=mqtt_$app --domain=$mqtt_domain --path="/" #fi if [ "$domain" == "$mqtt_domain" ]; then @@ -58,18 +58,18 @@ fi #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." +#REMOVEME? ynh_script_progression --message="Storing installation settings..." -ynh_app_setting_set --app="$app" --key=domain --value="$domain" -ynh_app_setting_set --app="$app" --key=path --value="$path_url" +#REMOVEME? ynh_app_setting_set --app="$app" --key=domain --value="$domain" +#REMOVEME? ynh_app_setting_set --app="$app" --key=path --value="$path" #Will be used in restore script to check that we're restoring on the same OS/Board type ynh_app_setting_set --app="$app" --key=OS --value="$os" ynh_app_setting_set --app="$app" --key=mach --value="$mach" #path used by api & mqtt to read/update domoticz -ynh_app_setting_set --app="$app" --key=api_path --value="$api_path" -[[ ! -z "$mqtt_domain" ]] && ynh_app_setting_set --app="$app" --key=mqtt_domain --value="$mqtt_domain" +#REMOVEME? ynh_app_setting_set --app="$app" --key=api_path --value="$api_path" +#REMOVEME? [[ ! -z "$mqtt_domain" ]] && ynh_app_setting_set --app="$app" --key=mqtt_domain --value="$mqtt_domain" #================================================= @@ -80,32 +80,32 @@ ynh_app_setting_set --app="$app" --key=api_path --value="$api_path" ynh_script_progression --message="Finding available port..." # Find an available port -port=$(ynh_find_port --port=8080) -ynh_app_setting_set --app="$app" --key=port --value="$port" +#REMOVEME? port=$(ynh_find_port --port=8080) +#REMOVEME? ynh_app_setting_set --app="$app" --key=port --value="$port" if [ ! -z "$mqtt_domain" ]; then ynh_script_progression --message="Finding available ports for Mosquitto..." - mqtt_port=$(ynh_find_port --port="$default_mqtt_port") - ynh_app_setting_set --app="$app" --key=mqtt_port --value="$mqtt_port" +#REMOVEME? mqtt_port=$(ynh_find_port --port="$default_mqtt_port") +#REMOVEME? ynh_app_setting_set --app="$app" --key=mqtt_port --value="$mqtt_port" - mqtt_websocket_port=$(ynh_find_port --port="$default_mqtt_websocket_port") - ynh_app_setting_set --app="$app" --key=mqtt_websocket_port --value="$mqtt_websocket_port" +#REMOVEME? mqtt_websocket_port=$(ynh_find_port --port="$default_mqtt_websocket_port") +#REMOVEME? ynh_app_setting_set --app="$app" --key=mqtt_websocket_port --value="$mqtt_websocket_port" fi #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=15 +#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=15 -ynh_install_app_dependencies "$pkg_dependencies" +#REMOVEME? ynh_install_app_dependencies "$pkg_dependencies" #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." +#REMOVEME? ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username="$app" --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username="$app" --home_dir="$install_dir" #allow user to access USB / serial port to communicate with tools (RFXtrx, Z-wave dongle, etc.) & i2c bus if grep dialout -q < /etc/group; then @@ -127,23 +127,23 @@ chmod 440 /etc/sudoers.d/"$app" #================================================= ynh_script_progression --message="Setting up source files..." --weight=5 -ynh_app_setting_set --app="$app" --key=final_path --value="$final_path" +#REMOVEME? ynh_app_setting_set --app="$app" --key=install_dir --value="$install_dir" # Download, check integrity, uncompress and patch the source from app.src # Create an app.src for the correct version of domoticz # match string are fulfilled in _common.sh via the upstream bash installation script ynh_add_config --template="../conf/app.src.default" --destination="../conf/app.src" -ynh_setup_source --dest_dir="$final_path" +ynh_setup_source --dest_dir="$install_dir" #Create the database file -if [ ! -f "$final_path"/domoticz.db ]; then - touch "$final_path"/domoticz.db - chmod 640 "$final_path"/domoticz.db +if [ ! -f "$install_dir"/domoticz.db ]; then + touch "$install_dir"/domoticz.db + chmod 640 "$install_dir"/domoticz.db fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R "$app":"$app" "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app":"$app" "$install_dir" #================================================= @@ -154,7 +154,7 @@ if [ ! -z "$mqtt_domain" ]; then ynh_script_progression --message="Setting up mosquitto..." --weight=5 #Installing packages - ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian buster main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" +#REMOVEME? ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian buster main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" #Setting up conf file for access ynh_add_config --template="../conf/domoticz_mosquitto.conf" --destination="/etc/mosquitto/conf.d/"$app"_mosquitto.conf" @@ -163,7 +163,7 @@ if [ ! -z "$mqtt_domain" ]; then #Setting up user&pwd for mqtt access ynh_app_setting_set --app="$app" --key=mqtt_user --value=$(ynh_string_random --length=8) ynh_app_setting_set --app="$app" --key=mqtt_pwd --value=$(ynh_string_random) - echo $(ynh_app_setting_get --app="$app" --key=mqtt_user):$(ynh_app_setting_get --app="$app" --key=mqtt_pwd) > "/etc/mosquitto/conf.d/"$app"_credentials" +#REMOVEME? echo $(ynh_app_setting_get --app="$app" --key=mqtt_user):$(ynh_app_setting_get --app="$app" --key=mqtt_pwd) > "/etc/mosquitto/conf.d/"$app"_credentials" mosquitto_passwd -U "/etc/mosquitto/conf.d/"$app"_credentials" ynh_print_info --message="The credential to the mosquitto server has been saved in the settings of the app" @@ -249,27 +249,27 @@ ynh_print_info --message="If you wish for Fail2ban to work, set up your local ad #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." +#REMOVEME? ynh_script_progression --message="Configuring permissions..." # Make app public if necessary -if [ "$is_public" -eq 1 ] +#REMOVEME? 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" +#REMOVEME? ynh_permission_update --permission="main" --add="visitors" fi #API & MQTT should stay publicly accessible. -ynh_permission_create --permission="domoticz_API" --label="api" --url="$domain$api_path" --allowed="visitors" --show_tile="false" --protected="true" -[[ ! -z "$mqtt_domain" ]] && ynh_permission_create --permission="domoticz_MQTT" --label="MQTT" --url="$mqtt_domain" --allowed="visitors" --show_tile="false" --protected="true" +#REMOVEME? ynh_permission_create --permission="domoticz_API" --label="api" --url="$domain$api_path" --allowed="visitors" --show_tile="false" --protected="true" +#REMOVEME? [[ ! -z "$mqtt_domain" ]] && ynh_permission_create --permission="domoticz_MQTT" --label="MQTT" --url="$mqtt_domain" --allowed="visitors" --show_tile="false" --protected="true" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 9304492..376d7df 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,14 +12,14 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -app="$YNH_APP_INSTANCE_NAME" +#REMOVEME? 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) -mqtt_domain=$(ynh_app_setting_get --app="$app" --key=mqtt_domain) +#REMOVEME? domain=$(ynh_app_setting_get --app="$app" --key=domain) +#REMOVEME? port=$(ynh_app_setting_get --app="$app" --key=port) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app="$app" --key=install_dir) +#REMOVEME? mqtt_domain=$(ynh_app_setting_get --app="$app" --key=mqtt_domain) #================================================= # STANDARD REMOVE @@ -57,19 +57,19 @@ fi #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=3 +#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=3 # Remove metapackage and its dependencies [[ ! -z "$mqtt_domain" ]] && ynh_secure_remove --file="/etc/mosquitto/conf.d" -ynh_remove_app_dependencies +#REMOVEME? ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=3 +#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=3 # Remove the app directory securely -ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" #================================================= # REMOVE NGINX CONFIGURATION @@ -122,13 +122,13 @@ ynh_secure_remove --file="/etc/sudoers.d/$app" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." +#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user -ynh_system_user_delete --username="$app" +#REMOVEME? 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 \ No newline at end of file diff --git a/scripts/restore b/scripts/restore index d6e51db..13a9e59 100755 --- a/scripts/restore +++ b/scripts/restore @@ -14,32 +14,32 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting -} +#} # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -app="$YNH_APP_INSTANCE_NAME" +#REMOVEME? 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) -backup_OS=$(ynh_app_setting_get --app="$app" --key=OS) -backup_mach=$(ynh_app_setting_get --app="$app" --key=mach) -mqtt_domain=$(ynh_app_setting_get --app="$app" --key=mqtt_domain) +#REMOVEME? domain=$(ynh_app_setting_get --app="$app" --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app="$app" --key=path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app="$app" --key=install_dir) +#REMOVEME? backup_OS=$(ynh_app_setting_get --app="$app" --key=OS) +#REMOVEME? backup_mach=$(ynh_app_setting_get --app="$app" --key=mach) +#REMOVEME? mqtt_domain=$(ynh_app_setting_get --app="$app" --key=mqtt_domain) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." -test ! -d "$final_path" \ - || ynh_die --message="There is already a directory: $final_path " +#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." +#REMOVEME? test ! -d "$install_dir" \ + || ynh_die --message="There is already a directory: $install_dir " #As we are downloading compiled binaries for each system, we have to check if the restore occurs #on the same system type. If we are restoring on another system type it won't work and in that #case we must go through a reinstall process. @@ -62,10 +62,10 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$mqtt_domain.d/mqtt_$app.conf" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." +#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create --username="$app" --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username="$app" --home_dir="$install_dir" #allow user to access USB / serial port to communicate with tools (RFXtrx, Z-wave dongle, etc.) & i2c bus if grep dialout -q < /etc/group; then @@ -86,21 +86,21 @@ ynh_restore_file --origin_path="/etc/sudoers.d/$app" #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=5 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R "$app":"$app" "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app":"$app" "$install_dir" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=5 +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=5 # Define and install dependencies -ynh_install_app_dependencies "$pkg_dependencies" +#REMOVEME? ynh_install_app_dependencies "$pkg_dependencies" #================================================= # SET MOSQUITTO SETTINGS @@ -109,7 +109,7 @@ if [ ! -z "$mqtt_domain" ]; then ynh_script_progression --message="Reinstalling up mosquitto..." --weight=5 #Installing packages - ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian buster main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" +#REMOVEME? ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian buster main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" #reinstalling settings ynh_restore_file --origin_path="/etc/mosquitto/conf.d" --not_mandatory fi diff --git a/scripts/upgrade b/scripts/upgrade index f2c0390..e165e1b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,20 +16,20 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +#REMOVEME? ynh_script_progression --message="Loading installation settings..." -app="$YNH_APP_INSTANCE_NAME" +#REMOVEME? 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) -current_OS=$(ynh_app_setting_get --app="$app" --key=OS) -current_mach=$(ynh_app_setting_get --app="$app" --key=mach) -api_path=$(ynh_app_setting_get --app="$app" --key=api_path) -mqtt_domain=$(ynh_app_setting_get --app="$app" --key=mqtt_domain) -mqtt_port=$(ynh_app_setting_get --app="$app" --key=mqtt_port) -mqtt_websocket_port=$(ynh_app_setting_get --app="$app" --key=mqtt_websocket_port) +#REMOVEME? domain=$(ynh_app_setting_get --app="$app" --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app="$app" --key=path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app="$app" --key=install_dir) +#REMOVEME? port=$(ynh_app_setting_get --app="$app" --key=port) +#REMOVEME? current_OS=$(ynh_app_setting_get --app="$app" --key=OS) +#REMOVEME? current_mach=$(ynh_app_setting_get --app="$app" --key=mach) +#REMOVEME? api_path=$(ynh_app_setting_get --app="$app" --key=api_path) +#REMOVEME? mqtt_domain=$(ynh_app_setting_get --app="$app" --key=mqtt_domain) +#REMOVEME? mqtt_port=$(ynh_app_setting_get --app="$app" --key=mqtt_port) +#REMOVEME? mqtt_websocket_port=$(ynh_app_setting_get --app="$app" --key=mqtt_websocket_port) #================================================= # CHECK VERSION @@ -41,7 +41,7 @@ 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)..." +#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Ugly hack so that previous version backup script from "https://github.com/anubister/domoticz_ynh" works : # It creates a dummy file in /etc/cron.d so that the backup do not fail. @@ -52,12 +52,12 @@ if version_gt "4.9701" "$current_upstream_version" && version_gt "2" "$current_p fi # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting # Restore it if the upgrade fails - ynh_restore_upgradebackup -} +#REMOVEME? ynh_restore_upgradebackup +#} #remove ugly hack if [ -f /etc/cron.d/"$app" ]; then @@ -65,7 +65,7 @@ if [ -f /etc/cron.d/"$app" ]; then fi # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS @@ -89,20 +89,20 @@ if [ -z "$current_mach" ]; then ynh_app_setting_set --app="$app" --key=mach --value="$MACH" fi -# If final_path doesn't exist, create it -if [ -z "$final_path" ]; then - final_path=/var/www/"$app" - ynh_app_setting_set --app="$app" --key=final_path --value="$final_path" +# If install_dir doesn't exist, create it +if [ -z "$install_dir" ]; then +#REMOVEME? install_dir=/var/www/"$app" +#REMOVEME? ynh_app_setting_set --app="$app" --key=install_dir --value="$install_dir" fi #Create a dedicated path for the api access if [ -z "$api_path" ]; then - if [ "$path_url" == "/" ]; then + if [ "$path" == "/" ]; then api_path=/api_/"$app" else - api_path=/api_"$path_url" + api_path=/api_"$path" fi - ynh_app_setting_set --app="$app" --key=api_path --value="$api_path" +#REMOVEME? ynh_app_setting_set --app="$app" --key=api_path --value="$api_path" fi #Create a dedicated path for the mqtt access @@ -112,38 +112,39 @@ fi #Port to listen for MQTT internal if [[ -z "$mqtt_port" && ! -z "$mqtt_domain" ]]; then - mqtt_port=$(ynh_find_port --port="$default_mqtt_port") - ynh_app_setting_set --app="$app" --key=mqtt_port --value="$mqtt_port" +#REMOVEME? mqtt_port=$(ynh_find_port --port="$default_mqtt_port") +#REMOVEME? ynh_app_setting_set --app="$app" --key=mqtt_port --value="$mqtt_port" fi #Port to listen for MQTT websocket if [[ -z "$mqtt_websocket_port" && ! -z "$mqtt_domain" ]]; then - mqtt_websocket_port=$(ynh_find_port --port="$default_mqtt_websocket_port") - ynh_app_setting_set --app="$app" --key=mqtt_websocket_port --value="$mqtt_websocket_port" +#REMOVEME? mqtt_websocket_port=$(ynh_find_port --port="$default_mqtt_websocket_port") +#REMOVEME? ynh_app_setting_set --app="$app" --key=mqtt_websocket_port --value="$mqtt_websocket_port" fi + # Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all +#REMOVEME? if ynh_legacy_permissions_exists; then +#REMOVEME? ynh_legacy_permissions_delete_all ynh_app_setting_delete --app="$app" --key=is_public fi # Create the permission "domoticz_API" only if it doesn't exist. -if ! ynh_permission_exists --permission="domoticz_API" +#REMOVEME? if ! ynh_permission_exists --permission="domoticz_API" then # API Authorization with dedicated URL - ynh_permission_create --permission="domoticz_API" --label="api" --url="$domain$api_path" --allowed="visitors" --show_tile="false" --protected="true" +#REMOVEME? ynh_permission_create --permission="domoticz_API" --label="api" --url="$domain$api_path" --allowed="visitors" --show_tile="false" --protected="true" fi # Create the permission "domoticz_MQTT" only if it doesn't exist. if [ ! -z "$mqtt_domain" ]; then - if ! ynh_permission_exists --permission="domoticz_MQTT" +#REMOVEME? if ! ynh_permission_exists --permission="domoticz_MQTT" then # API Authorization with dedicated URL - ynh_permission_create --permission="domoticz_MQTT" --label="MQTT" --url="$mqtt_domain" --allowed="visitors" --show_tile="false" --protected="true" +#REMOVEME? ynh_permission_create --permission="domoticz_MQTT" --label="MQTT" --url="$mqtt_domain" --allowed="visitors" --show_tile="false" --protected="true" fi fi @@ -155,10 +156,10 @@ fi #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." +#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) -ynh_system_user_create --username="$app" --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username="$app" --home_dir="$install_dir" #allow user to access USB / serial port to communicate with tools (RFXtrx, Z-wave dongle, etc.) & i2c bus if grep dialout -q < /etc/group; then @@ -185,17 +186,17 @@ then # Download, check integrity, uncompress and patch the source from app.src ynh_add_config --template="../conf/app.src.default" --destination="../conf/app.src" - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$install_dir" #Create the database file - if [ ! -f "$final_path"/domoticz.db ]; then - touch "$final_path"/domoticz.db - chmod 644 "$final_path"/domoticz.db + if [ ! -f "$install_dir"/domoticz.db ]; then + touch "$install_dir"/domoticz.db + chmod 644 "$install_dir"/domoticz.db fi fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R "$app":"$app" "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app":"$app" "$install_dir" #================================================= # SET MOSQUITTO SETTINGS @@ -204,7 +205,7 @@ if [ ! -z "$mqtt_domain" ]; then ynh_script_progression --message="Setting up mosquitto..." --weight=5 #Installing packages - ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian buster main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" +#REMOVEME? ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian buster main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" #Setting up conf file for access if [ ! -f "/etc/mosquitto/conf.d/"$app"_mosquitto.conf" ] @@ -215,7 +216,7 @@ if [ ! -z "$mqtt_domain" ]; then #Setting up user&pwd for mqtt access ynh_app_setting_set --app="$app" --key=mqtt_user --value=$(ynh_string_random --length=8) ynh_app_setting_set --app="$app" --key=mqtt_pwd --value=$(ynh_string_random) - echo $(ynh_app_setting_get --app="$app" --key=mqtt_user):$(ynh_app_setting_get --app="$app" --key=mqtt_pwd) > "/etc/mosquitto/conf.d/"$app"_credentials" +#REMOVEME? echo $(ynh_app_setting_get --app="$app" --key=mqtt_user):$(ynh_app_setting_get --app="$app" --key=mqtt_pwd) > "/etc/mosquitto/conf.d/"$app"_credentials" mosquitto_passwd -U "/etc/mosquitto/conf.d/"$app"_credentials" ynh_print_info --message="The credential to the mosquitto server has been saved in the settings of the app" @@ -245,9 +246,9 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=5 +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=5 -ynh_install_app_dependencies "$pkg_dependencies" +#REMOVEME? ynh_install_app_dependencies "$pkg_dependencies" #================================================= # SPECIFIC UPGRADE @@ -310,9 +311,9 @@ ynh_systemd_action --service_name="$app" --action="start" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT From 2ecdcddb9663248169fcb4441b1ad9f22fae2dc4 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 20 Feb 2023 21:22:47 +0000 Subject: [PATCH 02/51] Auto-update README --- README.md | 3 ++- README_fr.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c466a4f..7f0f56e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ It shall NOT be edited by hand. # Domoticz for YunoHost -[![Integration level](https://dash.yunohost.org/integration/domoticz.svg)](https://dash.yunohost.org/appci/app/domoticz) ![Working status](https://ci-apps.yunohost.org/ci/badges/domoticz.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/domoticz.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/domoticz.svg)](https://dash.yunohost.org/appci/app/domoticz) ![Working status](https://ci-apps.yunohost.org/ci/badges/domoticz.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/domoticz.maintain.svg) + [![Install Domoticz with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=domoticz) *[Lire ce readme en français.](./README_fr.md)* diff --git a/README_fr.md b/README_fr.md index 9cdde37..db2d3bd 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,7 +5,8 @@ It shall NOT be edited by hand. # Domoticz pour YunoHost -[![Niveau d’intégration](https://dash.yunohost.org/integration/domoticz.svg)](https://dash.yunohost.org/appci/app/domoticz) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/domoticz.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/domoticz.maintain.svg) +[![Niveau d’intégration](https://dash.yunohost.org/integration/domoticz.svg)](https://dash.yunohost.org/appci/app/domoticz) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/domoticz.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/domoticz.maintain.svg) + [![Installer Domoticz avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=domoticz) *[Read this readme in english.](./README.md)* From fdda287acf4649d7531562c4b820ff27df5b42f8 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Mon, 27 Feb 2023 23:24:05 +0100 Subject: [PATCH 03/51] convert to v2 --- check_process | 54 ---------- conf/sudoer | 14 --- conf/systemd.service | 20 ++-- doc/ADMIN.md | 90 ++++++++++++++++ doc/ADMIN_fr.md | 91 ++++++++++++++++ doc/DESCRIPTION.md | 94 +--------------- doc/DESCRIPTION_fr.md | 91 ---------------- doc/{DISCLAIMER_fr.md => POST_INSTALL_fr.md} | 1 - doc/{DISCLAIMER.md => POST_INTALL.md} | 3 +- doc/PRE_INSTALL.md | 5 + doc/PRE_INSTALL_fr.md | 5 + manifest.json | 68 ------------ manifest.toml | 46 ++++---- scripts/_common.sh | 16 +-- scripts/backup | 22 ---- scripts/install | 95 +++------------- scripts/remove | 108 +++---------------- scripts/restore | 53 ++------- scripts/upgrade | 99 +++-------------- sources/patches/app-index.html.patch | 32 ++++++ tests.toml | 38 +++++++ 21 files changed, 348 insertions(+), 697 deletions(-) delete mode 100644 check_process delete mode 100644 conf/sudoer create mode 100644 doc/ADMIN.md create mode 100644 doc/ADMIN_fr.md rename doc/{DISCLAIMER_fr.md => POST_INSTALL_fr.md} (98%) rename doc/{DISCLAIMER.md => POST_INTALL.md} (97%) create mode 100644 doc/PRE_INSTALL.md create mode 100644 doc/PRE_INSTALL_fr.md delete mode 100644 manifest.json create mode 100644 sources/patches/app-index.html.patch create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index 46b58c6..0000000 --- a/check_process +++ /dev/null @@ -1,54 +0,0 @@ -;; Test avec Mosquitto - ; pre-install - set -euxo pipefail - yunohost domain add mqtt.domain.tld - ; pre-upgrade - set -euxo pipefail - yunohost app setting domoticz mqtt_domain -v mqtt.domain.tld - ; Manifest - domain="domain.tld" (DOMAIN) - path="/domoticz" (PATH) - is_public=1 (PUBLIC|public=1|private=0) - mqtt_domain="mqtt.domain.tld" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_private=1 - setup_public=1 - upgrade=1 - upgrade=1 from_commit=048ae59a016755b0829a4e8f3ed5d0dbbd1b826b - backup_restore=1 - port_already_use=1 - change_url=1 -;;; Options -Email=nicolas@aubonalbanais.ovh -Notification=none -;;; Upgrade options - ; commit=048ae59a016755b0829a4e8f3ed5d0dbbd1b826b - name=Package ynh3 - -##;; Test sans Mosquitto -## ; Manifest -## domain="domain.tld" (DOMAIN) -## path="/domoticz" (PATH) -## is_public=1 (PUBLIC|public=1|private=0) -## mqtt_domain="sub.domain.tld" -## ; Checks -## pkg_linter=0 -## setup_sub_dir=1 -## setup_root=1 -## setup_private=1 -## setup_public=1 -## upgrade=1 -## upgrade=1 from_commit=048ae59a016755b0829a4e8f3ed5d0dbbd1b826b -## backup_restore=1 -## port_already_use=1 -## change_url=1 -##;;; Options -##Email=nicolas@aubonalbanais.ovh -##Notification=none -##;;; Upgrade options -## ; commit=048ae59a016755b0829a4e8f3ed5d0dbbd1b826b -## name=Package ynh3 - diff --git a/conf/sudoer b/conf/sudoer deleted file mode 100644 index 09e5800..0000000 --- a/conf/sudoer +++ /dev/null @@ -1,14 +0,0 @@ -# -# This file MUST be edited with the 'visudo' command as root. -# -# Use 'visudo -f /etc/sudoers.d/domoticz' to do so. -# -# See the man page for details on how to write a sudoers file. - -#This file allow domoticz user to restart the service while upgrading the application with the upstream internal updater - -#alias for command to restart service (will be used during upgrade) -Cmnd_Alias RESTART_CMD = /sbin/service __APP__.sh restart - -#authorized app user to run restart command -__APP__ ALL=(ALL) NOPASSWD: RESTART_CMD \ No newline at end of file diff --git a/conf/systemd.service b/conf/systemd.service index d40db54..f9dc6fb 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,31 +7,29 @@ User=__APP__ Group=__APP__ ExecStart=__INSTALL_DIR__/domoticz -www __PORT__ -sslwww 0 -log /var/log/__APP__/__APP__.log -loglevel normal,status,error WorkingDirectory=__INSTALL_DIR__/ -PermissionsStartOnly=true -ExecStartPre=setcap 'cap_net_bind_service=+ep cap_net_raw=+eip' __INSTALL_DIR__/domoticz +ExecStartPre=+setcap 'cap_net_bind_service=+ep cap_net_raw=+eip' __INSTALL_DIR__/domoticz Restart=on-failure RestartSec=1m #StandardOutput=null # Sandboxing options to harden security # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html -# Most of the options are disabled as they prevent domoticz to correctly update -#NoNewPrivileges=yes +NoNewPrivileges=yes PrivateTmp=yes #Private device restrict access to device in /dev/, so to any devices like razberry, zigate, etc. #PrivateDevices=yes -#RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 -#RestrictNamespaces=yes -#RestrictRealtime=yes +RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 +RestrictNamespaces=yes +RestrictRealtime=yes #Same : restrict access to devices #DevicePolicy=closed ProtectSystem=full ProtectControlGroups=yes -#ProtectKernelModules=yes -#ProtectKernelTunables=yes -#LockPersonality=yes +ProtectKernelModules=yes +ProtectKernelTunables=yes +LockPersonality=yes #@setuid prevent system call such as ping or other command lines -#SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @swap +SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @swap #SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap # Denying access to capabilities that should not be relevant for webapps diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..e7da649 --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1,90 @@ +## Configuration + +### Broker Mosquitto + +During installation, a [MQTT](https://en.wikipedia.org/wiki/MQTT) broker, [Mosquitto](https://mosquitto.org/), is installed at the same time as Domoticz. The installed version is the one from the official project repo and not from Debian ones. +This broker requires a dedicated domain or subdomain to work (ex : mqtt.your.domain.tld) : creating this domain prior installation is a prerequisite + +#### Adding in domoticz + +To use mosquitto, you need to customize the communication between domoticz and the broker by following the [domoticz documentation](https://www.domoticz.com/wiki/MQTT#Installing_Mosquitto), part *Add hardware "MQTT Client Gateway"*. +User and password are automatically generated during installation, you may retrieve them with +```` +sudo yunohost app setting domoticz mqtt_user +sudo yunohost app setting domoticz mqtt_pwd +```` + +#### Publish/Subscribe + +By default, mosquitto will listen on 2 ports: +- 1883 on localhost using mqtt protocol +- 8883 using websocket protocol. Nginx redirect external port 443 to this internal port. + +Hence, To publish/subscribe on a topic from the outside, you have to use a software supporting websocket protocol (ex : paho python library). + +#### Mosquitto_pub et mosquitto_sub + +These 2 tools do not support websocket protocol, only direct mqtt: base settings will not allow communication from an outside device. +If you're using them directly from your server, this kind of syntax should work: +```` +mosquitto_pub -u *user* -P *password* -h mqtt.your.domain.tld -p 1883 -t 'domoticz/in' -m '{ "idx" : 1, "nvalue" : 0, "svalue" : "25.0" }' +```` +In the same way: +```` +mosquitto_sub -u *user* -P *password* -h mqtt.your.domain.tld -p 1883 -t 'domoticz/out' +```` + +If you wish to open direct mqtt protocol from an outside device, you'll need to: +- open port 1883 on Yunohost firewall (**Attention, security risk**) +- Allows IP addresses in mosquitto configuration for this listener +- Set the tls setting in mosquitto configuration by giving access to crt.pem and key.pem from your mqtt domain by setting respective certfile et keyfile variables. **This is mandatory to ensure a secure connection.** + +#### Upgrade from version without mosquitto +If you have package ynh3 or below or if you have chosen to not set a domain during initial installation, mosquitto is not installed by default. +If you need to activate mosquitto in retrospect, do following actions: +1. Create a domain or a subdomain (for example : 'mqtt.your.domain.tld') +2. Connect to your server in command line +3. Type following command : `yunohost app setting domoticz mqtt_domain -v mqtt.your.domain.tld` +4. Upgrade domoticz to last package. +If you're already on the last package version, use the following command : `yunohost app upgrade domoticz --force` + +## Configuration + +### Sensors, language and this kind of stuff +Main configuration of the app take place inside the app itself. + +### Zwave management +If you're using zwave devices, install mosquitto along domoticz and give a try to [zwave-JS-UI package](https://github.com/YunoHost-Apps/zwave-js-ui_ynh). +Once installed, just follow instructions from the [wiki](https://www.domoticz.com/wiki/Zwave-JS-UI) + +### Access and API +By default, access for the [JSON API](https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's) is allowed on following path `/yourdomain.tld/api_/domoticzpath`. +So if you access domoticz via https://mydomainname.tld/domoticz, use the following webpath for the api : `/mydomainname.tld/api_/domoticz/json.htm?yourapicommand` + +By default, only sensor updates and switch toogle are authorized. To authorized a new command, you have to manually update the nginx config file : +```` +sudo nano /etc/nginx/conf.d/yourdomain.tld.d/api_domoticz.conf +```` +Then edit the following block by adding the regex of the command you want to allow: +```` + #set the list of authorized json command here in regex format + #you may retrieve the command from https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's + #By default, sensors updates and toggle switch are authorized + if ( $args ~* type=command¶m=udevice&idx=[0-9]*&nvalue=[0-9]*&svalue=.*$|type=command¶m=switchlight&idx=[0-9]*&switchcmd=Toggle$) { + set $api "1"; + } +```` +For example, to add the json command to retrieve the status of a device (/json.htm?type=devices&rid=IDX),modify the line as this: +```` + if ( $args ~* type=command¶m=udevice&idx=[0-9]*&nvalue=[0-9]*&svalue=.*$|type=command¶m=switchlight&idx=[0-9]*&switchcmd=Toggle$|type=devices&rid=[0-9]* ) { + set $api "1"; + } +```` + +All IPv4 addresses within the local network (192.168.0.0/24) and *all IPv6* addresses are authorized as API. +As far as I know, there is no way to filter for IPv6 address on local network : You may remove the authorization by removing or commenting this line in `/etc/nginx/conf.d/yourdomain.tld.d/domoticz.conf`: +```` +allow ::/1; +```` +This will authorized only IPv4 within local network to access your domoticz API. +You may add individual IPv6 address in the same way. \ No newline at end of file diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md new file mode 100644 index 0000000..478cc8d --- /dev/null +++ b/doc/ADMIN_fr.md @@ -0,0 +1,91 @@ +## Configuration + +### Broker MQTT Mosquitto + +A l'installation, un broker [MQTT](https://fr.wikipedia.org/wiki/MQTT), [Mosquitto](https://mosquitto.org/), est installé en même temps que Domoticz. La version installée est celle du dépot officiel du projet, et non des dépots Debian. +Ce broker nécessite un domaine ou un sous-domaine particulier pour fonctionner (ex : mqtt.your.domain.tld) : il est nécessaire de créer ce domaine auparavant. + +#### Ajout dans domoticz + +Pour pouvoir l'utiliser, vous devez paramétrer la communication avec entre domoticz et le broker en suivant la [documentation de domoticz](https://www.domoticz.com/wiki/MQTT#Installing_Mosquitto) dans la partie *Add hardware "MQTT Client Gateway"* +Les users et mot de passe du broker sont automatiquement générés lors de l'installation. Vous pouvez les récupérer avec +```` +sudo yunohost app setting domoticz mqtt_user +sudo yunohost app setting domoticz mqtt_pwd +```` + +#### Publier/souscrire + +Par défaut, mosquitto va écouter sur 2 ports: +- Le 1883 sur localhost en protocole mqtt +- Le 8883 en protocole websocket. Nginx redirige le port 443 externe vers ce port en interne. +Pour publier/souscrire sur un topic depuis l'exterieur, vous devez donc utiliser un programme supportant le protocole websocket (ex : la bibliothèque python paho).: + +#### Mosquitto_pub et mosquitto_sub + +Ces deux programmes ne supportent pas le protocole websocket mais uniquement le mqtt : le paramétrage de base ne vous autorise donc pas à les utiliser pour communiquer depuis un client externe. +Si vous les utilisez directement depuis votre serveur, ce genre de syntaxe devrait marcher: +```` +mosquitto_pub -u *user* -P *password* -h mqtt.your.domain.tld -p 1883 -t 'domoticz/in' -m '{ "idx" : 1, "nvalue" : 0, "svalue" : "25.0" }' +```` +De la même manière:c +```` +mosquitto_sub -u *user* -P *password* -h mqtt.your.domain.tld -p 1883 -t 'domoticz/out' +```` +Si vous souhaitez ouvrir le protocole mqtt depuis l'extérieur afin de pouvoir les utiliser depuis un autre serveur, il vous faudra: +- ouvrir le port 1883 sur le firewall Yunohost (**Attention, risque de sécurité**) +- autoriser les adresses IP souhaitées dans la configuration de mosquitto pour ce listener +- paramétrer le tls dans la configuration de mosquitto en donnant accès au crt.pem et key.pem de votre domaine mqtt en les paramétrant respectivement avec les variables certfile et keyfile. **Ceci est obligatoire pour sécuriser la connexion.** + + + + +#### Mise à jour depuis les versions n'ayant pas mosquittoo +Si vous êtes sur le package ynh3 ou inférieur, mosquitto n'est pas installé par défaut. +De même si vous avez choisi de ne pas indiquer de domaine pour mosquitto lors de l'installation initiale. +Pour pouvoir l'installer après coup, faites les actions suivantes: +1. créez un domaine ou sous-domaine pour recevoir les informations (par exemple : 'mqtt.your.domain.tld') +2. connecter vous en ligne de commande à votre serveur +3. taper la commande suivante : `yunohost app setting domoticz mqtt_domain -v mqtt.your.domain.tld` +4. Procédez à la mise à jour. +Si vous êtes déjà sur la dernière version, utiliser la commmande suivante : `yunohost app upgrade domoticz --force` + + +### Senseurs, langue et ce genre de choses +Toute la configuration de l'application a lieu dans l'application elle même + +### Gestion du Zwave +Si vous utilisez des équipements zwave, installez mosquitto en plus de domoticz et essayez le [package zwave-JS-UI](https://github.com/YunoHost-Apps/zwave-js-ui_ynh). +Une fois installé, suivez simplement les indications du [wiki](https://www.domoticz.com/wiki/Zwave-JS-UI) + +### Accès et API +Par défaut, l'accès aux [API JSON](https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's) est autorisé sur cette URL `/votredomaine.tld/api_/chemindedomoticz`. +Donc, si vous accédez à domoticz par https://votredomaine.tld/domoticz, utilisez le chemin suivant pour l'api: `/votredomaine.tld/api_/domoticz/json.htm?votrecommandeapi` + +Par défaut, seule la mise à jour de senseur et les interrupteurs sont autorisés. Pour autoriser une nouvelle commande, vous devez manuellement éditer le fichier de configuration nginx : +```` +sudo nano /etc/nginx/conf.d/yourdomain.tld.d/api_domoticz.conf +```` +Puis éditer le bloc suivant en y ajoutant le regex de la commmande à autoriser : +```` + #set the list of authorized json command here in regex format + #you may retrieve the command from https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's + #By default, sensors updates and toggle switch are authorized + if ( $args ~* type=command¶m=udevice&idx=[0-9]*&nvalue=[0-9]*&svalue=.*$|type=command¶m=switchlight&idx=[0-9]*&switchcmd=Toggle$) { + set $api "1"; + } +```` +Par exemple, pour ajouter la commmande json pour retrouver le statut d'un équipement (/json.htm?type=devices&rid=IDX),il faut modifier la ligne comme ceci: +```` + if ( $args ~* type=command¶m=udevice&idx=[0-9]*&nvalue=[0-9]*&svalue=.*$|type=command¶m=switchlight&idx=[0-9]*&switchcmd=Toggle$|type=devices&rid=[0-9]* ) { + set $api "1"; + } +```` + +Toutes les adresses IPv4 du réseau local (192.168.0.0/24) et toutes les adresses IPv6 sont autorisées pour l'API. +A ma connaissance, il n'y a pas moyen d'effectuer un filtre pour les adresses IPv6 sur le réseau local, vous pouvez donc retirer leur autorisation en enlevant ou en commentant la ligne suivante dans `/etc/nginx/conf.d/yourdomain.tld.d/domoticz.conf`: +```` +allow ::/1; +```` +Ceci autorisera seulement les adresses IPv4 local a accéder aux API de domoticz. +Vous pouvez ajouter des adresses IPv6 de la même façon. diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 215178f..d4ad925 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -15,96 +15,4 @@ For example this system can be used with: **Shipped version:** Always the last stable one. The last compiled version is retrieved from [this directory](https://releases.domoticz.com/releases/?dir=./release) during install. Once installed, **updates from the uptream app are managed from within the app**. Yunohost upgrade script will only upgrade the Yunohost package. -The MQTT broker mosquitto is integrated into the package. It requires its own domain or subdomain. It's an optional setting: during install if you set the same domaine as your main app domain, it won't be installed. - -## Configuration - -### Broker Mosquitto - -During installation, a [MQTT](https://en.wikipedia.org/wiki/MQTT) broker, [Mosquitto](https://mosquitto.org/), is installed at the same time as Domoticz. The installed version is the one from the official project repo and not from Debian ones. -This broker requires a dedicated domain or subdomain to work (ex : mqtt.your.domain.tld) : creating this domain prior installation is a prerequisite - -#### Adding in domoticz - -To use mosquitto, you need to customize the communication between domoticz and the broker by following the [domoticz documentation](https://www.domoticz.com/wiki/MQTT#Installing_Mosquitto), part *Add hardware "MQTT Client Gateway"*. -User and password are automatically generated during installation, you may retrieve them with -```` -sudo yunohost app setting domoticz mqtt_user -sudo yunohost app setting domoticz mqtt_pwd -```` - -#### Publish/Subscribe - -By default, mosquitto will listen on 2 ports: -- 1883 on localhost using mqtt protocol -- 8883 using websocket protocol. Nginx redirect external port 443 to this internal port. - -Hence, To publish/subscribe on a topic from the outside, you have to use a software supporting websocket protocol (ex : paho python library). - -#### Mosquitto_pub et mosquitto_sub - -These 2 tools do not support websocket protocol, only direct mqtt: base settings will not allow communication from an outside device. -If you're using them directly from your server, this kind of syntax should work: -```` -mosquitto_pub -u *user* -P *password* -h mqtt.your.domain.tld -p 1883 -t 'domoticz/in' -m '{ "idx" : 1, "nvalue" : 0, "svalue" : "25.0" }' -```` -In the same way: -```` -mosquitto_sub -u *user* -P *password* -h mqtt.your.domain.tld -p 1883 -t 'domoticz/out' -```` - -If you wish to open direct mqtt protocol from an outside device, you'll need to: -- open port 1883 on Yunohost firewall (**Attention, security risk**) -- Allows IP addresses in mosquitto configuration for this listener -- Set the tls setting in mosquitto configuration by giving access to crt.pem and key.pem from your mqtt domain by setting respective certfile et keyfile variables. **This is mandatory to ensure a secure connection.** - -#### Upgrade from version without mosquitto -If you have package ynh3 or below, mosquitto is not installed by default. -If you have chosen to not set a domain during initial installation also. -So, if you need to activate mosquitto in retrospect, do following actions: -1. Create a domain or a subdomain (for example : 'mqtt.your.domain.tld') -2. Connect to your server in command line -3. Type following command : `yunohost app setting domoticz mqtt_domain -v mqtt.your.domain.tld` -4. Upgrade domoticz to last package. -If you're already on the last package version, use the following command : `yunohost app upgrade domoticz --force` - -## Configuration - -### Sensors, language and this kind of stuff -Main configuration of the app take place inside the app itself. - -### Zwave management -If you're using zwave devices, install mosquitto along domoticz and give a try to [zwave-JS-UI package](https://github.com/YunoHost-Apps/zwave-js-ui_ynh). -Once installed, just follow instructions from the [wiki](https://www.domoticz.com/wiki/Zwave-JS-UI) - -### Access and API -By default, access for the [JSON API](https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's) is allowed on following path `/yourdomain.tld/api_/domoticzpath`. -So if you access domoticz via https://mydomainname.tld/domoticz, use the following webpath for the api : `/mydomainname.tld/api_/domoticz/json.htm?yourapicommand` - -By default, only sensor updates and switch toogle are authorized. To authorized a new command, you have to manually update the nginx config file : -```` -sudo nano /etc/nginx/conf.d/yourdomain.tld.d/api_domoticz.conf -```` -Then edit the following block by adding the regex of the command you want to allow: -```` - #set the list of authorized json command here in regex format - #you may retrieve the command from https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's - #By default, sensors updates and toggle switch are authorized - if ( $args ~* type=command¶m=udevice&idx=[0-9]*&nvalue=[0-9]*&svalue=.*$|type=command¶m=switchlight&idx=[0-9]*&switchcmd=Toggle$) { - set $api "1"; - } -```` -For example, to add the json command to retrieve the status of a device (/json.htm?type=devices&rid=IDX),modify the line as this: -```` - if ( $args ~* type=command¶m=udevice&idx=[0-9]*&nvalue=[0-9]*&svalue=.*$|type=command¶m=switchlight&idx=[0-9]*&switchcmd=Toggle$|type=devices&rid=[0-9]* ) { - set $api "1"; - } -```` - -All IPv4 addresses within the local network (192.168.0.0/24) and *all IPv6* addresses are authorized as API. -As far as I know, there is no way to filter for IPv6 address on local network : You may remove the authorization by removing or commenting this line in `/etc/nginx/conf.d/yourdomain.tld.d/domoticz.conf`: -```` -allow ::/1; -```` -This will authorized only IPv4 within local network to access your domoticz API. -You may add individual IPv6 address in the same way. \ No newline at end of file +The MQTT broker mosquitto is integrated into the package. It requires its own domain or subdomain. It's an optional setting: during install if you set the same domaine as your main app domain, it won't be installed. \ No newline at end of file diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md index f87a128..a120655 100644 --- a/doc/DESCRIPTION_fr.md +++ b/doc/DESCRIPTION_fr.md @@ -16,94 +16,3 @@ Une fois installée, **les mises à jour de l'application sont gérées depuis l Le broker MQTT mosquitto est intégré au package et nécessite un sous-domaine ou un domaine distinct. Il est optionnel et si vous indiquez lors de l'installation le même domaine que le domaine principal, il ne sera pas installé. -## Configuration - -### Broker MQTT Mosquitto - -A l'installation, un broker [MQTT](https://fr.wikipedia.org/wiki/MQTT), [Mosquitto](https://mosquitto.org/), est installé en même temps que Domoticz. La version installée est celle du dépot officiel du projet, et non des dépots Debian. -Ce broker nécessite un domaine ou un sous-domaine particulier pour fonctionner (ex : mqtt.your.domain.tld) : il est nécessaire de créer ce domaine auparavant. - -#### Ajout dans domoticz - -Pour pouvoir l'utiliser, vous devez paramétrer la communication avec entre domoticz et le broker en suivant la [documentation de domoticz](https://www.domoticz.com/wiki/MQTT#Installing_Mosquitto) dans la partie *Add hardware "MQTT Client Gateway"* -Les users et mot de passe du broker sont automatiquement générés lors de l'installation. Vous pouvez les récupérer avec -```` -sudo yunohost app setting domoticz mqtt_user -sudo yunohost app setting domoticz mqtt_pwd -```` - -#### Publier/souscrire - -Par défaut, mosquitto va écouter sur 2 ports: -- Le 1883 sur localhost en protocole mqtt -- Le 8883 en protocole websocket. Nginx redirige le port 443 externe vers ce port en interne. -Pour publier/souscrire sur un topic depuis l'exterieur, vous devez donc utiliser un programme supportant le protocole websocket (ex : la bibliothèque python paho).: - -#### Mosquitto_pub et mosquitto_sub - -Ces deux programmes ne supportent pas le protocole websocket mais uniquement le mqtt : le paramétrage de base ne vous autorise donc pas à les utiliser pour communiquer depuis un client externe. -Si vous les utilisez directement depuis votre serveur, ce genre de syntaxe devrait marcher: -```` -mosquitto_pub -u *user* -P *password* -h mqtt.your.domain.tld -p 1883 -t 'domoticz/in' -m '{ "idx" : 1, "nvalue" : 0, "svalue" : "25.0" }' -```` -De la même manière:c -```` -mosquitto_sub -u *user* -P *password* -h mqtt.your.domain.tld -p 1883 -t 'domoticz/out' -```` -Si vous souhaitez ouvrir le protocole mqtt depuis l'extérieur afin de pouvoir les utiliser depuis un autre serveur, il vous faudra: -- ouvrir le port 1883 sur le firewall Yunohost (**Attention, risque de sécurité**) -- autoriser les adresses IP souhaitées dans la configuration de mosquitto pour ce listener -- paramétrer le tls dans la configuration de mosquitto en donnant accès au crt.pem et key.pem de votre domaine mqtt en les paramétrant respectivement avec les variables certfile et keyfile. **Ceci est obligatoire pour sécuriser la connexion.** - - - - -#### Mise à jour depuis les versions n'ayant pas mosquittoo -Si vous êtes sur le package ynh3 ou inférieur, mosquitto n'est pas installé par défaut. -De même si vous avez choisi de ne pas indiquer de domaine pour mosquitto lors de l'installation initiale. -Pour pouvoir l'installer après coup, faites les actions suivantes: -1. créez un domaine ou sous-domaine pour recevoir les informations (par exemple : 'mqtt.your.domain.tld') -2. connecter vous en ligne de commande à votre serveur -3. taper la commande suivante : `yunohost app setting domoticz mqtt_domain -v mqtt.your.domain.tld` -4. Procédez à la mise à jour. -Si vous êtes déjà sur la dernière version, utiliser la commmande suivante : `yunohost app upgrade domoticz --force` - - -### Senseurs, langue et ce genre de choses -Toute la configuration de l'application a lieu dans l'application elle même - -### Gestion du Zwave -Si vous utilisez des équipements zwave, installez mosquitto en plus de domoticz et essayez le [package zwave-JS-UI](https://github.com/YunoHost-Apps/zwave-js-ui_ynh). -Une fois installé, suivez simplement les indications du [wiki](https://www.domoticz.com/wiki/Zwave-JS-UI) - -### Accès et API -Par défaut, l'accès aux [API JSON](https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's) est autorisé sur cette URL `/votredomaine.tld/api_/chemindedomoticz`. -Donc, si vous accédez à domoticz par https://votredomaine.tld/domoticz, utilisez le chemin suivant pour l'api: `/votredomaine.tld/api_/domoticz/json.htm?votrecommandeapi` - -Par défaut, seule la mise à jour de senseur et les interrupteurs sont autorisés. Pour autoriser une nouvelle commande, vous devez manuellement éditer le fichier de configuration nginx : -```` -sudo nano /etc/nginx/conf.d/yourdomain.tld.d/api_domoticz.conf -```` -Puis éditer le bloc suivant en y ajoutant le regex de la commmande à autoriser : -```` - #set the list of authorized json command here in regex format - #you may retrieve the command from https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's - #By default, sensors updates and toggle switch are authorized - if ( $args ~* type=command¶m=udevice&idx=[0-9]*&nvalue=[0-9]*&svalue=.*$|type=command¶m=switchlight&idx=[0-9]*&switchcmd=Toggle$) { - set $api "1"; - } -```` -Par exemple, pour ajouter la commmande json pour retrouver le statut d'un équipement (/json.htm?type=devices&rid=IDX),il faut modifier la ligne comme ceci: -```` - if ( $args ~* type=command¶m=udevice&idx=[0-9]*&nvalue=[0-9]*&svalue=.*$|type=command¶m=switchlight&idx=[0-9]*&switchcmd=Toggle$|type=devices&rid=[0-9]* ) { - set $api "1"; - } -```` - -Toutes les adresses IPv4 du réseau local (192.168.0.0/24) et toutes les adresses IPv6 sont autorisées pour l'API. -A ma connaissance, il n'y a pas moyen d'effectuer un filtre pour les adresses IPv6 sur le réseau local, vous pouvez donc retirer leur autorisation en enlevant ou en commentant la ligne suivante dans `/etc/nginx/conf.d/yourdomain.tld.d/domoticz.conf`: -```` -allow ::/1; -```` -Ceci autorisera seulement les adresses IPv4 local a accéder aux API de domoticz. -Vous pouvez ajouter des adresses IPv6 de la même façon. diff --git a/doc/DISCLAIMER_fr.md b/doc/POST_INSTALL_fr.md similarity index 98% rename from doc/DISCLAIMER_fr.md rename to doc/POST_INSTALL_fr.md index baca40c..a384450 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/POST_INSTALL_fr.md @@ -1,4 +1,3 @@ - ## Limitations * Pas de gestion d'utilisateurs ni d'intégration LDAP. L'application ne [prévoit pas de gérer les utilisateurs par LDAP](https://github.com/domoticz/domoticz/issues/838), donc le package non plus. diff --git a/doc/DISCLAIMER.md b/doc/POST_INTALL.md similarity index 97% rename from doc/DISCLAIMER.md rename to doc/POST_INTALL.md index 66a8856..0486c62 100644 --- a/doc/DISCLAIMER.md +++ b/doc/POST_INTALL.md @@ -1,4 +1,3 @@ - ## Limitations * No user management nor LDAP integration This function is [not planned to be implemented into the app](https://github.com/domoticz/domoticz/issues/838), hence it's not planned into the package neither. @@ -12,4 +11,4 @@ Although you may activate a login page on the application (either from the *Setu It seems advisable to not make the app publicly available outside of the yunohost sso (public = yes at install or setting the domoticz permission to 'visitors' in the admin panel). If for any reason you need to, I recommend the following: - Activate the website protection/user management (with login page instead of Basic-auth) - - In *Setup/Settings/System/Local Networks (no username/password)* enter the address of the nginx proxy (should be "::1;127.0.0.1" in any standard Yunohost installation) so that the Fail2ban settings is active (see last lines of [this wiki](https://www.domoticz.com/wiki/WebServer_Proxy) + - In *Setup/Settings/System/Local Networks (no username/password)* enter the address of the nginx proxy (should be "::1;127.0.0.1" in any standard Yunohost installation) so that the Fail2ban settings is active (see last lines of [this wiki](https://www.domoticz.com/wiki/WebServer_Proxy) \ No newline at end of file diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md new file mode 100644 index 0000000..2ee8450 --- /dev/null +++ b/doc/PRE_INSTALL.md @@ -0,0 +1,5 @@ +## Mosquitto Broker + +During installation, a [MQTT](https://en.wikipedia.org/wiki/MQTT) broker, [Mosquitto](https://mosquitto.org/), may be installed at the same time as Domoticz. It's an optional setting: during install if you set the same domaine as your main app domain, it won't be installed. +The installed version is the one from the official project repo and not from Debian ones. +This broker requires a dedicated domain or subdomain to work (ex : mqtt.your.domain.tld) : creating this domain prior installation is a prerequisite diff --git a/doc/PRE_INSTALL_fr.md b/doc/PRE_INSTALL_fr.md new file mode 100644 index 0000000..de4d7c0 --- /dev/null +++ b/doc/PRE_INSTALL_fr.md @@ -0,0 +1,5 @@ +## Broker MQTT Mosquitto + +A l'installation, un broker [MQTT](https://fr.wikipedia.org/wiki/MQTT), [Mosquitto](https://mosquitto.org/), peut être installé en même temps que Domoticz. Il est optionnel et si vous indiquez lors de l'installation le même domaine que le domaine principal, il ne sera pas installé. +La version installée est celle du dépot officiel du projet, et non des dépots Debian. +Ce broker nécessite un domaine ou un sous-domaine particulier pour fonctionner (ex : mqtt.your.domain.tld) : il est nécessaire de créer ce domaine auparavant. \ No newline at end of file diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 47e5938..0000000 --- a/manifest.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "Domoticz", - "id": "domoticz", - "packaging_format": 1, - "description": { - "en": "Home automation system that lets you monitor and configure miscellaneous devices", - "fr": "Logiciel de domotique qui vous permet de configurer un grand nombre d'appareils" - }, - "version": "2020.2~ynh7", - "url": "https://www.domoticz.com", - "upstream": { - "license": "GPL-3.0-or-later", - "website": "https://domoticz.com/", - "admindoc": "https://www.domoticz.com/wiki/Main_Page", - "userdoc": "https://www.domoticz.com/DomoticzManual.pdf", - "code": "https://github.com/domoticz/domoticz", - "cpe": "cpe:2.3:a:domoticz:domoticz" - }, - "license": "GPL-3.0-or-later", - "maintainer": { - "name": "Krakinou", - "email": "misterl56@hotmail.com" - }, - "requirements": { - "yunohost": ">= 11.0.0" - }, - "multi_instance": false, - "services": [ - "nginx" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/domoticz", - "default": "/domoticz" - }, - { - "name": "is_public", - "type": "boolean", - "default": false, - "help": { - "fr": "Attention, cette application n'a pas de gestion d'utilisateur par défaut, si vous la mettez public, n importe qui y aura accès!", - "en": "Beware, there is no user management by default. If it's set as public, anyone will have access!" - } - }, - { - "name": "mqtt_domain", - "type": "domain", - "ask": { - "fr": "Domaine MQTT", - "en": "MQTT domain" - }, - "example": "mqtt.your.domain.com", - "optional": true, - "help": { - "fr": "Domaine pour le serveur MQTT. Remettez le domaine principal si vous ne souhaitez pas l'utiliser. Lire la documentation pour plus d'informations", - "en": "MQTT server domain. Set the main domain if you don't wish to use it. See the doc for more info" - } - } - ] - } -} \ No newline at end of file diff --git a/manifest.toml b/manifest.toml index 27a6209..9968ea5 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Domoticz" description.en = "Home automation system that lets you monitor and configure miscellaneous devices" description.fr = "Logiciel de domotique qui vous permet de configurer un grand nombre d'appareils" -version = "2020.2~ynh8" +version = "2023.1~ynh1" maintainers = ["Krakinou"] @@ -15,34 +15,32 @@ website = "https://domoticz.com/" admindoc = "https://www.domoticz.com/wiki/Main_Page" userdoc = "https://www.domoticz.com/DomoticzManual.pdf" code = "https://github.com/domoticz/domoticz" -cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) -fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. +cpe = "cpe:2.3:a:domoticz:domoticz" +fund = "https://www.paypal.com/donate?token=rF_gUybGmQGia_jzLfu3vkeXRqYLRV-v-BxCTylrTsEN4mB-nDdSVQhg3a-I9LkiqORq70Gtxbo6rq3r&locale.x=US" [integration] -yunohost = ">= 11.0.0" -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"] +yunohost = ">= 11.1.11" +architectures = "all" multi_instance = false -ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. -sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. -disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... -ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... -ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ldap = false +sso = false +disk = "100M" +ram.build = "50M" +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 = "/domoticz" [install.init_main_permission] - help.fr = "Attention, cette application n'a pas de gestion d'utilisateur par défaut, si vous la mettez public, n importe qui y aura accès!" + help.fr = "Attention, cette application n'a pas de gestion d'utilisateur par défaut, si vous la mettez public, n'importe qui y aura accès!" help.en = "Beware, there is no user management by default. If it's set as public, anyone will have access!" type = "group" - default = false + default = "all_users" [install.mqtt_domain] ask.fr = "Domaine MQTT" @@ -56,17 +54,25 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources.system_user] [resources.install_dir] - + dir = /opt/yunohost/__APP__ + [resources.permissions] main.url = "/" + + api.url = "/_api/__APP_" + api.show_title = false + [resources.ports] main.default = 8080 + #to be checked if it can become conditionnal + #mqtt.default = 1883 + #mqtt_websocket.default = 8883 [resources.apt] - packages = "libudev-dev, python3-dev, mosquitto, mosquitto-clients, $pkg_dependencies, $add_dep" + packages = "libudev-dev, python3-dev, libcurl4, libusb-0.1-4" - [[resources.apt.extras]] - repo = "deb https://repo.mosquitto.org/debian buster main" - key = "http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" - packages = "#FIXME#$extra_pkg_dependencies \ No newline at end of file + #[[resources.apt.extras]] + #repo = "deb https://repo.mosquitto.org/debian buster main" + #key = "http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" + #packages = "#FIXME#$extra_pkg_dependencies \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index b8f6638..f8f7923 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,26 +4,12 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -#python3-dev required as per https://www.domoticz.com/forum/viewtopic.php?f=65&t=16116&p=119747 #mosquitto and mosquitto-clients are required for mqtt -#other dependencies are from standard install script... seems quite useles... -#REMOVEME? pkg_dependencies="libudev-dev python3-dev" -#REMOVEME? extra_pkg_dependencies="mosquitto mosquitto-clients" +extra_pkg_dependencies="mosquitto mosquitto-clients" default_mqtt_port=1883 default_mqtt_websocket_port=8883 -#ALL FOLLOWING LINE FROM THE upstream bash installation script -DEBIAN_ID=$(grep -oP '(?<=^ID=).+' /etc/*-release | tr -d '"') -DEBIAN_VERSION=$(grep -oP '(?<=^VERSION_ID=).+' /etc/*-release | tr -d '"') -if test ${DEBIAN_VERSION} -lt 10 -then - add_dep="libcurl3" -else - add_dep="libcurl4 libusb-0.1-4" -fi; -#REMOVEME? pkg_dependencies="$pkg_dependencies $add_dep" lowercase(){ echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/" diff --git a/scripts/backup b/scripts/backup index 0c62fca..435dd07 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,27 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -#} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_print_info --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? mqtt_domain=$(ynh_app_setting_get --app=$app --key=mqtt_domain) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -75,7 +54,6 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/sudoers.d/$app" [[ ! -z "$mqtt_domain" ]] && ynh_backup --src_path="/etc/mosquitto/conf.d" --not_mandatory ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/95-nginx_domoticz" diff --git a/scripts/install b/scripts/install index 6e83340..3666820 100755 --- a/scripts/install +++ b/scripts/install @@ -9,47 +9,16 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -#} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -#REMOVEME? domain="$YNH_APP_ARG_DOMAIN" -#REMOVEME? path="$YNH_APP_ARG_PATH" -#REMOVEME? is_public="$YNH_APP_ARG_IS_PUBLIC" -#REMOVEME? mqtt_domain="$YNH_APP_ARG_MQTT_DOMAIN" - -#REMOVEME? app="$YNH_APP_INSTANCE_NAME" - #Set dedicated variables if [ "$path" == "/" ]; then api_path=/api_/"$app" else api_path=/api_"$path" fi -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -#REMOVEME? ynh_script_progression --message="Validating installation parameters..." - -#REMOVEME? install_dir=/opt/yunohost/"$app" -#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -#REMOVEME? ynh_webpath_register --app="$app" --domain="$domain" --path="$path" -#impossible de booker plusieurs webpath -#if [ ! -z $mqtt_domain ]; then -#REMOVEME? # ynh_webpath_register --app=mqtt_$app --domain=$mqtt_domain --path="/" -#fi if [ "$domain" == "$mqtt_domain" ]; then mqtt_domain="" @@ -58,18 +27,15 @@ fi #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -#REMOVEME? ynh_script_progression --message="Storing installation settings..." - -#REMOVEME? ynh_app_setting_set --app="$app" --key=domain --value="$domain" -#REMOVEME? ynh_app_setting_set --app="$app" --key=path --value="$path" +ynh_script_progression --message="Storing installation settings..." #Will be used in restore script to check that we're restoring on the same OS/Board type ynh_app_setting_set --app="$app" --key=OS --value="$os" ynh_app_setting_set --app="$app" --key=mach --value="$mach" #path used by api & mqtt to read/update domoticz -#REMOVEME? ynh_app_setting_set --app="$app" --key=api_path --value="$api_path" -#REMOVEME? [[ ! -z "$mqtt_domain" ]] && ynh_app_setting_set --app="$app" --key=mqtt_domain --value="$mqtt_domain" +ynh_app_setting_set --app="$app" --key=api_path --value="$api_path" +[[ ! -z "$mqtt_domain" ]] && ynh_app_setting_set --app="$app" --key=mqtt_domain --value="$mqtt_domain" #================================================= @@ -77,35 +43,19 @@ ynh_app_setting_set --app="$app" --key=mach --value="$mach" #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Finding available port..." - -# Find an available port -#REMOVEME? port=$(ynh_find_port --port=8080) -#REMOVEME? ynh_app_setting_set --app="$app" --key=port --value="$port" - if [ ! -z "$mqtt_domain" ]; then ynh_script_progression --message="Finding available ports for Mosquitto..." -#REMOVEME? mqtt_port=$(ynh_find_port --port="$default_mqtt_port") -#REMOVEME? ynh_app_setting_set --app="$app" --key=mqtt_port --value="$mqtt_port" + mqtt_port=$(ynh_find_port --port="$default_mqtt_port") + ynh_app_setting_set --app="$app" --key=mqtt_port --value="$mqtt_port" -#REMOVEME? mqtt_websocket_port=$(ynh_find_port --port="$default_mqtt_websocket_port") -#REMOVEME? ynh_app_setting_set --app="$app" --key=mqtt_websocket_port --value="$mqtt_websocket_port" + mqtt_websocket_port=$(ynh_find_port --port="$default_mqtt_websocket_port") + ynh_app_setting_set --app="$app" --key=mqtt_websocket_port --value="$mqtt_websocket_port" fi -#================================================= -# INSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=15 - -#REMOVEME? ynh_install_app_dependencies "$pkg_dependencies" - #================================================= # CREATE DEDICATED USER #================================================= -#REMOVEME? ynh_script_progression --message="Configuring system user..." - -# Create a system user -#REMOVEME? ynh_system_user_create --username="$app" --home_dir="$install_dir" +ynh_script_progression --message="Configuring system user..." #allow user to access USB / serial port to communicate with tools (RFXtrx, Z-wave dongle, etc.) & i2c bus if grep dialout -q < /etc/group; then @@ -118,16 +68,11 @@ if grep gpio -q < /etc/group; then usermod -a -G gpio "$app" fi -#allow app user to restart service on startup -ynh_add_config --template="../conf/sudoer" --destination="/etc/sudoers.d/$app" -chmod 440 /etc/sudoers.d/"$app" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=5 -#REMOVEME? ynh_app_setting_set --app="$app" --key=install_dir --value="$install_dir" # Download, check integrity, uncompress and patch the source from app.src # Create an app.src for the correct version of domoticz # match string are fulfilled in _common.sh via the upstream bash installation script @@ -154,7 +99,7 @@ if [ ! -z "$mqtt_domain" ]; then ynh_script_progression --message="Setting up mosquitto..." --weight=5 #Installing packages -#REMOVEME? ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian buster main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" + ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian buster main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" #Setting up conf file for access ynh_add_config --template="../conf/domoticz_mosquitto.conf" --destination="/etc/mosquitto/conf.d/"$app"_mosquitto.conf" @@ -163,7 +108,7 @@ if [ ! -z "$mqtt_domain" ]; then #Setting up user&pwd for mqtt access ynh_app_setting_set --app="$app" --key=mqtt_user --value=$(ynh_string_random --length=8) ynh_app_setting_set --app="$app" --key=mqtt_pwd --value=$(ynh_string_random) -#REMOVEME? echo $(ynh_app_setting_get --app="$app" --key=mqtt_user):$(ynh_app_setting_get --app="$app" --key=mqtt_pwd) > "/etc/mosquitto/conf.d/"$app"_credentials" + echo $(ynh_app_setting_get --app="$app" --key=mqtt_user):$(ynh_app_setting_get --app="$app" --key=mqtt_pwd) > "/etc/mosquitto/conf.d/"$app"_credentials" mosquitto_passwd -U "/etc/mosquitto/conf.d/"$app"_credentials" ynh_print_info --message="The credential to the mosquitto server has been saved in the settings of the app" @@ -179,7 +124,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 #Set Hook for nginx domain cp -R ../sources/hooks/conf_regen/95-nginx_domoticz /usr/share/yunohost/hooks/conf_regen/ -yunohost tools regen-conf nginx # Create a dedicated NGINX config ynh_add_config --template="api_nginx.conf" --destination="/etc/nginx/conf.d/"$domain".d/api_"$app".conf" @@ -242,6 +186,7 @@ if [ ! -f "$log_file" ]; then chown $app: "$log_file" fi + # Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*Error: Failed login attempt from .*$" --max_retry=5 ynh_print_info --message="If you wish for Fail2ban to work, set up your local address in Setup/Settings/System/Local Networks as per documentation" @@ -251,26 +196,12 @@ ynh_print_info --message="If you wish for Fail2ban to work, set up your local ad #================================================= #REMOVEME? ynh_script_progression --message="Configuring permissions..." -# Make app public if necessary -#REMOVEME? if [ "$is_public" -eq 1 ] -then - # Everyone can access the app. - # The "main" permission is automatically created before the install script. -#REMOVEME? ynh_permission_update --permission="main" --add="visitors" -fi #API & MQTT should stay publicly accessible. -#REMOVEME? ynh_permission_create --permission="domoticz_API" --label="api" --url="$domain$api_path" --allowed="visitors" --show_tile="false" --protected="true" -#REMOVEME? [[ ! -z "$mqtt_domain" ]] && ynh_permission_create --permission="domoticz_MQTT" --label="MQTT" --url="$mqtt_domain" --allowed="visitors" --show_tile="false" --protected="true" +ynh_permission_create --permission="domoticz_API" --label="api" --url="$domain$api_path" --allowed="visitors" --show_tile="false" --protected="true" +[[ ! -z "$mqtt_domain" ]] && ynh_permission_create --permission="domoticz_MQTT" --label="MQTT" --url="$mqtt_domain" --allowed="visitors" --show_tile="false" --protected="true" -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 376d7df..2e5b416 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,123 +9,43 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? app="$YNH_APP_INSTANCE_NAME" - -#REMOVEME? domain=$(ynh_app_setting_get --app="$app" --key=domain) -#REMOVEME? port=$(ynh_app_setting_get --app="$app" --key=port) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app="$app" --key=install_dir) -#REMOVEME? mqtt_domain=$(ynh_app_setting_get --app="$app" --key=mqtt_domain) - #================================================= # STANDARD REMOVE #================================================= # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) +if [ ! -z "$mqtt_domain" ]; then + ynh_script_progression --message="Removing system configurations related to Mosquitto..." --weight=1 + yunohost service remove mosquitto + ynh_secure_remove --file="/etc/mosquitto/conf.d" + ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/95-nginx_domoticz" + ynh_secure_remove --file="/etc/nginx/conf.d/"$mqtt_domain".d/mqtt_"$app".conf" + yunohost tools regen-conf postfix + ynh_secure_remove --file="/var/log/mosquitto" + #not required as handled by the core? + #ynh_remove_app_dependencies + +fi + +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 if ynh_exec_warn_less yunohost service status "$app" >/dev/null then ynh_script_progression --message="Removing $app service integration..." yunohost service remove "$app" - [[ ! -z "$mqtt_domain" ]] && yunohost service remove mosquitto fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." - # Remove the dedicated systemd config ynh_remove_systemd_config - -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." --weight=1 - ynh_exec_warn_less yunohost firewall disallow TCP "$port" -fi - -#================================================= -# REMOVE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=3 - -# Remove metapackage and its dependencies -[[ ! -z "$mqtt_domain" ]] && ynh_secure_remove --file="/etc/mosquitto/conf.d" -#REMOVEME? ynh_remove_app_dependencies - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=3 - -# Remove the app directory securely -#REMOVEME? ynh_secure_remove --file="$install_dir" - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." - -#remove hook for mqtt nginx -ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/95-nginx_domoticz" -yunohost tools regen-conf postfix - - -# Remove the dedicated NGINX config -[[ ! -z "$mqtt_domain" ]] && ynh_secure_remove --file="/etc/nginx/conf.d/"$mqtt_domain".d/mqtt_"$app".conf" - ynh_secure_remove --file="/etc/nginx/conf.d/"$domain".d/api_"$app".conf" ynh_remove_nginx_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." - -# Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE FAIL2BAN CONFIGURATION -#================================================= -ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=8 - -# Remove the dedicated Fail2Ban config ynh_remove_fail2ban_config -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." - -# Remove the log files ynh_secure_remove --file="/var/log/$app" -[[ ! -z "$mqtt_domain" ]] && ynh_secure_remove --file="/var/log/mosquitto" - -#Delete the sudoer file -ynh_secure_remove --file="/etc/sudoers.d/$app" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." - -# Delete a system user -#REMOVEME? ynh_system_user_delete --username="$app" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 13a9e59..d69ce61 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,36 +10,15 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -#} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? app="$YNH_APP_INSTANCE_NAME" - -#REMOVEME? domain=$(ynh_app_setting_get --app="$app" --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app="$app" --key=path) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app="$app" --key=install_dir) -#REMOVEME? backup_OS=$(ynh_app_setting_get --app="$app" --key=OS) -#REMOVEME? backup_mach=$(ynh_app_setting_get --app="$app" --key=mach) -#REMOVEME? mqtt_domain=$(ynh_app_setting_get --app="$app" --key=mqtt_domain) +#Have to reload them as otherwise they are all the same +backup_OS=$(ynh_app_setting_get --app="$app" --key=OS) +backup_mach=$(ynh_app_setting_get --app="$app" --key=mach) +os=`lowercase \`uname -s\`` +mach=`uname -m` #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." -#REMOVEME? test ! -d "$install_dir" \ - || ynh_die --message="There is already a directory: $install_dir " #As we are downloading compiled binaries for each system, we have to check if the restore occurs #on the same system type. If we are restoring on another system type it won't work and in that #case we must go through a reinstall process. @@ -62,11 +41,6 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$mqtt_domain.d/mqtt_$app.conf" #================================================= # RECREATE THE DEDICATED USER #================================================= -#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." - -# Create the dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username="$app" --home_dir="$install_dir" - #allow user to access USB / serial port to communicate with tools (RFXtrx, Z-wave dongle, etc.) & i2c bus if grep dialout -q < /etc/group; then usermod -a -G dialout "$app" @@ -78,9 +52,6 @@ if grep gpio -q < /etc/group; then usermod -a -G gpio "$app" fi -#Restore user authorization to restart server -ynh_restore_file --origin_path="/etc/sudoers.d/$app" - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -92,16 +63,6 @@ chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R "$app":"$app" "$install_dir" -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=5 - -# Define and install dependencies -#REMOVEME? ynh_install_app_dependencies "$pkg_dependencies" - #================================================= # SET MOSQUITTO SETTINGS #================================================= @@ -109,7 +70,7 @@ if [ ! -z "$mqtt_domain" ]; then ynh_script_progression --message="Reinstalling up mosquitto..." --weight=5 #Installing packages -#REMOVEME? ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian buster main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" + ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian buster main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" #reinstalling settings ynh_restore_file --origin_path="/etc/mosquitto/conf.d" --not_mandatory fi @@ -157,7 +118,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_script_progression --message="Restoring various files..." ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/95-nginx_domoticz" -yunohost tools regen-conf postfix +#yunohost tools regen-conf postfix #================================================= # RESTORE THE FAIL2BAN CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index e165e1b..a2ac64b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -13,23 +13,8 @@ version_gt() { source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? app="$YNH_APP_INSTANCE_NAME" - -#REMOVEME? domain=$(ynh_app_setting_get --app="$app" --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app="$app" --key=path) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app="$app" --key=install_dir) -#REMOVEME? port=$(ynh_app_setting_get --app="$app" --key=port) #REMOVEME? current_OS=$(ynh_app_setting_get --app="$app" --key=OS) #REMOVEME? current_mach=$(ynh_app_setting_get --app="$app" --key=mach) -#REMOVEME? api_path=$(ynh_app_setting_get --app="$app" --key=api_path) -#REMOVEME? mqtt_domain=$(ynh_app_setting_get --app="$app" --key=mqtt_domain) -#REMOVEME? mqtt_port=$(ynh_app_setting_get --app="$app" --key=mqtt_port) -#REMOVEME? mqtt_websocket_port=$(ynh_app_setting_get --app="$app" --key=mqtt_websocket_port) #================================================= # CHECK VERSION @@ -38,35 +23,6 @@ ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." - -# Ugly hack so that previous version backup script from "https://github.com/anubister/domoticz_ynh" works : -# It creates a dummy file in /etc/cron.d so that the backup do not fail. -current_upstream_version=$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$app/manifest.json") -current_package_version=$(ynh_app_package_version --manifest="/etc/yunohost/apps/$app/manifest.json") -if version_gt "4.9701" "$current_upstream_version" && version_gt "2" "$current_package_version" ; then - touch /etc/cron.d/"$app" -fi - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -#} - -#remove ugly hack -if [ -f /etc/cron.d/"$app" ]; then - rm /etc/cron.d/"$app" -fi - -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -89,10 +45,9 @@ if [ -z "$current_mach" ]; then ynh_app_setting_set --app="$app" --key=mach --value="$MACH" fi -# If install_dir doesn't exist, create it -if [ -z "$install_dir" ]; then -#REMOVEME? install_dir=/var/www/"$app" -#REMOVEME? ynh_app_setting_set --app="$app" --key=install_dir --value="$install_dir" +#sudoer file for restarting is not required anymore (from 2023.1~ynh1) as upgrade is managed by the Yunohost Package +if [ -f /etc/sudoers.d/domoticz ]; then + rm /etc/sudoers.d/domoticz fi #Create a dedicated path for the api access @@ -102,7 +57,7 @@ if [ -z "$api_path" ]; then else api_path=/api_"$path" fi -#REMOVEME? ynh_app_setting_set --app="$app" --key=api_path --value="$api_path" + ynh_app_setting_set --app="$app" --key=api_path --value="$api_path" fi #Create a dedicated path for the mqtt access @@ -112,39 +67,29 @@ fi #Port to listen for MQTT internal if [[ -z "$mqtt_port" && ! -z "$mqtt_domain" ]]; then -#REMOVEME? mqtt_port=$(ynh_find_port --port="$default_mqtt_port") -#REMOVEME? ynh_app_setting_set --app="$app" --key=mqtt_port --value="$mqtt_port" + mqtt_port=$(ynh_find_port --port="$default_mqtt_port") + ynh_app_setting_set --app="$app" --key=mqtt_port --value="$mqtt_port" fi #Port to listen for MQTT websocket if [[ -z "$mqtt_websocket_port" && ! -z "$mqtt_domain" ]]; then -#REMOVEME? mqtt_websocket_port=$(ynh_find_port --port="$default_mqtt_websocket_port") -#REMOVEME? ynh_app_setting_set --app="$app" --key=mqtt_websocket_port --value="$mqtt_websocket_port" -fi - - - -# Cleaning legacy permissions -#REMOVEME? if ynh_legacy_permissions_exists; then -#REMOVEME? ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app="$app" --key=is_public + mqtt_websocket_port=$(ynh_find_port --port="$default_mqtt_websocket_port") + ynh_app_setting_set --app="$app" --key=mqtt_websocket_port --value="$mqtt_websocket_port" fi # Create the permission "domoticz_API" only if it doesn't exist. -#REMOVEME? if ! ynh_permission_exists --permission="domoticz_API" +if ! ynh_permission_exists --permission="domoticz_API" then # API Authorization with dedicated URL -#REMOVEME? ynh_permission_create --permission="domoticz_API" --label="api" --url="$domain$api_path" --allowed="visitors" --show_tile="false" --protected="true" - + ynh_permission_create --permission="domoticz_API" --label="api" --url="$domain$api_path" --allowed="visitors" --show_tile="false" --protected="true" fi # Create the permission "domoticz_MQTT" only if it doesn't exist. if [ ! -z "$mqtt_domain" ]; then -#REMOVEME? if ! ynh_permission_exists --permission="domoticz_MQTT" + if ! ynh_permission_exists --permission="domoticz_MQTT" then # API Authorization with dedicated URL -#REMOVEME? ynh_permission_create --permission="domoticz_MQTT" --label="MQTT" --url="$mqtt_domain" --allowed="visitors" --show_tile="false" --protected="true" + ynh_permission_create --permission="domoticz_MQTT" --label="MQTT" --url="$mqtt_domain" --allowed="visitors" --show_tile="false" --protected="true" fi fi @@ -158,9 +103,6 @@ fi #================================================= #REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." -# Create a dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username="$app" --home_dir="$install_dir" - #allow user to access USB / serial port to communicate with tools (RFXtrx, Z-wave dongle, etc.) & i2c bus if grep dialout -q < /etc/group; then usermod -a -G dialout "$app" @@ -172,10 +114,6 @@ if grep gpio -q < /etc/group; then usermod -a -G gpio "$app" fi -#allow app user to restart service on startup -ynh_add_config --template="../conf/sudoer" --destination="/etc/sudoers.d/$app" -chmod 440 /etc/sudoers.d/"$app" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -205,7 +143,7 @@ if [ ! -z "$mqtt_domain" ]; then ynh_script_progression --message="Setting up mosquitto..." --weight=5 #Installing packages -#REMOVEME? ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian buster main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" + ynh_install_extra_app_dependencies --repo="deb https://repo.mosquitto.org/debian buster main" --package="$extra_pkg_dependencies" --key="http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key" #Setting up conf file for access if [ ! -f "/etc/mosquitto/conf.d/"$app"_mosquitto.conf" ] @@ -216,7 +154,7 @@ if [ ! -z "$mqtt_domain" ]; then #Setting up user&pwd for mqtt access ynh_app_setting_set --app="$app" --key=mqtt_user --value=$(ynh_string_random --length=8) ynh_app_setting_set --app="$app" --key=mqtt_pwd --value=$(ynh_string_random) -#REMOVEME? echo $(ynh_app_setting_get --app="$app" --key=mqtt_user):$(ynh_app_setting_get --app="$app" --key=mqtt_pwd) > "/etc/mosquitto/conf.d/"$app"_credentials" + echo $(ynh_app_setting_get --app="$app" --key=mqtt_user):$(ynh_app_setting_get --app="$app" --key=mqtt_pwd) > "/etc/mosquitto/conf.d/"$app"_credentials" mosquitto_passwd -U "/etc/mosquitto/conf.d/"$app"_credentials" ynh_print_info --message="The credential to the mosquitto server has been saved in the settings of the app" @@ -232,7 +170,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." #Set Hook for nginx domain cp -R ../sources/hooks/conf_regen/95-nginx_domoticz /usr/share/yunohost/hooks/conf_regen/ -yunohost tools regen-conf nginx # Create a dedicated NGINX config if [[ ! -f "/etc/nginx/conf.d/"$domain".d/api_"$app".conf" ]] @@ -243,13 +180,6 @@ then fi ynh_add_nginx_config -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=5 - -#REMOVEME? ynh_install_app_dependencies "$pkg_dependencies" - #================================================= # SPECIFIC UPGRADE #================================================= @@ -289,6 +219,7 @@ fi # Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*Error: Failed login attempt from .*$" --max_retry=5 ynh_print_info --message="If you wish for Fail2ban to work, set up your local address in Setup/Settings/System/Local Networks as per documentation" + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= diff --git a/sources/patches/app-index.html.patch b/sources/patches/app-index.html.patch new file mode 100644 index 0000000..f23c0cc --- /dev/null +++ b/sources/patches/app-index.html.patch @@ -0,0 +1,32 @@ +--- a/www/index.html 2023-02-26 22:22:14.971932399 +0100 ++++ b/www/index.html 2023-02-26 22:27:12.926431427 +0100 +@@ -170,14 +170,15 @@ + } + + function ShowUpdateNotification(Revision, SystemName, DownloadURL) { +- var msgtxt=$.t('A new version of Domoticz is Available!...'); ++ ++ var msgtxt=$.t('A new version of Domoticz is Available, please wait for the Yunohost Package!...'); + msgtxt+='
' + $.t('Version') + ': ' + Revision + ', ' + $.t('Latest Changes') + ': ' + $.t('Click Here') + ''; +- if (SystemName=="windows") { ++ + generate_noty('success', msgtxt, false); + } + +@@ -1330,8 +1331,8 @@ +
  • Devices
  • +
  • Settings
  • +
  • +-
  • Update Domoticz
  • +-
  • Check for Update
  • ++ +