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 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": "
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": "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/config.conf similarity index 86% rename from conf/config.conf.example rename to conf/config.conf index f721721..e7bc21b 100644 --- a/conf/config.conf.example +++ b/conf/config.conf @@ -61,8 +61,8 @@ 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 -webroot = /usr/share/kiwiirc/ +enabled = false +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,8 @@ 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 +## notes for yunohost: it looks like the code accepts other values than deny and verify +action = none [dnsbl.servers] dnsbl.dronebl.org diff --git a/conf/nginx.conf b/conf/nginx.conf index 3512ed3..43f9646 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,18 +1,20 @@ 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; - + proxy_redirect default; + # Add X-Forwarded-* headers proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; # Allow upgrades to websockets 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..65c0456 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,59 @@ +#: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" +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" + 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..b09c1c6 100644 --- a/scripts/backup +++ b/scripts/backup @@ -9,41 +9,35 @@ 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 #================================================= 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 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 THE CONFIGURATION FILE +# BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/kiwiirc" - -ynh_backup --src_path="/var/log/$app.log" +ynh_backup --src_path="/var/log/$app" #================================================= # END OF SCRIPT 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..c6690c4 100644 --- a/scripts/install +++ b/scripts/install @@ -9,83 +9,40 @@ 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" -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" + +chmod 750 "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= -# 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 +ynh_add_systemd_config +yunohost service add "$app" --description="Versatile web based messenger using IRC" --log="/var/log/$app/$app.log" -yunohost service add $app --description="Versatile web based messenger using IRC" --log="/var/log/$app.log" +# Use logrotate to manage application logfile(s) +ynh_use_logrotate #================================================= # START SYSTEMD SERVICE @@ -93,14 +50,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..13b2032 100644 --- a/scripts/remove +++ b/scripts/remove @@ -10,60 +10,30 @@ 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 APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing Kiwiirc..." --weight=6 +ynh_remove_logrotate -dpkg --purge kiwiirc +# Remove the dedicated nginx config +ynh_remove_nginx_config #================================================= # 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" - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5 - -# Remove the dedicated nginx config -ynh_remove_nginx_config +ynh_secure_remove --file="/var/log/$app" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index f3c6ae1..6867dc6 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,66 +10,42 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE SCRIPT FAILURE +# RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=1 -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors +ynh_restore_file --origin_path="$install_dir" + +chown -R "$app:www-data" "$install_dir" #================================================= -# LOAD SETTINGS +# RESTORE SYSTEM CONFIGURATIONS #================================================= -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 +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/$app.log" -tempdir="$(mktemp -d)" -ynh_setup_source --dest_dir=$tempdir --source_id=app -ynh_exec_warn_less dpkg -i $tempdir/kiwiirc.deb +ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= -# 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" +ynh_restore_file --origin_path="/var/log/$app" #================================================= -# INTEGRATE SERVICE IN YUNOHOST +# GENERIC FINALIZATION #================================================= -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" - +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 - -ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" - -#================================================= -# 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..34300de 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,62 +9,35 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 - -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) - -#================================================= -# 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 -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # 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 --source_id=app - 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 +ynh_add_systemd_config +yunohost service add "$app" --description="Versatile web based messenger using IRC" --log="/var/log/$app/$app.log" -yunohost service add $app --description="Versatile web based messenger using IRC" --log="/var/log/$app.log" +# Use logrotate to manage application logfile(s) +ynh_use_logrotate #================================================= # START SYSTEMD SERVICE @@ -72,14 +45,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=1 - -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/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]