diff --git a/README.md b/README.md new file mode 100644 index 0000000..70a2d00 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ + + +# Gancio for YunoHost + +[![Integration level](https://dash.yunohost.org/integration/gancio.svg)](https://dash.yunohost.org/appci/app/gancio) ![Working status](https://ci-apps.yunohost.org/ci/badges/gancio.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/gancio.maintain.svg) + +[![Install Gancio with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=gancio) + +*[Lire ce readme en français.](./README_fr.md)* + +> *This package allows you to install Gancio quickly and simply on a YunoHost server. +If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* + +## Overview + +Gancio provide an online agenda open to contributions, and federated with the fediverse using ActivityPub. + + +**Shipped version:** 1.6.17~ynh1 + +**Demo:** https://demo.gancio.org/ +## Documentation and resources + +* Official app website: +* Official user documentation: +* Official admin documentation: +* Upstream app code repository: +* Report a bug: + +## Developer info + +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/gancio_ynh/tree/testing). + +To try the testing branch, please proceed like that. + +``` bash +sudo yunohost app install https://github.com/YunoHost-Apps/gancio_ynh/tree/testing --debug +or +sudo yunohost app upgrade gancio -u https://github.com/YunoHost-Apps/gancio_ynh/tree/testing --debug +``` + +**More info regarding app packaging:** diff --git a/README_fr.md b/README_fr.md new file mode 100644 index 0000000..3a0fda1 --- /dev/null +++ b/README_fr.md @@ -0,0 +1,44 @@ + + +# Gancio pour YunoHost + +[![Niveau d’intégration](https://dash.yunohost.org/integration/gancio.svg)](https://dash.yunohost.org/appci/app/gancio) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/gancio.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/gancio.maintain.svg) + +[![Installer Gancio avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=gancio) + +*[Read this readme in english.](./README.md)* + +> *Ce package vous permet d’installer Gancio rapidement et simplement sur un serveur YunoHost. +Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l’installer et en profiter.* + +## Vue d’ensemble + +Gancio propose un agenda en ligne ouvert aux contributions, et fédéré avec le fediverse via ActivityPub. + +**Version incluse :** 1.6.17~ynh1 + +**Démo :** https://demo.gancio.org/ +## Documentations et ressources + +* Site officiel de l’app : +* Documentation officielle utilisateur : +* Documentation officielle de l’admin : +* Dépôt de code officiel de l’app : +* Signaler un bug : + +## Informations pour les développeurs + +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/gancio_ynh/tree/testing). + +Pour essayer la branche testing, procédez comme suit. + +``` bash +sudo yunohost app install https://github.com/YunoHost-Apps/gancio_ynh/tree/testing --debug +ou +sudo yunohost app upgrade gancio -u https://github.com/YunoHost-Apps/gancio_ynh/tree/testing --debug +``` + +**Plus d’infos sur le packaging d’applications :** \ No newline at end of file diff --git a/conf/config.json b/conf/config.json new file mode 100644 index 0000000..6100205 --- /dev/null +++ b/conf/config.json @@ -0,0 +1,24 @@ +{ + "baseurl": "https://__DOMAIN__", + "server": { + "host": "localhost", + "port": "__PORT__" + }, + "log_level": "debug", + "log_path": "/var/log/__APP__/logs", + "db": { + "dialect": "postgres", + "storage": "", + "host": "localhost", + "database": "__DB_NAME__", + "username": "__DB_USER__", + "password": "__DB_PWD__", + "logging": false, + "dialectOptions": { + "autoJsonMap": true + } + }, + "user_locale": "__DATA_DIR__/user_locale", + "upload_path": "__DATA_DIR__/uploads", + "plugins_path": "__DATA_DIR__/plugins" +} diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..74bcc57 --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,11 @@ +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { + + proxy_pass http://127.0.0.1:__PORT__; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; +} diff --git a/conf/systemd.service b/conf/systemd.service new file mode 100644 index 0000000..93f2bbf --- /dev/null +++ b/conf/systemd.service @@ -0,0 +1,48 @@ +[Unit] +Description=Gancio: federated agenda +After=network.target + +[Service] +Type=simple +User=__APP__ +Group=__APP__ +WorkingDirectory=__INSTALL_DIR__/ +Environment="__YNH_NODE_LOAD_PATH__" +ExecStart=__YNH_NODE__ server/cli.js start --config ./config.json + +# 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 +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/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..760caef --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +Gancio provide an online agenda open to contributions, and federated with the fediverse using ActivityPub. diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..455d1a4 --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +Gancio propose un agenda en ligne ouvert aux contributions, et fédéré avec le fediverse via ActivityPub. \ No newline at end of file diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..1cc2df3 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,84 @@ +packaging_format = 2 + +id = "gancio" +name = "Gancio" + +description.en = "Shared agenda for local communities, federated with the fediverse" +description.fr = "Agenda partagé pour les communautés locales, fédéré avec le fédiverse" + +version = "1.6.17~ynh1" + +maintainers = ["Lapineige"] + +[upstream] +license = "AGPL-3.0-only" +website = "https://gancio.org" +demo = "https://demo.gancio.org/" +admindoc = "https://gancio.org/install/" +userdoc = "https://gancio.org/usage" +code = "https://framagit.org/les/gancio" + +[integration] +yunohost = ">= 11.2" +architectures = "all" +multi_instance = false +ldap = false +sso = false +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" + +[install] + + [install.domain] + type = "domain" + + [install.init_main_permission] + type = "group" + default = "visitors" + + [install.language] + ask.en = "Choose the application language" + ask.fr = "Choisissez la langue de l'application" + type = "select" + choices = ['en', 'fr', 'en', 'it', 'zh', 'pt', 'nl', 'ru'] + default = "en" + + [install.admin] + type = "user" + + [install.password] + help.en = "Choose admin user password" + help.fr = "Choisissez le mot de passe du compte d'administration." + type = "password" + +[resources] + + [resources.sources] + + [resources.sources.main] + url = "https://gancio.org/releases/gancio-v1.6.17.tgz" + sha256 = "fd9b0869d4c733c4b7de9f3bec0889918170822f1b12104ec32923c30648746f" + + [resources.system_user] + allow_email = true + + [resources.install_dir] + + [resources.data_dir] + subdirs = ['uploads', 'user_locale', 'plugins'] + + [resources.permissions] + main.url = "/" + + [resources.ports] + + [resources.apt] + packages = "postgresql" + extras.yarn.repo = "deb https://dl.yarnpkg.com/debian/ stable main" + extras.yarn.key = "https://dl.yarnpkg.com/debian/pubkey.gpg" + extras.yarn.packages = "yarn" + + [resources.database] + type = "postgresql" + diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..b818f0f --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +#================================================= +# COMMON VARIABLES +#================================================= + +nodejs_version=16 + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup new file mode 100644 index 0000000..129a147 --- /dev/null +++ b/scripts/backup @@ -0,0 +1,61 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# 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 DATA DIR +#================================================= + +ynh_backup --src_path="$data_dir" --is_big + +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= + +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP LOGROTATE +#================================================= + +ynh_backup --src_path="/etc/logrotate.d/$app" + +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup --src_path="/etc/systemd/system/$app.service" + +#================================================= +# BACKUP THE DATABASE +#================================================= +ynh_print_info --message="Backing up the postgresql database..." + +ynh_psql_dump_db --database="$db_name" > db.sql + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..6c33e71 --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,51 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 + +ynh_change_url_nginx_config + +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 + +ynh_add_config --template="config.json" --destination="$install_dir/config.json" + +chmod 400 "$install_dir/config.json" +chown $app:$app "$install_dir/config.json" + +#================================================= +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/config b/scripts/config new file mode 100644 index 0000000..90cd7aa --- /dev/null +++ b/scripts/config @@ -0,0 +1,105 @@ +#!/bin/bash +#### App file generated with YoloGen, the Yunohost app generator, version 0.6. +# This is the tutorial version of the app. +# It contains extra commands to explain what should be done in case you want to adjust some part of the script. +# Once you are done, you may remove them. +# In simple cases, you don't need a config script. + +# With a simple config_panel.toml, you can write in the app settings, in the +# upstream config file or replace complete files (logo ...) and restart services. + +# The config scripts allows you to go further, to handle specific cases +# (validation of several interdependent fields, specific getter/setter for a value, +# display dynamic informations or choices, pre-loading of config type .cube... ). +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source /usr/share/yunohost/helpers + +ynh_abort_if_errors + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) + +#================================================= +# SPECIFIC GETTERS FOR TOML SHORT KEY +#================================================= + +get__amount() { + # Here we can imagine to have an API call to stripe to know the amount of donation during a month + local amount = 200 + + # It's possible to change some properties of the question by overriding it: + if [ $amount -gt 100 ] + then + cat << EOF +style: success +value: $amount +ask: + en: A lot of donation this month: **$amount €** +EOF + else + cat << EOF +style: danger +value: $amount +ask: + en: Not so much donation this month: $amount € +EOF + fi +} + +get__prices() { + local prices = "$(grep "DONATION\['" "$install_dir/settings.py" | sed -r "s@^DONATION\['([^']*)'\]\['([^']*)'\] = '([^']*)'@\1/\2/\3@g" | sed -z 's/\n/,/g;s/,$/\n/')" + if [ "$prices" == "," ]; + then + # Return YNH_NULL if you prefer to not return a value at all. + echo YNH_NULL + else + echo $prices + fi +} + + +#================================================= +# SPECIFIC VALIDATORS FOR TOML SHORT KEYS +#================================================= +validate__publishable_key() { + + # We can imagine here we test if the key is really a publisheable key + (is_secret_key $publishable_key) && + echo 'This key seems to be a secret key' +} + +#================================================= +# SPECIFIC SETTERS FOR TOML SHORT KEYS +#================================================= +set__prices() { + + #--------------------------------------------- + # IMPORTANT: setter are trigger only if a change is detected + #--------------------------------------------- + for price in $(echo $prices | sed "s/,/ /"); do + frequency=$(echo $price | cut -d/ -f1) + currency=$(echo $price | cut -d/ -f2) + price_id=$(echo $price | cut -d/ -f3) + sed "d/DONATION\['$frequency'\]\['$currency'\]" "$install_dir/settings.py" + + echo "DONATION['$frequency']['$currency'] = '$price_id'" >> "$install_dir/settings.py" + done + + #--------------------------------------------- + # IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too + #--------------------------------------------- + ynh_app_setting_set $app prices $prices +} + +#================================================= +# GENERIC FINALIZATION +#================================================= +ynh_app_config_run $1 \ No newline at end of file diff --git a/scripts/install b/scripts/install new file mode 100644 index 0000000..4118fb1 --- /dev/null +++ b/scripts/install @@ -0,0 +1,86 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=10 + +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + +#================================================= +# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC) +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_script_progression --message="Setting up source files..." --weight=1 + +ynh_setup_source --dest_dir="$install_dir" + +chown -R $app:www-data "$install_dir" + +#================================================= +# SYSTEM CONFIGURATION +#================================================= +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 + +# Create a dedicated NGINX config using the conf/nginx.conf template +ynh_add_nginx_config + +# Create a dedicated systemd config +ynh_add_systemd_config + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate + +mkdir -p /var/log/$app +chown $app -R /var/log/$app + +yunohost service add $app --description="Federated shared agenda for local communities" --log="/var/log/$app/$app.log" + +#================================================= +# APP INITIAL CONFIGURATION +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 + +ynh_add_config --template="config.json" --destination="$install_dir/config.json" + +chmod 400 "$install_dir/config.json" +chown $app:$app "$install_dir/config.json" + +#================================================= +# INSTALL YARN AND APP +#================================================= +ynh_script_progression --message="Installing app dependencies and creating admin user..." --weight=15 + +pushd $install_dir + ynh_use_nodejs + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install # Install dependencies + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH ./server/cli.js users create __ADMIN__ --admin --config ./config.json +popd + +#================================================= +# GENERIC FINALIZATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" + +#================================================= +# END OF SCRIPT +#================================================= +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove new file mode 100644 index 0000000..7d5b107 --- /dev/null +++ b/scripts/remove @@ -0,0 +1,38 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# REMOVE SYSTEM CONFIGURATIONS +#================================================= +# REMOVE SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 + +# 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 + ynh_script_progression --message="Removing $app service integration..." --weight=1 + yunohost service remove $app +fi + +ynh_remove_systemd_config + +ynh_remove_nginx_config + +ynh_remove_logrotate + +ynh_secure_remove --file="/var/log/$app" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore new file mode 100644 index 0000000..8dee014 --- /dev/null +++ b/scripts/restore @@ -0,0 +1,84 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=10 + +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + +#================================================= +# 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 THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." --weight=1 + +ynh_restore_file --origin_path="$data_dir" --not_mandatory + +# (Same as for install dir) +chown -R $app:www-data "$data_dir" + +#================================================= +# RESTORE THE MYSQL DATABASE +#================================================= +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 + +ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql + +#================================================= +# RESTORE SYSTEM CONFIGURATIONS +#================================================= +# RESTORE THE PHP-FPM 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" + +mkdir -p /var/log/$app +chown $app -R /var/log/$app + +ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +systemctl enable $app.service --quiet + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + +chown $app:$app "/var/log/$app" + +yunohost service add $app --description="Federated shared agenda for local communities" --log="/var/log/$app/$app.log" + + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE +#================================================= +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 + +# Typically you only have either $app or php-fpm but not both at the same time... +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100644 index 0000000..0f45e8f --- /dev/null +++ b/scripts/upgrade @@ -0,0 +1,90 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +upgrade_type=$(ynh_check_app_version_changed) + +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" + +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." --weight=1 + + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$install_dir" --keep="config.json" +fi + +chown -R $app:www-data "$install_dir" + +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=10 + +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + +#================================================= +# REAPPLY SYSTEM CONFIGURATIONS +#================================================= +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 + +# This should be a literal copypasta of what happened in the install's "System configuration" section +ynh_add_nginx_config + +ynh_add_systemd_config + +ynh_use_logrotate --non-append + +yunohost service add $app --description="Federated shared agenda for local communities" --log="/var/log/$app/$app.log" + +#================================================= +# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) +#================================================= +# UPDATE A CONFIG FILE +#================================================= +#ynh_script_progression --message="Updating a configuration file..." --weight=1 + +#ynh_add_config --template="config.json" --destination="$install_dir/config.json" + +#chmod 400 "$install_dir/config.json" +#chown $app:$app "$install_dir/config.json" + +#================================================= +# CONFIGURE THE APP +#================================================= +ynh_script_progression --message="Updating app dependencies..." --weight=15 + +pushd $install_dir + ynh_use_nodejs + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install # Install/upgrade dependencies +popd + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --last diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..91daf17 --- /dev/null +++ b/tests.toml @@ -0,0 +1,7 @@ +test_format = 1.0 + +[default] + + # ------------ + # Tests to run + # ------------ \ No newline at end of file