From 57c0f8e01c45124f160c7f507ca22c2871bc0170 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Thu, 13 May 2021 17:47:54 +0200 Subject: [PATCH 1/8] [autopatch] Update issue and PR templates --- .../ISSUE_TEMPLATE.md | 39 ++++++++++++------- .github/PULL_REQUEST_TEMPLATE.md | 16 ++++++++ pull_request_template.md | 18 --------- 3 files changed, 40 insertions(+), 33 deletions(-) rename issue_template.md => .github/ISSUE_TEMPLATE.md (53%) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 pull_request_template.md diff --git a/issue_template.md b/.github/ISSUE_TEMPLATE.md similarity index 53% rename from issue_template.md rename to .github/ISSUE_TEMPLATE.md index 5bdc240..2729a6b 100644 --- a/issue_template.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,46 +1,55 @@ --- name: Bug report -about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all. +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 hotspot itself. Refer to its documentation or repository for help.* - - *If you have a doubt, post here, we will figure it out together.* + - *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** +### Describe the bug + *A clear and concise description of what the bug is.* -**Versions** +### 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* +- 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`* -**To Reproduce** -*Steps to reproduce the behavior.* +### Steps to reproduce + - *If you performed a command from the CLI, the command itself is enough. For example:* ```sh - sudo yunohost app install hotspot + 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 '....'* + 2. *Click on '...'* + 3. *Scroll down to '...'* 4. *See error* -**Expected behavior** +### 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** -*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.* +### 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/pull_request_template.md b/pull_request_template.md deleted file mode 100644 index 470c11f..0000000 --- a/pull_request_template.md +++ /dev/null @@ -1,18 +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 ---- -*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/hotspot_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/hotspot_ynh%20PR-NUM-%20(USERNAME)/) From 165c82b77d74e19b1c85db3703fbff703de22010 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 15 May 2021 20:52:43 +0200 Subject: [PATCH 2/8] Apply example_ynh --- manifest.json | 132 ++++++++++++++++++++++++------------------------ scripts/backup | 5 +- scripts/install | 79 +++++++++++++++-------------- scripts/remove | 8 +-- scripts/restore | 49 +++++++++--------- scripts/upgrade | 65 ++++++++++-------------- 6 files changed, 170 insertions(+), 168 deletions(-) diff --git a/manifest.json b/manifest.json index 6727fcd..7a2790a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,68 +1,68 @@ { - "name": "Wifi Hotspot", - "id": "hotspot", - "packaging_format": 1, - "description": { - "en": "Create and manager wifi networks, share Internet access and use Yunohost apps accross wifi", - "fr": "Créer et configurer des réseaux wifi, partager l'accès a Internet et utiliser les applications Yunohost via wifi" - }, - "url": "https://github.com/labriqueinternet/hotspot_ynh", - "version": "1.2.0~ynh4", - "license": "AGPL-3.0", - "maintainer": { - "name": "Julien Vaubourg", - "email": "julien@vaubourg.com", - "url": "http://julien.vaubourg.com" - }, - "requirements": { - "yunohost": ">= 4.1.0" - }, - "multi_instance": false, - "services": [ - "nginx", - "php7.0-fpm" - ], - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain", - "example": "domain.org" - }, - { - "name": "path", - "type": "path", - "default": "/wifiadmin" - }, - { - "name": "wifi_ssid", - "type": "string", - "ask": { - "en": "Choose a wifi name (SSID)", - "fr": "Choisissez un nom pour le wifi (SSID)" - }, - "example": "myNeutralNetwork", - "default": "myNeutralNetwork" - }, - { - "name": "wifi_passphrase", - "type": "password", - "ask": { - "en": "Choose a wifi password (at least 8 characters for WPA2)", - "fr": "Choisissez un mot de passe wifi (au minimum 8 caractères pour le WPA2)" - }, - "example": "VhegT8oev0jZI" - }, - { - "name": "firmware_nonfree", - "type": "string", - "ask": { - "en": "Install non-free firmwares - in addition to the free ones - for the wifi dongle (yes/no)", - "fr": "Installer des firmwares non-libres (en plus des libres) pour la clé USB wifi (yes/no)" - }, - "choice": [ "yes", "no" ], - "default": "no" - } - ] - } + "name": "Wifi Hotspot", + "id": "hotspot", + "packaging_format": 1, + "description": { + "en": "Create and manager wifi networks, share Internet access and use Yunohost apps accross wifi", + "fr": "Créer et configurer des réseaux wifi, partager l'accès a Internet et utiliser les applications Yunohost via wifi" + }, + "version": "1.2.0~ynh4", + "url": "https://github.com/labriqueinternet/hotspot_ynh", + "license": "AGPL-3.0", + "maintainer": { + "name": "Julien Vaubourg", + "email": "julien@vaubourg.com", + "url": "http://julien.vaubourg.com" + }, + "requirements": { + "yunohost": ">= 4.1.0" + }, + "multi_instance": false, + "services": [ + "nginx", + "php7.0-fpm" + ], + "arguments": { + "install" : [ + { + "name": "domain", + "type": "domain", + "example": "domain.org" + }, + { + "name": "path", + "type": "path", + "default": "/wifiadmin" + }, + { + "name": "wifi_ssid", + "type": "string", + "ask": { + "en": "Choose a wifi name (SSID)", + "fr": "Choisissez un nom pour le wifi (SSID)" + }, + "example": "myNeutralNetwork", + "default": "myNeutralNetwork" + }, + { + "name": "wifi_passphrase", + "type": "password", + "ask": { + "en": "Choose a wifi password (at least 8 characters for WPA2)", + "fr": "Choisissez un mot de passe wifi (au minimum 8 caractères pour le WPA2)" + }, + "example": "VhegT8oev0jZI" + }, + { + "name": "firmware_nonfree", + "type": "string", + "ask": { + "en": "Install non-free firmwares - in addition to the free ones - for the wifi dongle (yes/no)", + "fr": "Installer des firmwares non-libres (en plus des libres) pour la clé USB wifi (yes/no)" + }, + "choice": [ "yes", "no" ], + "default": "no" + } + ] + } } diff --git a/scripts/backup b/scripts/backup index 93ecf39..3b62cb5 100644 --- 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 @@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors diff --git a/scripts/install b/scripts/install index 1af354d..00bc1f2 100644 --- a/scripts/install +++ b/scripts/install @@ -30,6 +30,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -60,25 +63,25 @@ test ! -e "$final_path" || ynh_die --message="This path already contains a folde ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url if [ $firmware_nonfree = "no" ]; then - firmware_nonfree=0 + firmware_nonfree=0 elif [ $firmware_nonfree = "yes" ]; then - firmware_nonfree=1 + firmware_nonfree=1 fi # Check arguments if [[ -z $wifi_ssid || -z $wifi_passphrase ]]; then - ynh_die --message="Your Wifi Hotspot needs a name and a password" + ynh_die --message="Your Wifi Hotspot needs a name and a password" fi # Check passphrase length wifi_passphrase_length="$(echo -n "${wifi_passphrase}" | wc -c)" if [[ $wifi_passphrase_length -lt 8 || $wifi_passphrase_length -gt 63 ]]; then - ynh_die --message="Your password must from 8 to 63 characters (WPA2 passphrase)" + ynh_die --message="Your password must from 8 to 63 characters (WPA2 passphrase)" fi # Check no special characters are present in the passphrase if [[ $wifi_passphrase =~ [^[:print:]] ]]; then - ynh_die --message="Only printable ASCII characters are permitted in your password (WPA2 passphrase)" + ynh_die --message="Only printable ASCII characters are permitted in your password (WPA2 passphrase)" fi #================================================= @@ -86,7 +89,7 @@ fi #================================================= ynh_script_progression --message="Storing installation settings..." -ynh_app_setting_set --app=$app --key=domain --value="$domain" +ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=wifi_ssid --value="$wifi_ssid" ynh_app_setting_set --app=$app --key=wifi_passphrase --value="$wifi_passphrase" ynh_app_setting_set --app=$app --key=firmware_nonfree --value="$firmware_nonfree" @@ -113,18 +116,18 @@ export DEBIAN_FRONTEND=noninteractive # Packaged USB Wireless Device firmwares # Based on https://wiki.debian.org/WiFi#USB_Devices if [[ $firmware_nonfree -eq 1 ]]; then - check_armbian_nonfree_conflict - ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages" + check_armbian_nonfree_conflict + ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages" else - pkg_dependencies="$pkg_dependencies $free_firmware_packages" + pkg_dependencies="$pkg_dependencies $free_firmware_packages" fi #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies" +ynh_script_progression --message="Installing dependencies..." -ynh_install_app_dependencies "$pkg_dependencies" +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER @@ -150,18 +153,18 @@ install -o root -g root -m 0755 ../conf/ipv6_expanded /usr/local/bin/ install -o root -g root -m 0755 ../conf/ipv6_compressed /usr/local/bin/ if [[ ! -v ip6_net ]]; then # if ip6_net not set - ip6_net=none - ip6_addr=none + ip6_net=none + ip6_addr=none - if [[ -e /tmp/.ynh-vpnclient-started ]]; then - vpnclient_ip6_net=$(ynh_app_setting_get vpnclient ip6_net 2>&1) - vpnclient_ip6_addr=$(ynh_app_setting_get vpnclient ip6_addr 2>&1) + if [[ -e /tmp/.ynh-vpnclient-started ]]; then + vpnclient_ip6_net=$(ynh_app_setting_get vpnclient ip6_net 2>&1) + vpnclient_ip6_addr=$(ynh_app_setting_get vpnclient ip6_addr 2>&1) - if [[ $vpnclient_ip6_net =~ :: && $vpnclient_ip6_addr =~ :: ]]; then - ip6_net=${vpnclient_ip6_net} - ip6_addr=${vpnclient_ip6_addr} - fi - fi + if [[ $vpnclient_ip6_net =~ :: && $vpnclient_ip6_addr =~ :: ]]; then + ip6_net=${vpnclient_ip6_net} + ip6_addr=${vpnclient_ip6_addr} + fi + fi fi hot_reload_usb_wifi_cards @@ -184,10 +187,10 @@ ynh_app_setting_set --app=$app --key=ip4_nat_prefix --value=10.0.242 ynh_app_setting_set --app=$app --key=vpnclient --value=no if [[ -z $wifi_device ]]; then - ynh_app_setting_set --app=$app --key=service_enabled --value=0 - wifi_device=none + ynh_app_setting_set --app=$app --key=service_enabled --value=0 + wifi_device=none else - ynh_app_setting_set --app=$app --key=service_enabled --value=1 + ynh_app_setting_set --app=$app --key=service_enabled --value=1 fi #================================================= @@ -212,28 +215,30 @@ ynh_replace_string --match_string="__PHPVERSION__" --replace_string="${YNH_PHP_V ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path -mkdir -pm 0755 ${final_path}/ +mkdir -pm 0755 $final_path cp -a ../sources/* ${final_path}/ -chown -R $app:$app ${final_path}/ + chmod -R 0644 ${final_path}/* +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app ${final_path} find ${final_path}/ -type d -exec chmod +x {} \; -chmod o-rwx ${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 #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring php-fpm..." +ynh_script_progression --message="Configuring PHP-FPM..." -# Create a dedicated php-fpm config +# Create a dedicated PHP-FPM config ynh_add_fpm_config #================================================= @@ -277,9 +282,9 @@ ynh_add_systemd_config --service=$service_name # Remove IPv6 address set if there is a VPN installed if [[ $ip6_addr != none ]]; then - if ip -6 address show dev tun0 2> /dev/null | grep -q "${ip6_addr}/"; then - ip address delete "${ip6_addr}/128" dev tun0 &> /dev/null - fi + if ip -6 address show dev tun0 2> /dev/null | grep -q "${ip6_addr}/"; then + ip address delete "${ip6_addr}/128" dev tun0 &> /dev/null + fi fi #================================================= @@ -287,7 +292,7 @@ fi #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd" +yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd" --needs_exposed_ports 67 547 #================================================= # START SYSTEMD SERVICE @@ -296,9 +301,9 @@ ynh_script_progression --message="Starting a systemd service..." # Start a systemd service if device is present if [[ $wifi_device == none ]]; then - echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2 + echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2 else - ynh_systemd_action --service_name=$service_name --action="start" --log_path=systemd #--line_match="Started YunoHost Wifi Hotspot" + ynh_systemd_action --service_name=$service_name --action="start" --log_path=systemd #--line_match="Started YunoHost Wifi Hotspot" fi #================================================= diff --git a/scripts/remove b/scripts/remove index 23c9457..177d401 100644 --- a/scripts/remove +++ b/scripts/remove @@ -102,17 +102,17 @@ done #================================================= # 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 #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Removing php-fpm configuration..." +ynh_script_progression --message="Removing PHP-FPM configuration..." -# Remove the dedicated php-fpm config +# Remove the dedicated PHP-FPM config ynh_remove_fpm_config #================================================= diff --git a/scripts/restore b/scripts/restore index bc1c089..e12c0a5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -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 @@ -14,13 +14,16 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -46,10 +49,18 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the nginx configuration..." +ynh_script_progression --message="Restoring the NGINX configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# 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=$final_path + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -58,10 +69,10 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" if [[ $firmware_nonfree -eq 1 ]]; then - check_armbian_nonfree_conflict - ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages" + check_armbian_nonfree_conflict + ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages" else - pkg_dependencies="$pkg_dependencies $free_firmware_packages" + pkg_dependencies="$pkg_dependencies $free_firmware_packages" fi ynh_restore_file --origin_path="/etc/sudoers.d/${app}_ynh" @@ -83,14 +94,6 @@ ynh_restore_file --origin_path="/usr/local/bin/$service_name" ynh_restore_file --origin_path="/etc/init.d/hostapd" -#================================================= -# 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 - #================================================= # RESTORE USER RIGHTS #================================================= @@ -105,7 +108,7 @@ chmod o-rwx ${final_path} #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Restoring PHP-FPM configuration..." +ynh_script_progression --message="Restoring the PHP-FPM configuration..." ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" @@ -117,7 +120,7 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies -ynh_install_app_dependencies "$pkg_dependencies" +ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE SYSTEMD @@ -132,7 +135,7 @@ systemctl enable $service_name.service --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd" +yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd" --needs_exposed_ports 67 547 #================================================= # START SYSTEMD SERVICE @@ -143,17 +146,17 @@ hot_reload_usb_wifi_cards wifi_device=$(bash ../settings/conf/iw_devices | awk -F\| '{ print $1 }') if [[ -z $wifi_device ]]; then - ynh_app_setting_set --app=$app --key=service_enabled --value=0 - wifi_device=none + ynh_app_setting_set --app=$app --key=service_enabled --value=0 + wifi_device=none else - ynh_app_setting_set --app=$app --key=service_enabled --value=1 + ynh_app_setting_set --app=$app --key=service_enabled --value=1 fi # Start a systemd service if device is present if [[ $wifi_device == none ]]; then - echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2 + echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2 else - ynh_systemd_action --service_name=$service_name --action="start" --log_path=systemd #--line_match="Started YunoHost Wifi Hotspot" + ynh_systemd_action --service_name=$service_name --action="start" --log_path=systemd #--line_match="Started YunoHost Wifi Hotspot" fi #================================================= @@ -161,7 +164,7 @@ fi #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading nginx web server and php-fpm..." +ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index ee7beb6..9ed8b05 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -74,7 +74,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -89,6 +89,14 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$service_name --action="stop" --log_path=systemd #--line_match="Started YunoHost Wifi Hotspot" +#================================================= +# 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 #================================================= @@ -104,9 +112,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 #================================================= @@ -115,28 +123,20 @@ ynh_add_nginx_config ynh_script_progression --message="Upgrading dependencies..." if [[ $firmware_nonfree -eq 1 ]]; then - check_armbian_nonfree_conflict - ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages" + check_armbian_nonfree_conflict + ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages" else - pkg_dependencies="$pkg_dependencies $free_firmware_packages" + pkg_dependencies="$pkg_dependencies $free_firmware_packages" fi -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 +ynh_install_app_dependencies $pkg_dependencies #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading php-fpm configuration..." +ynh_script_progression --message="Upgrading PHP-FPM configuration..." -# Create a dedicated php-fpm config +# Create a dedicated PHP-FPM config ynh_add_fpm_config #================================================= @@ -158,11 +158,13 @@ install -o root -g root -m 0755 ../conf/$service_name /usr/local/bin/ ynh_replace_string --match_string="__PHPVERSION__" --replace_string="${phpversion}" --target_file="/usr/local/bin/$service_name" #================================================= -# MODIFY A CONFIG FILE +# UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." +ynh_script_progression --message="Updating a configuration file..." ynh_add_config --template="config.php.tpl" --destination="$final_path/config.php" + +chmod 400 "$final_path/config.php" chown $app:$app "$final_path/config.php" #================================================= @@ -175,23 +177,12 @@ ynh_add_systemd_config --service=$service_name #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions on app files -chown -R $app:$app ${final_path}/ -chmod -R 0644 ${final_path}/* -find ${final_path}/ -type d -exec chmod +x {} \; -chmod o-rwx "${final_path}" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd" +yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd" --needs_exposed_ports 67 547 #================================================= # START SYSTEMD SERVICE @@ -202,23 +193,23 @@ hot_reload_usb_wifi_cards wifi_device=$(bash ../conf/iw_devices | awk -F\| '{ print $1 }') if [[ -z $wifi_device ]]; then - ynh_app_setting_set --app=$app --key=service_enabled --value=0 - wifi_device=none + ynh_app_setting_set --app=$app --key=service_enabled --value=0 + wifi_device=none else - ynh_app_setting_set --app=$app --key=service_enabled --value=1 + ynh_app_setting_set --app=$app --key=service_enabled --value=1 fi # Start a systemd service if device is present if [[ $wifi_device == none ]]; then - echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2 + echo "WARNING: Wifi Hotspot is not started because no wifi device was found (please, check the web admin)" >&2 else - ynh_systemd_action --service_name=$service_name --action="start" --log_path=systemd #--line_match="Started YunoHost Wifi Hotspot" + ynh_systemd_action --service_name=$service_name --action="start" --log_path=systemd #--line_match="Started YunoHost Wifi Hotspot" fi #================================================= # 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 b3a8cd07d7d17e089970ade41aef72e7564117d4 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 22 May 2021 11:43:59 +0200 Subject: [PATCH 3/8] Update scripts/install Co-authored-by: Alexandre Aubin --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 00bc1f2..f8faf1d 100644 --- a/scripts/install +++ b/scripts/install @@ -292,7 +292,7 @@ fi #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd" --needs_exposed_ports 67 547 +yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd" #================================================= # START SYSTEMD SERVICE From 42ce455c13c2f89546aec47b1b9977118761ec10 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 22 May 2021 11:44:05 +0200 Subject: [PATCH 4/8] Update scripts/upgrade Co-authored-by: Alexandre Aubin --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 9ed8b05..8177f5d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -182,7 +182,7 @@ ynh_add_systemd_config --service=$service_name #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd" --needs_exposed_ports 67 547 +yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd" #================================================= # START SYSTEMD SERVICE From 36abf65737db0df93e4e1bf7b0456ada5a998e81 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 22 May 2021 11:44:30 +0200 Subject: [PATCH 5/8] Update scripts/restore Co-authored-by: Alexandre Aubin --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index e12c0a5..2333b46 100644 --- a/scripts/restore +++ b/scripts/restore @@ -135,7 +135,7 @@ systemctl enable $service_name.service --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd" --needs_exposed_ports 67 547 +yunohost service add $service_name --description "Creates a Wi-Fi access point" --test_status "systemctl is-active hostapd" #================================================= # START SYSTEMD SERVICE From 2534da618ec814d05a642786468e1a774a875b37 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 22 May 2021 11:53:07 +0200 Subject: [PATCH 6/8] Missing stuff --- scripts/install | 4 +--- scripts/restore | 6 +++--- scripts/upgrade | 52 +++++++++++++++++++++++++++---------------------- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/scripts/install b/scripts/install index 00bc1f2..50bef85 100644 --- a/scripts/install +++ b/scripts/install @@ -218,12 +218,10 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path mkdir -pm 0755 $final_path cp -a ../sources/* ${final_path}/ - chmod -R 0644 ${final_path}/* chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app ${final_path} -find ${final_path}/ -type d -exec chmod +x {} \; +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index e12c0a5..d6ff090 100644 --- a/scripts/restore +++ b/scripts/restore @@ -100,10 +100,10 @@ ynh_restore_file --origin_path="/etc/init.d/hostapd" ynh_script_progression --message="Restoring user rights..." # Restore permissions on app files -chown -R $app:$app ${final_path}/ chmod -R 0644 ${final_path}/* -find ${final_path}/ -type d -exec chmod +x {} \; -chmod o-rwx ${final_path} +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" #================================================= # RESTORE THE PHP-FPM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 9ed8b05..002d54d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -30,6 +30,29 @@ ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$service_name --action="stop" --log_path=systemd #--line_match="Started YunoHost Wifi Hotspot" + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -66,29 +89,6 @@ if [ -z $service_name ]; then ynh_app_setting_set --app=$app --key=service_name --value=$service_name 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 - -#================================================= -# STANDARD UPGRADE STEPS -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." - -ynh_systemd_action --service_name=$service_name --action="stop" --log_path=systemd #--line_match="Started YunoHost Wifi Hotspot" - #================================================= # CREATE DEDICATED USER #================================================= @@ -109,6 +109,12 @@ then cp -a ../sources/* ${final_path}/ fi +# Restore permissions on app files +chmod -R 0644 ${final_path}/* +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= From c206729f627b75cdbb942c15a1fc23caa9ff1b96 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 28 May 2021 02:16:18 +0200 Subject: [PATCH 7/8] Fix rights --- conf/nginx.conf | 2 +- scripts/_common.sh | 2 +- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 886817a..2155190 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -27,7 +27,7 @@ location __PATH__/ { } index index.php; - + # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file client_max_body_size 10G; diff --git a/scripts/_common.sh b/scripts/_common.sh index 6a73103..2d8cdfc 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,7 @@ # COMMON VARIABLES #================================================= -pkg_dependencies="sipcalc hostapd iptables iw dnsmasq" +pkg_dependencies="sipcalc hostapd iptables iw dnsmasq kmod" nonfree_firmware_packages="firmware-atheros firmware-realtek firmware-ralink firmware-libertas atmel-firmware firmware-zd1211" free_firmware_packages="firmware-ath9k-htc" diff --git a/scripts/install b/scripts/install index 7cba03e..4bdd3f7 100644 --- a/scripts/install +++ b/scripts/install @@ -221,7 +221,7 @@ cp -a ../sources/* ${final_path}/ chmod -R 0644 ${final_path}/* chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index fe93249..e5ae118 100644 --- a/scripts/restore +++ b/scripts/restore @@ -103,7 +103,7 @@ ynh_script_progression --message="Restoring user rights..." chmod -R 0644 ${final_path}/* chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # RESTORE THE PHP-FPM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 40ab91e..c54e8c7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -113,7 +113,7 @@ fi chmod -R 0644 ${final_path}/* chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION From 7c1c6c8e15645e12f8a500b5c3d232e84659e554 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 7 Jun 2021 18:32:16 +0200 Subject: [PATCH 8/8] Fix weird permission stuff --- scripts/install | 3 +-- scripts/restore | 17 ++++++----------- scripts/upgrade | 3 +-- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/scripts/install b/scripts/install index 4bdd3f7..481b999 100644 --- a/scripts/install +++ b/scripts/install @@ -218,9 +218,8 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path mkdir -pm 0755 $final_path cp -a ../sources/* ${final_path}/ -chmod -R 0644 ${final_path}/* chmod 750 "$final_path" -chmod -R o-rwx "$final_path" +chmod o-rwx "$final_path" chown -R $app:www-data "$final_path" #================================================= diff --git a/scripts/restore b/scripts/restore index e5ae118..b388245 100644 --- a/scripts/restore +++ b/scripts/restore @@ -68,6 +68,12 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" +# Restore permissions on app files +chmod 750 "$final_path" +chmod o-rwx "$final_path" +chown -R $app:www-data "$final_path" + + if [[ $firmware_nonfree -eq 1 ]]; then check_armbian_nonfree_conflict ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages" @@ -94,17 +100,6 @@ ynh_restore_file --origin_path="/usr/local/bin/$service_name" ynh_restore_file --origin_path="/etc/init.d/hostapd" -#================================================= -# RESTORE USER RIGHTS -#================================================= -ynh_script_progression --message="Restoring user rights..." - -# Restore permissions on app files -chmod -R 0644 ${final_path}/* -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c54e8c7..1db62df 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -110,9 +110,8 @@ then fi # Restore permissions on app files -chmod -R 0644 ${final_path}/* chmod 750 "$final_path" -chmod -R o-rwx "$final_path" +chmod o-rwx "$final_path" chown -R $app:www-data "$final_path" #=================================================