diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh deleted file mode 100755 index 72eb5cb..0000000 --- a/.github/workflows/updater.sh +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/bash - -#================================================= -# PACKAGE UPDATING HELPER -#================================================= - -# This script is meant to be run by GitHub Actions -# The YunoHost-Apps organisation offers a template Action to run this script periodically -# Since each app is different, maintainers can adapt its contents so as to perform -# automatic actions when a new upstream release is detected. - -# Remove this exit command when you are ready to run this Action -exit 1 - -#================================================= -# FETCHING LATEST RELEASE AND ITS ASSETS -#================================================= - -# Fetching information -current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') -repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') -# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) -version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) -assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) - -# Later down the script, we assume the version has only digits and dots -# Sometimes the release name starts with a "v", so let's filter it out. -# You may need more tweaks here if the upstream repository has different naming conventions. -if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then - version=${version:1} -fi - -# Setting up the environment variables -echo "Current version: $current_version" -echo "Latest release from upstream: $version" -echo "VERSION=$version" >> $GITHUB_ENV -echo "REPO=$repo" >> $GITHUB_ENV -# For the time being, let's assume the script will fail -echo "PROCEED=false" >> $GITHUB_ENV - -# Proceed only if the retrieved version is greater than the current one -if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then - echo "::warning ::No new version available" - exit 0 -# Proceed only if a PR for this new version does not already exist -elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then - echo "::warning ::A branch already exists for this update" - exit 0 -fi - -# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) -echo "${#assets[@]} available asset(s)" - -#================================================= -# UPDATE SOURCE FILES -#================================================= - -# Here we use the $assets variable to get the resources published in the upstream release. -# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. - -# Let's loop over the array of assets URLs -for asset_url in ${assets[@]}; do - -echo "Handling asset at $asset_url" - -# Assign the asset to a source file in conf/ directory -# Here we base the source file name upon a unique keyword in the assets url (admin vs. update) -# Leave $src empty to ignore the asset -case $asset_url in - *"admin"*) - src="app" - ;; - *"update"*) - src="app-upgrade" - ;; - *) - src="" - ;; -esac - -# If $src is not empty, let's process the asset -if [ ! -z "$src" ]; then - -# Create the temporary directory -tempdir="$(mktemp -d)" - -# Download sources and calculate checksum -filename=${asset_url##*/} -curl --silent -4 -L $asset_url -o "$tempdir/$filename" -checksum=$(sha256sum "$tempdir/$filename" | head -c 64) - -# Delete temporary directory -rm -rf $tempdir - -# Get extension -if [[ $filename == *.tar.gz ]]; then - extension=tar.gz -else - extension=${filename##*.} -fi - -# Rewrite source file -cat < conf/$src.src -SOURCE_URL=$asset_url -SOURCE_SUM=$checksum -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=$extension -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -EOT -echo "... conf/$src.src updated" - -else -echo "... asset ignored" -fi - -done - -#================================================= -# SPECIFIC UPDATE STEPS -#================================================= - -# Any action on the app's source code can be done. -# The GitHub Action workflow takes care of committing all changes after this script ends. - -#================================================= -# GENERIC FINALIZATION -#================================================= - -# Replace new version in manifest -echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json - -# No need to update the README, yunohost-bot takes care of it - -# The Action will proceed only if the PROCEED environment variable is set to true -echo "PROCEED=true" >> $GITHUB_ENV -exit 0 diff --git a/README.md b/README.md index 6f03f2a..4350c41 100644 --- a/README.md +++ b/README.md @@ -16,23 +16,17 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Isso – *Ich schrei sonst* – is a lightweight commenting server written in -Python and JavaScript. It aims to be a drop-in replacement for +Isso – *Ich schrei sonst* – is a lightweight commenting server written in Python and JavaScript. It aims to be a drop-in replacement for [Disqus](http://disqus.com). ### Features -- **Comments written in Markdown** - Users can edit or delete own comments (within 15 minutes by default). - Comments in moderation queue are not publicly visible before activation. -- **SQLite backend** - *Because comments are not Big Data.* -- **Disqus & WordPress Import** - You can migrate your Disqus/WordPress comments without any hassle. -- **Configurable JS client** - Embed a single JS file, 65kB (20kB gzipped) and you are done. +- Comments written in Markdown +- SQLite backend +- Disqus & WordPress Import +- Configurable JS client -**Shipped version:** 0.13.0~ynh2 +**Shipped version:** 0.13.0~ynh1 **Demo:** https://isso-comments.de @@ -40,23 +34,13 @@ Python and JavaScript. It aims to be a drop-in replacement for ![Screenshot of Isso](./doc/screenshots/example.jpg) -## Disclaimers / important information - -* Limitations - * Requires a dedicated domain - -* Extra information - * The admin interface for the app is `https://yourdomain.tld/admin` - * One app instance can only be installed for one domain - * Please do not add a trailing `/` in the target_domain - ## Documentation and resources * Official app website: * Official user documentation: * Official admin documentation: * Upstream app code repository: -* YunoHost documentation for this app: +* YunoHost Store: * Report a bug: ## Developer info diff --git a/README_fr.md b/README_fr.md index 91ea1fd..c47fa1d 100644 --- a/README_fr.md +++ b/README_fr.md @@ -16,23 +16,16 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ## Vue d’ensemble -Isso – *Ich schrei sonst* – is a lightweight commenting server written in -Python and JavaScript. It aims to be a drop-in replacement for -[Disqus](http://disqus.com). +Isso – *Ich schrei sonst* – est un serveur de commentaires léger écrit en Python et JavaScript. Il vise à être un remplacement direct pour [Disqus](http://disqus.com). -### Features +### Caractéristiques -- **Comments written in Markdown** - Users can edit or delete own comments (within 15 minutes by default). - Comments in moderation queue are not publicly visible before activation. -- **SQLite backend** - *Because comments are not Big Data.* -- **Disqus & WordPress Import** - You can migrate your Disqus/WordPress comments without any hassle. -- **Configurable JS client** - Embed a single JS file, 65kB (20kB gzipped) and you are done. +- Commentaires rédigés en Markdown +- Back-end SQLite +- Importation Disqus & WordPress +- Client JS paramétrable -**Version incluse :** 0.13.0~ynh2 +**Version incluse :** 0.13.0~ynh1 **Démo :** https://isso-comments.de @@ -40,23 +33,13 @@ Python and JavaScript. It aims to be a drop-in replacement for ![Capture d’écran de Isso](./doc/screenshots/example.jpg) -## Avertissements / informations importantes - -* Limitations - * Requires a dedicated domain - -* Extra information - * The admin interface for the app is `https://yourdomain.tld/admin` - * One app instance can only be installed for one domain - * Please do not add a trailing `/` in the target_domain - ## 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 : -* Documentation YunoHost pour cette app : +* YunoHost Store: * Signaler un bug : ## Informations pour les développeurs diff --git a/check_process b/check_process deleted file mode 100644 index 087739c..0000000 --- a/check_process +++ /dev/null @@ -1,21 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/admin" (PATH) - is_public=1 - admin="john" - password="1Strong-Password" - port="666" - target_domain="https://google.com" - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=1 - setup_nourl=0 - setup_private=0 - setup_public=1 - upgrade=1 - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=0 diff --git a/conf/isso.cfg b/conf/isso.cfg index 1e2212e..c729d67 100644 --- a/conf/isso.cfg +++ b/conf/isso.cfg @@ -4,8 +4,8 @@ approve-if-email-previously-approved = true purge-after = 69d [general] -dbpath = __DATADIR__/comments.db -host = __TARGETDOMAIN__ +dbpath = __DATA_DIR__/comments.db +host = __TARGET_DOMAIN__ notify = smtp gravatar = true @@ -16,12 +16,12 @@ password = host = localhost port = 25 security = none -to = __ADMINMAIL__ +to = __EMAIL__ from = "Isso Comments" timeout = 10 [server] -listen = http://localhost:__PORT__ +listen = http://127.0.0.1:__PORT__ public-endpoint = trusted-proxies = ['127.0.0.1','localhost'] diff --git a/conf/nginx.conf b/conf/nginx.conf index d5cea5a..d7eb2ea 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,6 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { + proxy_pass http://127.0.0.1:__PORT__; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; diff --git a/conf/systemd.service b/conf/systemd.service index 1d6ffd3..f52ac8e 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,13 +1,13 @@ [Unit] -Description=isso commenting system +Description=Isso: commenting system After=network.target [Service] Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/venv/bin/isso -c __FINALPATH__/isso.cfg run +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/venv/bin/isso -c __INSTALL_DIR__/isso.cfg run StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..cb4ded8 --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1,2 @@ +* The admin interface for the app is `https://__DOMAIN__/admin` +* One app instance can only be installed for one domain diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md new file mode 100644 index 0000000..cb4ded8 --- /dev/null +++ b/doc/ADMIN_fr.md @@ -0,0 +1,2 @@ +* The admin interface for the app is `https://__DOMAIN__/admin` +* One app instance can only be installed for one domain diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 708fcff..9d1ccec 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1,15 +1,9 @@ -Isso – *Ich schrei sonst* – is a lightweight commenting server written in -Python and JavaScript. It aims to be a drop-in replacement for +Isso – *Ich schrei sonst* – is a lightweight commenting server written in Python and JavaScript. It aims to be a drop-in replacement for [Disqus](http://disqus.com). ### Features -- **Comments written in Markdown** - Users can edit or delete own comments (within 15 minutes by default). - Comments in moderation queue are not publicly visible before activation. -- **SQLite backend** - *Because comments are not Big Data.* -- **Disqus & WordPress Import** - You can migrate your Disqus/WordPress comments without any hassle. -- **Configurable JS client** - Embed a single JS file, 65kB (20kB gzipped) and you are done. \ No newline at end of file +- Comments written in Markdown +- SQLite backend +- Disqus & WordPress Import +- Configurable JS client \ No newline at end of file diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..f6b58c6 --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1,8 @@ +Isso – *Ich schrei sonst* – est un serveur de commentaires léger écrit en Python et JavaScript. Il vise à être un remplacement direct pour [Disqus](http://disqus.com). + +### Caractéristiques + +- Commentaires rédigés en Markdown +- Back-end SQLite +- Importation Disqus & WordPress +- Client JS paramétrable \ No newline at end of file diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index 2077c8a..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,7 +0,0 @@ -* Limitations - * Requires a dedicated domain - -* Extra information - * The admin interface for the app is `https://yourdomain.tld/admin` - * One app instance can only be installed for one domain - * Please do not add a trailing `/` in the target_domain diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 2805b83..0000000 --- a/manifest.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "Isso", - "id": "isso", - "packaging_format": 1, - "description": { - "en": "Lightweight commenting server", - "fr": "Système de commentaire léger" - }, - "version": "0.13.0~ynh2", - "url": "https://isso-comments.de", - "upstream": { - "license": "MIT", - "website": "https://isso-comments.de", - "demo": "https://isso-comments.de", - "admindoc": "https://isso-comments.de/docs/reference/server-config/", - "userdoc": "https://isso-comments.de/docs/reference/client-config/", - "code": "https://github.com/posativ/isso" - }, - "license": "MIT", - "maintainer": { - "name": "Navan Chauhan", - "email": "isso@navan.email" - }, - "requirements": { - "yunohost": ">= 11.0.9" - }, - "multi_instance": true, - "services": [ - "nginx" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "target_domain", - "type": "string", - "ask": { - "en": "your website or blog (not the location of Isso!)" - }, - "example": "https://someotherwebsite.com/" - }, { - "name": "admin", - "type": "user", - "help": { - "en": "User who will receive moderation emails" - } - }, - { - "name": "password", - "type": "password", - "help": { - "en": "Password for the admin interface", - "fr": "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question." - } - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..7e8fc65 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,77 @@ +packaging_format = 2 + +id = "isso" +name = "Isso" +description.en = "Lightweight commenting server" +description.fr = "Système de commentaire léger" + +version = "0.13.0~ynh1" + +maintainers = ["Navan Chauhan"] + +[upstream] +license = "MIT" +website = "https://isso-comments.de" +demo = "https://isso-comments.de" +admindoc = "https://isso-comments.de/docs/reference/server-config/" +userdoc = "https://isso-comments.de/docs/reference/client-config/" +code = "https://github.com/posativ/isso" + +[integration] +yunohost = ">= 11.2" +architectures = "all" +multi_instance = true + +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.target_domain] + ask.en = "your website or blog (not the location of Isso!). Please do not add a trailing `/` in the target_domain" + ask.fr = "votre site Web ou votre blog (pas l'emplacement d'Isso !). Veuillez ne pas ajouter de `/` à la fin du domaine_cible" + type = "string" + example = "https://someotherwebsite.com" + + [install.admin] + help.en = "User who will receive moderation emails" + help.fr = "Utilisateur qui recevra les emails de modération" + type = "user" + + [install.password] + help.en = "Password for the admin interface." + help.fr = "Mot de passe pour l'interface d'administration." + type = "password" + +[resources] + + [resources.ports] + + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + + [resources.permissions] + main.url = "/" + admin.url = "/admin" + admin.allowed = "admins" + api.url = "/api" + api.allowed = "visitors" + api.show_tile = false + api.protected = true + + [resources.apt] + packages = "git, curl, python3, python3-pip, python3-venv, libpq-dev, libsasl2-dev, python3-dev, libssl-dev, libffi-dev, python3-cffi" diff --git a/scripts/_common.sh b/scripts/_common.sh index 3357689..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app (must be on a single line) -pkg_dependencies="git curl python3 python3-pip python3-venv libpq-dev libsasl2-dev python3-dev libssl-dev libffi-dev python3-cffi" - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 4ba0b55..d4006e2 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,28 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -41,13 +19,13 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$datadir" --is_big +ynh_backup --src_path="$data_dir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 322641b..3a9b28d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,64 +9,6 @@ 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 - -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -# Add settings here as needed by your application -#db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#db_user=$db_name -#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) - -#================================================= -# BACKUP BEFORE CHANGE URL 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 - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -74,42 +16,14 @@ fi #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +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 -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 - -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= +ynh_change_url_nginx_config #================================================= # GENERIC FINALISATION @@ -118,14 +32,7 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# 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="start" --log_path="systemd" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 15eac79..c80c21f 100755 --- a/scripts/install +++ b/scripts/install @@ -9,92 +9,18 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -domain=$YNH_APP_ARG_DOMAIN -path_url=/ -password=$YNH_APP_ARG_PASSWORD -is_public=1 -admin=$YNH_APP_ARG_ADMIN -targetdomain=$YNH_APP_ARG_TARGET_DOMAIN - -app=$YNH_APP_INSTANCE_NAME - -adminmail=$(ynh_user_get_info --username=$admin --key=mail) - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 - -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 - -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=targetdomain --value=$targetdomain +email=$(ynh_user_get_info --username=$admin --key=mail) ynh_app_setting_set --app=$app --key=password --value=$password -ynh_app_setting_set --app=$app --key=admin --value=$admin -ynh_app_setting_set --app=$app --key=adminmail --value=$adminmail - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 - -# Find an available port -port=$(ynh_find_port --port=8095) -ynh_app_setting_set --app=$app --key=port --value=$port - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=3 - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # Setup Final Path #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -mkdir -p $final_path +mkdir -p $install_dir -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - -ynh_app_setting_set --app=$app --key=final_path --value=$final_path +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # NGINX CONFIGURATION @@ -108,37 +34,23 @@ ynh_add_nginx_config # SPECIFIC SETUP #================================================= -pushd $final_path - ynh_exec_as $app python3 -m venv $final_path/venv - ynh_exec_as $app "$final_path/venv/bin/pip" install --upgrade pip - ynh_exec_as $app "$final_path/venv/bin/pip" install --upgrade setuptools - ynh_exec_as $app "$final_path/venv/bin/pip" install --upgrade MarkupSafe - ynh_exec_as $app "$final_path/venv/bin/pip" install isso gunicorn +pushd $install_dir + ynh_exec_as $app python3 -m venv $install_dir/venv + ynh_exec_as $app "$install_dir/venv/bin/pip" install --upgrade pip + ynh_exec_as $app "$install_dir/venv/bin/pip" install --upgrade setuptools + ynh_exec_as $app "$install_dir/venv/bin/pip" install --upgrade MarkupSafe + ynh_exec_as $app "$install_dir/venv/bin/pip" install isso gunicorn popd -#================================================= -# CREATE DATA DIRECTORY -#================================================= -ynh_script_progression --message="Creating a data directory..." --weight=2 - -datadir=/home/yunohost.app/$app -ynh_app_setting_set --app=$app --key=datadir --value=$datadir - -mkdir -p $datadir - -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" - #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template="isso.cfg" --destination="$final_path/isso.cfg" +ynh_add_config --template="isso.cfg" --destination="$install_dir/isso.cfg" -chmod 400 "$final_path/isso.cfg" -chown $app:$app "$final_path/isso.cfg" +chmod 400 "$install_dir/isso.cfg" +chown $app:$app "$install_dir/isso.cfg" #================================================= # SETUP SYSTEMD @@ -148,22 +60,10 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 - # Use logrotate to manage application logfile(s) ynh_use_logrotate -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Isso - a commenting server" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Lightweight commenting server" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE @@ -171,33 +71,7 @@ yunohost service add $app --description="Isso - a commenting server" --log="/var ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # Everyone can access the app. - # The "main" permission is automatically created before the install script. - ynh_permission_update --permission="main" --add="visitors" -fi - -# Only the admin can access the admin panel of the app (if the app has an admin panel) -ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin - -# Possible js bundle and api permission -# ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true" - -#================================================= -# 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="start" --log_path="systemd" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index cbe2841..c04a74d 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,18 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) - #================================================= # STANDARD REMOVE #================================================= @@ -34,87 +22,18 @@ 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 LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 - # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" - -#================================================= -# REMOVE DATA DIR -#================================================= - -# Remove the data directory if --purge option is used -if [ "${YNH_APP_PURGE:-0}" -eq 1 ] -then - ynh_script_progression --message="Removing app data directory..." --weight=1 - ynh_secure_remove --file="$datadir" -fi - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." --weight=1 - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." --weight=2 - # Remove the log files ynh_secure_remove --file="/var/log/$app" -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 99c80ba..ed9c14b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,80 +10,24 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod -R o-rwx "$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="$datadir" --not_mandatory +ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $datadir - -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" - -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=1 - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +chown -R $app:www-data "$data_dir" #================================================= # RESTORE THE NGINX CONFIGURATION @@ -92,19 +36,9 @@ ynh_script_progression --message="Restoring the NGINX web server configuration.. ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 - ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 - mkdir -p "/var/log/$app" chown -R $app: "/var/log/$app" @@ -115,21 +49,14 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Isso - a commenting server" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Lightweight commenting server" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --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 7c3ec86..9e48c67 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,22 +9,7 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -admin=$(ynh_app_setting_get --app=$app --key=admin) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -targetdomain=$(ynh_app_setting_get --app=$app --key=targetdomain) -adminmail=$(ynh_app_setting_get --app=$app --key=adminmail) -port=$(ynh_app_setting_get --app=$app --key=port) -password=$(ynh_app_setting_get --app=$app --key=password) +email=$(ynh_user_get_info --username=$admin --key=mail) #================================================= # CHECK VERSION @@ -32,20 +17,6 @@ password=$(ynh_app_setting_get --app=$app --key=password) upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -53,21 +24,13 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -76,21 +39,13 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 - pushd $final_path - ynh_exec_as $app "$final_path/venv/bin/pip" install --upgrade isso gunicorn + pushd $install_dir + ynh_exec_as $app "$install_dir/venv/bin/pip" install --upgrade isso gunicorn popd fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -ynh_install_app_dependencies $pkg_dependencies +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # NGINX CONFIGURATION @@ -105,10 +60,10 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=1 -ynh_add_config --template="isso.cfg" --destination="$final_path/isso.cfg" +ynh_add_config --template="isso.cfg" --destination="$install_dir/isso.cfg" -chmod 400 "$final_path/isso.cfg" -chown $app:$app "$final_path/isso.cfg" +chmod 400 "$install_dir/isso.cfg" +chown $app:$app "$install_dir/isso.cfg" #================================================= # SETUP SYSTEMD @@ -133,21 +88,14 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Isso - a commenting server" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Lightweight commenting server" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# 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="start" --log_path="systemd" #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..f483290 --- /dev/null +++ b/tests.toml @@ -0,0 +1,7 @@ +test_format = 1.0 + +[default] + + + +args.target_domain="https://google.com" \ No newline at end of file