From 389230b58b6334b2bc2a4f476204db22d66c330c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 5 Feb 2024 13:11:42 +0100 Subject: [PATCH 01/10] Packagingv2, revamp --- check_process | 22 ------ conf/app.src | 7 -- conf/{client.json.example => client.json} | 14 ++-- conf/{config.conf.example => server.conf} | 13 +++- conf/systemd.service | 49 +++++++++++++ doc/DISCLAIMER.md | 0 manifest.json | 37 ---------- manifest.toml | 52 ++++++++++++++ scripts/backup | 17 ----- scripts/change_url | 83 +---------------------- scripts/install | 78 ++++----------------- scripts/remove | 38 +++-------- scripts/restore | 50 ++++---------- scripts/upgrade | 24 +++---- tests.toml | 5 ++ 15 files changed, 172 insertions(+), 317 deletions(-) delete mode 100644 check_process delete mode 100644 conf/app.src rename conf/{client.json.example => client.json} (89%) rename conf/{config.conf.example => server.conf} (89%) create mode 100644 conf/systemd.service delete mode 100644 doc/DISCLAIMER.md delete mode 100644 manifest.json create mode 100644 manifest.toml create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index d2aa1b0..0000000 --- a/check_process +++ /dev/null @@ -1,22 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - admin="john" - is_public=1 - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - backup_restore=1 - multi_instance=0 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1& diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 768a4e4..0000000 --- a/conf/app.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://kiwiirc.com/downloads/kiwiirc_20.05.24.1-1_amd64.deb -SOURCE_SUM=c99504c6de678fd91aed357ff0dada16a8df9e932970ed85767b516a9f87df52 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=deb -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=kiwiirc.deb -SOURCE_EXTRACT=false diff --git a/conf/client.json.example b/conf/client.json similarity index 89% rename from conf/client.json.example rename to conf/client.json index a875a34..49a1977 100644 --- a/conf/client.json.example +++ b/conf/client.json @@ -16,10 +16,16 @@ { "name": "Elite", "url": "static/themes/elite" } ], "startupOptions" : { + "infoContent": "

Welcome to your Kiwi IRC page!

Now to configure it.

You can modify this page via the /etc/kiwiirc/client.json file.
Add your IRC network details to /etc/kiwiirc/config.conf

Have a quick read through the config file - there are plenty of comments explaining each feature.

" + "infoBackground": "", + "greetingText": "Libera Chat", "channel": "#yunohost", "nick": "web?", - "greetingText": "Libera Chat", - "infoBackground": "", - "infoContent": "

Welcome to your Kiwi IRC page!

Now to configure it.

You can modify this page via the /etc/kiwiirc/client.json file.
Add your IRC network details to /etc/kiwiirc/config.conf

Have a quick read through the config file - there are plenty of comments explaining each feature.

" - } + }, + "embedly": { + "key": "" + }, + "plugins": [ + { "name": "customise", "url": "static/plugins/customise.html" } + ] } diff --git a/conf/config.conf.example b/conf/server.conf similarity index 89% rename from conf/config.conf.example rename to conf/server.conf index f721721..41f9af5 100644 --- a/conf/config.conf.example +++ b/conf/server.conf @@ -62,7 +62,7 @@ port = __PORT__ # Optional, but handy for serving the Kiwi IRC client if no other webserver is available [fileserving] enabled = true -webroot = /usr/share/kiwiirc/ +webroot = __INSTALL_DIR__/www/ [transports] websocket @@ -98,6 +98,11 @@ throttle = 2 # Webirc password as set in the IRC server config webirc = "" serverpassword = "" +# Outgoing protocol, valid options: tcp, tcp4, tcp6, unix +# this can be used to force ipv4, ipv6 etc +protocol = tcp +# IP address of the local network interface to bind for outgoing connections +localaddr = "" # A public gateway to any IRC network @@ -107,6 +112,10 @@ serverpassword = "" enabled = false timeout = 5 throttle = 2 +# Outgoing protocol, valid options: tcp, tcp4, tcp6 +protocol = tcp +# IP address of the local network interface to bind for outgoing connections +localaddr = "" # Whitelisted IRC networks while in public gateway mode # If any networks are in this list then connections can only be made to these @@ -122,7 +131,7 @@ irc.network2.org = webirc_password [dnsbl] # "verify" - if the client supports it, tell it to show a captcha # "deny" - deny the connection entirely -action = deny +action = verify [dnsbl.servers] dnsbl.dronebl.org diff --git a/conf/systemd.service b/conf/systemd.service new file mode 100644 index 0000000..d9366dd --- /dev/null +++ b/conf/systemd.service @@ -0,0 +1,49 @@ +[Unit] +Description=KiwiIRC server +After=network.target + +[Service] +Type=simple +User=__APP__ +Group=__APP__ +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/kiwiirc --config __INSTALL_DIR__/config.conf +StandardOutput=append:/var/log/__APP__/__APP__.log +StandardError=inherit + +### Depending on specificities of your service/app, you may need to tweak these +### .. but this should be a good baseline +# Sandboxing options to harden security +# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html +NoNewPrivileges=yes +PrivateTmp=yes +PrivateDevices=yes +RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK +RestrictNamespaces=yes +RestrictRealtime=yes +DevicePolicy=closed +ProtectClock=yes +ProtectHostname=yes +ProtectProc=invisible +ProtectSystem=full +ProtectControlGroups=yes +ProtectKernelModules=yes +ProtectKernelTunables=yes +LockPersonality=yes +SystemCallArchitectures=native +SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap @cpu-emulation @privileged + +# Denying access to capabilities that should not be relevant for webapps +# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html +CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD +CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE +CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT +CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK +CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM +CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG +CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE +CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW +CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG + +[Install] +WantedBy=multi-user.target diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index e69de29..0000000 diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 45e31df..0000000 --- a/manifest.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "KiwiIRC", - "id": "kiwiirc", - "packaging_format": 1, - "description": { - "en": "Versatile web based messenger using IRC", - "fr": "Messagerie Web polyvalente utilisant IRC" - }, - "version": "20.05.24.1~ynh1", - "url": "https://github.com/kiwiirc/kiwiirc", - "upstream": { - "license": "AGPL-3.0-only", - "website": "https://kiwiirc.com/", - "demo": "https://kiwiirc.com/nextclient", - "admindoc": "https://github.com/kiwiirc/kiwiirc/wiki", - "code": "https://github.com/kiwiirc/kiwiirc" - }, - "license": "AGPL-3.0-only", - "maintainer": { - "name": "eric_G" - }, - "requirements": { - "yunohost": ">= 4.3.0" - }, - "multi_instance": false, - "services": [ - "nginx" - ], - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..c2e62ef --- /dev/null +++ b/manifest.toml @@ -0,0 +1,52 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "kiwiirc" +name = "KiwiIRC" +description.en = "Versatile web based messenger using IRC" +description.fr = "Messagerie Web polyvalente utilisant IRC" + +version = "1.7.0~ynh1" + +maintainers = ["eric_G"] + +[upstream] +license = "AGPL-3.0-only" +website = "https://kiwiirc.com/" +demo = "https://kiwiirc.com/nextclient" +admindoc = "https://github.com/kiwiirc/kiwiirc/wiki" +code = "https://github.com/kiwiirc/kiwiirc" +fund = "https://kiwiirc.com/donate" + +[integration] +yunohost = ">= 11.2" +architectures = "all" +multi_instance = false +ldap = "not_relevant" +sso = "not_relevant" +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.domain] + type = "domain" + +[resources] + [resources.sources.main] + amd64.url = "https://github.com/kiwiirc/kiwiirc/releases/download/v1.7.0/kiwiirc-server_v1.7.0-2_linux_amd64.zip" + amd64.sha256 = "790d3b126ac4096d6a34de518f4cade9a291a1e0fe454c99aa460d508e916964" + arm64.url = "https://github.com/kiwiirc/kiwiirc/releases/download/v1.7.0/kiwiirc-server_v1.7.0-2_linux_arm64.zip" + arm64.sha256 = "32e1cc27f15c3057cd6c523a89c45e1663e0b02a4499df6a0c8338e8eebb0329" + armhf.url = "https://github.com/kiwiirc/kiwiirc/releases/download/v1.7.0/kiwiirc-server_v1.7.0-2_linux_armhf.zip" + armhf.sha256 = "a437d67447b169f6c72ae1a216aff277e2cd35df145c339d6ffd08eb796b6e22" + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + + [resources.ports] + main.default = 7778 diff --git a/scripts/backup b/scripts/backup index 474d4f0..4ef0540 100644 --- a/scripts/backup +++ b/scripts/backup @@ -9,23 +9,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= diff --git a/scripts/change_url b/scripts/change_url index 6834cfe..4ba8cf7 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,93 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH - -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -port=$(ynh_app_setting_get --app=$app --key=port) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. - ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then - change_domain=1 -fi - -change_path=0 -if [ "$old_path" != "$new_path" ] -then - change_path=1 -fi - #================================================= # MODIFY URL IN NGINX CONF #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the NGINX config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" - # Create a dedicated NGINX config - ynh_add_nginx_config -fi - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload +ynh_change_url_nginx_config #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 489f595..17786a5 100644 --- a/scripts/install +++ b/scripts/install @@ -9,83 +9,36 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -domain=$YNH_APP_ARG_DOMAIN -path_url="/" - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." --weight=2 - -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url - -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 - -# Find an available port -port=$(ynh_find_port --port=7778) -ynh_app_setting_set --app=$app --key=port --value=$port - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=2 -tempdir="$(mktemp -d)" -ynh_setup_source --dest_dir=$tempdir --source_id=app -ynh_exec_warn_less dpkg -i $tempdir/kiwiirc.deb +ynh_setup_source --source_id="main" --dest_dir="$install_dir" #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template="../conf/client.json.example" --destination="/etc/kiwiirc/client.json" -ynh_add_config --template="../conf/config.conf.example" --destination="/etc/kiwiirc/config.conf" +ynh_add_config --template="config.conf" --destination="$install_dir/config.conf" +chmod 400 "$install_dir/config.conf" +chown root: "$install_dir/config.conf" -chmod 744 "/etc/kiwiirc/config.conf" -chown root: "/etc/kiwiirc/config.conf" -chmod 744 "/etc/kiwiirc/client.json" -chown root: "/etc/kiwiirc/client.json" +ynh_add_config --template="client.json" --destination="$install_dir/www/static/client.json" +chmod 400 "$install_dir/www/static/client.json" +chown root: "$install_dir/www/static/client.json" #================================================= -# NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=2 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Versatile web based messenger using IRC" --log="/var/log/$app.log" +ynh_add_systemd_config +yunohost service add "$app" --description="Versatile web based messenger using IRC" --log="/var/log/$app.log" #================================================= # START SYSTEMD SERVICE @@ -93,14 +46,7 @@ yunohost service add $app --description="Versatile web based messenger using IRC ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 - -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 873bdbf..0707233 100644 --- a/scripts/remove +++ b/scripts/remove @@ -10,35 +10,21 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# LOAD SETTINGS +# REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) - -#================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST -#================================================= - -if ynh_exec_warn_less yunohost service status $app >/dev/null -then - ynh_script_progression --message="Removing $app service integration..." --weight=1 - yunohost service remove $app +# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) +if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then + yunohost service remove "$app" fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 - # Remove the dedicated systemd config ynh_remove_systemd_config +# Remove the dedicated nginx config +ynh_remove_nginx_config + #================================================= # REMOVE APP MAIN DIR #================================================= @@ -57,14 +43,6 @@ ynh_secure_remove --file="/etc/$app" # Remove the log files ynh_secure_remove --file="/var/log/$app.log" -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5 - -# Remove the dedicated nginx config -ynh_remove_nginx_config - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index f3c6ae1..8bc5a8d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,37 +10,13 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE SCRIPT FAILURE +# RESTORE SYSTEM CONFIGURATIONS #================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) - -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= -ynh_script_progression --message="Setting up source files..." --weight=2 - -tempdir="$(mktemp -d)" -ynh_setup_source --dest_dir=$tempdir --source_id=app -ynh_exec_warn_less dpkg -i $tempdir/kiwiirc.deb +yunohost service add $app --description="Versatile web based messenger using IRC" --log="/var/log/$app.log" #================================================= # RESTORE THE NGINX CONFIGURATION @@ -52,24 +28,22 @@ ynh_restore_file --origin_path="/etc/kiwiirc" ynh_restore_file --origin_path="/var/log/$app.log" #================================================= -# INTEGRATE SERVICE IN YUNOHOST +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression --message="Setting up source files..." --weight=2 -yunohost service add $app --description="Versatile web based messenger using IRC" --log="/var/log/$app.log" +tempdir="$(mktemp -d)" +ynh_setup_source --dest_dir=$tempdir +ynh_exec_warn_less dpkg -i $tempdir/kiwiirc.deb #================================================= -# START SYSTEMD SERVICE +# GENERIC FINALIZATION #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 - -ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" - +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 99de337..6a1dd10 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,13 +12,13 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2 -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) -port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # CHECK VERSION @@ -32,13 +32,13 @@ upgrade_type=$(ynh_check_app_version_changed) ynh_script_progression --message="Backing up KiwiIRC before upgrading..." --weight=3 # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -47,7 +47,7 @@ ynh_abort_if_errors if [ "$upgrade_type" == "UPGRADE_APP" ] then tempdir="$(mktemp -d)" - ynh_setup_source --dest_dir=$tempdir --source_id=app + ynh_setup_source --dest_dir=$tempdir ynh_exec_warn_less dpkg -i $tempdir/kiwiirc.deb fi @@ -77,9 +77,9 @@ ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..94abb79 --- /dev/null +++ b/tests.toml @@ -0,0 +1,5 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] From 7507771942e078028f92fb8a3f46e9d7aaf45469 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 5 Feb 2024 12:11:49 +0000 Subject: [PATCH 02/10] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8b245e2..45b246d 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ A versatile web based messenger using IRC - Extremely versatile via a single JSON config file at runtime -**Shipped version:** 20.05.24.1~ynh1 +**Shipped version:** 1.7.0~ynh1 **Demo:** https://kiwiirc.com/nextclient diff --git a/README_fr.md b/README_fr.md index 5cd89b3..5f41cbd 100644 --- a/README_fr.md +++ b/README_fr.md @@ -28,7 +28,7 @@ A versatile web based messenger using IRC - Extremely versatile via a single JSON config file at runtime -**Version incluse :** 20.05.24.1~ynh1 +**Version incluse :** 1.7.0~ynh1 **Démo :** https://kiwiirc.com/nextclient From 1a8ce2116b85c4e37690dfa8f4f1c1ac69c1518d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 5 Feb 2024 13:29:29 +0100 Subject: [PATCH 03/10] rename config file --- conf/{server.conf => config.conf} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename conf/{server.conf => config.conf} (100%) diff --git a/conf/server.conf b/conf/config.conf similarity index 100% rename from conf/server.conf rename to conf/config.conf From daa5a67fef3f506675fe59111950d840328aacd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 5 Feb 2024 14:30:09 +0100 Subject: [PATCH 04/10] fix permission --- scripts/install | 4 ++-- scripts/remove | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/scripts/install b/scripts/install index 17786a5..78c62e8 100644 --- a/scripts/install +++ b/scripts/install @@ -23,11 +23,11 @@ ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_add_config --template="config.conf" --destination="$install_dir/config.conf" chmod 400 "$install_dir/config.conf" -chown root: "$install_dir/config.conf" ynh_add_config --template="client.json" --destination="$install_dir/www/static/client.json" chmod 400 "$install_dir/www/static/client.json" -chown root: "$install_dir/www/static/client.json" + +chown -R "$app:www-data" "$install_dir" #================================================= # SYSTEM CONFIGURATION diff --git a/scripts/remove b/scripts/remove index 0707233..d1a8d31 100644 --- a/scripts/remove +++ b/scripts/remove @@ -25,21 +25,11 @@ ynh_remove_systemd_config # Remove the dedicated nginx config ynh_remove_nginx_config -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing Kiwiirc..." --weight=6 - -dpkg --purge kiwiirc - #================================================= # REMOVE VARIOUS FILES #================================================= ynh_script_progression --message="Removing various files..." --weight=1 -# Remove a cron file -ynh_secure_remove --file="/etc/$app" - # Remove the log files ynh_secure_remove --file="/var/log/$app.log" From 0dea66feb052a0ad8b96fb538f732a4ae0fcc989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 5 Feb 2024 14:37:30 +0100 Subject: [PATCH 05/10] Fix permission --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index 78c62e8..442bf6f 100644 --- a/scripts/install +++ b/scripts/install @@ -27,6 +27,7 @@ chmod 400 "$install_dir/config.conf" ynh_add_config --template="client.json" --destination="$install_dir/www/static/client.json" chmod 400 "$install_dir/www/static/client.json" +chmod 750 "$install_dir" chown -R "$app:www-data" "$install_dir" #================================================= From 0dca6a2d1834f653fb637a63e28b480b4d7f1ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 5 Feb 2024 14:44:20 +0100 Subject: [PATCH 06/10] Fix web server --- conf/config.conf | 2 +- conf/nginx.conf | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conf/config.conf b/conf/config.conf index 41f9af5..266d000 100644 --- a/conf/config.conf +++ b/conf/config.conf @@ -61,7 +61,7 @@ port = __PORT__ # Serve static files from a web root folder. # Optional, but handy for serving the Kiwi IRC client if no other webserver is available [fileserving] -enabled = true +enabled = false webroot = __INSTALL_DIR__/www/ [transports] diff --git a/conf/nginx.conf b/conf/nginx.conf index 3512ed3..8447990 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,15 +1,15 @@ location / { index index.html; - root /usr/share/kiwiirc/; + root __INSTALL_DIR/www/; } location /webirc/ { # Forward incoming requests to local webircgateway socket proxy_pass http://127.0.0.1:__PORT__/webirc/; - + # Set http version and headers proxy_http_version 1.1; - + # Add X-Forwarded-* headers proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Proto $scheme; From 1726a341614e11a3c09214f78d9d5ebd2d55c9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 5 Feb 2024 15:08:20 +0100 Subject: [PATCH 07/10] oops again --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 8447990..e424dc1 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,6 +1,6 @@ location / { index index.html; - root __INSTALL_DIR/www/; + root __INSTALL_DIR__/www/; } location /webirc/ { From ce77689c863374030386ed05ed56573d4327650f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 5 Feb 2024 15:30:16 +0100 Subject: [PATCH 08/10] continue packaging v2 --- scripts/backup | 16 +++++++++--- scripts/restore | 26 +++++++++---------- scripts/upgrade | 69 ++++++++++++------------------------------------- 3 files changed, 41 insertions(+), 70 deletions(-) diff --git a/scripts/backup b/scripts/backup index 4ef0540..273bf59 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,17 +14,25 @@ source /usr/share/yunohost/helpers #================================================= ynh_print_info --message="Declaring files to be backed up..." +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +ynh_backup --src_path="$install_dir" + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= +# Backup the nginx configuration ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP THE CONFIGURATION FILE -#================================================= +# Backup the systemd service unit +ynh_backup --src_path="/etc/systemd/system/$app.service" -ynh_backup --src_path="/etc/kiwiirc" +#================================================= +# BACKUP VARIOUS FILES +#================================================= ynh_backup --src_path="/var/log/$app.log" diff --git a/scripts/restore b/scripts/restore index 8bc5a8d..46494ed 100644 --- a/scripts/restore +++ b/scripts/restore @@ -9,6 +9,15 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=1 + +ynh_restore_file --origin_path="$install_dir" + +chown -R "$app:www-data" "$install_dir" + #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= @@ -16,26 +25,17 @@ ynh_script_progression --message="Restoring system configurations related to $ap ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -yunohost service add $app --description="Versatile web based messenger using IRC" --log="/var/log/$app.log" +ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +systemctl enable "$app.service" --quiet +yunohost service add "$app" --description="Versatile web based messenger using IRC" --log="/var/log/$app.log" #================================================= -# RESTORE THE NGINX CONFIGURATION +# RESTORE VARIOUS FILES #================================================= ynh_script_progression --message="Restoring various file..." --weight=1 -ynh_restore_file --origin_path="/etc/kiwiirc" - ynh_restore_file --origin_path="/var/log/$app.log" -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= -ynh_script_progression --message="Setting up source files..." --weight=2 - -tempdir="$(mktemp -d)" -ynh_setup_source --dest_dir=$tempdir -ynh_exec_warn_less dpkg -i $tempdir/kiwiirc.deb - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 6a1dd10..f32f2c6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,62 +9,32 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2 - -#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? port=$(ynh_app_setting_get --app=$app --key=port) - -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up KiwiIRC before upgrading..." --weight=3 - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - # restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Setting up source files..." --weight=2 -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - tempdir="$(mktemp -d)" - ynh_setup_source --dest_dir=$tempdir - ynh_exec_warn_less dpkg -i $tempdir/kiwiirc.deb -fi +ynh_setup_source --source_id="main" --dest_dir="$install_dir" --full_replace=1 --keep="config.conf www/static/client.json" + +ynh_add_config --template="config.conf" --destination="$install_dir/config.conf" +chmod 400 "$install_dir/config.conf" + +ynh_add_config --template="client.json" --destination="$install_dir/www/static/client.json" +chmod 400 "$install_dir/www/static/client.json" + +chmod 750 "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= -# NGINX CONFIGURATION +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Versatile web based messenger using IRC" --log="/var/log/$app.log" +ynh_add_systemd_config +yunohost service add "$app" --description="Versatile web based messenger using IRC" --log="/var/log/$app.log" #================================================= # START SYSTEMD SERVICE @@ -72,14 +42,7 @@ yunohost service add $app --description="Versatile web based messenger using IRC ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" - -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd" #================================================= # END OF SCRIPT From a64892a5431f150442960c45247c00916f65817c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 5 Feb 2024 15:39:09 +0100 Subject: [PATCH 09/10] Use logrotate, fix path to logfile --- scripts/backup | 5 ++++- scripts/install | 5 ++++- scripts/remove | 4 +++- scripts/restore | 6 ++++-- scripts/upgrade | 5 ++++- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/scripts/backup b/scripts/backup index 273bf59..b09c1c6 100644 --- a/scripts/backup +++ b/scripts/backup @@ -30,11 +30,14 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" # Backup the systemd service unit ynh_backup --src_path="/etc/systemd/system/$app.service" +# Backup the logrotate configuration +ynh_backup --src_path="/etc/logrotate.d/$app" + #================================================= # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/var/log/$app.log" +ynh_backup --src_path="/var/log/$app" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 442bf6f..c6690c4 100644 --- a/scripts/install +++ b/scripts/install @@ -39,7 +39,10 @@ ynh_script_progression --message="Adding system configurations related to $app.. ynh_add_nginx_config ynh_add_systemd_config -yunohost service add "$app" --description="Versatile web based messenger using IRC" --log="/var/log/$app.log" +yunohost service add "$app" --description="Versatile web based messenger using IRC" --log="/var/log/$app/$app.log" + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate #================================================= # START SYSTEMD SERVICE diff --git a/scripts/remove b/scripts/remove index d1a8d31..13b2032 100644 --- a/scripts/remove +++ b/scripts/remove @@ -22,6 +22,8 @@ fi # Remove the dedicated systemd config ynh_remove_systemd_config +ynh_remove_logrotate + # Remove the dedicated nginx config ynh_remove_nginx_config @@ -31,7 +33,7 @@ ynh_remove_nginx_config ynh_script_progression --message="Removing various files..." --weight=1 # Remove the log files -ynh_secure_remove --file="/var/log/$app.log" +ynh_secure_remove --file="/var/log/$app" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 46494ed..6867dc6 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,14 +27,16 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable "$app.service" --quiet -yunohost service add "$app" --description="Versatile web based messenger using IRC" --log="/var/log/$app.log" +yunohost service add "$app" --description="Versatile web based messenger using IRC" --log="/var/log/$app/$app.log" + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # RESTORE VARIOUS FILES #================================================= ynh_script_progression --message="Restoring various file..." --weight=1 -ynh_restore_file --origin_path="/var/log/$app.log" +ynh_restore_file --origin_path="/var/log/$app" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index f32f2c6..34300de 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -34,7 +34,10 @@ ynh_script_progression --message="Upgrading system configurations related to $ap ynh_add_nginx_config ynh_add_systemd_config -yunohost service add "$app" --description="Versatile web based messenger using IRC" --log="/var/log/$app.log" +yunohost service add "$app" --description="Versatile web based messenger using IRC" --log="/var/log/$app/$app.log" + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate #================================================= # START SYSTEMD SERVICE From 7a06a660b46fe5dea3300841ba0b39026ffa3cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Mon, 5 Feb 2024 15:56:02 +0100 Subject: [PATCH 10/10] fix linter --- manifest.toml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/manifest.toml b/manifest.toml index c2e62ef..65c0456 100644 --- a/manifest.toml +++ b/manifest.toml @@ -23,15 +23,22 @@ fund = "https://kiwiirc.com/donate" yunohost = ">= 11.2" architectures = "all" multi_instance = false + ldap = "not_relevant" + sso = "not_relevant" -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, ... + +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" [install.domain] type = "domain" + [install.init_main_permission] + type = "group" + default = "visitors" + [resources] [resources.sources.main] amd64.url = "https://github.com/kiwiirc/kiwiirc/releases/download/v1.7.0/kiwiirc-server_v1.7.0-2_linux_amd64.zip"