From 39c6bdd601418b7f1d0fba5d607e46a9ab4f5d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 22 Oct 2020 20:57:28 +0200 Subject: [PATCH 01/24] Update README.md --- README.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f2eef3a..b0c4f13 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ -# ZeroNet package for YunoHost +# ZeroNet for YunoHost [![Integration level](https://dash.yunohost.org/integration/zeronet.svg)](https://dash.yunohost.org/appci/app/zeronet) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.maintain.svg) [![Install ZeroNet with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=zeronet) -- [ZeroNet project](https://github.com/HelloZeroNet/ZeroNet) - ## Install - This app can only be installed on root path, i.e you will need to use a dedicated domain name, e.g.`zeronet.domain.tld`. - The app is installed in private mode only so unauthenticated users can not temper with your content. @@ -16,3 +14,23 @@ ## Hint - Use at your own risk :-) + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/zeronet_ynh/issues + * App website: https://zeronet.io/ + * Upstream app repository: https://github.com/HelloZeroNet/ZeroNet + * YunoHost website: https://yunohost.org/ + +--- + +## Developer info + +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/zeronet_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/zeronet_ynh/tree/testing --debug +or +sudo yunohost app upgrade zeronet -u https://github.com/YunoHost-Apps/zeronet_ynh/tree/testing --debug +``` From 33e6d5c4a66ca377add700429ad7ec66b1e5d2df Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 22 Oct 2020 21:15:55 +0200 Subject: [PATCH 02/24] Upgrade to v.0.7.1 --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++-- conf/app.src | 6 +++--- manifest.json | 10 ++++----- scripts/backup | 2 +- scripts/functions.sh | 14 ++++++------- scripts/install | 40 ++++++++++++++++++------------------ scripts/remove | 20 +++++++++--------- scripts/restore | 24 +++++++++++----------- scripts/upgrade | 4 ++-- 9 files changed, 106 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index b0c4f13..1dc8d7d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,24 @@ [![Integration level](https://dash.yunohost.org/integration/zeronet.svg)](https://dash.yunohost.org/appci/app/zeronet) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.maintain.svg) [![Install ZeroNet with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=zeronet) +*[Lire ce readme en français.](./README_fr.md)* + +> *This package allows you to install REPLACEBYYOURAPP 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 +eroNet allows you to publish static and dynamic websites on a distributed web platform. + +**Shipped version:** 0.7.1 + +## Screenshots + +![](https://camo.githubusercontent.com/4629a7d44a828f5bb20cedd90522ae62f0947b35/68747470733a2f2f692e696d6775722e636f6d2f4836304f4148592e706e67) + +## Demo + +* [Official demo](Link to a demo site for this app.) + ## Install - This app can only be installed on root path, i.e you will need to use a dedicated domain name, e.g.`zeronet.domain.tld`. - The app is installed in private mode only so unauthenticated users can not temper with your content. @@ -12,8 +30,34 @@ - Installing multiple instances of the app is *experimental*. Internally each instance it will use a unique port for both for ZeroNet UserInterface and FileServer. However, the tracker will see all instances as one peer, as they all use one and the same external IP address. - A solution that hasn't been confirmed yet is to use Tor instead. Each instance should then have a unique external address. -## Hint -- Use at your own risk :-) +## Documentation + + * Official documentation: https://zeronet.io/docs/site_development/getting_started/ + * YunoHost documentation: If specific documentation is needed, feel free to contribute. + +## YunoHost specific features + +#### Multi-user support + +Are LDAP and HTTP auth supported? +Can the app be used by multiple users? + +#### Supported architectures + +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/REPLACEBYYOURAPP/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/REPLACEBYYOURAPP/) + +## Limitations + +* Any known limitations. + +## Additional information + +* Other info you would like to add about this app. + +**More info on the documentation page:** +https://yunohost.org/packaging_apps + ## Links diff --git a/conf/app.src b/conf/app.src index a86eff8..aa97514 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,3 +1,3 @@ -SOURCE_URL=https://github.com/HelloZeroNet/ZeroNet/archive/v0.6.2.tar.gz -SOURCE_SUM=d07aa18ca81ca30be9a118dfb845bbaeca6551b13672e6d87851f3544f9d7f2f -SOURCE_VERSION=0.6.2 +SOURCE_URL=https://github.com/HelloZeroNet/ZeroNet/archive/v0.7.1.tar.gz +SOURCE_SUM=78a27e1687d8e3699a854b77b516c95b30a8ba667f7ebbef0aabf7ec6ec7272d +SOURCE_VERSION=0.7.1 diff --git a/manifest.json b/manifest.json index 2e30ef2..7260872 100644 --- a/manifest.json +++ b/manifest.json @@ -4,17 +4,17 @@ "packaging_format": 1, "description": { "en": "Decentralized websites using Bitcoin crypto and BitTorrent network", - "fr": "Decentralized websites using Bitcoin crypto and BitTorrent network" + "fr": "Sites Web décentralisés utilisant la crypto Bitcoin et le réseau BitTorrent" }, + "version": "0.7.1~ynh1", "url": "https://zeronet.io", "license": "AGPL-3.0", - "version": "0.6.0", "maintainer": { "name": "whypsi", "email": "whypsi@riseup.net" }, "requirements": { - "yunohost": ">> 2.4.0" + "yunohost": ">> 3.8.1" }, "multi_instance": true, "services": [ @@ -26,8 +26,8 @@ "name": "domain", "type": "domain", "ask": { - "en": "Choose a sub domain name for ynhexample", - "fr": "Choisissez un nom de domaine pour ynhexample" + "en": "Choose a sub domain name for ZeroNet", + "fr": "Choisissez un nom de domaine pour ZeroNet" }, "example": "zeronet.domain.tld" }, diff --git a/scripts/backup b/scripts/backup index 2fb9a6a..348f844 100755 --- a/scripts/backup +++ b/scripts/backup @@ -15,7 +15,7 @@ main() { ynh_backup $deploy_path "sources" - sudo mkdir --parent ./conf + mkdir --parent ./conf ynh_backup $nginx_config_file "conf/nginx.conf" ynh_backup $systemd_service_file "conf/${systemd_service_name}" ynh_backup $user_zeronet_dir "conf/.zeronet" diff --git a/scripts/functions.sh b/scripts/functions.sh index c970e4c..f975fa2 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -3,7 +3,7 @@ set -eu install_dependencies() { - sudo apt-get install --quiet --yes python-msgpack python-gevent + apt-get install --quiet --yes python-msgpack python-gevent } app_config_get() { @@ -40,8 +40,8 @@ extract_archive() { local src_file=$1 local deploy_path=$2 - sudo mkdir --parents ${deploy_path} - sudo tar --extract --file=${src_file} --directory=${deploy_path} --overwrite --strip-components 1 + mkdir --parents ${deploy_path} + tar --extract --file=${src_file} --directory=${deploy_path} --overwrite --strip-components 1 } obtain_and_deploy_source() { @@ -57,9 +57,9 @@ obtain_and_deploy_source() { check_file_integrity $src_file $src_checksum extract_archive $src_file $deploy_path - sudo rm -f $symlink_to_deploy_path - sudo ln --symbolic --force $deploy_path $symlink_to_deploy_path + rm -f $symlink_to_deploy_path + ln --symbolic --force $deploy_path $symlink_to_deploy_path - sudo chown $user: -LR $symlink_to_deploy_path - sudo chown $user: -h $symlink_to_deploy_path + chown $user: -LR $symlink_to_deploy_path + chown $user: -h $symlink_to_deploy_path } diff --git a/scripts/install b/scripts/install index cb103e3..8ad4ff9 100755 --- a/scripts/install +++ b/scripts/install @@ -7,7 +7,7 @@ nginx_config_file() { local app=$1 local domain=$2 - sudo mkdir --parents "/etc/nginx/conf.d/${domain}.d" + mkdir --parents "/etc/nginx/conf.d/${domain}.d" echo "/etc/nginx/conf.d/${domain}.d/${app}.conf" } @@ -19,12 +19,12 @@ update_nginx_configuration() { local path=$4 local ui_port=$5 - sudo cp $config_template $config_file + cp $config_template $config_file - sudo sed --in-place "s@YNH_WWW_PATH@${path}@g" ${config_file} - sudo sed --in-place "s@YNH_LOCAL_PORT@${ui_port}/@g" ${config_file} + sed --in-place "s@YNH_WWW_PATH@${path}@g" ${config_file} + sed --in-place "s@YNH_LOCAL_PORT@${ui_port}/@g" ${config_file} - sudo service nginx reload + service nginx reload } systemd_service_name() { @@ -55,25 +55,25 @@ update_systemd_configuration() { local data_dir=$zeronet_dir/data local log_dir=$zeronet_dir/log - sudo mkdir -p $data_dir - sudo mkdir -p $log_dir - sudo chown -R $user: $zeronet_dir + mkdir -p $data_dir + mkdir -p $log_dir + chown -R $user: $zeronet_dir # configure systemd service - sudo cp $service_template $service_file + cp $service_template $service_file - sudo sed --in-place "s@__USER__@$user@g" $service_file - sudo sed --in-place "s@__UI_PORT__@$ui_port@g" $service_file - sudo sed --in-place "s@__FS_PORT__@$fs_port@g" $service_file - sudo sed --in-place "s@__UI_HOST__@$ui_host@g" $service_file - sudo sed --in-place "s@__APP_NAME__@$app@g" $service_file - sudo sed --in-place "s@__WORKING_DIRECTORY__@$symlink_to_deploy_path@g" $service_file - sudo sed --in-place "s@__DATA_DIR__@$data_dir@g" $service_file - sudo sed --in-place "s@__LOG_DIR__@$log_dir@g" $service_file + sed --in-place "s@__USER__@$user@g" $service_file + sed --in-place "s@__UI_PORT__@$ui_port@g" $service_file + sed --in-place "s@__FS_PORT__@$fs_port@g" $service_file + sed --in-place "s@__UI_HOST__@$ui_host@g" $service_file + sed --in-place "s@__APP_NAME__@$app@g" $service_file + sed --in-place "s@__WORKING_DIRECTORY__@$symlink_to_deploy_path@g" $service_file + sed --in-place "s@__DATA_DIR__@$data_dir@g" $service_file + sed --in-place "s@__LOG_DIR__@$log_dir@g" $service_file - sudo systemctl daemon-reload - sudo systemctl enable $service_name - sudo systemctl start $service_name + systemctl daemon-reload + systemctl enable $service_name + systemctl start $service_name } # Source: https://github.com/YunoHost/yunohost/blob/901e3df9b604f542f2c460aad05bcc8efc9fd054/data/helpers.d/network diff --git a/scripts/remove b/scripts/remove index 0828382..fb79174 100755 --- a/scripts/remove +++ b/scripts/remove @@ -7,32 +7,32 @@ remove_systemd_service_() { local service_name=$1 local service_file=$2 - sudo systemctl stop $service_name - sudo systemctl disable $service_name - sudo rm $service_file - sudo systemctl daemon-reload - sudo systemctl reset-failed + systemctl stop $service_name + systemctl disable $service_name + rm $service_file + systemctl daemon-reload + systemctl reset-failed } remove_nginx_config() { local nginx_config_file=$1 - sudo rm -rf $nginx_config_file - sudo service nginx reload + ynh_secure_remove $nginx_config_file + service nginx reload } remove_user_data() { local user_zeronet_dir=$1 - sudo rm -rf $user_zeronet_dir + ynh_secure_remove $user_zeronet_dir } remove_zeronet() { local deploy_path=$1 local symlink_to_deploy_path=$2 - sudo rm -rf $deploy_path - sudo rm -rf $symlink_to_deploy_path + ynh_secure_remove $deploy_path + ynh_secure_remove $symlink_to_deploy_path } main() { diff --git a/scripts/restore b/scripts/restore index 4dc03b3..314471d 100755 --- a/scripts/restore +++ b/scripts/restore @@ -7,7 +7,7 @@ source /usr/share/yunohost/helpers # TODO: remove with fix of https://github.com/YunoHost/yunohost/pull/246 install_dependencies() { - sudo apt-get install --quiet --yes python-msgpack python-gevent + apt-get install --quiet --yes python-msgpack python-gevent } is_app_restorable() { @@ -42,20 +42,20 @@ main() { install_dependencies - sudo cp -a "./sources" $deploy_path - sudo ln --symbolic --force $deploy_path $symlink_to_deploy_path - sudo chown $user: -LR $symlink_to_deploy_path - sudo chown $user: -h $symlink_to_deploy_path + cp -a "./sources" $deploy_path + ln --symbolic --force $deploy_path $symlink_to_deploy_path + chown $user: -LR $symlink_to_deploy_path + chown $user: -h $symlink_to_deploy_path - sudo rm -rf $user_zeronet_dir - sudo cp -aR "./conf/.zeronet" $user_zeronet_dir - sudo chown -R $user: $user_zeronet_dir + ynh_secure_remove $user_zeronet_dir + cp -aR "./conf/.zeronet" $user_zeronet_dir + chown -R $user: $user_zeronet_dir - sudo cp -a "./conf/nginx.conf" $nginx_config_file - sudo service nginx reload + cp -a "./conf/nginx.conf" $nginx_config_file + service nginx reload - sudo cp -a "./conf/${systemd_service_name}" $systemd_service_file - sudo systemctl restart $systemd_service_name + cp -a "./conf/${systemd_service_name}" $systemd_service_file + systemctl restart $systemd_service_name } main diff --git a/scripts/upgrade b/scripts/upgrade index 4364ee4..3b09cd2 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,13 +20,13 @@ main() { obtain_and_deploy_source $app_config $new_deploy_path $symlink_to_deploy_path $user - sudo systemctl restart $systemd_service_name + systemctl restart $systemd_service_name ynh_app_setting_set $app installed_version $source_version ynh_app_setting_set $app deploy_path $new_deploy_path if [ $new_deploy_path != $old_deploy_path ]; then - sudo rm -rf $old_deploy_path + ynh_secure_remove $old_deploy_path fi } From d0ef0cd3bb9f24db2baf9ad59ec31549ed28573a Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 9 Nov 2020 17:57:06 +0530 Subject: [PATCH 03/24] Use latest helpers --- README.md | 6 +- check_process | 8 +- conf/app.src | 6 +- conf/nginx.conf | 9 + conf/nginx.conf.template | 14 -- conf/systemd.service | 14 ++ conf/systemd.service.template | 14 -- scripts/_common.sh | 20 ++ scripts/backup | 80 ++++++-- scripts/change_url | 143 ++++++++++++++ scripts/functions.sh | 65 ------- scripts/install | 339 +++++++++++++++++++++------------- scripts/remove | 126 ++++++++----- scripts/restore | 163 +++++++++++----- scripts/upgrade | 183 +++++++++++++++--- 15 files changed, 836 insertions(+), 354 deletions(-) create mode 100644 conf/nginx.conf delete mode 100644 conf/nginx.conf.template create mode 100644 conf/systemd.service delete mode 100644 conf/systemd.service.template create mode 100644 scripts/_common.sh create mode 100644 scripts/change_url delete mode 100644 scripts/functions.sh diff --git a/README.md b/README.md index 1dc8d7d..84227ef 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # ZeroNet for YunoHost -[![Integration level](https://dash.yunohost.org/integration/zeronet.svg)](https://dash.yunohost.org/appci/app/zeronet) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/zeronet.svg)](https://dash.yunohost.org/appci/app/zeronet) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.maintain.svg) [![Install ZeroNet with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=zeronet) *[Lire ce readme en français.](./README_fr.md)* -> *This package allows you to install REPLACEBYYOURAPP quickly and simply on a YunoHost server. +> *This package allows you to install ZeroNet 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 @@ -55,7 +55,7 @@ Can the app be used by multiple users? * Other info you would like to add about this app. -**More info on the documentation page:** +**More info on the documentation page:** https://yunohost.org/packaging_apps diff --git a/check_process b/check_process index 9f2a7ae..d966a49 100644 --- a/check_process +++ b/check_process @@ -13,14 +13,14 @@ pkg_linter=1 setup_sub_dir=0 # setup_sub_dir=0 test disabled because app is always installed on / - setup_root=1 + setup_root=1 setup_nourl=0 setup_private=0 # setup_private=0 test disabled because app is always installed as private setup_public=0 upgrade=1 backup_restore=1 - multi_instance=0 + multi_instance=0 # multi_instance=1 test disabled because it requires installation on sub-path which is not available. successfully conducted test manually wrong_user=1 wrong_path=0 @@ -33,8 +33,8 @@ Level 1=auto Level 2=auto Level 3=auto - Level 4=na -# level 4: the app does not directly use Yunohost user data + Level 4=na +# level 4: the app does not directly use Yunohost user data Level 5=auto Level 6=auto Level 7=auto diff --git a/conf/app.src b/conf/app.src index aa97514..0117e6c 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,3 +1,7 @@ SOURCE_URL=https://github.com/HelloZeroNet/ZeroNet/archive/v0.7.1.tar.gz SOURCE_SUM=78a27e1687d8e3699a854b77b516c95b30a8ba667f7ebbef0aabf7ec6ec7272d -SOURCE_VERSION=0.7.1 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.gz +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME=0.7.1 +SOURCE_EXTRACT=true diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..ba502fb --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,9 @@ + + location / { + + proxy_pass http://127.0.0.1:__PORT__; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + } \ No newline at end of file diff --git a/conf/nginx.conf.template b/conf/nginx.conf.template deleted file mode 100644 index c8fb620..0000000 --- a/conf/nginx.conf.template +++ /dev/null @@ -1,14 +0,0 @@ -location YNH_WWW_PATH { - - proxy_pass http://127.0.0.1:YNH_LOCAL_PORT; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Accept 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; - - # 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..3cc5fc5 --- /dev/null +++ b/conf/systemd.service @@ -0,0 +1,14 @@ +[Unit] +Description=__APP__ service +After=network.target + +[Service] +User=noreply +ExecStart=/usr/bin/python3 __FINALPATH__/zeronet.py --ui_port __PORT__ --ui_host __DOMAIN__ --fileserver_port __FS_PORT__ --data_dir __DATADIR__/data --log_dir __DATADIR__/log +WorkingDirectory=/var/www/ZeroNet-py3 +ExecReload=/bin/kill -HUP $MAINPID +KillMode=process +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/conf/systemd.service.template b/conf/systemd.service.template deleted file mode 100644 index 4e6f674..0000000 --- a/conf/systemd.service.template +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=ZeroNet for __USER__ -After=network.target - -[Service] -User=__USER__ -ExecStart=/usr/bin/python2 ./zeronet.py --ui_port __UI_PORT__ --ui_host __UI_HOST__ --fileserver_port __FS_PORT__ --data_dir __DATA_DIR__ --log_dir __LOG_DIR__ -WorkingDirectory=__WORKING_DIRECTORY__ -ExecReload=/bin/kill -HUP $MAINPID -KillMode=process -Restart=on-failure - -[Install] -WantedBy=multi-user.target diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..b7bf9c2 --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +#================================================= +# COMMON VARIABLES +#================================================= + +# dependencies used by the app +pkg_dependencies="python-msgpack python-gevent" + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index 348f844..62c9f8b 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,24 +1,68 @@ -#!/usr/bin/env bash +#!/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 -main() { - ynh_abort_if_errors +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= - local app=$YNH_APP_INSTANCE_NAME - local backup_dir=$YNH_APP_BACKUP_DIR - local deploy_path=$( ynh_app_setting_get $app deploy_path ) - local nginx_config_file=$( ynh_app_setting_get $app nginx_config_file ) - local systemd_service_name=$( ynh_app_setting_get $app systemd_service_name ) - local systemd_service_file=$( ynh_app_setting_get $app systemd_service_file ) - local user_zeronet_dir=$( ynh_app_setting_get $app user_zeronet_dir ) - - ynh_backup $deploy_path "sources" - - mkdir --parent ./conf - ynh_backup $nginx_config_file "conf/nginx.conf" - ynh_backup $systemd_service_file "conf/${systemd_service_name}" - ynh_backup $user_zeronet_dir "conf/.zeronet" +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 -main +#================================================= +# 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 +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + +### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs +### to be backuped and not an actual copy of any file. The actual backup that +### creates and fill the archive with the files happens in the core after this +### script is called. Hence ynh_backups calls takes basically 0 seconds to run. + +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +ynh_backup --src_path="$final_path" +ynh_backup --src_path="$datadir" + +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= + +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup --src_path="/etc/systemd/system/$app.service" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." \ No newline at end of file diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..d0ef915 --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,143 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +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..." + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +port=$(ynh_app_setting_get --app=$app --key=port) +fs_port=$(ynh_app_setting_get --app=$app --key=fs_port) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) + +# 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 UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." + +# 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 +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" --log_path="$datadir/log/debug-last.log" + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating nginx web server configuration..." + +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 +#================================================= +# ... +#================================================= + +#================================================= +# GENERIC FINALISATION +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app --description "$app service" --others_var="$fs_port $datadir" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" + +#================================================= +# START SYSTEMD SERVICE +#================================================= + +ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log/debug-last.log" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --time --last diff --git a/scripts/functions.sh b/scripts/functions.sh deleted file mode 100644 index f975fa2..0000000 --- a/scripts/functions.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env bash - -set -eu - -install_dependencies() { - apt-get install --quiet --yes python-msgpack python-gevent -} - -app_config_get() { - local app_config=$1 - local attribute=$2 - - cat ${app_config} \ - | grep ${attribute} \ - | cut --delimiter== --fields=2 -} - -make_deploy_path() { - local app=$1 - local source_version=$2 - - echo "/var/www/${app}-v${source_version}" # e.g. /var/www/zeronet__2-0.5.3 -} - -download_file() { - local url=$1 - local output_document=$2 - wget --no-verbose --output-document=${output_document} ${url} -} - -check_file_integrity() { - local file=$1 - local expected_checksum=$2 - - echo "${expected_checksum} ${file}" | sha256sum --check --status \ - || ynh_die "Corrupt source!" -} - -extract_archive() { - local src_file=$1 - local deploy_path=$2 - - mkdir --parents ${deploy_path} - tar --extract --file=${src_file} --directory=${deploy_path} --overwrite --strip-components 1 -} - -obtain_and_deploy_source() { - local app_config=$1 - local deploy_path=$2 - local symlink_to_deploy_path=$3 - local user=$4 - local src_url=$(app_config_get $app_config "SOURCE_URL") - local src_checksum=$(app_config_get $app_config "SOURCE_SUM") - local src_file="/tmp/source.tar.gz" - - download_file $src_url $src_file - check_file_integrity $src_file $src_checksum - extract_archive $src_file $deploy_path - - rm -f $symlink_to_deploy_path - ln --symbolic --force $deploy_path $symlink_to_deploy_path - - chown $user: -LR $symlink_to_deploy_path - chown $user: -h $symlink_to_deploy_path -} diff --git a/scripts/install b/scripts/install index 8ad4ff9..6f65378 100755 --- a/scripts/install +++ b/scripts/install @@ -1,155 +1,246 @@ -#!/usr/bin/env bash +#!/bin/bash +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh source /usr/share/yunohost/helpers -source functions.sh -nginx_config_file() { - local app=$1 - local domain=$2 +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= - mkdir --parents "/etc/nginx/conf.d/${domain}.d" - - echo "/etc/nginx/conf.d/${domain}.d/${app}.conf" +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 -update_nginx_configuration() { - local app=$1 - local config_template=$2 - local config_file=$3 - local path=$4 - local ui_port=$5 +#================================================= +# RETRIEVE ARGUMENTS FROM THE MANIFEST +#================================================= - cp $config_template $config_file +domain=$YNH_APP_ARG_DOMAIN +path_url="/" +admin=$YNH_APP_ARG_ADMIN +datadir="/home/yunohost.app/${app}" - sed --in-place "s@YNH_WWW_PATH@${path}@g" ${config_file} - sed --in-place "s@YNH_LOCAL_PORT@${ui_port}/@g" ${config_file} +### If it's a multi-instance app, meaning it can be installed several times independently +### The id of the app as stated in the manifest is available as $YNH_APP_ID +### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...) +### The app instance name is available as $YNH_APP_INSTANCE_NAME +### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample +### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 +### - ynhexample__{N} for the subsequent installations, with N=3,4, ... +### The app instance name is probably what interests you most, since this is +### guaranteed to be unique. This is a good unique identifier to define installation path, +### db names, ... +app=$YNH_APP_INSTANCE_NAME - service nginx reload -} +#================================================= +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS +#================================================= +### About --weight and --time +### ynh_script_progression will show to your final users the progression of each scripts. +### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script. +### --time is a packager option, it will show you the execution time since the previous call. +### This option should be removed before releasing your app. +### Use the execution time, given by --time, to estimate the weight of a step. +### A common way to do it is to set a weight equal to the execution time in second +1. +### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call. +ynh_script_progression --message="Validating installation parameters..." -systemd_service_name() { - local app=$1 - local user=$2 +### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". +### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" +final_path=/var/www/$app +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" - echo "ynh-${app}-${user}.service" -} +# Register (book) web path +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url -# -# Creates service which runs zeronet on unique -# UserInterace and FileServer port for the user -# ZeroNet data is stored in the users home directory in ~/.zeronet -# -update_systemd_configuration() { - local app=$1 - local service_template=$2 - local service_name=$3 - local service_file=$4 - local user=$5 - local ui_port=$6 - local symlink_to_deploy_path=$7 - local zeronet_dir=$8 - local ui_host=$9 - local fs_port=${10} # only works with bash +#================================================= +# STORE SETTINGS FROM MANIFEST +#================================================= +ynh_script_progression --message="Storing installation settings..." - # create zeronet user data location - local data_dir=$zeronet_dir/data - local log_dir=$zeronet_dir/log +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=admin --value=$admin +ynh_app_setting_set --app=$app --key=datadir --value=$datadir - mkdir -p $data_dir - mkdir -p $log_dir - chown -R $user: $zeronet_dir - # configure systemd service - cp $service_template $service_file +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# FIND AND OPEN A PORT +#================================================= +ynh_script_progression --message="Configuring firewall..." - sed --in-place "s@__USER__@$user@g" $service_file - sed --in-place "s@__UI_PORT__@$ui_port@g" $service_file - sed --in-place "s@__FS_PORT__@$fs_port@g" $service_file - sed --in-place "s@__UI_HOST__@$ui_host@g" $service_file - sed --in-place "s@__APP_NAME__@$app@g" $service_file - sed --in-place "s@__WORKING_DIRECTORY__@$symlink_to_deploy_path@g" $service_file - sed --in-place "s@__DATA_DIR__@$data_dir@g" $service_file - sed --in-place "s@__LOG_DIR__@$log_dir@g" $service_file +### Use these lines if you have to open a port for the application +### `ynh_find_port` will find the first available port starting from the given port. +### If you're not using these lines: +### - Remove the section "CLOSE A PORT" in the remove script - systemctl daemon-reload - systemctl enable $service_name - systemctl start $service_name -} +# Find an available port +port=$(ynh_find_port --port=43110) +fs_port=$(ynh_find_port --port=15441) +ynh_app_setting_set --app=$app --key=port --value=$port +ynh_app_setting_set --app=$app --key=fs_port --value=$fs_port -# Source: https://github.com/YunoHost/yunohost/blob/901e3df9b604f542f2c460aad05bcc8efc9fd054/data/helpers.d/network -# -# Find a free port and return it -# -# example: port=$(ynh_find_port 8080) -# -# usage: ynh_find_port begin_port -# | arg: begin_port - port to start to search -ynh_find_port () { - port=$1 +# Optional: Expose this port publicly +# (N.B. : you only need to do this if the app actually needs to expose the port publicly. +# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !) - while netcat -z 127.0.0.1 $port # Check if the port is free - do - port=$((port+1)) # Else, pass to next port - done - echo $port -} +# Open the port +ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $fs_port -main() { - ynh_abort_if_errors +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." +### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. +### Those deb packages will be installed as dependencies of this package. +### If you're not using this helper: +### - Remove the section "REMOVE DEPENDENCIES" in the remove script +### - Remove the variable "pkg_dependencies" in _common.sh +### - As well as the section "REINSTALL DEPENDENCIES" in the restore script +### - And the section "UPGRADE DEPENDENCIES" in the upgrade script - local app=$YNH_APP_INSTANCE_NAME - local number=$YNH_APP_INSTANCE_NUMBER - local domain=$YNH_APP_ARG_DOMAIN - local user=$YNH_APP_ARG_ADMIN +ynh_install_app_dependencies $pkg_dependencies - local ui_port=$( ynh_find_port 43110 ) # the port zeronet ui listens on - local fs_port=$( ynh_find_port 15441 ) # the port zeronet fileserver listens on +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_script_progression --message="Setting up source files..." - local path="/" - local is_public=0 # by defaut access to zeronet is private - local nginx_config_template=../conf/nginx.conf.template - local systemd_service_template=../conf/systemd.service.template - local app_config=../conf/app.src - local systemd_service_dir=/etc/systemd/system +### `ynh_setup_source` is used to install an app from a zip or tar.gz file, +### downloaded from an upstream source, like a git repository. +### `ynh_setup_source` use the file conf/app.src - local url=$domain$path - local source_version=$( app_config_get $app_config "SOURCE_VERSION" ) - local systemd_service_name=$( systemd_service_name $app $user ) - local systemd_service_file="${systemd_service_dir}/${systemd_service_name}" - local nginx_config_file=$( nginx_config_file $app $domain ) - local user_zeronet_dir="/home/${user}/.zeronet" - local deploy_path=$( make_deploy_path $app $source_version ) - local symlink_to_deploy_path="/var/www/${app}" +ynh_app_setting_set --app=$app --key=final_path --value=$final_path +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$final_path" - ynh_webpath_available $domain $path - ynh_webpath_register $app $domain $path +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring nginx web server..." - ynh_user_exists $user +### `ynh_add_nginx_config` will use the file conf/nginx.conf - ynh_app_setting_set $app is_public $is_public - ynh_app_setting_set $app domain $domain - ynh_app_setting_set $app path $path - ynh_app_setting_set $app url $url - ynh_app_setting_set $app admin $user - ynh_app_setting_set $app allowed_users $user - ynh_app_setting_set $app deploy_path $deploy_path - ynh_app_setting_set $app symlink_to_deploy_path $symlink_to_deploy_path - ynh_app_setting_set $app ui_port $ui_port - ynh_app_setting_set $app fs_port $fs_port - ynh_app_setting_set $app installed_version $source_version - ynh_app_setting_set $app nginx_config_file $nginx_config_file - ynh_app_setting_set $app user $user - ynh_app_setting_set $app user_zeronet_dir $user_zeronet_dir - ynh_app_setting_set $app systemd_service_name $systemd_service_name - ynh_app_setting_set $app systemd_service_file $systemd_service_file +# Create a dedicated nginx config +ynh_add_nginx_config - install_dependencies +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." - obtain_and_deploy_source $app_config $deploy_path $symlink_to_deploy_path $user +# Create a system user +ynh_system_user_create --username=$app - update_nginx_configuration $app $nginx_config_template $nginx_config_file $path $ui_port - update_systemd_configuration $app $systemd_service_template $systemd_service_name $systemd_service_file \ - $user $ui_port $symlink_to_deploy_path $user_zeronet_dir $domain $fs_port -} +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." +### `ynh_systemd_config` is used to configure a systemd script for an app. +### It can be used for apps that use sysvinit (with adaptation) or systemd. +### Have a look at the app to be sure this app needs a systemd script. +### `ynh_systemd_config` will use the file conf/systemd.service +### If you're not using these lines: +### - You can remove those files in conf/. +### - Remove the section "BACKUP SYSTEMD" in the backup script +### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script +### - As well as the section "RESTORE SYSTEMD" in the restore script +### - And the section "SETUP SYSTEMD" in the upgrade script -main +# Create a dedicated systemd config +ynh_add_systemd_config + +#================================================= +# SETUP APPLICATION WITH CURL +#================================================= + +### Use these lines only if the app installation needs to be finalized through +### web forms. We generally don't want to ask the final user, +### so we're going to use curl to automatically fill the fields and submit the +### forms. + +# Set right permissions for curl install +mkdir -p $datadir/data +mkdir -p $datadir/log +chown -R $app: $final_path +chown -R $app: $datadir + + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +### `yunohost service add` integrates a service in YunoHost. It then gets +### displayed in the admin interface and through the others `yunohost service` commands. +### (N.B. : this line only makes sense if the app adds a service to the system!) +### If you're not using these lines: +### - You can remove these files in conf/. +### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script +### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script +### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script + +yunohost service add $app --description "$app service" --others_var="$fs_port $datadir" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" + +### Additional options starting with 3.8: +### +### --needs_exposed_ports "$port" a list of ports that needs to be publicly exposed +### which will then be checked by YunoHost's diagnosis system +### (N.B. DO NOT USE THIS is the port is only internal !!!) +### +### --test_status "some command" a custom command to check the status of the service +### (only relevant if 'systemctl status' doesn't do a good job) +### +### --test_conf "some command" some command similar to "nginx -t" that validates the conf of the service +### +### Re-calling 'yunohost service add' during the upgrade script is the right way +### to proceed if you later realize that you need to enable some flags that +### weren't enabled on old installs (be careful it'll override the existing +### service though so you should re-provide all relevant flags when doing so) +### + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." +### `ynh_systemd_action` is used to start a systemd service for an app. +### Only needed if you have configure a systemd service +### If you're not using these lines: +### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script +### - As well as the section "START SYSTEMD SERVICE" in the restore script +### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script +### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log/debug-last.log" + +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Configuring SSOwat..." + +# Restrict access to admin only +yunohost app addaccess --users=$admin $app + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index fb79174..6fe8ad5 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,57 +1,95 @@ -#!/usr/bin/env bash -set -u +#!/bin/bash +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh source /usr/share/yunohost/helpers -remove_systemd_service_() { - local service_name=$1 - local service_file=$2 +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." - systemctl stop $service_name - systemctl disable $service_name - rm $service_file - systemctl daemon-reload - systemctl reset-failed -} +app=$YNH_APP_INSTANCE_NAME -remove_nginx_config() { - local nginx_config_file=$1 +domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) +fs_port=$(ynh_app_setting_get --app=$app --key=fs_port) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) - ynh_secure_remove $nginx_config_file - service nginx reload -} +#================================================= +# STANDARD REMOVE +#================================================= +# REMOVE SERVICE INTEGRATION IN YUNOHOST +#================================================= -remove_user_data() { - local user_zeronet_dir=$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..." + yunohost service remove $app +fi - ynh_secure_remove $user_zeronet_dir -} +#================================================= +# STOP AND REMOVE SERVICE +#================================================= +ynh_script_progression --message="Stopping and removing the systemd service..." -remove_zeronet() { - local deploy_path=$1 - local symlink_to_deploy_path=$2 +# Remove the dedicated systemd config +ynh_remove_systemd_config - ynh_secure_remove $deploy_path - ynh_secure_remove $symlink_to_deploy_path -} +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." -main() { - local app=${YNH_APP_INSTANCE_NAME} - local domain=$( ynh_app_setting_get $app domain ) - local user=$( ynh_app_setting_get $app admin ) - local nginx_config_file=$( ynh_app_setting_get $app nginx_config_file ) - local systemd_service_name=$( ynh_app_setting_get $app systemd_service_name ) - local systemd_service_file=$( ynh_app_setting_get $app systemd_service_file ) - local deploy_path=$( ynh_app_setting_get $app deploy_path ) - local symlink_to_deploy_path=$( ynh_app_setting_get $app symlink_to_deploy_path ) - local user_zeronet_dir=$( ynh_app_setting_get $app user_zeronet_dir ) +# Remove metapackage and its dependencies +ynh_remove_app_dependencies - if [ -n $domain ]; then - remove_nginx_config $nginx_config_file - remove_user_data $user_zeronet_dir - remove_systemd_service_ $systemd_service_name $systemd_service_file - remove_zeronet $deploy_path $symlink_to_deploy_path - fi -} +#================================================= +# REMOVE APP MAIN DIR +#================================================= +ynh_script_progression --message="Removing app main directory..." -main +# Remove the app directory securely +ynh_secure_remove --file="$final_path" +ynh_secure_remove --file="$datadir" + +#================================================= +# REMOVE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Removing nginx web server configuration..." + +# Remove the dedicated nginx config +ynh_remove_nginx_config + +#================================================= +# CLOSE A PORT +#================================================= + +if yunohost firewall list | grep -q "\- $fs_port$" +then + ynh_script_progression --message="Closing port $port..." + ynh_exec_warn_less yunohost firewall disallow TCP $fs_port +fi + +#================================================= +# GENERIC FINALIZATION +#================================================= +# REMOVE DEDICATED USER +#================================================= +ynh_script_progression --message="Removing the dedicated system user..." + +# Delete a system user +ynh_system_user_delete --username=$app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 314471d..d4afe49 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,61 +1,134 @@ -#!/usr/bin/env bash +#!/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 -# TODO: enable with fix of https://github.com/YunoHost/yunohost/pull/246 -# source .hfunctions +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= -# TODO: remove with fix of https://github.com/YunoHost/yunohost/pull/246 -install_dependencies() { - apt-get install --quiet --yes python-msgpack python-gevent +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 -is_app_restorable() { - local -r domain=$1 - local -r path=$2 - local -r deploy_path=$3 +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." - ynh_webpath_available $domain $path \ - || ynh_die "Path not available: ${domain}${path}" +app=$YNH_APP_INSTANCE_NAME - test ! -d $deploy_path \ - || ynh_die "There is already a directory: $deploy_path" -} +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) +port=$(ynh_app_setting_get --app=$app --key=port) +fs_port=$(ynh_app_setting_get --app=$app --key=fs_port) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) -main() { - ynh_abort_if_errors +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= +ynh_script_progression --message="Validating restoration parameters..." - local app=$YNH_APP_INSTANCE_NAME - local domain=$(ynh_app_setting_get $app domain) - local path=$(ynh_app_setting_get $app path) - local deploy_path=$(ynh_app_setting_get $app deploy_path) - local symlink_to_deploy_path=$(ynh_app_setting_get $app symlink_to_deploy_path) - local nginx_config_file=$( ynh_app_setting_get $app nginx_config_file ) - local systemd_service_name=$( ynh_app_setting_get $app systemd_service_name ) - local systemd_service_file=$( ynh_app_setting_get $app systemd_service_file ) - local user=$( ynh_app_setting_get $app user ) - local user_zeronet_dir=$( ynh_app_setting_get $app user_zeronet_dir ) +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " - local url=$(ynh_app_setting_get $app url) +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= - is_app_restorable $domain $path $deploy_path +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - install_dependencies +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." - cp -a "./sources" $deploy_path - ln --symbolic --force $deploy_path $symlink_to_deploy_path - chown $user: -LR $symlink_to_deploy_path - chown $user: -h $symlink_to_deploy_path +ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$datadir" - ynh_secure_remove $user_zeronet_dir - cp -aR "./conf/.zeronet" $user_zeronet_dir - chown -R $user: $user_zeronet_dir - - cp -a "./conf/nginx.conf" $nginx_config_file - service nginx reload - - cp -a "./conf/${systemd_service_name}" $systemd_service_file - systemctl restart $systemd_service_name -} +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." -main +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R $app: $final_path +chown -R $app: $datadir + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# RESTORE SYSTEMD +#================================================= +ynh_script_progression --message="Restoring the systemd configuration..." + +ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +systemctl enable $app.service + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app --description "$app service" --others_var="$fs_port $datadir" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log/debug-last.log" + +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." + +# Restrict access to admin only +yunohost app addaccess --users=$admin $app + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server and php-fpm..." + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index 3b09cd2..54891e5 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,33 +1,172 @@ -#!/usr/bin/env bash +#!/bin/bash +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh source /usr/share/yunohost/helpers -source functions.sh -main() { - ynh_abort_if_errors +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." - local app=${YNH_APP_INSTANCE_NAME} - local user=$( ynh_app_setting_get $app user ) - local deploy_path=$( ynh_app_setting_get $app deploy_path ) - local symlink_to_deploy_path=$( ynh_app_setting_get $app symlink_to_deploy_path ) - local installed_version=$( ynh_app_setting_get $app installed_version ) - local systemd_service_name=$( ynh_app_setting_get $app systemd_service_name ) - local app_config=../conf/app.src - local source_version=$(app_config_get $app_config "SOURCE_VERSION") +app=$YNH_APP_INSTANCE_NAME - local old_deploy_path=$deploy_path - local new_deploy_path=$( make_deploy_path $app $source_version ) +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) +port=$(ynh_app_setting_get --app=$app --key=port) +fs_port=$(ynh_app_setting_get --app=$app --key=fs_port) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) - obtain_and_deploy_source $app_config $new_deploy_path $symlink_to_deploy_path $user +#================================================= +# CHECK VERSION +#================================================= - systemctl restart $systemd_service_name +### This helper will compare the version of the currently installed app and the version of the upstream package. +### $upgrade_type can have 2 different values +### - UPGRADE_APP if the upstream app version has changed +### - UPGRADE_PACKAGE if only the YunoHost package has changed +### ynh_check_app_version_changed will stop the upgrade if the app is up to date. +### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. +upgrade_type=$(ynh_check_app_version_changed) - ynh_app_setting_set $app installed_version $source_version - ynh_app_setting_set $app deploy_path $new_deploy_path +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." - if [ $new_deploy_path != $old_deploy_path ]; then - ynh_secure_remove $old_deploy_path - fi +# If final_path doesn't exist, create it +if [ -z "$final_path" ]; then + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path +fi + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." + +# 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 -main +#================================================= +# CHECK THE PATH +#================================================= + +# Normalize the URL path syntax +# N.B. : this is for app installations before YunoHost 2.7 +# where this value might be something like /foo/ or foo/ +# instead of /foo .... +# If nobody installed your app before 2.7, then you may +# safely remove this line +path_url=$(ynh_normalize_url_path --path_url=$path_url) + +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" --log_path="$datadir/log/debug-last.log" + +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." + + # Download, check integrity, uncompress and patch the source from app.src + ynh_secure_remove --file="$final_path" + ynh_setup_source --dest_dir="$final_path" +fi + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading nginx web server configuration..." + +# Create a dedicated nginx config +ynh_add_nginx_config + +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." + +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app + +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Upgrading systemd configuration..." + +# Create a dedicated systemd config +ynh_add_systemd_config + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Set permissions on app files +chown -R $app: $final_path +chown -R $app: $datadir + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app --description "$app service" --others_var="$fs_port $datadir" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log/debug-last.log" + +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." + +# Restrict access to admin only +yunohost app addaccess --users=$admin $app + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" From e455ce0b5098e0b5b1cafdb484bd03336d7812fb Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 9 Nov 2020 18:09:10 +0530 Subject: [PATCH 04/24] move datadir below app in install --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 6f65378..12e1395 100755 --- a/scripts/install +++ b/scripts/install @@ -27,7 +27,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" admin=$YNH_APP_ARG_ADMIN -datadir="/home/yunohost.app/${app}" + ### If it's a multi-instance app, meaning it can be installed several times independently ### The id of the app as stated in the manifest is available as $YNH_APP_ID @@ -40,7 +40,7 @@ datadir="/home/yunohost.app/${app}" ### guaranteed to be unique. This is a good unique identifier to define installation path, ### db names, ... app=$YNH_APP_INSTANCE_NAME - +datadir="/home/yunohost.app/${app}" #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= From f8885b35441d6b2b127b84e8ba945dc7055d0744 Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 9 Nov 2020 18:23:45 +0530 Subject: [PATCH 05/24] Added ynh_add_systemd_config for adding datadir and fs_port --- scripts/change_url | 6 +----- scripts/install | 3 ++- scripts/restore | 3 ++- scripts/upgrade | 4 ++-- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index d0ef915..cc6c0e4 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,9 +28,6 @@ ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) -port=$(ynh_app_setting_get --app=$app --key=port) -fs_port=$(ynh_app_setting_get --app=$app --key=fs_port) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) # Add settings here as needed by your application #db_name=$(ynh_app_setting_get --app=$app --key=db_name) @@ -120,8 +117,7 @@ fi # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add $app --description "$app service" --others_var="$fs_port $datadir" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" +ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="/etc/systemd/system/${app}.service" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/install b/scripts/install index 12e1395..0aa9771 100755 --- a/scripts/install +++ b/scripts/install @@ -190,8 +190,9 @@ ynh_script_progression --message="Integrating service in YunoHost..." ### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script ### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script ### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script +ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="$fs_port $datadir" -yunohost service add $app --description "$app service" --others_var="$fs_port $datadir" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" +yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" ### Additional options starting with 3.8: ### diff --git a/scripts/restore b/scripts/restore index d4afe49..06c7079 100755 --- a/scripts/restore +++ b/scripts/restore @@ -101,7 +101,8 @@ systemctl enable $app.service #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "$app service" --others_var="$fs_port $datadir" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" +ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="$fs_port $datadir" +yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 54891e5..c9d52d6 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -140,8 +140,8 @@ chown -R $app: $datadir # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add $app --description "$app service" --others_var="$fs_port $datadir" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" +ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="$fs_port $datadir" +yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" #================================================= # START SYSTEMD SERVICE From d3d02b8f2c46f1f37435c39bc2bd8c78d6dc3555 Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 9 Nov 2020 18:36:26 +0530 Subject: [PATCH 06/24] Fixed ynh_add_systemd_config --- conf/systemd.service | 2 +- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index 3cc5fc5..53a900e 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -5,7 +5,7 @@ After=network.target [Service] User=noreply ExecStart=/usr/bin/python3 __FINALPATH__/zeronet.py --ui_port __PORT__ --ui_host __DOMAIN__ --fileserver_port __FS_PORT__ --data_dir __DATADIR__/data --log_dir __DATADIR__/log -WorkingDirectory=/var/www/ZeroNet-py3 +WorkingDirectory=__FINALPATH__ ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure diff --git a/scripts/install b/scripts/install index 0aa9771..872a7db 100755 --- a/scripts/install +++ b/scripts/install @@ -190,7 +190,7 @@ ynh_script_progression --message="Integrating service in YunoHost..." ### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script ### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script ### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script -ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="$fs_port $datadir" +ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port datadir" yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" diff --git a/scripts/restore b/scripts/restore index 06c7079..7b61ac4 100755 --- a/scripts/restore +++ b/scripts/restore @@ -101,7 +101,7 @@ systemctl enable $app.service #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="$fs_port $datadir" +ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port datadir" yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c9d52d6..706fc8d 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -140,7 +140,7 @@ chown -R $app: $datadir # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="$fs_port $datadir" +ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port datadir" yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" #================================================= From 1bb8879997dff92ed0e047400209d49fc019a005 Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 9 Nov 2020 18:43:53 +0530 Subject: [PATCH 07/24] added port and domain replacement in systemd --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 872a7db..b8fe100 100755 --- a/scripts/install +++ b/scripts/install @@ -190,7 +190,7 @@ ynh_script_progression --message="Integrating service in YunoHost..." ### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script ### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script ### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script -ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port datadir" +ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir" yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" diff --git a/scripts/restore b/scripts/restore index 7b61ac4..26e2ac5 100755 --- a/scripts/restore +++ b/scripts/restore @@ -101,7 +101,7 @@ systemctl enable $app.service #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port datadir" +ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir" yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 706fc8d..f5187f6 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -140,7 +140,7 @@ chown -R $app: $datadir # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port datadir" +ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir" yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" #================================================= From 14eb4b985f102932ef104879aa075cccd55c7664 Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 9 Nov 2020 20:16:29 +0530 Subject: [PATCH 08/24] use pip3 to install dependencies --- scripts/_common.sh | 2 +- scripts/install | 4 ++-- scripts/remove | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index b7bf9c2..46d94b0 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="python-msgpack python-gevent" +pkg_dependencies="python3-msgpack python3-socks python3-gevent" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index b8fe100..29c63ce 100755 --- a/scripts/install +++ b/scripts/install @@ -110,7 +110,7 @@ ynh_script_progression --message="Installing dependencies..." ### - As well as the section "REINSTALL DEPENDENCIES" in the restore script ### - And the section "UPGRADE DEPENDENCIES" in the upgrade script -ynh_install_app_dependencies $pkg_dependencies +pip3 install msgpack-python gevent #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -232,7 +232,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log ynh_script_progression --message="Configuring SSOwat..." # Restrict access to admin only -yunohost app addaccess --users=$admin $app +#yunohost app addaccess --users=$admin $app #================================================= # RELOAD NGINX diff --git a/scripts/remove b/scripts/remove index 6fe8ad5..dc8974e 100755 --- a/scripts/remove +++ b/scripts/remove @@ -49,7 +49,7 @@ ynh_remove_systemd_config ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies -ynh_remove_app_dependencies +pip3 uninstall msgpack-python gevent #================================================= # REMOVE APP MAIN DIR diff --git a/scripts/restore b/scripts/restore index 26e2ac5..38a1312 100755 --- a/scripts/restore +++ b/scripts/restore @@ -86,7 +86,7 @@ chown -R $app: $datadir ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +pip3 install msgpack-python gevent #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index f5187f6..d78c87c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -108,7 +108,7 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Upgrading dependencies..." -ynh_install_app_dependencies $pkg_dependencies +pip3 install msgpack-python gevent #================================================= # CREATE DEDICATED USER From f2ec22de16fc827b6016ceffe40debb2a35b48ee Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 9 Nov 2020 20:23:13 +0530 Subject: [PATCH 09/24] Try without ssowat --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 29c63ce..11d1c0e 100755 --- a/scripts/install +++ b/scripts/install @@ -233,7 +233,7 @@ ynh_script_progression --message="Configuring SSOwat..." # Restrict access to admin only #yunohost app addaccess --users=$admin $app - +ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" #================================================= # RELOAD NGINX #================================================= From 497ab6eb32afe8169cedca2b9abc4c015089e0d5 Mon Sep 17 00:00:00 2001 From: anmol Date: Mon, 9 Nov 2020 22:00:01 +0530 Subject: [PATCH 10/24] service fix --- conf/systemd.service | 5 +++-- scripts/install | 4 ++-- scripts/remove | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index 53a900e..a38c32b 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -3,9 +3,10 @@ Description=__APP__ service After=network.target [Service] -User=noreply -ExecStart=/usr/bin/python3 __FINALPATH__/zeronet.py --ui_port __PORT__ --ui_host __DOMAIN__ --fileserver_port __FS_PORT__ --data_dir __DATADIR__/data --log_dir __DATADIR__/log +User=__APP__ +Group=__APP__ WorkingDirectory=__FINALPATH__ +ExecStart=/usr/bin/python3 ./zeronet.py --ui_port __PORT__ --ui_host __DOMAIN__ --fileserver_port __FS_PORT__ --data_dir __DATADIR__/data --log_dir __DATADIR__/log ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure diff --git a/scripts/install b/scripts/install index 11d1c0e..0a38620 100755 --- a/scripts/install +++ b/scripts/install @@ -110,7 +110,7 @@ ynh_script_progression --message="Installing dependencies..." ### - As well as the section "REINSTALL DEPENDENCIES" in the restore script ### - And the section "UPGRADE DEPENDENCIES" in the upgrade script -pip3 install msgpack-python gevent +pip3 install msgpack-python gevent #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -141,7 +141,7 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # SETUP SYSTEMD diff --git a/scripts/remove b/scripts/remove index dc8974e..5ff4037 100755 --- a/scripts/remove +++ b/scripts/remove @@ -49,7 +49,7 @@ ynh_remove_systemd_config ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies -pip3 uninstall msgpack-python gevent +pip3 uninstall -y msgpack-python gevent #================================================= # REMOVE APP MAIN DIR From 7e44eb2dbd34e4362169e1020a3da4acaa8ee02c Mon Sep 17 00:00:00 2001 From: anmol Date: Thu, 12 Nov 2020 21:11:29 +0530 Subject: [PATCH 11/24] Added user with shell --- conf/systemd.service | 2 +- scripts/install | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index a38c32b..2a3b270 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,7 +6,7 @@ After=network.target User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__ -ExecStart=/usr/bin/python3 ./zeronet.py --ui_port __PORT__ --ui_host __DOMAIN__ --fileserver_port __FS_PORT__ --data_dir __DATADIR__/data --log_dir __DATADIR__/log +ExecStart=/usr/bin/python3 __FINALPATH__/zeronet.py --ui_port __PORT__ --ui_host __DOMAIN__ --fileserver_port __FS_PORT__ --data_dir __DATADIR__/data --log_dir __DATADIR__/log ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure diff --git a/scripts/install b/scripts/install index 0a38620..0628dca 100755 --- a/scripts/install +++ b/scripts/install @@ -141,7 +141,7 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_system_user_create --username=$app --home_dir=$datadir -s #================================================= # SETUP SYSTEMD From 260a28279fad23a6ce828335676c906f448b2d12 Mon Sep 17 00:00:00 2001 From: anmol Date: Thu, 12 Nov 2020 22:50:42 +0530 Subject: [PATCH 12/24] Added password to access the app because app don't work with SSO --- check_process | 2 +- conf/systemd.service | 2 +- manifest.json | 13 +++++++------ scripts/_common.sh | 2 +- scripts/install | 25 +++++++++++-------------- scripts/remove | 2 +- scripts/restore | 13 +++++++------ scripts/upgrade | 16 ++++++++++------ 8 files changed, 39 insertions(+), 36 deletions(-) diff --git a/check_process b/check_process index d966a49..6f5a7bb 100644 --- a/check_process +++ b/check_process @@ -4,7 +4,7 @@ ; Manifest domain="sub.domain.tld" (DOMAIN) # path="/" (PATH) - admin="john" (USER) + password="seceret123" (USER) # language="fr" # is_public="Yes" (PUBLIC|public=Yes|private=No) # is_public=0 (PUBLIC|public=1|private=0) diff --git a/conf/systemd.service b/conf/systemd.service index 2a3b270..5462b79 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,7 +6,7 @@ After=network.target User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__ -ExecStart=/usr/bin/python3 __FINALPATH__/zeronet.py --ui_port __PORT__ --ui_host __DOMAIN__ --fileserver_port __FS_PORT__ --data_dir __DATADIR__/data --log_dir __DATADIR__/log +ExecStart=/usr/bin/python3 __FINALPATH__/zeronet.py --ui_port __PORT__ --ui_host __DOMAIN__ --fileserver_port __FS_PORT__ --data_dir __DATADIR__/data --log_dir __DATADIR__/log --ui_password __PASSWORD__ ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure diff --git a/manifest.json b/manifest.json index 7260872..0d3665e 100644 --- a/manifest.json +++ b/manifest.json @@ -32,14 +32,15 @@ "example": "zeronet.domain.tld" }, { - "name": "admin", - "type": "user", + "name": "password", + "type": "password", + "optional": true, "ask": { - "en": "Choose an admin user (the one who will be able to access the admin interface)", - "fr": "Choisissez l'administrateur (seul autorisé à accéder à l'interface d'administration)" + "en": "Set the password for the Zeronet.", + "fr": "Définissez le mot de passe pour votre Zeronet." }, - "example": "john doe" - } + "example": "myreallystrengthpassword" + } ] } } diff --git a/scripts/_common.sh b/scripts/_common.sh index 46d94b0..55107c1 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="python3-msgpack python3-socks python3-gevent" +pkg_dependencies="python3-venv python3-pip" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index 0628dca..679b9df 100755 --- a/scripts/install +++ b/scripts/install @@ -26,7 +26,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" -admin=$YNH_APP_ARG_ADMIN +password=$YNH_APP_ARG_PASSWORD ### If it's a multi-instance app, meaning it can be installed several times independently @@ -69,9 +69,8 @@ ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=datadir --value=$datadir - +ynh_app_setting_set --app=$app --key=password --value=$password #================================================= # STANDARD MODIFICATIONS @@ -110,7 +109,8 @@ ynh_script_progression --message="Installing dependencies..." ### - As well as the section "REINSTALL DEPENDENCIES" in the restore script ### - And the section "UPGRADE DEPENDENCIES" in the upgrade script -pip3 install msgpack-python gevent +ynh_install_app_dependencies $pkg_dependencies +pip3 install msgpack-python gevent base58 merkletools #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -162,21 +162,18 @@ ynh_script_progression --message="Configuring a systemd service..." ynh_add_systemd_config #================================================= -# SETUP APPLICATION WITH CURL +# SETUP APPLICATION PERMISSIONS #================================================= -### Use these lines only if the app installation needs to be finalized through -### web forms. We generally don't want to ask the final user, -### so we're going to use curl to automatically fill the fields and submit the -### forms. +# Enable password authentication for Zeronet +mv $final_path/plugins/disabled-UiPassword $final_path/plugins/UiPassword -# Set right permissions for curl install +# Set right permissions mkdir -p $datadir/data mkdir -p $datadir/log chown -R $app: $final_path chown -R $app: $datadir - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -190,7 +187,7 @@ ynh_script_progression --message="Integrating service in YunoHost..." ### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script ### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script ### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script -ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir" +ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir password" yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" @@ -231,9 +228,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log #================================================= ynh_script_progression --message="Configuring SSOwat..." -# Restrict access to admin only -#yunohost app addaccess --users=$admin $app +# Allow the app to be public ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" + #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/remove b/scripts/remove index 5ff4037..9b0c890 100755 --- a/scripts/remove +++ b/scripts/remove @@ -50,7 +50,7 @@ ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies pip3 uninstall -y msgpack-python gevent - +ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= diff --git a/scripts/restore b/scripts/restore index 38a1312..2d645b3 100755 --- a/scripts/restore +++ b/scripts/restore @@ -30,11 +30,11 @@ 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) port=$(ynh_app_setting_get --app=$app --key=port) fs_port=$(ynh_app_setting_get --app=$app --key=fs_port) datadir=$(ynh_app_setting_get --app=$app --key=datadir) +password=$(ynh_app_setting_get --app=$app --key=password) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -68,7 +68,7 @@ ynh_restore_file --origin_path="$datadir" ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir=$datadir -s #================================================= # RESTORE USER RIGHTS @@ -86,7 +86,8 @@ chown -R $app: $datadir ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies -pip3 install msgpack-python gevent +ynh_install_app_dependencies $pkg_dependencies +pip3 install msgpack-python gevent base58 merkletools #================================================= # RESTORE SYSTEMD @@ -101,7 +102,7 @@ systemctl enable $app.service #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir" +ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir password" yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" #================================================= @@ -116,8 +117,8 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log #================================================= ynh_script_progression --message="Upgrading SSOwat configuration..." -# Restrict access to admin only -yunohost app addaccess --users=$admin $app +# Allow the app to be public +ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index d78c87c..88bd534 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,11 +18,11 @@ 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) port=$(ynh_app_setting_get --app=$app --key=port) fs_port=$(ynh_app_setting_get --app=$app --key=fs_port) datadir=$(ynh_app_setting_get --app=$app --key=datadir) +password=$(ynh_app_setting_get --app=$app --key=password) #================================================= # CHECK VERSION @@ -108,7 +108,8 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Upgrading dependencies..." -pip3 install msgpack-python gevent +ynh_install_app_dependencies $pkg_dependencies +pip3 install msgpack-python gevent base58 merkletools #================================================= # CREATE DEDICATED USER @@ -116,7 +117,7 @@ pip3 install msgpack-python gevent ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir=$datadir -s #================================================= # SETUP SYSTEMD @@ -132,6 +133,9 @@ ynh_add_systemd_config # SECURE FILES AND DIRECTORIES #================================================= +# Enable password authentication for Zeronet +mv $final_path/plugins/disabled-UiPassword $final_path/plugins/UiPassword + # Set permissions on app files chown -R $app: $final_path chown -R $app: $datadir @@ -140,7 +144,7 @@ chown -R $app: $datadir # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir" +ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir password" yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" #================================================= @@ -155,8 +159,8 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log #================================================= ynh_script_progression --message="Upgrading SSOwat configuration..." -# Restrict access to admin only -yunohost app addaccess --users=$admin $app +# Allow the app to be public +ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" #================================================= # RELOAD NGINX From 3aba025038a0f2713d3fb5ebdb0fa9659121b2b8 Mon Sep 17 00:00:00 2001 From: anmol Date: Thu, 12 Nov 2020 23:12:50 +0530 Subject: [PATCH 13/24] Fix restore --- scripts/restore | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/restore b/scripts/restore index 2d645b3..4af5629 100755 --- a/scripts/restore +++ b/scripts/restore @@ -34,7 +34,6 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) fs_port=$(ynh_app_setting_get --app=$app --key=fs_port) datadir=$(ynh_app_setting_get --app=$app --key=datadir) -password=$(ynh_app_setting_get --app=$app --key=password) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -102,7 +101,6 @@ systemctl enable $app.service #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir password" yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" #================================================= From d81bd811d192fa2971c863bb8a92ac88090f280c Mon Sep 17 00:00:00 2001 From: anmol Date: Fri, 13 Nov 2020 00:15:22 +0530 Subject: [PATCH 14/24] Updated readme and dependencies --- README.md | 25 ++++++++++++------------- manifest.json | 2 +- scripts/install | 2 +- scripts/remove | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 84227ef..20c01c5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview -eroNet allows you to publish static and dynamic websites on a distributed web platform. +ZeroNet allows you to publish static and dynamic websites on a distributed web platform using Bitcoin crypto and the BitTorrent network. **Shipped version:** 0.7.1 @@ -16,18 +16,14 @@ eroNet allows you to publish static and dynamic websites on a distributed web pl ![](https://camo.githubusercontent.com/4629a7d44a828f5bb20cedd90522ae62f0947b35/68747470733a2f2f692e696d6775722e636f6d2f4836304f4148592e706e67) -## Demo -* [Official demo](Link to a demo site for this app.) - -## Install +## Install instructions - This app can only be installed on root path, i.e you will need to use a dedicated domain name, e.g.`zeronet.domain.tld`. -- The app is installed in private mode only so unauthenticated users can not temper with your content. -- If you want to be a proper ZeroNet peer (serving your and other's content) you will want to open TCP port 15441 in your firewall and make sure requests to this port reach your instance [do i need to have a port opened](https://zeronet.readthedocs.io/en/latest/faq/#do-i-need-to-have-a-port-opened) -- Alternatively you can setup Tor which has to be done manually [how to use zeronet with Tor](https://zeronet.readthedocs.io/en/latest/faq/#how-to-use-zeronet-with-tor) +- You can setup Tor which has to be done manually till its implimented in the app.[how to use zeronet with Tor](https://zeronet.readthedocs.io/en/latest/faq/#how-to-use-zeronet-with-tor) + ## Multiple Instances -- Installing multiple instances of the app is *experimental*. Internally each instance it will use a unique port for both for ZeroNet UserInterface and FileServer. However, the tracker will see all instances as one peer, as they all use one and the same external IP address. +- Installing multiple instances of the app is *experimental*. Internally each instance will use an unique port for both for ZeroNet UserInterface and FileServer. However, the tracker will see all instances as one peer, as they all use one and the same external IP address. But you try it and explain your user case. - A solution that hasn't been confirmed yet is to use Tor instead. Each instance should then have a unique external address. ## Documentation @@ -39,8 +35,11 @@ eroNet allows you to publish static and dynamic websites on a distributed web pl #### Multi-user support -Are LDAP and HTTP auth supported? -Can the app be used by multiple users? +Are LDAP and HTTP auth supported? No + +#### Android app (Still in beta) + +[Android app](https://github.com/canewsin/zeronet_mobile) #### Supported architectures @@ -49,11 +48,11 @@ Can the app be used by multiple users? ## Limitations -* Any known limitations. +* App can not be used inside SSO. See [here](https://github.com/HelloZeroNet/ZeroNet/issues/2541) and [here](https://github.com/YunoHost/issues/issues/1580). ## Additional information -* Other info you would like to add about this app. +* Other info you would like to add about this Zeronet. **More info on the documentation page:** https://yunohost.org/packaging_apps diff --git a/manifest.json b/manifest.json index 0d3665e..28a2f84 100644 --- a/manifest.json +++ b/manifest.json @@ -43,4 +43,4 @@ } ] } -} +} \ No newline at end of file diff --git a/scripts/install b/scripts/install index 679b9df..439b06b 100755 --- a/scripts/install +++ b/scripts/install @@ -110,7 +110,7 @@ ynh_script_progression --message="Installing dependencies..." ### - And the section "UPGRADE DEPENDENCIES" in the upgrade script ynh_install_app_dependencies $pkg_dependencies -pip3 install msgpack-python gevent base58 merkletools +pip3 install msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE diff --git a/scripts/remove b/scripts/remove index 9b0c890..077881b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -49,7 +49,7 @@ ynh_remove_systemd_config ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies -pip3 uninstall -y msgpack-python gevent +pip3 uninstall -y msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR diff --git a/scripts/restore b/scripts/restore index 4af5629..699ef1f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -86,7 +86,7 @@ ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies -pip3 install msgpack-python gevent base58 merkletools +pip3 install msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index 88bd534..86bcbac 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -109,7 +109,7 @@ ynh_add_nginx_config ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies -pip3 install msgpack-python gevent base58 merkletools +pip3 install msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb #================================================= # CREATE DEDICATED USER From 99bf7d4c77e673c776a3a2446a7496ac0d8dab4c Mon Sep 17 00:00:00 2001 From: anmol Date: Fri, 13 Nov 2020 00:20:50 +0530 Subject: [PATCH 15/24] Added issue and pr template --- README.md | 1 + issue_template.md | 55 ++++++++++++++++++++++++++++++++++++++++ pull_request_template.md | 18 +++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 issue_template.md create mode 100644 pull_request_template.md diff --git a/README.md b/README.md index 20c01c5..2e29e11 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # ZeroNet for YunoHost [![Integration level](https://dash.yunohost.org/integration/zeronet.svg)](https://dash.yunohost.org/appci/app/zeronet) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.maintain.svg) + [![Install ZeroNet with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=zeronet) *[Lire ce readme en français.](./README_fr.md)* diff --git a/issue_template.md b/issue_template.md new file mode 100644 index 0000000..75f3d9d --- /dev/null +++ b/issue_template.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Make sure you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!* + - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* + - *In doubt, ask here and we will figure it out together.* +3. *Delete these italic comments as you write over them below, and remove this guide.* +--- + +### Describe the bug + +*A clear and concise description of what the bug is.* + +### Context + +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +### Steps to reproduce + +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install zeronet + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '....'* + 3. *Scroll down to '....'* + 4. *See error* + +### Expected behavior + +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..824e95f --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,18 @@ +## Problem +- *Description of why you made this PR* + +## Solution +- *And how do you fix that problem* + +## PR Status +- [ ] Code finished. +- [ ] Tested with Package_check. +- [ ] Fix or enhancement tested. +- [ ] Upgrade from last version tested. +- [ ] Can be reviewed and tested. + +## Package_check results +--- +*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* + +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/zeronet_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/zeronet_ynh%20PR-NUM-%20(USERNAME)/) From 15fa947f2e6105f1af84f33f31f04b74a665c4be Mon Sep 17 00:00:00 2001 From: anmol26s Date: Thu, 19 Nov 2020 21:36:09 +0530 Subject: [PATCH 16/24] Added --line_match=Ui.UiServer Web interface for service start --- scripts/change_url | 2 +- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index cc6c0e4..d878e7c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -74,7 +74,7 @@ fi #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="$datadir/log/debug-last.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log/debug-last.log" --line_match="Ui.UiServer Web interface" --timeout=120 #================================================= # MODIFY URL IN NGINX CONF diff --git a/scripts/install b/scripts/install index 439b06b..01cdb0d 100755 --- a/scripts/install +++ b/scripts/install @@ -221,7 +221,7 @@ ynh_script_progression --message="Starting a systemd service..." ### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log/debug-last.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log/debug-last.log" --line_match="Ui.UiServer Web interface" --timeout=120 #================================================= # SETUP SSOWAT diff --git a/scripts/restore b/scripts/restore index 699ef1f..801fdea 100755 --- a/scripts/restore +++ b/scripts/restore @@ -108,7 +108,7 @@ yunohost service add $app --description "$app service" --log "$datadir/log/debug #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log/debug-last.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log/debug-last.log" --line_match="Ui.UiServer Web interface" --timeout=120 #================================================= # SETUP SSOWAT diff --git a/scripts/upgrade b/scripts/upgrade index 86bcbac..3cdebe8 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -152,7 +152,7 @@ yunohost service add $app --description "$app service" --log "$datadir/log/debug #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log/debug-last.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log/debug-last.log" --line_match="Ui.UiServer Web interface" --timeout=120 #================================================= # SETUP SSOWAT From 5549a7642fbd853060c84348ae836a87bf98bef1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 26 Nov 2020 11:29:29 +0100 Subject: [PATCH 17/24] Fix --- README.md | 4 +-- check_process | 11 +----- issue_template.md | 6 ++-- scripts/backup | 7 +--- scripts/change_url | 12 +------ scripts/install | 86 +--------------------------------------------- scripts/restore | 2 +- scripts/upgrade | 19 +--------- 8 files changed, 11 insertions(+), 136 deletions(-) diff --git a/README.md b/README.md index 2e29e11..8c98979 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ZeroNet for YunoHost -[![Integration level](https://dash.yunohost.org/integration/zeronet.svg)](https://dash.yunohost.org/appci/app/zeronet) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/zeronet.svg)](https://dash.yunohost.org/appci/app/zeronet) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.maintain.svg) [![Install ZeroNet with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=zeronet) *[Lire ce readme en français.](./README_fr.md)* @@ -15,7 +15,7 @@ ZeroNet allows you to publish static and dynamic websites on a distributed web p ## Screenshots -![](https://camo.githubusercontent.com/4629a7d44a828f5bb20cedd90522ae62f0947b35/68747470733a2f2f692e696d6775722e636f6d2f4836304f4148592e706e67) +![](https://camo.githubusercontent.com/7b79b9725df29fa5403ba490ff9870e0464a00e106bad5536867602625ca94cc/68747470733a2f2f692e696d6775722e636f6d2f4836304f4148592e706e67) ## Install instructions diff --git a/check_process b/check_process index 6f5a7bb..deefe1c 100644 --- a/check_process +++ b/check_process @@ -30,14 +30,5 @@ port_already_use=1 (66) final_path_already_use=1 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto - Level 4=na -# level 4: the app does not directly use Yunohost user data Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 + diff --git a/issue_template.md b/issue_template.md index 75f3d9d..653476a 100644 --- a/issue_template.md +++ b/issue_template.md @@ -7,7 +7,7 @@ about: When creating a bug report, please use the following template to provide **How to post a meaningful bug report** 1. *Read this whole template first.* 2. *Make sure you are on the right place:* - - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* - *In doubt, ask here and we will figure it out together.* 3. *Delete these italic comments as you write over them below, and remove this guide.* @@ -36,8 +36,8 @@ about: When creating a bug report, please use the following template to provide - *If you used the webadmin, please perform the equivalent command from the CLI first.* - *If the error occurs in your browser, explain what you did:* 1. *Go to '...'* - 2. *Click on '....'* - 3. *Scroll down to '....'* + 2. *Click on '...'* + 3. *Scroll down to '...'* 4. *See error* ### Expected behavior diff --git a/scripts/backup b/scripts/backup index 62c9f8b..7ee7cd8 100755 --- a/scripts/backup +++ b/scripts/backup @@ -37,11 +37,6 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= ynh_print_info --message="Declaring files to be backed up..." -### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs -### to be backuped and not an actual copy of any file. The actual backup that -### creates and fill the archive with the files happens in the core after this -### script is called. Hence ynh_backups calls takes basically 0 seconds to run. - #================================================= # BACKUP THE APP MAIN DIR #================================================= @@ -65,4 +60,4 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." \ No newline at end of file +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 index d878e7c..a77b3bc 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -29,11 +29,6 @@ ynh_script_progression --message="Loading installation settings..." # 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 UPGRADE THEN ACTIVE TRAP #================================================= @@ -105,18 +100,13 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - #================================================= # GENERIC FINALISATION #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." + ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="/etc/systemd/system/${app}.service" #================================================= diff --git a/scripts/install b/scripts/install index 01cdb0d..d27c4fc 100755 --- a/scripts/install +++ b/scripts/install @@ -28,34 +28,13 @@ domain=$YNH_APP_ARG_DOMAIN path_url="/" password=$YNH_APP_ARG_PASSWORD - -### If it's a multi-instance app, meaning it can be installed several times independently -### The id of the app as stated in the manifest is available as $YNH_APP_ID -### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...) -### The app instance name is available as $YNH_APP_INSTANCE_NAME -### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample -### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 -### - ynhexample__{N} for the subsequent installations, with N=3,4, ... -### The app instance name is probably what interests you most, since this is -### guaranteed to be unique. This is a good unique identifier to define installation path, -### db names, ... app=$YNH_APP_INSTANCE_NAME datadir="/home/yunohost.app/${app}" #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -### About --weight and --time -### ynh_script_progression will show to your final users the progression of each scripts. -### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script. -### --time is a packager option, it will show you the execution time since the previous call. -### This option should be removed before releasing your app. -### Use the execution time, given by --time, to estimate the weight of a step. -### A common way to do it is to set a weight equal to the execution time in second +1. -### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call. ynh_script_progression --message="Validating installation parameters..." -### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". -### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -79,21 +58,12 @@ ynh_app_setting_set --app=$app --key=password --value=$password #================================================= ynh_script_progression --message="Configuring firewall..." -### Use these lines if you have to open a port for the application -### `ynh_find_port` will find the first available port starting from the given port. -### If you're not using these lines: -### - Remove the section "CLOSE A PORT" in the remove script - # Find an available port port=$(ynh_find_port --port=43110) fs_port=$(ynh_find_port --port=15441) ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=fs_port --value=$fs_port -# Optional: Expose this port publicly -# (N.B. : you only need to do this if the app actually needs to expose the port publicly. -# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !) - # Open the port ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $fs_port @@ -101,15 +71,9 @@ ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $fs_port # INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Installing dependencies..." -### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. -### Those deb packages will be installed as dependencies of this package. -### If you're not using this helper: -### - Remove the section "REMOVE DEPENDENCIES" in the remove script -### - Remove the variable "pkg_dependencies" in _common.sh -### - As well as the section "REINSTALL DEPENDENCIES" in the restore script -### - And the section "UPGRADE DEPENDENCIES" in the upgrade script ynh_install_app_dependencies $pkg_dependencies + pip3 install msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb #================================================= @@ -117,10 +81,6 @@ pip3 install msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websoc #================================================= ynh_script_progression --message="Setting up source files..." -### `ynh_setup_source` is used to install an app from a zip or tar.gz file, -### downloaded from an upstream source, like a git repository. -### `ynh_setup_source` use the file conf/app.src - ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" @@ -130,8 +90,6 @@ ynh_setup_source --dest_dir="$final_path" #================================================= ynh_script_progression --message="Configuring nginx web server..." -### `ynh_add_nginx_config` will use the file conf/nginx.conf - # Create a dedicated nginx config ynh_add_nginx_config @@ -147,16 +105,6 @@ ynh_system_user_create --username=$app --home_dir=$datadir -s # SETUP SYSTEMD #================================================= ynh_script_progression --message="Configuring a systemd service..." -### `ynh_systemd_config` is used to configure a systemd script for an app. -### It can be used for apps that use sysvinit (with adaptation) or systemd. -### Have a look at the app to be sure this app needs a systemd script. -### `ynh_systemd_config` will use the file conf/systemd.service -### If you're not using these lines: -### - You can remove those files in conf/. -### - Remove the section "BACKUP SYSTEMD" in the backup script -### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script -### - As well as the section "RESTORE SYSTEMD" in the restore script -### - And the section "SETUP SYSTEMD" in the upgrade script # Create a dedicated systemd config ynh_add_systemd_config @@ -179,46 +127,14 @@ chown -R $app: $datadir #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -### `yunohost service add` integrates a service in YunoHost. It then gets -### displayed in the admin interface and through the others `yunohost service` commands. -### (N.B. : this line only makes sense if the app adds a service to the system!) -### If you're not using these lines: -### - You can remove these files in conf/. -### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script -### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script -### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir password" yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" -### Additional options starting with 3.8: -### -### --needs_exposed_ports "$port" a list of ports that needs to be publicly exposed -### which will then be checked by YunoHost's diagnosis system -### (N.B. DO NOT USE THIS is the port is only internal !!!) -### -### --test_status "some command" a custom command to check the status of the service -### (only relevant if 'systemctl status' doesn't do a good job) -### -### --test_conf "some command" some command similar to "nginx -t" that validates the conf of the service -### -### Re-calling 'yunohost service add' during the upgrade script is the right way -### to proceed if you later realize that you need to enable some flags that -### weren't enabled on old installs (be careful it'll override the existing -### service though so you should re-provide all relevant flags when doing so) -### - #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." -### `ynh_systemd_action` is used to start a systemd service for an app. -### Only needed if you have configure a systemd service -### If you're not using these lines: -### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script -### - As well as the section "START SYSTEMD SERVICE" in the restore script -### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script -### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log/debug-last.log" --line_match="Ui.UiServer Web interface" --timeout=120 diff --git a/scripts/restore b/scripts/restore index 801fdea..3a12695 100755 --- a/scripts/restore +++ b/scripts/restore @@ -123,7 +123,7 @@ ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server and php-fpm..." +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 3cdebe8..3bbfcf3 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,12 +28,6 @@ password=$(ynh_app_setting_get --app=$app --key=password) # CHECK VERSION #================================================= -### This helper will compare the version of the currently installed app and the version of the upstream package. -### $upgrade_type can have 2 different values -### - UPGRADE_APP if the upstream app version has changed -### - UPGRADE_PACKAGE if only the YunoHost package has changed -### ynh_check_app_version_changed will stop the upgrade if the app is up to date. -### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. upgrade_type=$(ynh_check_app_version_changed) #================================================= @@ -61,18 +55,6 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# CHECK THE PATH -#================================================= - -# Normalize the URL path syntax -# N.B. : this is for app installations before YunoHost 2.7 -# where this value might be something like /foo/ or foo/ -# instead of /foo .... -# If nobody installed your app before 2.7, then you may -# safely remove this line -path_url=$(ynh_normalize_url_path --path_url=$path_url) - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -109,6 +91,7 @@ ynh_add_nginx_config ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies + pip3 install msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb #================================================= From 0dc00083775676c6a43207200e09a05f037bda19 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 26 Nov 2020 11:32:52 +0100 Subject: [PATCH 18/24] fix --- conf/nginx.conf | 4 ++-- scripts/change_url | 2 +- scripts/remove | 1 + scripts/restore | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index ba502fb..13a4178 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,9 +1,9 @@ - location / { +location / { proxy_pass http://127.0.0.1:__PORT__; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; - } \ No newline at end of file +} \ No newline at end of file diff --git a/scripts/change_url b/scripts/change_url index a77b3bc..b612d37 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -126,4 +126,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --time --last +ynh_script_progression --message="Change of URL completed for $app" diff --git a/scripts/remove b/scripts/remove index 077881b..e049e1b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -51,6 +51,7 @@ ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies pip3 uninstall -y msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb ynh_remove_app_dependencies + #================================================= # REMOVE APP MAIN DIR #================================================= diff --git a/scripts/restore b/scripts/restore index 3a12695..cb1f3c2 100755 --- a/scripts/restore +++ b/scripts/restore @@ -131,4 +131,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" \ No newline at end of file +ynh_script_progression --message="Restoration completed for $app" From bb874a79a0a5a1cb914544236bdf76566f5b20a9 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 26 Nov 2020 11:35:22 +0100 Subject: [PATCH 19/24] Fix --- scripts/change_url | 14 +++++++------- scripts/install | 7 ++++--- scripts/remove | 4 ++-- scripts/restore | 4 +--- scripts/upgrade | 7 ++++--- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index b612d37..477a937 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -74,23 +74,23 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -# Change the path in the nginx config file +# 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 + # 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 + # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - # Create a dedicated nginx config + # Create a dedicated NGINX config ynh_add_nginx_config fi -# Change the domain for nginx +# Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location @@ -118,7 +118,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index d27c4fc..676cc94 100755 --- a/scripts/install +++ b/scripts/install @@ -88,9 +88,9 @@ ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." +ynh_script_progression --message="Configuring NGINX web server..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -150,7 +150,8 @@ ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." + ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/remove b/scripts/remove index e049e1b..a4ff691 100755 --- a/scripts/remove +++ b/scripts/remove @@ -64,9 +64,9 @@ ynh_secure_remove --file="$datadir" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." +ynh_script_progression --message="Removing NGINX web server configuration..." -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config #================================================= diff --git a/scripts/restore b/scripts/restore index cb1f3c2..6e07ce6 100755 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,6 @@ # 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 @@ -15,7 +14,6 @@ source /usr/share/yunohost/helpers #================================================= 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 @@ -123,7 +121,7 @@ ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 3bbfcf3..4e3f6ad 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -80,9 +80,9 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -127,6 +127,7 @@ chown -R $app: $datadir # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." + ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="fs_port port domain datadir password" yunohost service add $app --description "$app service" --log "$datadir/log/debug-last.log" --needs_exposed_ports "$fs_port" @@ -148,7 +149,7 @@ ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload From 728aabf41403532128321cfba6e7dcadd2844a48 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 1 Dec 2020 10:53:34 +0100 Subject: [PATCH 20/24] Fix --- check_process | 3 --- manifest.json | 2 +- scripts/change_url | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/check_process b/check_process index deefe1c..e1028e4 100644 --- a/check_process +++ b/check_process @@ -29,6 +29,3 @@ fail_download_source=0 port_already_use=1 (66) final_path_already_use=1 -;;; Levels - Level 5=auto - diff --git a/manifest.json b/manifest.json index 28a2f84..71d64e2 100644 --- a/manifest.json +++ b/manifest.json @@ -40,7 +40,7 @@ "fr": "Définissez le mot de passe pour votre Zeronet." }, "example": "myreallystrengthpassword" - } + } ] } } \ No newline at end of file diff --git a/scripts/change_url b/scripts/change_url index 477a937..c77f72c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -32,7 +32,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade From 3bce373847bcb012f72da704047591e3af53e99d Mon Sep 17 00:00:00 2001 From: anmol26s Date: Tue, 9 Feb 2021 00:24:55 +0530 Subject: [PATCH 21/24] Added geventwebsocket module --- README.md | 6 +++--- check_process | 24 +++++++++++------------- scripts/install | 6 +++--- scripts/remove | 2 +- scripts/restore | 10 +--------- scripts/upgrade | 10 +--------- 6 files changed, 20 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 8c98979..b4eb840 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ZeroNet for YunoHost -[![Integration level](https://dash.yunohost.org/integration/zeronet.svg)](https://dash.yunohost.org/appci/app/zeronet) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/zeronet.svg)](https://dash.yunohost.org/appci/app/zeronet) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.maintain.svg) [![Install ZeroNet with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=zeronet) *[Lire ce readme en français.](./README_fr.md)* @@ -44,8 +44,8 @@ Are LDAP and HTTP auth supported? No #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/REPLACEBYYOURAPP/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/REPLACEBYYOURAPP/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/zeronet%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/zeronet/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/zeronet%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/zeronet/) ## Limitations diff --git a/check_process b/check_process index e1028e4..25c2bab 100644 --- a/check_process +++ b/check_process @@ -1,6 +1,5 @@ -;; Nom du test - auto_remove=1 -# Commentaire ignoré +;; Complete Test +# Comment ignored ; Manifest domain="sub.domain.tld" (DOMAIN) # path="/" (PATH) @@ -19,13 +18,12 @@ # setup_private=0 test disabled because app is always installed as private setup_public=0 upgrade=1 - backup_restore=1 - multi_instance=0 -# multi_instance=1 test disabled because it requires installation on sub-path which is not available. successfully conducted test manually - wrong_user=1 - wrong_path=0 - incorrect_path=0 -# corrupt_source=0 - fail_download_source=0 - port_already_use=1 (66) - final_path_already_use=1 + backup_restore=1 + multi_instance=q +;;; Options +Email= +Notification=none +;;; Upgrade options + ; commit=CommitHash + name=Name and date of the commit. + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&password=pass& \ No newline at end of file diff --git a/scripts/install b/scripts/install index 676cc94..b594621 100755 --- a/scripts/install +++ b/scripts/install @@ -74,7 +74,7 @@ ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies -pip3 install msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb +pip3 install gevent-websocket msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -142,10 +142,10 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." +ynh_script_progression --message="Configuring permissions..." # Allow the app to be public -ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" +ynh_permission_update --permission="main" --add="visitors" #================================================= # RELOAD NGINX diff --git a/scripts/remove b/scripts/remove index a4ff691..3e6e221 100755 --- a/scripts/remove +++ b/scripts/remove @@ -49,7 +49,7 @@ ynh_remove_systemd_config ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies -pip3 uninstall -y msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb +pip3 uninstall -y gevent-websocket msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb ynh_remove_app_dependencies #================================================= diff --git a/scripts/restore b/scripts/restore index 6e07ce6..9ba2eaa 100755 --- a/scripts/restore +++ b/scripts/restore @@ -84,7 +84,7 @@ ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies -pip3 install msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb +pip3 install gevent-websocket msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb #================================================= # RESTORE SYSTEMD @@ -108,14 +108,6 @@ ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log/debug-last.log" --line_match="Ui.UiServer Web interface" --timeout=120 -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." - -# Allow the app to be public -ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 4e3f6ad..e72b2a3 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -92,7 +92,7 @@ ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies -pip3 install msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb +pip3 install gevent-websocket msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb #================================================= # CREATE DEDICATED USER @@ -138,14 +138,6 @@ ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="$datadir/log/debug-last.log" --line_match="Ui.UiServer Web interface" --timeout=120 -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." - -# Allow the app to be public -ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" - #================================================= # RELOAD NGINX #================================================= From 25992b9ff3ffde6be4ea82ebd5b8cbd2ab82ed16 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 8 Feb 2021 21:29:31 +0100 Subject: [PATCH 22/24] Fix linter warnings --- check_process | 2 +- scripts/restore | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index 25c2bab..374da40 100644 --- a/check_process +++ b/check_process @@ -19,7 +19,7 @@ setup_public=0 upgrade=1 backup_restore=1 - multi_instance=q + multi_instance=1 ;;; Options Email= Notification=none diff --git a/scripts/restore b/scripts/restore index 9ba2eaa..d06a2e8 100755 --- a/scripts/restore +++ b/scripts/restore @@ -92,7 +92,7 @@ pip3 install gevent-websocket msgpack-python gevent base58 merkletools rsa PySoc ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service +systemctl enable $app.service --quiet #================================================= # INTEGRATE SERVICE IN YUNOHOST From 30bd03fc031924c4a5daccd2174f5b577c4bc12a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 8 Feb 2021 21:36:31 +0100 Subject: [PATCH 23/24] Add cleaning legacy permissions --- pull_request_template.md | 4 +--- scripts/upgrade | 7 +++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pull_request_template.md b/pull_request_template.md index 824e95f..6c28fc5 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -13,6 +13,4 @@ ## Package_check results --- -*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* - -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/zeronet_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/zeronet_ynh%20PR-NUM-%20(USERNAME)/) +* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"* diff --git a/scripts/upgrade b/scripts/upgrade index e72b2a3..4588b45 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -41,6 +41,13 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= From ee6804163eea8e74c8d774328088874fbd4a1f6c Mon Sep 17 00:00:00 2001 From: anmol26s <5068843+anmol26s@users.noreply.github.com> Date: Tue, 9 Feb 2021 20:19:32 +0530 Subject: [PATCH 24/24] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b4eb840..cadfe7d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ZeroNet for YunoHost -[![Integration level](https://dash.yunohost.org/integration/zeronet.svg)](https://dash.yunohost.org/appci/app/zeronet) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/zeronet.svg)](https://dash.yunohost.org/appci/app/zeronet) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/zeronet.maintain.svg) [![Install ZeroNet with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=zeronet) *[Lire ce readme en français.](./README_fr.md)*