ynh-hotspot 17 KB

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