1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/hotspot_ynh.git synced 2024-09-03 19:25:53 +02:00

Apply example_ynh

This commit is contained in:
yalh76 2021-05-15 20:52:43 +02:00
parent 1f4bb0ab4d
commit 165c82b77d
6 changed files with 170 additions and 168 deletions

View file

@ -1,68 +1,68 @@
{ {
"name": "Wifi Hotspot", "name": "Wifi Hotspot",
"id": "hotspot", "id": "hotspot",
"packaging_format": 1, "packaging_format": 1,
"description": { "description": {
"en": "Create and manager wifi networks, share Internet access and use Yunohost apps accross wifi", "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" "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",
"version": "1.2.0~ynh4", "url": "https://github.com/labriqueinternet/hotspot_ynh",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"maintainer": { "maintainer": {
"name": "Julien Vaubourg", "name": "Julien Vaubourg",
"email": "julien@vaubourg.com", "email": "julien@vaubourg.com",
"url": "http://julien.vaubourg.com" "url": "http://julien.vaubourg.com"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.1.0" "yunohost": ">= 4.1.0"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [
"nginx", "nginx",
"php7.0-fpm" "php7.0-fpm"
], ],
"arguments": { "arguments": {
"install" : [ "install" : [
{ {
"name": "domain", "name": "domain",
"type": "domain", "type": "domain",
"example": "domain.org" "example": "domain.org"
}, },
{ {
"name": "path", "name": "path",
"type": "path", "type": "path",
"default": "/wifiadmin" "default": "/wifiadmin"
}, },
{ {
"name": "wifi_ssid", "name": "wifi_ssid",
"type": "string", "type": "string",
"ask": { "ask": {
"en": "Choose a wifi name (SSID)", "en": "Choose a wifi name (SSID)",
"fr": "Choisissez un nom pour le wifi (SSID)" "fr": "Choisissez un nom pour le wifi (SSID)"
}, },
"example": "myNeutralNetwork", "example": "myNeutralNetwork",
"default": "myNeutralNetwork" "default": "myNeutralNetwork"
}, },
{ {
"name": "wifi_passphrase", "name": "wifi_passphrase",
"type": "password", "type": "password",
"ask": { "ask": {
"en": "Choose a wifi password (at least 8 characters for WPA2)", "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)" "fr": "Choisissez un mot de passe wifi (au minimum 8 caractères pour le WPA2)"
}, },
"example": "VhegT8oev0jZI" "example": "VhegT8oev0jZI"
}, },
{ {
"name": "firmware_nonfree", "name": "firmware_nonfree",
"type": "string", "type": "string",
"ask": { "ask": {
"en": "Install non-free firmwares - in addition to the free ones - for the wifi dongle (yes/no)", "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)" "fr": "Installer des firmwares non-libres (en plus des libres) pour la clé USB wifi (yes/no)"
}, },
"choice": [ "yes", "no" ], "choice": [ "yes", "no" ],
"default": "no" "default": "no"
} }
] ]
} }
} }

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors

View file

@ -30,6 +30,9 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors 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 ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
if [ $firmware_nonfree = "no" ]; then if [ $firmware_nonfree = "no" ]; then
firmware_nonfree=0 firmware_nonfree=0
elif [ $firmware_nonfree = "yes" ]; then elif [ $firmware_nonfree = "yes" ]; then
firmware_nonfree=1 firmware_nonfree=1
fi fi
# Check arguments # Check arguments
if [[ -z $wifi_ssid || -z $wifi_passphrase ]]; then 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 fi
# Check passphrase length # Check passphrase length
wifi_passphrase_length="$(echo -n "${wifi_passphrase}" | wc -c)" wifi_passphrase_length="$(echo -n "${wifi_passphrase}" | wc -c)"
if [[ $wifi_passphrase_length -lt 8 || $wifi_passphrase_length -gt 63 ]]; then 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 fi
# Check no special characters are present in the passphrase # Check no special characters are present in the passphrase
if [[ $wifi_passphrase =~ [^[:print:]] ]]; then 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 fi
#================================================= #=================================================
@ -86,7 +89,7 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." 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_ssid --value="$wifi_ssid"
ynh_app_setting_set --app=$app --key=wifi_passphrase --value="$wifi_passphrase" ynh_app_setting_set --app=$app --key=wifi_passphrase --value="$wifi_passphrase"
ynh_app_setting_set --app=$app --key=firmware_nonfree --value="$firmware_nonfree" 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 # Packaged USB Wireless Device firmwares
# Based on https://wiki.debian.org/WiFi#USB_Devices # Based on https://wiki.debian.org/WiFi#USB_Devices
if [[ $firmware_nonfree -eq 1 ]]; then if [[ $firmware_nonfree -eq 1 ]]; then
check_armbian_nonfree_conflict 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" ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages"
else else
pkg_dependencies="$pkg_dependencies $free_firmware_packages" pkg_dependencies="$pkg_dependencies $free_firmware_packages"
fi fi
#================================================= #=================================================
# INSTALL DEPENDENCIES # 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 # 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/ install -o root -g root -m 0755 ../conf/ipv6_compressed /usr/local/bin/
if [[ ! -v ip6_net ]]; then # if ip6_net not set if [[ ! -v ip6_net ]]; then # if ip6_net not set
ip6_net=none ip6_net=none
ip6_addr=none ip6_addr=none
if [[ -e /tmp/.ynh-vpnclient-started ]]; then if [[ -e /tmp/.ynh-vpnclient-started ]]; then
vpnclient_ip6_net=$(ynh_app_setting_get vpnclient ip6_net 2>&1) vpnclient_ip6_net=$(ynh_app_setting_get vpnclient ip6_net 2>&1)
vpnclient_ip6_addr=$(ynh_app_setting_get vpnclient ip6_addr 2>&1) vpnclient_ip6_addr=$(ynh_app_setting_get vpnclient ip6_addr 2>&1)
if [[ $vpnclient_ip6_net =~ :: && $vpnclient_ip6_addr =~ :: ]]; then if [[ $vpnclient_ip6_net =~ :: && $vpnclient_ip6_addr =~ :: ]]; then
ip6_net=${vpnclient_ip6_net} ip6_net=${vpnclient_ip6_net}
ip6_addr=${vpnclient_ip6_addr} ip6_addr=${vpnclient_ip6_addr}
fi fi
fi fi
fi fi
hot_reload_usb_wifi_cards 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 ynh_app_setting_set --app=$app --key=vpnclient --value=no
if [[ -z $wifi_device ]]; then if [[ -z $wifi_device ]]; then
ynh_app_setting_set --app=$app --key=service_enabled --value=0 ynh_app_setting_set --app=$app --key=service_enabled --value=0
wifi_device=none wifi_device=none
else else
ynh_app_setting_set --app=$app --key=service_enabled --value=1 ynh_app_setting_set --app=$app --key=service_enabled --value=1
fi 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_script_progression --message="Setting up source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path 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}/ cp -a ../sources/* ${final_path}/
chown -R $app:$app ${final_path}/
chmod -R 0644 ${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 {} \; find ${final_path}/ -type d -exec chmod +x {} \;
chmod o-rwx ${final_path}
#================================================= #=================================================
# NGINX CONFIGURATION # 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 ynh_add_nginx_config
#================================================= #=================================================
# PHP-FPM CONFIGURATION # 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 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 # Remove IPv6 address set if there is a VPN installed
if [[ $ip6_addr != none ]]; then if [[ $ip6_addr != none ]]; then
if ip -6 address show dev tun0 2> /dev/null | grep -q "${ip6_addr}/"; 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 ip address delete "${ip6_addr}/128" dev tun0 &> /dev/null
fi fi
fi fi
#================================================= #=================================================
@ -287,7 +292,7 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Integrating 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 # START SYSTEMD SERVICE
@ -296,9 +301,9 @@ ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service if device is present # Start a systemd service if device is present
if [[ $wifi_device == none ]]; then 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 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 fi
#================================================= #=================================================

View file

@ -102,17 +102,17 @@ done
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # 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 ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE PHP-FPM CONFIGURATION # 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 ynh_remove_fpm_config
#================================================= #=================================================

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -14,13 +14,16 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -46,10 +49,18 @@ test ! -d $final_path \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # 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" 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 # 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" ynh_restore_file --origin_path="$final_path"
if [[ $firmware_nonfree -eq 1 ]]; then if [[ $firmware_nonfree -eq 1 ]]; then
check_armbian_nonfree_conflict 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" ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages"
else else
pkg_dependencies="$pkg_dependencies $free_firmware_packages" pkg_dependencies="$pkg_dependencies $free_firmware_packages"
fi fi
ynh_restore_file --origin_path="/etc/sudoers.d/${app}_ynh" 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" 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 # RESTORE USER RIGHTS
#================================================= #=================================================
@ -105,7 +108,7 @@ chmod o-rwx ${final_path}
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # 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" 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..." ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies "$pkg_dependencies" ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
@ -132,7 +135,7 @@ systemctl enable $service_name.service --quiet
#================================================= #=================================================
ynh_script_progression --message="Integrating 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 # START SYSTEMD SERVICE
@ -143,17 +146,17 @@ hot_reload_usb_wifi_cards
wifi_device=$(bash ../settings/conf/iw_devices | awk -F\| '{ print $1 }') wifi_device=$(bash ../settings/conf/iw_devices | awk -F\| '{ print $1 }')
if [[ -z $wifi_device ]]; then if [[ -z $wifi_device ]]; then
ynh_app_setting_set --app=$app --key=service_enabled --value=0 ynh_app_setting_set --app=$app --key=service_enabled --value=0
wifi_device=none wifi_device=none
else else
ynh_app_setting_set --app=$app --key=service_enabled --value=1 ynh_app_setting_set --app=$app --key=service_enabled --value=1
fi fi
# Start a systemd service if device is present # Start a systemd service if device is present
if [[ $wifi_device == none ]]; then 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 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 fi
#================================================= #=================================================
@ -161,7 +164,7 @@ fi
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # 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=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload

View file

@ -74,7 +74,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
# restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # 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" 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 # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -104,9 +112,9 @@ fi
#================================================= #=================================================
# NGINX CONFIGURATION # 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 ynh_add_nginx_config
#================================================= #=================================================
@ -115,28 +123,20 @@ ynh_add_nginx_config
ynh_script_progression --message="Upgrading dependencies..." ynh_script_progression --message="Upgrading dependencies..."
if [[ $firmware_nonfree -eq 1 ]]; then if [[ $firmware_nonfree -eq 1 ]]; then
check_armbian_nonfree_conflict 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" ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $(ynh_get_debian_release) non-free" --package="$nonfree_firmware_packages"
else else
pkg_dependencies="$pkg_dependencies $free_firmware_packages" pkg_dependencies="$pkg_dependencies $free_firmware_packages"
fi fi
ynh_install_app_dependencies "$pkg_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
#================================================= #=================================================
# PHP-FPM CONFIGURATION # 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 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" 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" 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" chown $app:$app "$final_path/config.php"
#================================================= #=================================================
@ -175,23 +177,12 @@ ynh_add_systemd_config --service=$service_name
#================================================= #=================================================
# GENERIC FINALIZATION # 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 # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating 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 # START SYSTEMD SERVICE
@ -202,23 +193,23 @@ hot_reload_usb_wifi_cards
wifi_device=$(bash ../conf/iw_devices | awk -F\| '{ print $1 }') wifi_device=$(bash ../conf/iw_devices | awk -F\| '{ print $1 }')
if [[ -z $wifi_device ]]; then if [[ -z $wifi_device ]]; then
ynh_app_setting_set --app=$app --key=service_enabled --value=0 ynh_app_setting_set --app=$app --key=service_enabled --value=0
wifi_device=none wifi_device=none
else else
ynh_app_setting_set --app=$app --key=service_enabled --value=1 ynh_app_setting_set --app=$app --key=service_enabled --value=1
fi fi
# Start a systemd service if device is present # Start a systemd service if device is present
if [[ $wifi_device == none ]]; then 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 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 fi
#================================================= #=================================================
# RELOAD NGINX # 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 ynh_systemd_action --service_name=nginx --action=reload