ynh-hotspot 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  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. local i=${1}
  26. [[ -n "${ip6_net[${i}]}" ]] && [[ "${ip6_net[${i}]}" != "none" ]]
  27. }
  28. ip6addrfromdelegatedprefix() {
  29. local i=${1}
  30. echo "${ip6_net[${i}]}${i}001"
  31. }
  32. is_nat_set() {
  33. local gateway_interface=${1}
  34. iptables -w -nvt nat -L POSTROUTING | grep MASQUERADE | grep -q "${gateway_interface}"
  35. }
  36. is_ip4nataddr_set() {
  37. local i=${1}
  38. dev=$(devfromid "${i}")
  39. ip address show dev "${dev}" 2> /dev/null | grep -q "${ip4_nat_prefix[${i}]}.1/24"
  40. }
  41. is_ip6addr_set() {
  42. local i=${1}
  43. dev=$(devfromid "${i}")
  44. ip address show dev "${dev}" 2> /dev/null | grep -q "$(ip6addrfromdelegatedprefix $i)/64"
  45. }
  46. is_ip6firewall_set() {
  47. local i=${1}
  48. dev=$(devfromid "${i}")
  49. ip6tables -w -nvL FORWARD | grep DROP | grep -q "${dev}"
  50. }
  51. is_forwarding_set() {
  52. local ip6=$(sysctl net.ipv6.conf.all.forwarding | awk '{ print $NF; }')
  53. local ip4=$(sysctl net.ipv4.conf.all.forwarding | awk '{ print $NF; }')
  54. [ "${ip6}" -eq 1 -a "${ip4}" -eq 1 ]
  55. }
  56. is_dhcpd6_running() {
  57. local i=${1}
  58. $(ps aux | grep "dhcpdv6-ssid${i}" | grep -qv grep)
  59. }
  60. is_dhcpd4_running() {
  61. local i=${1}
  62. $(ps aux | grep "dhcpdv4-ssid${i}" | grep -qv grep)
  63. }
  64. is_hostapd_running() {
  65. systemctl is-active hostapd &> /dev/null
  66. }
  67. is_running() {
  68. for i in $(seq 0 $((${multissid} - 1))); do
  69. ( has_ip6delegatedprefix ${i} && is_ip6addr_set ${i}\
  70. && ( [ "${ip6_firewall[${i}]}" -eq 1 ] && is_ip6firewall_set ${i} || [ "${ip6_firewall[${i}]}" -eq 0 ] )\
  71. && is_dhcpd6_running ${i} || ! has_ip6delegatedprefix ${i} )\
  72. && is_ip4nataddr_set ${i} && is_dhcpd4_running ${i}
  73. if [ ! $? -eq 0 ]; then
  74. return 1
  75. fi
  76. done
  77. is_hostapd_running && is_forwarding_set && ( [ -z "${new_gateway_interface}" ] || is_nat_set "${new_gateway_interface}" )
  78. }
  79. ## Setters
  80. set_nat() {
  81. local gateway_interface=${1}
  82. iptables -w -t nat -A POSTROUTING -o "${gateway_interface}" -j MASQUERADE
  83. }
  84. set_ip4nataddr() {
  85. local i=${1}
  86. local dev=$(devfromid "${i}")
  87. ip address add "${ip4_nat_prefix[${i}]}.1/24" dev "${dev}"
  88. }
  89. set_ip6addr() {
  90. local i=${1}
  91. local dev=$(devfromid "${i}")
  92. ip address delete "$(ip6addrfromdelegatedprefix $i)/64" dev tun0 &> /dev/null
  93. ip address add "$(ip6addrfromdelegatedprefix $i)/64" dev "${dev}"
  94. }
  95. set_ip6firewall() {
  96. local i=${1}
  97. local dev=$(devfromid "${i}")
  98. ip6tables -w -A FORWARD -i "${dev}" -j ACCEPT
  99. ip6tables -w -A FORWARD -o "${dev}" -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  100. ip6tables -w -A FORWARD -o "${dev}" -j DROP
  101. }
  102. set_forwarding() {
  103. sysctl -w net.ipv6.conf.all.forwarding=1 > /dev/null
  104. sysctl -w net.ipv4.conf.all.forwarding=1 > /dev/null
  105. }
  106. start_dhcpd6() {
  107. local i=${1}
  108. local dev=$(devfromid "${i}")
  109. cp /etc/dnsmasq.dhcpd/dhcpdv6{.conf.tpl,-ssid${i}.conf}
  110. sed "s|__WIFI_DEVICE__|${dev}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
  111. sed "s|__IP6_NET__|${ip6_net[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
  112. sed "s|__IP6_DNS__|${ip6_dns[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf
  113. dnsmasq -C /etc/dnsmasq.dhcpd/dhcpdv6-ssid${i}.conf -p0
  114. }
  115. start_dhcpd4() {
  116. local i=${1}
  117. local dev=$(devfromid "${i}")
  118. cp /etc/dnsmasq.dhcpd/dhcpdv4{.conf.tpl,-ssid${i}.conf}
  119. sed "s|__IP4_DNS__|${ip4_dns[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
  120. sed "s|__WIFI_DEVICE__|${dev}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
  121. sed "s|__IP4_NAT_PREFIX__|${ip4_nat_prefix[${i}]}|g" -i /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf
  122. dnsmasq -C /etc/dnsmasq.dhcpd/dhcpdv4-ssid${i}.conf -p0
  123. }
  124. configure_hostapd() {
  125. local ethaddr=$(ip link show dev "${wifi_device}" | grep link/ether | awk -F: '{ printf "02:%s:%s:%s:%s:00", $2, $3, $4, $5 }')
  126. ip link set addr "${ethaddr}" dev "${wifi_device}"
  127. cp /etc/hostapd/hostapd.base.conf /etc/hostapd/hostapd.conf
  128. sed "s|__WIFI_DEVICE__|${wifi_device}|g" -i /etc/hostapd/hostapd.conf
  129. sed "s|__WIFI_CHANNEL__|${wifi_channel}|g" -i /etc/hostapd/hostapd.conf
  130. sed "s|__N_COMMENT__||g" -i /etc/hostapd/hostapd.conf
  131. for i in $(seq 0 $((${multissid} - 1))); do
  132. [ "${wifi_secure[${i}]}" -eq 1 ] && local sec_comment="" || local sec_comment="#"
  133. [ "${i}" -eq 0 ] && local bss_comment="#" || local bss_comment=""
  134. cp /etc/hostapd/hostapd.accesspoint.conf /etc/hostapd/hostapd.conf.tmp
  135. sed "s|__WIFI_INTERFACE__|hotspot${i}|g" -i /etc/hostapd/hostapd.conf.tmp
  136. sed "s|__WIFI_SSID__|${wifi_ssid[${i}]}|g" -i /etc/hostapd/hostapd.conf.tmp
  137. sed "s|__WIFI_PASSPHRASE__|${wifi_passphrase[${i}]}|g" -i /etc/hostapd/hostapd.conf.tmp
  138. sed "s|__SEC_COMMENT__|${sec_comment}|g" -i /etc/hostapd/hostapd.conf.tmp
  139. sed "s|__BSS_COMMENT__|${bss_comment}|g" -i /etc/hostapd/hostapd.conf.tmp
  140. cat /etc/hostapd/hostapd.conf.tmp >> /etc/hostapd/hostapd.conf
  141. rm /etc/hostapd/hostapd.conf.tmp
  142. done
  143. }
  144. ## Unsetters
  145. unset_nat() {
  146. local gateway_interface=${1}
  147. iptables -w -t nat -D POSTROUTING -o "${gateway_interface}" -j MASQUERADE
  148. }
  149. unset_ip4nataddr() {
  150. local i=${1}
  151. local dev=$(devfromid "${i}")
  152. ip address delete "${ip4_nat_prefix[${i}]}.1/24" dev "${dev}"
  153. }
  154. unset_ip6addr() {
  155. local i=${1}
  156. local dev=$(devfromid "${i}")
  157. ip address delete "$(ip6addrfromdelegatedprefix $i)/64" dev "${dev}"
  158. }
  159. unset_ip6firewall() {
  160. local i=${1}
  161. local dev=$(devfromid "${i}")
  162. ip6tables -w -D FORWARD -i "${dev}" -j ACCEPT
  163. ip6tables -w -D FORWARD -o "${dev}" -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  164. ip6tables -w -D FORWARD -o "${dev}" -j DROP
  165. }
  166. unset_forwarding() {
  167. sysctl -w net.ipv6.conf.all.forwarding=0 > /dev/null
  168. sysctl -w net.ipv4.conf.all.forwarding=0 > /dev/null
  169. }
  170. stop_dhcpd6() {
  171. kill $(ps aux | grep 'dhcpdv6-ssid' | grep -v grep | awk '{ print $2 }')
  172. rm -f /etc/dnsmasq.d/dhcpdv6-ssid*.conf
  173. }
  174. stop_dhcpd4() {
  175. kill $(ps aux | grep 'dhcpdv4-ssid' | grep -v grep | awk '{ print $2 }')
  176. rm -f /etc/dnsmasq.d/dhcpdv4-ssid*.conf
  177. }
  178. stop_hostapd() {
  179. systemctl stop hostapd
  180. }
  181. ## Tools
  182. ynh_setting_get() {
  183. APP="$1" KEY="$2" python3 - <<EOF
  184. import os, yaml, sys
  185. app = os.environ['APP']
  186. key = os.environ['KEY']
  187. setting_file = "/etc/yunohost/apps/%s/settings.yml" % app
  188. assert os.path.exists(setting_file), "Setting file %s does not exists ?" % setting_file
  189. with open(setting_file) as f:
  190. settings = yaml.safe_load(f)
  191. if key in settings:
  192. print(settings[key])
  193. EOF
  194. }
  195. ynh_setting_set() {
  196. # This is a partial copypasta of the official ynh_app_setting internal helper
  197. # In particular, we do this instead of relying on 'yunohost app setting' for
  198. # performance reasons (it takes a few second to run every yunohost commands)
  199. # and to remove the need for the infamous '--need-lock' option/issue.
  200. APP="$1" KEY="$2" VALUE="${3:-}" python3 - <<EOF
  201. import os, yaml, sys
  202. app = os.environ['APP']
  203. key, value = os.environ['KEY'], os.environ.get('VALUE', None)
  204. setting_file = "/etc/yunohost/apps/%s/settings.yml" % app
  205. assert os.path.exists(setting_file), "Setting file %s does not exists ?" % setting_file
  206. with open(setting_file) as f:
  207. settings = yaml.load(f)
  208. settings[key] = value
  209. with open(setting_file, "w") as f:
  210. yaml.safe_dump(settings, f, default_flow_style=False)
  211. EOF
  212. }
  213. devfromid() {
  214. local i=${1}
  215. if [ "${i}" -eq 0 ]; then
  216. echo "${wifi_device}"
  217. else
  218. echo "hotspot${i}"
  219. fi
  220. }
  221. if [ "$1" != restart ]; then
  222. # Variables
  223. echo -n "Retrieving Yunohost settings... "
  224. service_enabled=$(systemctl is-enabled ynh-hotspot)
  225. wifi_device=$(ynh_setting_get hotspot wifi_device)
  226. wifi_channel=$(ynh_setting_get hotspot wifi_channel)
  227. multissid=$(ynh_setting_get hotspot multissid)
  228. IFS='|' read -a wifi_ssid <<< "$(ynh_setting_get hotspot wifi_ssid)"
  229. IFS='|' read -a wifi_secure <<< "$(ynh_setting_get hotspot wifi_secure)"
  230. IFS='|' read -a wifi_passphrase <<< "$(ynh_setting_get hotspot wifi_passphrase)"
  231. IFS='|' read -a ip6_firewall <<< "$(ynh_setting_get hotspot ip6_firewall)"
  232. IFS='|' read -a ip6_net <<< "$(ynh_setting_get hotspot ip6_net)"
  233. IFS='|' read -a dns <<< "$(ynh_setting_get hotspot dns)"
  234. IFS='|' read -a ip4_nat_prefix <<< "$(ynh_setting_get hotspot ip4_nat_prefix)"
  235. for i in $(seq 0 $((${multissid} - 1))); do
  236. ip6_dns[${i}]=""
  237. ip4_dns[${i}]=""
  238. for ip in $(echo "${dns[${i}]}" | tr ',' ' '); do
  239. if [[ "$ip" == *":"* ]]
  240. then
  241. ip6_dns[${i}]+="[$ip],"
  242. else
  243. ip4_dns[${i}]+="$ip,"
  244. fi
  245. done
  246. # Remove trailing ,
  247. ip6_dns[${i}]="${ip6_dns[${i}]%%,}"
  248. ip4_dns[${i}]="${ip4_dns[${i}]%%,}"
  249. done
  250. old_gateway_interface=$(ynh_setting_get hotspot gateway_interface)
  251. new_gateway_interface=$(ip route get 1.2.3.4 | awk '{ print $5; }')
  252. # Switch the NAT interface if there is a VPN
  253. ip link show dev tun0 &> /dev/null
  254. if [ "$?" -eq 0 ]; then
  255. new_gateway_interface=tun0
  256. fi
  257. echo "OK"
  258. fi
  259. # Script
  260. case "$1" in
  261. start)
  262. if is_running; then
  263. echo "Already started"
  264. exit 0
  265. elif [ "${service_enabled}" != "enabled" ]; then
  266. echo "Not starting because hotspod service is disabled"
  267. exit 1
  268. fi
  269. if [ -z "${wifi_device}" ]; then
  270. echo "[FAIL] No wifi device selected. Make sure your wifi antenna is plugged-in / available and select it in the Hotspot admin"
  271. exit 1
  272. fi
  273. echo "[hotspot] Starting..."
  274. touch /tmp/.ynh-hotspot-started
  275. # Check old state of the ipv4 NAT settings
  276. if [ ! -z "${old_gateway_interface}" -a "${new_gateway_interface}" != "${old_gateway_interface}" ]\
  277. && is_nat_set "${old_gateway_interface}"; then
  278. unset_nat "${old_gateway_interface}"
  279. fi
  280. # Set ipv4 NAT
  281. if [ ! -z "${new_gateway_interface}" ] && ! is_nat_set "${new_gateway_interface}"; then
  282. echo "Set NAT"
  283. set_nat "${new_gateway_interface}"
  284. fi
  285. # Set forwarding for ipv6 and ipv4
  286. if ! is_forwarding_set; then
  287. echo "Set forwarding"
  288. set_forwarding
  289. fi
  290. # Run hostapd
  291. if ! is_hostapd_running; then
  292. echo "Configuring hostapd"
  293. configure_hostapd
  294. echo "Starting hostapd..."
  295. if ! systemctl start hostapd
  296. journalctl -u hostapd -n 100 --no-hostname --no-pager
  297. exit 1
  298. fi
  299. sleep 1
  300. i=0;
  301. while ! ip link show dev hotspot1 &> /dev/null; do
  302. sleep 1
  303. if [ ${i} -gt 20 ]
  304. then
  305. echo "Failed to see hotspot interface showing up in 'ip a'"
  306. stop_hostapd
  307. exit 1
  308. fi
  309. i=$(($i + 1))
  310. done
  311. fi
  312. # For each registred ssid
  313. for i in $(seq 0 $((${multissid} - 1))); do
  314. # Set ipv4 NAT address
  315. if ! is_ip4nataddr_set ${i}; then
  316. echo "hotspot${i}: Set IPv4 NAT address"
  317. set_ip4nataddr ${i}
  318. fi
  319. # Set the ipv6 address
  320. if has_ip6delegatedprefix ${i} && ! is_ip6addr_set ${i}; then
  321. echo "hotspot${i}: Set IPv6 address"
  322. set_ip6addr ${i}
  323. fi
  324. # Set ipv6 firewalling
  325. if has_ip6delegatedprefix ${i} && [ "${ip6_firewall[${i}]}" -eq 1 ] && ! is_ip6firewall_set ${i}; then
  326. echo "hotspot${i}: Set IPv6 firewalling"
  327. set_ip6firewall ${i}
  328. fi
  329. # Run DHCPv6 server
  330. if has_ip6delegatedprefix ${i} && ! is_dhcpd6_running ${i}; then
  331. echo "hotspot${i}: Start the NDP and DHCPv6 server (dnsmasq)"
  332. start_dhcpd6 ${i}
  333. fi
  334. # Run DHCPv4 server
  335. if ! is_dhcpd4_running ${i}; then
  336. echo "hotspot${i}: Start the DHCPv4 server (dnsmasq)"
  337. start_dhcpd4 ${i}
  338. fi
  339. done
  340. # Update dynamic settings
  341. ynh_setting_set hotspot gateway_interface "${new_gateway_interface}"
  342. ;;
  343. stop)
  344. echo "[hotspot] Stopping..."
  345. rm -f /tmp/.ynh-hotspot-started
  346. if [ ! -z "${old_gateway_interface}" ] && is_nat_set "${old_gateway_interface}"; then
  347. echo "Unset NAT"
  348. unset_nat "${old_gateway_interface}"
  349. fi
  350. if is_forwarding_set; then
  351. echo "Unset forwarding"
  352. unset_forwarding
  353. fi
  354. for i in $(seq 0 $((${multissid} - 1))); do
  355. if is_ip4nataddr_set ${i}; then
  356. echo "hotspot${i}: Unset IPv4 NAT address"
  357. unset_ip4nataddr ${i}
  358. fi
  359. if has_ip6delegatedprefix ${i} && is_ip6addr_set ${i}; then
  360. echo "hotspot${i}: Unset IPv6 address"
  361. unset_ip6addr ${i}
  362. fi
  363. if has_ip6delegatedprefix ${i} && [ "${ip6_firewall[${i}]}" -eq 1 ] && is_ip6firewall_set ${i}; then
  364. echo "hotspot${i}: Unset IPv6 firewalling"
  365. unset_ip6firewall ${i}
  366. fi
  367. if is_dhcpd6_running ${i}; then
  368. echo "hotspot${i}: Stop the NDP and DHCPv6 server (dnsmasq)"
  369. stop_dhcpd6 ${i}
  370. fi
  371. if is_dhcpd4_running ${i}; then
  372. echo "hotspot${i}: Stop the DHCPv4 server (dnsmasq)"
  373. stop_dhcpd4 ${i}
  374. fi
  375. done
  376. if is_hostapd_running; then
  377. echo "Stop hostapd"
  378. stop_hostapd
  379. fi
  380. # Fix configuration
  381. if has_vpnclient_app; then
  382. ynh-vpnclient start
  383. fi
  384. ;;
  385. restart)
  386. $0 stop
  387. $0 start
  388. ;;
  389. status)
  390. exitcode=0
  391. if [ "${service_enabled}" != "enabled" ]; then
  392. echo "[FAIL] Hotspot Service disabled"
  393. exit 1
  394. fi
  395. if [ -z "${wifi_device}" ]; then
  396. echo "[FAIL] No wifi device selected. Make sure your wifi antenna is plugged-in / available and select it in the Hotspot admin"
  397. exit 1
  398. fi
  399. echo "[INFO] Autodetected internet interface: ${new_gateway_interface} (last start: ${old_gateway_interface})"
  400. if is_nat_set "${new_gateway_interface}"; then
  401. echo "[ OK ] IPv4 NAT set"
  402. else
  403. if [ -z "${new_gateway_interface}" ]; then
  404. echo "[INFO] No IPv4 NAT set (no internet interface)"
  405. else
  406. echo "[FAIL] No IPv4 NAT set"
  407. fi
  408. exitcode=1
  409. fi
  410. if is_forwarding_set; then
  411. echo "[ OK ] IPv6/IPv4 forwarding set"
  412. else
  413. echo "[FAIL] No IPv6/IPv4 forwarding set"
  414. exitcode=1
  415. fi
  416. if is_hostapd_running; then
  417. echo "[ OK ] Hostapd is running"
  418. else
  419. echo "[FAIL] Hostapd is not running"
  420. exitcode=1
  421. fi
  422. for i in $(seq 0 $((${multissid} - 1))); do
  423. if has_ip6delegatedprefix ${i}; then
  424. echo "[INFO] hotspot${i}: IPv6 delegated prefix found"
  425. echo "[INFO] hotspot${i}: IPv6 address computed from the delegated prefix: $(ip6addrfromdelegatedprefix $i)"
  426. if is_ip6addr_set ${i}; then
  427. echo "[ OK ] hotspot${i}: IPv6 address set"
  428. else
  429. echo "[FAIL] hotspot${i}: No IPv6 address set"
  430. exitcode=1
  431. fi
  432. if is_ip6firewall_set ${i}; then
  433. echo "[ OK ] hotspot${i}: IPv6 firewalling set"
  434. else
  435. if [ "${ip6_firewall[${i}]}" -eq 1 ]; then
  436. echo "[FAIL] hotspot${i}: No IPv6 firewalling set"
  437. else
  438. echo "[INFO] hotspot${i}: No IPv6 firewalling set"
  439. fi
  440. exitcode=1
  441. fi
  442. if is_dhcpd6_running ${i}; then
  443. echo "[ OK ] hotspot${i}: NDP and DHCPv6 server (dnsmasq) are running"
  444. else
  445. echo "[FAIL] hotspot${i}: NDP and DHCPv6 server (dnsmasq) are not running"
  446. exitcode=1
  447. fi
  448. else
  449. echo "[INFO] hotspot${i}: No IPv6 delegated prefix found"
  450. fi
  451. if is_dhcpd4_running ${i}; then
  452. echo "[ OK ] hotspot${i}: DHCPv4 server (dnsmasq) is running"
  453. else
  454. echo "[FAIL] hotspot${i}: DHCPv4 (dnsmasq) is not running"
  455. exitcode=1
  456. fi
  457. if is_ip4nataddr_set ${i}; then
  458. echo "[ OK ] hotspot${i}: IPv4 NAT address set"
  459. else
  460. echo "[FAIL] hotspot${i}: No IPv4 NAT address set"
  461. exitcode=1
  462. fi
  463. done
  464. exit ${exitcode}
  465. ;;
  466. *)
  467. echo "Usage: $0 {start|stop|restart|status}"
  468. exit 1
  469. ;;
  470. esac
  471. exit 0