Browse Source

Merge pull request #56 from labriqueinternet/fix-if

Misc fixes (for RPi3 but not only)
Alexandre Aubin 6 years ago
parent
commit
157a5b8eb6
2 changed files with 8 additions and 4 deletions
  1. 2 2
      conf/ynh-hotspot
  2. 6 2
      scripts/install

+ 2 - 2
conf/ynh-hotspot

@@ -320,7 +320,7 @@ case "$1" in
   start)
     if is_running; then
       echo "Already started"
-    elif [ "${ynh_service_enabled}" -eq 0 ]; then
+    elif [ "${ynh_service_enabled}" != "enabled" ]; then
       echo "Disabled service"
     else
       echo "[hotspot] Starting..."
@@ -469,7 +469,7 @@ case "$1" in
   status)
     exitcode=0
 
-    if [ "${ynh_service_enabled}" -eq 0 ]; then
+    if [ "${ynh_service_enabled}" != "enabled" ]; then
       echo "[ERR] Hotspot Service disabled"
       exitcode=1
     fi

+ 6 - 2
scripts/install

@@ -259,6 +259,10 @@ find /var/www/wifiadmin/ -type d -exec chmod +x {} \;
 
 ## hostapd
 sed 's|^DAEMON_CONF=$|&/etc/hostapd/hostapd.conf|' -i /etc/init.d/hostapd
+# We also need to put this in /etc/default/hostapd because on some setup
+# like RPi, the version of hostapd is different and /etc/init.d/hostapd
+# isnt used ... instead the service is "pure systemd" ...
+echo "DAEMON_CONF=/etc/hostapd/hostapd.conf" > /etc/default/hostapd
 
 ## nginx
 sed "s|<TPL:NGINX_LOCATION>|${path_url}|g" -i "/etc/nginx/conf.d/${domain}.d/wifiadmin.conf"
@@ -287,14 +291,14 @@ yunohost firewall allow --no-upnp UDP 67
 # and the ynh-hotspot service handles them.
 systemctl disable hostapd
 systemctl stop hostapd
+systemctl unmask hostapd # On some system e.g. RPi, for some reason hostapd is masked after install ...
 systemctl enable php5-fpm
 systemctl restart php5-fpm
 systemctl reload nginx
 
 # Remove IPv6 address set if there is a VPN installed
 if [[ $ip6_addr != none ]]; then
-  ip -6 address show dev tun0 2> /dev/null | grep -q "${ip6_addr}/"
-  if [[ "$?" -eq 0 ]]; 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
 fi