ynh-hotspot 17 KB

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