mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
Merge pull request #45 from keomabrun/dev_42
#42 using systemctl to get service status
This commit is contained in:
commit
27092350fb
2 changed files with 14 additions and 8 deletions
|
@ -285,7 +285,7 @@ if [ "$1" != restart ]; then
|
||||||
|
|
||||||
echo -n "Retrieving Yunohost settings... "
|
echo -n "Retrieving Yunohost settings... "
|
||||||
|
|
||||||
ynh_service_enabled=$(ynh_setting_get hotspot service_enabled)
|
ynh_service_enabled=$(systemctl is-enabled ynh-hotspot)
|
||||||
ynh_wifi_device=$(ynh_setting_get hotspot wifi_device)
|
ynh_wifi_device=$(ynh_setting_get hotspot wifi_device)
|
||||||
ynh_wifi_channel=$(ynh_setting_get hotspot wifi_channel)
|
ynh_wifi_channel=$(ynh_setting_get hotspot wifi_channel)
|
||||||
ynh_multissid=$(ynh_setting_get hotspot multissid)
|
ynh_multissid=$(ynh_setting_get hotspot multissid)
|
||||||
|
|
|
@ -46,6 +46,9 @@ firmware_nonfree=$YNH_APP_ARG_FIRMWARE_NONFREE
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# the service name must match the service template files
|
||||||
|
service_name='ynh-hotspot'
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -165,9 +168,11 @@ wifi_device=$(sudo bash ../conf/iw_devices | awk -F\| '{ print $1 }')
|
||||||
# Save arguments
|
# Save arguments
|
||||||
|
|
||||||
if [[ -z $wifi_device ]]; then
|
if [[ -z $wifi_device ]]; then
|
||||||
|
ynh_systemctl disable $service_name
|
||||||
ynh_app_setting_set $app service_enabled 0
|
ynh_app_setting_set $app service_enabled 0
|
||||||
wifi_device=none
|
wifi_device=none
|
||||||
else
|
else
|
||||||
|
ynh_systemctl enable $service_name
|
||||||
ynh_app_setting_set $app service_enabled 1
|
ynh_app_setting_set $app service_enabled 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -190,6 +195,7 @@ ynh_app_setting_set $app ip4_dns0 80.67.188.188
|
||||||
ynh_app_setting_set $app ip4_dns1 80.67.169.12
|
ynh_app_setting_set $app ip4_dns1 80.67.169.12
|
||||||
ynh_app_setting_set $app ip4_nat_prefix 10.0.242
|
ynh_app_setting_set $app ip4_nat_prefix 10.0.242
|
||||||
ynh_app_setting_set $app vpnclient no
|
ynh_app_setting_set $app vpnclient no
|
||||||
|
ynh_app_setting_set $app service_name $service_name
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -249,8 +255,8 @@ sed 's|<TPL:NGINX_REALPATH>|/var/www/wifiadmin/|g' -i /etc/php5/fpm/pool.d/wifia
|
||||||
sed "s|<TPL:NGINX_LOCATION>|${path_url}|g" -i /var/www/wifiadmin/config.php
|
sed "s|<TPL:NGINX_LOCATION>|${path_url}|g" -i /var/www/wifiadmin/config.php
|
||||||
|
|
||||||
# Copy init script
|
# Copy init script
|
||||||
install -o root -g root -m 0755 ../conf/ynh-hotspot /usr/local/bin/
|
install -o root -g root -m 0755 ../conf/$service_name /usr/local/bin/
|
||||||
install -o root -g root -m 0644 ../conf/ynh-hotspot.service /etc/systemd/system/
|
install -o root -g root -m 0644 ../conf/$service_name.service /etc/systemd/system/
|
||||||
|
|
||||||
# Update firewall for DHCP
|
# Update firewall for DHCP
|
||||||
yunohost firewall allow --no-upnp --ipv6 UDP 547
|
yunohost firewall allow --no-upnp --ipv6 UDP 547
|
||||||
|
@ -273,15 +279,15 @@ if [[ $ip6_addr != none ]]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
systemctl enable ynh-hotspot
|
# register the service
|
||||||
yunohost service add ynh-hotspot --description "creates a Wi-Fi access point"
|
yunohost service add $service_name --description "creates a Wi-Fi access point"
|
||||||
|
|
||||||
|
# start the 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
|
||||||
|
ynh_systemctl start $service_name
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# start the app
|
|
||||||
ynh_systemctl start ynh-hotspot
|
|
||||||
|
|
||||||
# Reload SSOwat config
|
# Reload SSOwat config
|
||||||
yunohost app ssowatconf
|
yunohost app ssowatconf
|
||||||
|
|
Loading…
Reference in a new issue