ynh-hotspot 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. #!/bin/bash
  2. #
  3. # Wifi Hotspot app for YunoHost
  4. # Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
  5. # Contribute at https://github.com/labriqueinternet/hotspot_ynh
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. # Functions
  20. ## State functions
  21. has_vpnclient_app() {
  22. [ -e /tmp/.ynh-vpnclient-started ]
  23. }
  24. has_ip6delegatedprefix() {
  25. i=${1}
  26. [ "${ynh_ip6_net[${i}]}" != none ]
  27. }
  28. is_nat_set() {
  29. internet_device=${1}
  30. iptables -w -nvt nat -L POSTROUTING | grep MASQUERADE | grep -q "${internet_device}"
  31. }
  32. is_ip4nataddr_set() {
  33. i=${1}
  34. dev=$(devfromid "${i}")
  35. ip address show dev "${dev}" 2> /dev/null | grep -q "${ynh_ip4_nat_prefix[${i}]}.1/24"
  36. }
  37. is_ip6addr_set() {
  38. i=${1}
  39. dev=$(devfromid "${i}")
  40. ip address show dev "${dev}" 2> /dev/null | grep -q "${ynh_ip6_addr[${i}]}/64"
  41. }
  42. is_ip6firewall_set() {
  43. i=${1}
  44. dev=$(devfromid "${i}")
  45. ip6tables -w -nvL FORWARD | grep DROP | grep -q "${dev}"
  46. }
  47. is_forwarding_set() {
  48. ip6=$(sysctl net.ipv6.conf.all.forwarding | awk '{ print $NF; }')
  49. ip4=$(sysctl net.ipv4.conf.all.forwarding | awk '{ print $NF; }')
  50. [ "${ip6}" -eq 1 -a "${ip4}" -eq 1 ]
  51. }
  52. is_dhcpd6_running() {
  53. i=${1}
  54. $(ps aux | grep "dhcpdv6-ssid${i}" | grep -qv grep)
  55. }
  56. is_dhcpd4_running() {
  57. i=${1}
  58. $(ps aux | grep "dhcpdv4-ssid${i}" | grep -qv grep)
  59. }
  60. is_hostapd_running() {
  61. systemctl is-active hostapd &> /dev/null
  62. }
  63. is_running() {
  64. for i in $(seq 0 $((${ynh_multissid} - 1))); do
  65. ( has_ip6delegatedprefix ${i} && is_ip6addr_set ${i}\
  66. && ( [ "${ynh_ip6_firewall[${i}]}" -eq 1 ] && is_ip6firewall_set ${i} || [ "${ynh_ip6_firewall[${i}]}" -eq 0 ] )\
  67. && is_dhcpd6_running ${i} || ! has_ip6delegatedprefix ${i} )\
  68. && is_ip4nataddr_set ${i} && is_dhcpd4_running ${i}
  69. if [ ! $? -eq 0 ]; then
  70. return 1
  71. fi
  72. done
  73. is_hostapd_running && is_forwarding_set && ( [ -z "${new_internet_device}" ] || is_nat_set "${new_internet_device}" )
  74. }
  75. ## Setters
  76. set_nat() {
  77. internet_device=${1}
  78. iptables -w -t nat -A POSTROUTING -o "${internet_device}" -j MASQUERADE
  79. }
  80. set_ip4nataddr() {
  81. i=${1}
  82. dev=$(devfromid "${i}")
  83. ip address add "${ynh_ip4_nat_prefix[${i}]}.1/24" dev "${dev}"
  84. }
  85. set_ip6addr() {
  86. i=${1}
  87. dev=$(devfromid "${i}")
  88. ip address delete "${ynh_ip6_addr[${i}]}/64" dev tun0 &> /dev/null
  89. ip address add "${ynh_ip6_addr[${i}]}/64" dev "${dev}"
  90. }
  91. set_ip6firewall() {
  92. i=${1}
  93. dev=$(devfromid "${i}")
  94. ip6tables -w -A FORWARD -i "${dev}" -j ACCEPT
  95. ip6tables -w -A FORWARD -o "${dev}" -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  96. ip6tables -w -A FORWARD -o "${dev}" -j DROP
  97. }
  98. set_forwarding() {
  99. sysctl -w net.ipv6.conf.all.forwarding=1 > /dev/null
  100. sysctl -w net.ipv4.conf.all.forwarding=1 > /dev/null
  101. }
  102. start_dhcpd6() {
  103. i=${1}
  104. dev=$(devfromid "${i}")
  105. cp /etc/dnsmasq.dhcpd/dhcpdv6{.conf.tpl,-ssid${i}.conf}
  106. sed "s|<TPL:WIFI_DEVICE>|${dev}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
  107. sed "s|<TPL:IP6_NET>|${ynh_ip6_net[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
  108. sed "s|<TPL:IP6_DNS0>|${ynh_ip6_dns0[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
  109. sed "s|<TPL:IP6_DNS1>|${ynh_ip6_dns1[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
  110. dnsmasq -C /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf -p0
  111. }
  112. start_dhcpd4() {
  113. i=${1}
  114. dev=$(devfromid "${i}")
  115. cp /etc/dnsmasq.dhcpd/dhcpdv4{.conf.tpl,-ssid${i}.conf}
  116. sed "s|<TPL:IP4_DNS0>|${ynh_ip4_dns0[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
  117. sed "s|<TPL:IP4_DNS1>|${ynh_ip4_dns1[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
  118. sed "s|<TPL:WIFI_DEVICE>|${dev}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
  119. sed "s|<TPL:IP4_NAT_PREFIX>|${ynh_ip4_nat_prefix[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
  120. dnsmasq -C /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf -p0
  121. }
  122. start_hostapd() {
  123. cp /etc/hostapd/hostapd.conf{.tpl1,}
  124. ethaddr=$(ip link show dev "${ynh_wifi_device}" | grep link/ether | awk -F: '{ printf "02:%s:%s:%s:%s:00", $2, $3, $4, $5 }')
  125. ip link set addr "${ethaddr}" dev "${ynh_wifi_device}"
  126. sed "s|<TPL:WIFI_DEVICE>|${ynh_wifi_device}|g" -i /etc/hostapd/hostapd.conf
  127. sed "s|<TPL:WIFI_CHANNEL>|${ynh_wifi_channel}|g" -i /etc/hostapd/hostapd.conf
  128. sed "s|<TPL:N_COMMENT>||g" -i /etc/hostapd/hostapd.conf
  129. for i in $(seq 0 $((${ynh_multissid} - 1))); do
  130. cp /etc/hostapd/hostapd.conf{.tpl2,.tmp}
  131. sed "s|<TPL:WIFI_INTERFACE>|hotspot${i}|g" -i /etc/hostapd/hostapd.conf.tmp
  132. sed "s|<TPL:WIFI_SSID>|${ynh_wifi_ssid[${i}]}|g" -i /etc/hostapd/hostapd.conf.tmp
  133. sed "s|<TPL:WIFI_PASSPHRASE>|${ynh_wifi_passphrase[${i}]}|g" -i /etc/hostapd/hostapd.conf.tmp
  134. if [ "${ynh_wifi_secure[${i}]}" -eq 1 ]; then
  135. sed "s|<TPL:SEC_COMMENT>||g" -i /etc/hostapd/hostapd.conf.tmp
  136. else
  137. sed "s|<TPL:SEC_COMMENT>|#|g" -i /etc/hostapd/hostapd.conf.tmp
  138. fi
  139. if [ "${i}" -eq 0 ]; then
  140. sed "s|<TPL:BSS_COMMENT>|#|g" -i /etc/hostapd/hostapd.conf.tmp
  141. else
  142. sed "s|<TPL:BSS_COMMENT>||g" -i /etc/hostapd/hostapd.conf.tmp
  143. fi
  144. cat /etc/hostapd/hostapd.conf.tmp >> /etc/hostapd/hostapd.conf
  145. rm /etc/hostapd/hostapd.conf.tmp
  146. done
  147. systemctl start hostapd
  148. }
  149. ## Unsetters
  150. unset_nat() {
  151. internet_device=${1}
  152. iptables -w -t nat -D POSTROUTING -o "${internet_device}" -j MASQUERADE
  153. }
  154. unset_ip4nataddr() {
  155. i=${1}
  156. dev=$(devfromid "${i}")
  157. ip address delete "${ynh_ip4_nat_prefix[${i}]}.1/24" dev "${dev}"
  158. }
  159. unset_ip6addr() {
  160. i=${1}
  161. dev=$(devfromid "${i}")
  162. ip address delete "${ynh_ip6_addr[${i}]}/64" dev "${dev}"
  163. }
  164. unset_ip6firewall() {
  165. i=${1}
  166. dev=$(devfromid "${i}")
  167. ip6tables -w -D FORWARD -i "${dev}" -j ACCEPT
  168. ip6tables -w -D FORWARD -o "${dev}" -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  169. ip6tables -w -D FORWARD -o "${dev}" -j DROP
  170. }
  171. unset_forwarding() {
  172. sysctl -w net.ipv6.conf.all.forwarding=0 > /dev/null
  173. sysctl -w net.ipv4.conf.all.forwarding=0 > /dev/null
  174. }
  175. stop_dhcpd6() {
  176. kill $(ps aux | grep 'dhcpdv6-ssid' | grep -v grep | awk '{ print $2 }')
  177. rm -f /etc/dnsmasq.d/dhcpdv6-ssid*.conf
  178. }
  179. stop_dhcpd4() {
  180. kill $(ps aux | grep 'dhcpdv4-ssid' | grep -v grep | awk '{ print $2 }')
  181. rm -f /etc/dnsmasq.d/dhcpdv4-ssid*.conf
  182. }
  183. stop_hostapd() {
  184. systemctl stop hostapd
  185. }
  186. ## Tools
  187. ynh_setting_get() {
  188. app=${1}
  189. setting=${2}
  190. grep "^${setting}:" "/etc/yunohost/apps/${app}/settings.yml" | sed s/^[^:]\\+:\\s*[\"\']\\?// | sed s/\\s*[\"\']\$//
  191. }
  192. ynh_setting_set() {
  193. # This is a partial copypasta of the official ynh_app_setting internal helper
  194. # In particular, we do this instead of relying on 'yunohost app setting' for
  195. # performance reasons (it takes a few second to run every yunohost commands)
  196. # and to remove the need for the infamous '--need-lock' option/issue.
  197. app="$1" key="$2" value="${3:-}" python2.7 - <<EOF
  198. import os, yaml, sys
  199. app = os.environ['app']
  200. key, value = os.environ['key'], os.environ.get('value', None)
  201. setting_file = "/etc/yunohost/apps/%s/settings.yml" % app
  202. assert os.path.exists(setting_file), "Setting file %s does not exists ?" % setting_file
  203. with open(setting_file) as f:
  204. settings = yaml.load(f)
  205. settings[key] = value
  206. with open(setting_file, "w") as f:
  207. yaml.safe_dump(settings, f, default_flow_style=False)
  208. EOF
  209. }
  210. devfromid() {
  211. i=${1}
  212. if [ "${i}" -eq 0 ]; then
  213. echo "${ynh_wifi_device}"
  214. else
  215. echo "hotspot${i}"
  216. fi
  217. }
  218. if [ "$1" != restart ]; then
  219. # Variables
  220. echo -n "Retrieving Yunohost settings... "
  221. ynh_service_enabled=$(systemctl is-enabled ynh-hotspot)
  222. ynh_wifi_device=$(ynh_setting_get hotspot wifi_device)
  223. ynh_wifi_channel=$(ynh_setting_get hotspot wifi_channel)
  224. ynh_multissid=$(ynh_setting_get hotspot multissid)
  225. IFS='|' read -a ynh_wifi_ssid <<< "$(ynh_setting_get hotspot wifi_ssid)"
  226. IFS='|' read -a ynh_wifi_secure <<< "$(ynh_setting_get hotspot wifi_secure)"
  227. IFS='|' read -a ynh_wifi_passphrase <<< "$(ynh_setting_get hotspot wifi_passphrase)"
  228. IFS='|' read -a ynh_ip6_addr <<< "$(ynh_setting_get hotspot ip6_addr)"
  229. IFS='|' read -a ynh_ip6_firewall <<< "$(ynh_setting_get hotspot ip6_firewall)"
  230. IFS='|' read -a ynh_ip6_net <<< "$(ynh_setting_get hotspot ip6_net)"
  231. IFS='|' read -a ynh_ip6_dns0 <<< "$(ynh_setting_get hotspot ip6_dns0)"
  232. IFS='|' read -a ynh_ip6_dns1 <<< "$(ynh_setting_get hotspot ip6_dns1)"
  233. IFS='|' read -a ynh_ip4_dns0 <<< "$(ynh_setting_get hotspot ip4_dns0)"
  234. IFS='|' read -a ynh_ip4_dns1 <<< "$(ynh_setting_get hotspot ip4_dns1)"
  235. IFS='|' read -a ynh_ip4_nat_prefix <<< "$(ynh_setting_get hotspot ip4_nat_prefix)"
  236. old_internet_device=$(ynh_setting_get hotspot internet_device)
  237. new_internet_device=$(ip route | awk '/default via/ { print $NF; }')
  238. # Switch the NAT interface if there is a VPN
  239. ip link show dev tun0 &> /dev/null
  240. if [ "$?" -eq 0 ]; then
  241. new_internet_device=tun0
  242. fi
  243. echo "OK"
  244. fi
  245. # Script
  246. case "$1" in
  247. start)
  248. if is_running; then
  249. echo "Already started"
  250. elif [ "${ynh_service_enabled}" != "enabled" ]; then
  251. echo "Disabled service"
  252. else
  253. if [ -z "${ynh_wifi_device}" ]; then
  254. echo "[ERR] No wifi device selected. Make sure your wifi antenna is plugged-in / available and select it in the Hotspot admin"
  255. exitcode=1
  256. fi
  257. echo "[hotspot] Starting..."
  258. touch /tmp/.ynh-hotspot-started
  259. if [ "${new_internet_device}" == tun0 ]; then
  260. ynh_setting_set hotspot vpnclient yes
  261. else
  262. ynh_setting_set hotspot vpnclient no
  263. fi
  264. # Check old state of the ipv4 NAT settings
  265. if [ ! -z "${old_internet_device}" -a "${new_internet_device}" != "${old_internet_device}" ]\
  266. && is_nat_set "${old_internet_device}"; then
  267. unset_nat "${old_internet_device}"
  268. fi
  269. # Set ipv4 NAT
  270. if [ ! -z "${new_internet_device}" ] && ! is_nat_set "${new_internet_device}"; then
  271. echo "Set NAT"
  272. set_nat "${new_internet_device}"
  273. fi
  274. # Set forwarding for ipv6 and ipv4
  275. if ! is_forwarding_set; then
  276. echo "Set forwarding"
  277. set_forwarding
  278. fi
  279. # Run hostapd
  280. if ! is_hostapd_running; then
  281. echo "Run hostapd"
  282. start_hostapd ${i}
  283. if [ ! $? -eq 0 ]; then
  284. exit 1
  285. fi
  286. if [ "${ynh_multissid}" -gt 1 ]; then
  287. i=0; false || while [ $? -ne 0 ]; do
  288. sleep 1 && (( i++ ))
  289. [ ${i} -gt 20 ] && stop_hostapd
  290. [ ${i} -gt 20 ] && exit 1
  291. ip link show dev hotspot1 &> /dev/null
  292. done
  293. else
  294. sleep 1
  295. fi
  296. fi
  297. # For each registred ssid
  298. for i in $(seq 0 $((${ynh_multissid} - 1))); do
  299. # Set ipv4 NAT address
  300. if ! is_ip4nataddr_set ${i}; then
  301. echo "hotspot${i}: Set IPv4 NAT address"
  302. set_ip4nataddr ${i}
  303. fi
  304. # Set the ipv6 address
  305. if has_ip6delegatedprefix ${i} && ! is_ip6addr_set ${i}; then
  306. echo "hotspot${i}: Set IPv6 address"
  307. set_ip6addr ${i}
  308. fi
  309. # Set ipv6 firewalling
  310. if has_ip6delegatedprefix ${i} && [ "${ynh_ip6_firewall[${i}]}" -eq 1 ] && ! is_ip6firewall_set ${i}; then
  311. echo "hotspot${i}: Set IPv6 firewalling"
  312. set_ip6firewall ${i}
  313. fi
  314. # Run DHCPv6 server
  315. if has_ip6delegatedprefix ${i} && ! is_dhcpd6_running ${i}; then
  316. echo "hotspot${i}: Start the NDP and DHCPv6 server (dnsmasq)"
  317. start_dhcpd6 ${i}
  318. fi
  319. # Run DHCPv4 server
  320. if ! is_dhcpd4_running ${i}; then
  321. echo "hotspot${i}: Start the DHCPv4 server (dnsmasq)"
  322. start_dhcpd4 ${i}
  323. fi
  324. done
  325. # Update dynamic settings
  326. ynh_setting_set hotspot internet_device "${new_internet_device}"
  327. fi
  328. ;;
  329. stop)
  330. echo "[hotspot] Stopping..."
  331. rm -f /tmp/.ynh-hotspot-started
  332. if [ ! -z "${old_internet_device}" ] && is_nat_set "${old_internet_device}"; then
  333. echo "Unset NAT"
  334. unset_nat "${old_internet_device}"
  335. fi
  336. if is_forwarding_set; then
  337. echo "Unset forwarding"
  338. unset_forwarding
  339. fi
  340. for i in $(seq 0 $((${ynh_multissid} - 1))); do
  341. if is_ip4nataddr_set ${i}; then
  342. echo "hotspot${i}: Unset IPv4 NAT address"
  343. unset_ip4nataddr ${i}
  344. fi
  345. if has_ip6delegatedprefix ${i} && is_ip6addr_set ${i}; then
  346. echo "hotspot${i}: Unset IPv6 address"
  347. unset_ip6addr ${i}
  348. fi
  349. if has_ip6delegatedprefix ${i} && [ "${ynh_ip6_firewall[${i}]}" -eq 1 ] && is_ip6firewall_set ${i}; then
  350. echo "hotspot${i}: Unset IPv6 firewalling"
  351. unset_ip6firewall ${i}
  352. fi
  353. if is_dhcpd6_running ${i}; then
  354. echo "hotspot${i}: Stop the NDP and DHCPv6 server (dnsmasq)"
  355. stop_dhcpd6 ${i}
  356. fi
  357. if is_dhcpd4_running ${i}; then
  358. echo "hotspot${i}: Stop the DHCPv4 server (dnsmasq)"
  359. stop_dhcpd4 ${i}
  360. fi
  361. done
  362. if is_hostapd_running; then
  363. echo "Stop hostapd"
  364. stop_hostapd
  365. fi
  366. # Fix configuration
  367. if has_vpnclient_app; then
  368. ynh-vpnclient start
  369. fi
  370. ;;
  371. restart)
  372. $0 stop
  373. $0 start
  374. ;;
  375. status)
  376. exitcode=0
  377. if [ "${ynh_service_enabled}" != "enabled" ]; then
  378. echo "[ERR] Hotspot Service disabled"
  379. exitcode=1
  380. fi
  381. if [ -z "${ynh_wifi_device}" ]; then
  382. echo "[ERR] No wifi device selected. Make sure your wifi antenna is plugged-in / available and select it in the Hotspot admin"
  383. exitcode=1
  384. fi
  385. echo "[INFO] Autodetected internet interface: ${new_internet_device} (last start: ${old_internet_device})"
  386. if is_nat_set "${new_internet_device}"; then
  387. echo "[OK] IPv4 NAT set"
  388. else
  389. if [ -z "${new_internet_device}" ]; then
  390. echo "[INFO] No IPv4 NAT set (no internet interface)"
  391. else
  392. echo "[ERR] No IPv4 NAT set"
  393. fi
  394. exitcode=1
  395. fi
  396. if is_forwarding_set; then
  397. echo "[OK] IPv6/IPv4 forwarding set"
  398. else
  399. echo "[ERR] No IPv6/IPv4 forwarding set"
  400. exitcode=1
  401. fi
  402. if is_hostapd_running; then
  403. echo "[OK] Hostapd is running"
  404. else
  405. echo "[ERR] Hostapd is not running"
  406. exitcode=1
  407. fi
  408. for i in $(seq 0 $((${ynh_multissid} - 1))); do
  409. if has_ip6delegatedprefix ${i}; then
  410. echo "[INFO] hotspot${i}: IPv6 delegated prefix found"
  411. echo "[INFO] hotspot${i}: IPv6 address computed from the delegated prefix: ${ynh_ip6_addr}"
  412. if is_ip6addr_set ${i}; then
  413. echo "[OK] hotspot${i}: IPv6 address set"
  414. else
  415. echo "[ERR] hotspot${i}: No IPv6 address set"
  416. exitcode=1
  417. fi
  418. if is_ip6firewall_set ${i}; then
  419. echo "[OK] hotspot${i}: IPv6 firewalling set"
  420. else
  421. if [ "${ynh_ip6_firewall[${i}]}" -eq 1 ]; then
  422. echo "[ERR] hotspot${i}: No IPv6 firewalling set"
  423. else
  424. echo "[INFO] hotspot${i}: No IPv6 firewalling set"
  425. fi
  426. exitcode=1
  427. fi
  428. if is_dhcpd6_running ${i}; then
  429. echo "[OK] hotspot${i}: NDP and DHCPv6 server (dnsmasq) are running"
  430. else
  431. echo "[ERR] hotspot${i}: NDP and DHCPv6 server (dnsmasq) are not running"
  432. exitcode=1
  433. fi
  434. else
  435. echo "[INFO] hotspot${i}: No IPv6 delegated prefix found"
  436. fi
  437. if is_dhcpd4_running ${i}; then
  438. echo "[OK] hotspot${i}: DHCPv4 server (dnsmasq) is running"
  439. else
  440. echo "[ERR] hotspot${i}: DHCPv4 (dnsmasq) is not running"
  441. exitcode=1
  442. fi
  443. if is_ip4nataddr_set ${i}; then
  444. echo "[OK] hotspot${i}: IPv4 NAT address set"
  445. else
  446. echo "[ERR] hotspot${i}: No IPv4 NAT address set"
  447. exitcode=1
  448. fi
  449. done
  450. exit ${exitcode}
  451. ;;
  452. *)
  453. echo "Usage: $0 {start|stop|restart|status}"
  454. exit 1
  455. ;;
  456. esac
  457. exit 0