From 8060c30025e9f1624737855bea16e549630abedb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 12 May 2021 09:09:45 +0200 Subject: [PATCH] Testing (#26) * Fix permissions --- .github/ISSUE_TEMPLATE.md | 55 ++++++++++++++++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 16 ++++++++++ check_process | 3 +- manifest.json | 4 +-- pull_request_template.md | 16 ---------- scripts/backup | 3 +- scripts/change_url | 2 +- scripts/install | 16 +++++----- scripts/remove | 3 +- scripts/restore | 10 +++--- scripts/upgrade | 24 ++++++++------ 11 files changed, 107 insertions(+), 45 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 pull_request_template.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..2729a6b --- /dev/null +++ b/.github/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. *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.* + - *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 + +*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 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:* + 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/.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/check_process b/check_process index ee1a894..ffc8451 100644 --- a/check_process +++ b/check_process @@ -6,7 +6,7 @@ port="7777" (PORT) ; Checks pkg_linter=1 - setup_sub_dir=1 + setup_sub_dir=0 setup_root=1 setup_nourl=0 setup_private=1 @@ -14,7 +14,6 @@ upgrade=1 backup_restore=1 multi_instance=0 - port_already_use=1 change_url=1 ;;; Options Email= diff --git a/manifest.json b/manifest.json index 2883421..b3dde7a 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Open-source pastebin allowing to upload texts", "fr": "Pastebin open-source permettant de mettre en ligne du texte" }, - "version": "0.1.0~ynh6", + "version": "0.1.0~ynh7", "url": "https://github.com/seejohnrun/haste-server", "license": "MIT", "maintainer": { @@ -18,7 +18,7 @@ "email": "maxime.bugeia@gmail.com" }], "requirements": { - "yunohost": ">= 4.1.7" + "yunohost": ">= 4.2.4" }, "multi_instance": false, "services": [ 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 60b4845..9c7fc73 100755 --- a/scripts/backup +++ b/scripts/backup @@ -26,6 +26,7 @@ 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) +data_path=$(ynh_app_setting_get --app=$app --key=data_path) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -54,7 +55,7 @@ ynh_backup --src_path="/etc/logrotate.d/$app" # BACKUP DATADIR DIRECTORY #================================================= -ynh_backup --src_path="/home/yunohost.app/$app" +ynh_backup --src_path="$data_path" #================================================= # BACKUP BINARY diff --git a/scripts/change_url b/scripts/change_url index aac1a25..b1655f3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -17,7 +17,7 @@ old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH +new_path="/" app=$YNH_APP_INSTANCE_NAME diff --git a/scripts/install b/scripts/install index 780a33c..05612cf 100755 --- a/scripts/install +++ b/scripts/install @@ -95,8 +95,8 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # ADD SYSTEMD SERVICE #================================================= -ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" ynh_add_systemd_config @@ -119,6 +119,7 @@ data_path="/home/yunohost.app/${app}" # Create app folders mkdir -p "$data_path" +ynh_app_setting_set --app=$app --key=data_path --value=$data_path #================================================= # CONFIGURE HASTE @@ -135,10 +136,8 @@ ynh_replace_string --match_string="https://ajax.googleapis.com/ajax/libs/jquery/ # ADD HASTE AS A BINARY FILE #================================================= -ynh_replace_string --match_string="__HASTE_URL__" --replace_string="${domain}${path_url%/}" --target_file="../conf/haste.sh" -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/haste.sh" - -cp ../conf/haste.sh /usr/bin/$app +haste_url="${domain}${path_url}" +ynh_add_config --template="../conf/haste.sh" --destination="/usr/bin/$app" #================================================= # GENERIC FINALIZATION @@ -146,8 +145,9 @@ cp ../conf/haste.sh /usr/bin/$app # SECURE FILES AND DIRECTORIES #================================================= -chown -R root: $final_path -chown -R $app: "$final_path/static" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" chown -R $app: $data_path chmod +x /usr/bin/$app diff --git a/scripts/remove b/scripts/remove index 8ea90bb..e9b14d8 100755 --- a/scripts/remove +++ b/scripts/remove @@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +data_path=$(ynh_app_setting_get --app=$app --key=data_path) #================================================= # STANDARD REMOVE @@ -75,7 +76,7 @@ ynh_secure_remove --file="/usr/bin/$app" # REMOVE DATADIR DIRECTORY #================================================= -ynh_secure_remove --file="/home/yunohost.app/$app" +ynh_secure_remove --file="$data_path" #================================================= # REMOVE NODEJS diff --git a/scripts/restore b/scripts/restore index 556d104..9d68823 100755 --- a/scripts/restore +++ b/scripts/restore @@ -26,6 +26,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +data_path=$(ynh_app_setting_get --app=$app --key=data_path) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -72,7 +73,7 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # RESTORE VARIOUS FILES #================================================= -ynh_restore_file "/home/yunohost.app/$app" +ynh_restore_file "$data_path" #================================================= # RESTORE BINARY @@ -84,9 +85,10 @@ ynh_restore_file --origin_path="/usr/bin/$app" # SECURE FILES AND DIRECTORIES #================================================= -chown -R root: $final_path -chown -R $app: "$final_path/static" -chown -R $app: "/home/yunohost.app/$app" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +chown -R $app: "$data_path" chmod +x /usr/bin/$app #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 3addda7..23933b2 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,6 +19,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path_url) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) +data_path=$(ynh_app_setting_get --app=$app --key=data_path) #================================================= # CHECK VERSION @@ -37,6 +38,13 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +# If data_path doesn't exist, create it +if [ -z "$data_path" ]; then + data_path="/home/yunohost.app/${app}" + mkdir -p "$data_path" + ynh_app_setting_set --app=$app --key=data_path --value=$data_path +fi + # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all @@ -76,7 +84,7 @@ then ynh_script_progression --message="Upgrading source files..." --weight=7 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$final_path" --keep="$final_path/config.js" fi #================================================= @@ -134,10 +142,6 @@ ynh_add_systemd_config # UPGRADE HASTE CONFIGURATION #================================================= -# Define app's data directory -data_path="/home/yunohost.app/$app" -ynh_add_config --template="../conf/config.js" --destination="$final_path/config.js" - # Replace ajax.googleapis by local file cp ../sources/jquery.min.js "$final_path/static/jquery.min.js" @@ -147,9 +151,8 @@ ynh_replace_string --match_string="https://ajax.googleapis.com/ajax/libs/jquery/ # UPGRADE HASTE BINARY #================================================= -ynh_replace_string --match_string="__YNH_HASTE_URL__" --replace_string="${domain}${path_url}" --target_file="../conf/haste.sh" - -cp ../conf/haste.sh /usr/bin/$app +haste_url="${domain}${path_url}" +ynh_add_config --template="../conf/haste.sh" --destination="/usr/bin/$app" #================================================= # GENERIC FINALIZATION @@ -157,8 +160,9 @@ cp ../conf/haste.sh /usr/bin/$app # SECURE FILES AND DIRECTORIES #================================================= -chown -R root: $final_path -chown -R $app: "$final_path/static" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" chown -R $app: $data_path chmod +x /usr/bin/$app