diff --git a/issue_template.md b/.github/ISSUE_TEMPLATE.md similarity index 89% rename from issue_template.md rename to .github/ISSUE_TEMPLATE.md index 653476a..2729a6b 100644 --- a/issue_template.md +++ b/.github/ISSUE_TEMPLATE.md @@ -6,12 +6,12 @@ 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:* +2. *Determine if 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.* ---- + - *When in doubt, post here and we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- ### Describe the bug @@ -22,7 +22,7 @@ about: When creating a bug report, please use the following template to provide - 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* +- 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`* @@ -31,7 +31,7 @@ about: When creating a bug report, please use the following template to provide - *If you performed a command from the CLI, the command itself is enough. For example:* ```sh - sudo yunohost app install zeronet + sudo yunohost app install the_app ``` - *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:* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ef70e18 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +## Problem + +- *Description of why you made this PR* + +## Solution + +- *And how do you fix that problem* + +## PR Status + +- [ ] Code finished and ready to be reviewed/tested +- [ ] The fix/enhancement were manually tested (if applicable) + +## Automatic tests + +Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization) diff --git a/README.md b/README.md index cadfe7d..45c6338 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview 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 +**Shipped version:** 2021-01-25 ## Screenshots diff --git a/check_process b/check_process index 374da40..7db09ec 100644 --- a/check_process +++ b/check_process @@ -1,29 +1,22 @@ -;; Complete Test -# Comment ignored +;; Test complet ; Manifest - domain="sub.domain.tld" (DOMAIN) -# path="/" (PATH) - password="seceret123" (USER) -# language="fr" -# is_public="Yes" (PUBLIC|public=Yes|private=No) -# is_public=0 (PUBLIC|public=1|private=0) -# port="666" (PORT) + domain="sub.domain.tld" + password="seceret123" ; Checks 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_private=0 setup_public=0 upgrade=1 - backup_restore=1 + # 0.7.1~ynh1 + upgrade=1 from_commit=628e89b0536a3c1ff7e5f9d903527b670690b336 + backup_restore=1 multi_instance=1 ;;; 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 + ; commit=628e89b0536a3c1ff7e5f9d903527b670690b336 + name=0.7.1~ynh1 diff --git a/conf/app.src b/conf/app.src index 0117e6c..ffa1aa4 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,7 +1,7 @@ -SOURCE_URL=https://github.com/HelloZeroNet/ZeroNet/archive/v0.7.1.tar.gz -SOURCE_SUM=78a27e1687d8e3699a854b77b516c95b30a8ba667f7ebbef0aabf7ec6ec7272d +SOURCE_URL=https://github.com/HelloZeroNet/ZeroNet/archive/454c0b2e7e000fda7000cba49027541fbf327b96.tar.gz +SOURCE_SUM=9286971422470cedb8ca5f6675863816bf3f05f0769842a1bdc12f85fc594938 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=0.7.1 +SOURCE_FILENAME= SOURCE_EXTRACT=true diff --git a/conf/nginx.conf b/conf/nginx.conf index 13a4178..c71a07c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,5 @@ - -location / { +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { proxy_pass http://127.0.0.1:__PORT__; proxy_http_version 1.1; diff --git a/conf/systemd.service b/conf/systemd.service index 5462b79..296dbd0 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 --ui_password __PASSWORD__ +ExecStart=__FINALPATH__/venv/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 97cb0c4..69c1730 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "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", + "version": "2021-01-25~ynh1", "url": "https://zeronet.io", "license": "AGPL-3.0", "maintainer": { diff --git a/pull_request_template.md b/pull_request_template.md deleted file mode 100644 index 6c28fc5..0000000 --- a/pull_request_template.md +++ /dev/null @@ -1,16 +0,0 @@ -## 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 ---- -* 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/backup b/scripts/backup index 7ee7cd8..e345ceb 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# 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 +15,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 @@ -42,8 +41,6 @@ ynh_print_info --message="Declaring files to be backed up..." #================================================= ynh_backup --src_path="$final_path" -ynh_backup --src_path="$datadir" - #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= @@ -56,6 +53,12 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/systemd/system/$app.service" +#================================================= +# BACKUP VARIOUS FILES +#================================================= + +ynh_backup --src_path="$datadir" --is_big + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index c77f72c..a82ff1b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -69,7 +69,7 @@ fi #================================================= ynh_script_progression --message="Stopping 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 +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Ui.UiServer Web interface" --timeout=120 #================================================= # MODIFY URL IN NGINX CONF @@ -113,7 +113,7 @@ ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" - # START 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="systemd" --line_match="Ui.UiServer Web interface" --timeout=120 #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index 5956b79..c4f5a04 100755 --- a/scripts/install +++ b/scripts/install @@ -14,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 @@ -30,6 +29,7 @@ password=$YNH_APP_ARG_PASSWORD app=$YNH_APP_INSTANCE_NAME datadir="/home/yunohost.app/${app}" + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -73,8 +73,14 @@ ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $fs_port ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies -pip3 install --upgrade pip -pip3 install gevent-websocket msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -85,6 +91,10 @@ 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" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -94,12 +104,32 @@ ynh_script_progression --message="Configuring NGINX web server..." ynh_add_nginx_config #================================================= -# CREATE DEDICATED USER +# SPECIFIC SETUP #================================================= -ynh_script_progression --message="Configuring system user..." +# BUILDING ZERONET +#================================================= +ynh_script_progression --message="Building zeronet..." -# Create a system user -ynh_system_user_create --username=$app --home_dir=$datadir -s +pushd "$final_path" + python3 -m venv venv + venv/bin/pip install --upgrade pip + venv/bin/pip install -r requirements.txt +popd + +#================================================= +# CREATE DATA DIR +#================================================= +ynh_script_progression --message="Creating data directory..." + +mkdir -p $datadir/data +mkdir -p $datadir/log + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:$app "$datadir" + +# Enable password authentication for Zeronet +mv $final_path/plugins/disabled-UiPassword $final_path/plugins/UiPassword #================================================= # SETUP SYSTEMD @@ -109,27 +139,12 @@ ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# SETUP APPLICATION PERMISSIONS -#================================================= - -# Enable password authentication for Zeronet -mv $final_path/plugins/disabled-UiPassword $final_path/plugins/UiPassword - -# Set right permissions -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..." -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" +yunohost service add $app --description="$app service" --log="$datadir/log/debug-last.log" --needs_exposed_ports="$fs_port" #================================================= # START SYSTEMD SERVICE @@ -137,14 +152,14 @@ yunohost service add $app --description "$app service" --log "$datadir/log/debug ynh_script_progression --message="Starting a systemd service..." # 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 +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Ui.UiServer Web interface" --timeout=120 #================================================= # SETUP SSOWAT #================================================= ynh_script_progression --message="Configuring permissions..." -# Allow the app to be public +# Everyone can access the app. ynh_permission_update --permission="main" --add="visitors" #================================================= diff --git a/scripts/remove b/scripts/remove index 3e6e221..d408e37 100755 --- a/scripts/remove +++ b/scripts/remove @@ -28,7 +28,7 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir) # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) +# 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..." @@ -49,7 +49,6 @@ ynh_remove_systemd_config ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies -pip3 uninstall -y gevent-websocket msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb ynh_remove_app_dependencies #================================================= @@ -59,7 +58,6 @@ ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" -ynh_secure_remove --file="$datadir" #================================================= # REMOVE NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index b99b243..44dbae2 100755 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # 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 @@ -48,32 +49,27 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the NGINX configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring the app main directory..." - -ynh_restore_file --origin_path="$final_path" -ynh_restore_file --origin_path="$datadir" - #================================================= # RECREATE THE DEDICATED USER #================================================= ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$datadir -s +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= -# RESTORE USER RIGHTS +# RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restoring the app main directory..." -# Restore permissions on app files -chown -R $app: $final_path -chown -R $app: $datadir +ynh_restore_file --origin_path="$final_path" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" #================================================= # SPECIFIC RESTORATION @@ -84,8 +80,30 @@ ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies -pip3 install --upgrade pip -pip3 install gevent-websocket msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb + +#================================================= +# BUILDING ZERONET +#================================================= +ynh_script_progression --message="Building zeronet..." + +pushd "$final_path" + python3 -m venv venv + venv/bin/pip install --upgrade pip + venv/bin/pip install -r requirements.txt +popd + +#================================================= +# RESTORE VARIOUS FILES +#================================================= +ynh_script_progression --message="Restoring various files..." + +# Restore permissions on app files +ynh_restore_file --origin_path="$datadir" + +mkdir -p "$datadir" +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:$app "$datadir" #================================================= # RESTORE SYSTEMD @@ -100,14 +118,14 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "$app service" --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" #================================================= # 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" --line_match="Ui.UiServer Web interface" --timeout=120 +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Ui.UiServer Web interface" --timeout=120 #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index b1ec08a..93cddb7 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -30,24 +30,6 @@ password=$(ynh_app_setting_get --app=$app --key=password) upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." - -# 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 - -# 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 #================================================= @@ -69,7 +51,33 @@ ynh_abort_if_errors #================================================= 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="stop" --log_path="systemd" + +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." + +# 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 + +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + +#================================================= +# 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 --home_dir=$final_path #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -80,10 +88,14 @@ 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_secure_remove --file="$final_path" ynh_setup_source --dest_dir="$final_path" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -98,16 +110,34 @@ ynh_add_nginx_config ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies -pip3 install --upgrade pip -pip3 install gevent-websocket msgpack-python gevent base58 merkletools rsa PySocks pyasn1 websocket_client gevent-ws coincurve maxminddb #================================================= -# CREATE DEDICATED USER +# SPECIFIC UPGRADE #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." +# BUILDING ZERONET +#================================================= +ynh_script_progression --message="Building zeronet..." -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$datadir -s +pushd "$final_path" + python3 -m venv venv + venv/bin/pip install --upgrade pip + venv/bin/pip install -r requirements.txt +popd + +#================================================= +# CREATE DATA DIR +#================================================= +ynh_script_progression --message="Creating data directory..." + +mkdir -p $datadir/data +mkdir -p $datadir/log + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:$app "$datadir" + +# Enable password authentication for Zeronet +mv $final_path/plugins/disabled-UiPassword $final_path/plugins/UiPassword #================================================= # SETUP SYSTEMD @@ -119,31 +149,19 @@ ynh_add_systemd_config #================================================= # GENERIC FINALIZATION -#================================================= -# 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 - #================================================= # 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" +yunohost service add $app --description="$app service" --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" --line_match="Ui.UiServer Web interface" --timeout=120 +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Ui.UiServer Web interface" --timeout=120 #================================================= # RELOAD NGINX