installer.sh.in 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533
  1. #!/bin/bash
  2. #-
  3. # Copyright (c) 2012-2015 Juan Romero Pardines <[email protected]>.
  4. # 2012 Dave Elusive <[email protected]>.
  5. # All rights reserved.
  6. #
  7. # Redistribution and use in source and binary forms, with or without
  8. # modification, are permitted provided that the following conditions
  9. # are met:
  10. # 1. Redistributions of source code must retain the above copyright
  11. # notice, this list of conditions and the following disclaimer.
  12. # 2. Redistributions in binary form must reproduce the above copyright
  13. # notice, this list of conditions and the following disclaimer in the
  14. # documentation and/or other materials provided with the distribution.
  15. #
  16. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  17. # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  18. # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  20. # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21. # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  25. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. #-
  27. # Make sure we don't inherit these from env.
  28. SOURCE_DONE=
  29. HOSTNAME_DONE=
  30. KEYBOARD_DONE=
  31. LOCALE_DONE=
  32. TIMEZONE_DONE=
  33. ROOTPASSWORD_DONE=
  34. USERLOGIN_DONE=
  35. USERPASSWORD_DONE=
  36. USERNAME_DONE=
  37. USERGROUPS_DONE=
  38. USERACCOUNT_DONE=
  39. BOOTLOADER_DONE=
  40. PARTITIONS_DONE=
  41. NETWORK_DONE=
  42. FILESYSTEMS_DONE=
  43. MIRROR_DONE=
  44. TARGETDIR=/mnt/target
  45. LOG=/dev/tty8
  46. CONF_FILE=/tmp/.void-installer.conf
  47. if [ ! -f $CONF_FILE ]; then
  48. touch -f $CONF_FILE
  49. fi
  50. ANSWER=$(mktemp -t vinstall-XXXXXXXX || exit 1)
  51. TARGET_FSTAB=$(mktemp -t vinstall-fstab-XXXXXXXX || exit 1)
  52. trap "DIE" INT TERM QUIT
  53. # disable printk
  54. if [ -w /proc/sys/kernel/printk ]; then
  55. echo 0 >/proc/sys/kernel/printk
  56. fi
  57. # Detect if this is an EFI system.
  58. if [ -e /sys/firmware/efi/systab ]; then
  59. EFI_SYSTEM=1
  60. EFI_FW_BITS=$(cat /sys/firmware/efi/fw_platform_size)
  61. if [ $EFI_FW_BITS -eq 32 ]; then
  62. EFI_TARGET=i386-efi
  63. else
  64. EFI_TARGET=x86_64-efi
  65. fi
  66. fi
  67. # dialog colors
  68. BLACK="\Z0"
  69. RED="\Z1"
  70. GREEN="\Z2"
  71. YELLOW="\Z3"
  72. BLUE="\Z4"
  73. MAGENTA="\Z5"
  74. CYAN="\Z6"
  75. WHITE="\Z7"
  76. BOLD="\Zb"
  77. REVERSE="\Zr"
  78. UNDERLINE="\Zu"
  79. RESET="\Zn"
  80. # Properties shared per widget.
  81. MENULABEL="${BOLD}Use UP and DOWN keys to navigate \
  82. menus. Use TAB to switch between buttons and ENTER to select.${RESET}"
  83. MENUSIZE="14 60 0"
  84. INPUTSIZE="8 60"
  85. MSGBOXSIZE="8 70"
  86. YESNOSIZE="$INPUTSIZE"
  87. WIDGET_SIZE="10 70"
  88. DIALOG() {
  89. rm -f $ANSWER
  90. dialog --colors --keep-tite --no-shadow --no-mouse \
  91. --backtitle "${BOLD}${WHITE}Void Linux installation -- https://www.voidlinux.org (@@MKLIVE_VERSION@@)${RESET}" \
  92. --cancel-label "Back" --aspect 20 "$@" 2>$ANSWER
  93. return $?
  94. }
  95. INFOBOX() {
  96. # Note: dialog --infobox and --keep-tite don't work together
  97. dialog --colors --no-shadow --no-mouse \
  98. --backtitle "${BOLD}${WHITE}Void Linux installation -- https://www.voidlinux.org (@@MKLIVE_VERSION@@)${RESET}" \
  99. --title "${TITLE}" --aspect 20 --infobox "$@"
  100. }
  101. DIE() {
  102. rval=$1
  103. [ -z "$rval" ] && rval=0
  104. clear
  105. rm -f $ANSWER $TARGET_FSTAB
  106. # reenable printk
  107. if [ -w /proc/sys/kernel/printk ]; then
  108. echo 4 >/proc/sys/kernel/printk
  109. fi
  110. umount_filesystems
  111. exit $rval
  112. }
  113. set_option() {
  114. if grep -Eq "^${1}.*" $CONF_FILE; then
  115. sed -i -e "/^${1}.*/d" $CONF_FILE
  116. fi
  117. echo "${1} ${2}" >>$CONF_FILE
  118. }
  119. get_option() {
  120. echo $(grep -E "^${1}.*" $CONF_FILE|sed -e "s|${1}||")
  121. }
  122. # ISO-639 language names for locales
  123. iso639_language() {
  124. case "$1" in
  125. aa) echo "Afar" ;;
  126. af) echo "Afrikaans" ;;
  127. an) echo "Aragonese" ;;
  128. ar) echo "Arabic" ;;
  129. ast) echo "Asturian" ;;
  130. be) echo "Belgian" ;;
  131. bg) echo "Bulgarian" ;;
  132. bhb) echo "Bhili" ;;
  133. br) echo "Breton" ;;
  134. bs) echo "Bosnian" ;;
  135. ca) echo "Catalan" ;;
  136. cs) echo "Czech" ;;
  137. cy) echo "Welsh" ;;
  138. da) echo "Danish" ;;
  139. de) echo "German" ;;
  140. el) echo "Greek" ;;
  141. en) echo "English" ;;
  142. es) echo "Spanish" ;;
  143. et) echo "Estonian" ;;
  144. eu) echo "Basque" ;;
  145. fi) echo "Finnish" ;;
  146. fo) echo "Faroese" ;;
  147. fr) echo "French" ;;
  148. ga) echo "Irish" ;;
  149. gd) echo "Scottish Gaelic" ;;
  150. gl) echo "Galician" ;;
  151. gv) echo "Manx" ;;
  152. he) echo "Hebrew" ;;
  153. hr) echo "Croatian" ;;
  154. hsb) echo "Upper Sorbian" ;;
  155. hu) echo "Hungarian" ;;
  156. id) echo "Indonesian" ;;
  157. is) echo "Icelandic" ;;
  158. it) echo "Italian" ;;
  159. iw) echo "Hebrew" ;;
  160. ja) echo "Japanese" ;;
  161. ka) echo "Georgian" ;;
  162. kk) echo "Kazakh" ;;
  163. kl) echo "Kalaallisut" ;;
  164. ko) echo "Korean" ;;
  165. ku) echo "Kurdish" ;;
  166. kw) echo "Cornish" ;;
  167. lg) echo "Ganda" ;;
  168. lt) echo "Lithuanian" ;;
  169. lv) echo "Latvian" ;;
  170. mg) echo "Malagasy" ;;
  171. mi) echo "Maori" ;;
  172. mk) echo "Macedonian" ;;
  173. ms) echo "Malay" ;;
  174. mt) echo "Maltese" ;;
  175. nb) echo "Norwegian Bokmål" ;;
  176. nl) echo "Dutch" ;;
  177. nn) echo "Norwegian Nynorsk" ;;
  178. oc) echo "Occitan" ;;
  179. om) echo "Oromo" ;;
  180. pl) echo "Polish" ;;
  181. pt) echo "Portugese" ;;
  182. ro) echo "Romanian" ;;
  183. ru) echo "Russian" ;;
  184. sk) echo "Slovak" ;;
  185. sl) echo "Slovenian" ;;
  186. so) echo "Somali" ;;
  187. sq) echo "Albanian" ;;
  188. st) echo "Southern Sotho" ;;
  189. sv) echo "Swedish" ;;
  190. tcy) echo "Tulu" ;;
  191. tg) echo "Tajik" ;;
  192. th) echo "Thai" ;;
  193. tl) echo "Tagalog" ;;
  194. tr) echo "Turkish" ;;
  195. uk) echo "Ukrainian" ;;
  196. uz) echo "Uzbek" ;;
  197. wa) echo "Walloon" ;;
  198. xh) echo "Xhosa" ;;
  199. yi) echo "Yiddish" ;;
  200. zh) echo "Chinese" ;;
  201. zu) echo "Zulu" ;;
  202. *) echo "$1" ;;
  203. esac
  204. }
  205. # ISO-3166 country codes for locales
  206. iso3166_country() {
  207. case "$1" in
  208. AD) echo "Andorra" ;;
  209. AE) echo "United Arab Emirates" ;;
  210. AL) echo "Albania" ;;
  211. AR) echo "Argentina" ;;
  212. AT) echo "Austria" ;;
  213. AU) echo "Australia" ;;
  214. BA) echo "Bonsia and Herzegovina" ;;
  215. BE) echo "Belgium" ;;
  216. BG) echo "Bulgaria" ;;
  217. BH) echo "Bahrain" ;;
  218. BO) echo "Bolivia" ;;
  219. BR) echo "Brazil" ;;
  220. BW) echo "Botswana" ;;
  221. BY) echo "Belarus" ;;
  222. CA) echo "Canada" ;;
  223. CH) echo "Switzerland" ;;
  224. CL) echo "Chile" ;;
  225. CN) echo "China" ;;
  226. CO) echo "Colombia" ;;
  227. CR) echo "Costa Rica" ;;
  228. CY) echo "Cyprus" ;;
  229. CZ) echo "Czech Republic" ;;
  230. DE) echo "Germany" ;;
  231. DJ) echo "Djibouti" ;;
  232. DK) echo "Denmark" ;;
  233. DO) echo "Dominican Republic" ;;
  234. DZ) echo "Algeria" ;;
  235. EC) echo "Ecuador" ;;
  236. EE) echo "Estonia" ;;
  237. EG) echo "Egypt" ;;
  238. ES) echo "Spain" ;;
  239. FI) echo "Finland" ;;
  240. FO) echo "Faroe Islands" ;;
  241. FR) echo "France" ;;
  242. GB) echo "Great Britain" ;;
  243. GE) echo "Georgia" ;;
  244. GL) echo "Greenland" ;;
  245. GR) echo "Greece" ;;
  246. GT) echo "Guatemala" ;;
  247. HK) echo "Hong Kong" ;;
  248. HN) echo "Honduras" ;;
  249. HR) echo "Croatia" ;;
  250. HU) echo "Hungary" ;;
  251. ID) echo "Indonesia" ;;
  252. IE) echo "Ireland" ;;
  253. IL) echo "Israel" ;;
  254. IN) echo "India" ;;
  255. IQ) echo "Iraq" ;;
  256. IS) echo "Iceland" ;;
  257. IT) echo "Italy" ;;
  258. JO) echo "Jordan" ;;
  259. JP) echo "Japan" ;;
  260. KE) echo "Kenya" ;;
  261. KR) echo "Korea, Republic of" ;;
  262. KW) echo "Kuwait" ;;
  263. KZ) echo "Kazakhstan" ;;
  264. LB) echo "Lebanon" ;;
  265. LT) echo "Lithuania" ;;
  266. LU) echo "Luxembourg" ;;
  267. LV) echo "Latvia" ;;
  268. LY) echo "Libya" ;;
  269. MA) echo "Morocco" ;;
  270. MG) echo "Madagascar" ;;
  271. MK) echo "Macedonia" ;;
  272. MT) echo "Malta" ;;
  273. MX) echo "Mexico" ;;
  274. MY) echo "Malaysia" ;;
  275. NI) echo "Nicaragua" ;;
  276. NL) echo "Netherlands" ;;
  277. NO) echo "Norway" ;;
  278. NZ) echo "New Zealand" ;;
  279. OM) echo "Oman" ;;
  280. PA) echo "Panama" ;;
  281. PE) echo "Peru" ;;
  282. PH) echo "Philippines" ;;
  283. PL) echo "Poland" ;;
  284. PR) echo "Puerto Rico" ;;
  285. PT) echo "Portugal" ;;
  286. PY) echo "Paraguay" ;;
  287. QA) echo "Qatar" ;;
  288. RO) echo "Romania" ;;
  289. RU) echo "Russian Federation" ;;
  290. SA) echo "Saudi Arabia" ;;
  291. SD) echo "Sudan" ;;
  292. SE) echo "Sweden" ;;
  293. SG) echo "Singapore" ;;
  294. SI) echo "Slovenia" ;;
  295. SK) echo "Slovakia" ;;
  296. SO) echo "Somalia" ;;
  297. SV) echo "El Salvador" ;;
  298. SY) echo "Syria" ;;
  299. TH) echo "Thailand" ;;
  300. TJ) echo "Tajikistan" ;;
  301. TN) echo "Tunisia" ;;
  302. TR) echo "Turkey" ;;
  303. TW) echo "Taiwan" ;;
  304. UA) echo "Ukraine" ;;
  305. UG) echo "Uganda" ;;
  306. US) echo "United States of America" ;;
  307. UY) echo "Uruguay" ;;
  308. UZ) echo "Uzbekistan" ;;
  309. VE) echo "Venezuela" ;;
  310. YE) echo "Yemen" ;;
  311. ZA) echo "South Africa" ;;
  312. ZW) echo "Zimbabwe" ;;
  313. *) echo "$1" ;;
  314. esac
  315. }
  316. show_disks() {
  317. local dev size sectorsize gbytes
  318. # IDE
  319. for dev in $(ls /sys/block|grep -E '^hd'); do
  320. if [ "$(cat /sys/block/$dev/device/media)" = "disk" ]; then
  321. # Find out nr sectors and bytes per sector;
  322. echo "/dev/$dev"
  323. size=$(cat /sys/block/$dev/size)
  324. sectorsize=$(cat /sys/block/$dev/queue/hw_sector_size)
  325. gbytes="$(($size * $sectorsize / 1024 / 1024 / 1024))"
  326. echo "size:${gbytes}GB;sector_size:$sectorsize"
  327. fi
  328. done
  329. # SATA/SCSI and Virtual disks (virtio)
  330. for dev in $(ls /sys/block|grep -E '^([sv]|xv)d|mmcblk|nvme'); do
  331. echo "/dev/$dev"
  332. size=$(cat /sys/block/$dev/size)
  333. sectorsize=$(cat /sys/block/$dev/queue/hw_sector_size)
  334. gbytes="$(($size * $sectorsize / 1024 / 1024 / 1024))"
  335. echo "size:${gbytes}GB;sector_size:$sectorsize"
  336. done
  337. # cciss(4) devices
  338. for dev in $(ls /dev/cciss 2>/dev/null|grep -E 'c[0-9]d[0-9]$'); do
  339. echo "/dev/cciss/$dev"
  340. size=$(cat /sys/block/cciss\!$dev/size)
  341. sectorsize=$(cat /sys/block/cciss\!$dev/queue/hw_sector_size)
  342. gbytes="$(($size * $sectorsize / 1024 / 1024 / 1024))"
  343. echo "size:${gbytes}GB;sector_size:$sectorsize"
  344. done
  345. }
  346. show_partitions() {
  347. local dev fstype fssize p part
  348. set -- $(show_disks)
  349. while [ $# -ne 0 ]; do
  350. disk=$(basename $1)
  351. shift 2
  352. # ATA/SCSI/SATA
  353. for p in /sys/block/$disk/$disk*; do
  354. if [ -d $p ]; then
  355. part=$(basename $p)
  356. fstype=$(lsblk -nfr /dev/$part|awk '{print $2}'|head -1)
  357. [ "$fstype" = "iso9660" ] && continue
  358. [ "$fstype" = "crypto_LUKS" ] && continue
  359. [ "$fstype" = "LVM2_member" ] && continue
  360. fssize=$(lsblk -nr /dev/$part|awk '{print $4}'|head -1)
  361. echo "/dev/$part"
  362. echo "size:${fssize:-unknown};fstype:${fstype:-none}"
  363. fi
  364. done
  365. done
  366. # Device Mapper
  367. for p in /dev/mapper/*; do
  368. part=$(basename $p)
  369. [ "${part}" = "live-rw" ] && continue
  370. [ "${part}" = "live-base" ] && continue
  371. [ "${part}" = "control" ] && continue
  372. fstype=$(lsblk -nfr $p|awk '{print $2}'|head -1)
  373. fssize=$(lsblk -nr $p|awk '{print $4}'|head -1)
  374. echo "${p}"
  375. echo "size:${fssize:-unknown};fstype:${fstype:-none}"
  376. done
  377. # Software raid (md)
  378. for p in $(ls -d /dev/md* 2>/dev/null|grep '[0-9]'); do
  379. part=$(basename $p)
  380. if cat /proc/mdstat|grep -qw $part; then
  381. fstype=$(lsblk -nfr /dev/$part|awk '{print $2}')
  382. [ "$fstype" = "crypto_LUKS" ] && continue
  383. [ "$fstype" = "LVM2_member" ] && continue
  384. fssize=$(lsblk -nr /dev/$part|awk '{print $4}')
  385. echo "$p"
  386. echo "size:${fssize:-unknown};fstype:${fstype:-none}"
  387. fi
  388. done
  389. # cciss(4) devices
  390. for part in $(ls /dev/cciss 2>/dev/null|grep -E 'c[0-9]d[0-9]p[0-9]+'); do
  391. fstype=$(lsblk -nfr /dev/cciss/$part|awk '{print $2}')
  392. [ "$fstype" = "crypto_LUKS" ] && continue
  393. [ "$fstype" = "LVM2_member" ] && continue
  394. fssize=$(lsblk -nr /dev/cciss/$part|awk '{print $4}')
  395. echo "/dev/cciss/$part"
  396. echo "size:${fssize:-unknown};fstype:${fstype:-none}"
  397. done
  398. if [ -e /sbin/lvs ]; then
  399. # LVM
  400. lvs --noheadings|while read lvname vgname perms size; do
  401. echo "/dev/mapper/${vgname}-${lvname}"
  402. echo "size:${size};fstype:lvm"
  403. done
  404. fi
  405. }
  406. menu_filesystems() {
  407. local dev fstype fssize mntpoint reformat
  408. while true; do
  409. DIALOG --ok-label "Change" --cancel-label "Done" \
  410. --title " Select the partition to edit " --menu "$MENULABEL" \
  411. ${MENUSIZE} $(show_partitions)
  412. [ $? -ne 0 ] && return
  413. dev=$(cat $ANSWER)
  414. DIALOG --title " Select the filesystem type for $dev " \
  415. --menu "$MENULABEL" ${MENUSIZE} \
  416. "btrfs" "Oracle's Btrfs" \
  417. "ext2" "Linux ext2 (no journaling)" \
  418. "ext3" "Linux ext3 (journal)" \
  419. "ext4" "Linux ext4 (journal)" \
  420. "f2fs" "Flash-Friendly Filesystem" \
  421. "swap" "Linux swap" \
  422. "vfat" "FAT32" \
  423. "xfs" "SGI's XFS"
  424. if [ $? -eq 0 ]; then
  425. fstype=$(cat $ANSWER)
  426. else
  427. continue
  428. fi
  429. if [ "$fstype" != "swap" ]; then
  430. DIALOG --inputbox "Please specify the mount point for $dev:" ${INPUTSIZE}
  431. if [ $? -eq 0 ]; then
  432. mntpoint=$(cat $ANSWER)
  433. elif [ $? -eq 1 ]; then
  434. continue
  435. fi
  436. else
  437. mntpoint=swap
  438. fi
  439. DIALOG --yesno "Do you want to create a new filesystem on $dev?" ${YESNOSIZE}
  440. if [ $? -eq 0 ]; then
  441. reformat=1
  442. elif [ $? -eq 1 ]; then
  443. reformat=0
  444. else
  445. continue
  446. fi
  447. fssize=$(lsblk -nr $dev|awk '{print $4}')
  448. set -- "$fstype" "$fssize" "$mntpoint" "$reformat"
  449. if [ -n "$1" -a -n "$2" -a -n "$3" -a -n "$4" ]; then
  450. local bdev=$(basename $dev)
  451. local ddev=$(basename $(dirname $dev))
  452. if [ "$ddev" != "dev" ]; then
  453. sed -i -e "/^MOUNTPOINT \/dev\/${ddev}\/${bdev}.*/d" $CONF_FILE
  454. else
  455. sed -i -e "/^MOUNTPOINT \/dev\/${bdev}.*/d" $CONF_FILE
  456. fi
  457. echo "MOUNTPOINT $dev $1 $2 $3 $4" >>$CONF_FILE
  458. fi
  459. done
  460. }
  461. menu_partitions() {
  462. DIALOG --title " Select the disk to partition " \
  463. --menu "$MENULABEL" ${MENUSIZE} $(show_disks)
  464. if [ $? -eq 0 ]; then
  465. local device=$(cat $ANSWER)
  466. DIALOG --title " Select the software for partitioning " \
  467. --menu "$MENULABEL" ${MENUSIZE} \
  468. "cfdisk" "Easy to use" \
  469. "fdisk" "More advanced"
  470. if [ $? -eq 0 ]; then
  471. local software=$(cat $ANSWER)
  472. DIALOG --title "Modify Partition Table on $device" --msgbox "\n
  473. ${BOLD}${software} will be executed in disk $device.${RESET}\n\n
  474. For BIOS systems, MBR or GPT partition tables are supported.\n
  475. To use GPT on PC BIOS systems an empty partition of 1MB must be added\n
  476. at the first 2GB of the disk with the TOGGLE \`bios_grub' enabled.\n
  477. ${BOLD}NOTE: you don't need this on EFI systems.${RESET}\n\n
  478. For EFI systems GPT is mandatory and a FAT32 partition with at least\n
  479. 100MB must be created with the TOGGLE \`boot', this will be used as\n
  480. EFI System Partition. This partition must have mountpoint as \`/boot/efi'.\n\n
  481. At least 1 partition is required for the rootfs (/).\n
  482. For swap, RAM*2 must be really enough. For / 600MB are required.\n\n
  483. ${BOLD}WARNING: /usr is not supported as a separate partition.${RESET}\n
  484. ${RESET}\n" 18 80
  485. if [ $? -eq 0 ]; then
  486. while true; do
  487. clear; $software $device; PARTITIONS_DONE=1
  488. break
  489. done
  490. else
  491. return
  492. fi
  493. fi
  494. fi
  495. }
  496. menu_keymap() {
  497. local _keymaps="$(find /usr/share/kbd/keymaps/ -type f -iname "*.map.gz" -printf "%f\n" | sed 's|.map.gz||g' | sort)"
  498. local _KEYMAPS=
  499. for f in ${_keymaps}; do
  500. _KEYMAPS="${_KEYMAPS} ${f} -"
  501. done
  502. while true; do
  503. DIALOG --title " Select your keymap " --menu "$MENULABEL" 14 70 14 ${_KEYMAPS}
  504. if [ $? -eq 0 ]; then
  505. set_option KEYMAP "$(cat $ANSWER)"
  506. loadkeys "$(cat $ANSWER)"
  507. KEYBOARD_DONE=1
  508. break
  509. else
  510. return
  511. fi
  512. done
  513. }
  514. set_keymap() {
  515. local KEYMAP=$(get_option KEYMAP)
  516. if [ -f /etc/vconsole.conf ]; then
  517. sed -i -e "s|KEYMAP=.*|KEYMAP=$KEYMAP|g" $TARGETDIR/etc/vconsole.conf
  518. else
  519. sed -i -e "s|#\?KEYMAP=.*|KEYMAP=$KEYMAP|g" $TARGETDIR/etc/rc.conf
  520. fi
  521. }
  522. menu_locale() {
  523. local _locales="$(grep -E '\.UTF-8' /etc/default/libc-locales|awk '{print $1}'|sed -e 's/^#//')"
  524. local LOCALES ISO639 ISO3166
  525. local TMPFILE=$(mktemp -t vinstall-XXXXXXXX || exit 1)
  526. INFOBOX "Scanning locales ..." 4 60
  527. for f in ${_locales}; do
  528. eval $(echo $f | awk 'BEGIN { FS="." } \
  529. { FS="_"; split($1, a); printf "ISO639=%s ISO3166=%s\n", a[1], a[2] }')
  530. echo "$f|$(iso639_language $ISO639) ($(iso3166_country $ISO3166))|" >> $TMPFILE
  531. done
  532. clear
  533. # Sort by ISO-639 language names
  534. LOCALES=$(sort -t '|' -k 2 < $TMPFILE | xargs | sed -e's/| /|/g')
  535. rm -f $TMPFILE
  536. while true; do
  537. (IFS="|"; DIALOG --title " Select your locale " --menu "$MENULABEL" 18 70 18 ${LOCALES})
  538. if [ $? -eq 0 ]; then
  539. set_option LOCALE "$(cat $ANSWER)"
  540. LOCALE_DONE=1
  541. break
  542. else
  543. return
  544. fi
  545. done
  546. }
  547. set_locale() {
  548. if [ -f $TARGETDIR/etc/default/libc-locales ]; then
  549. local LOCALE="$(get_option LOCALE)"
  550. : "${LOCALE:=C.UTF-8}"
  551. sed -i -e "s|LANG=.*|LANG=$LOCALE|g" $TARGETDIR/etc/locale.conf
  552. # Uncomment locale from /etc/default/libc-locales and regenerate it.
  553. sed -e "/${LOCALE}/s/^\#//" -i $TARGETDIR/etc/default/libc-locales
  554. echo "Running xbps-reconfigure -f glibc-locales ..." >$LOG
  555. chroot $TARGETDIR xbps-reconfigure -f glibc-locales >$LOG 2>&1
  556. fi
  557. }
  558. menu_timezone() {
  559. local areas=(Africa America Antarctica Arctic Asia Atlantic Australia Europe Indian Pacific)
  560. local area locations location
  561. while (IFS='|'; DIALOG ${area:+--default-item|"$area"} --title " Select area " --menu "$MENULABEL" 19 51 19 $(printf '%s||' "${areas[@]}")); do
  562. area=$(cat $ANSWER)
  563. read -a locations -d '\n' < <(find /usr/share/zoneinfo/$area -type f -printf '%P\n' | sort)
  564. if (IFS='|'; DIALOG --title " Select location (${area}) " --menu "$MENULABEL" 19 51 19 $(printf '%s||' "${locations[@]//_/ }")); then
  565. location=$(tr ' ' '_' < $ANSWER)
  566. set_option TIMEZONE "$area/$location"
  567. TIMEZONE_DONE=1
  568. return 0
  569. else
  570. continue
  571. fi
  572. done
  573. return 1
  574. }
  575. set_timezone() {
  576. local TIMEZONE="$(get_option TIMEZONE)"
  577. ln -sf "/usr/share/zoneinfo/${TIMEZONE}" "${TARGETDIR}/etc/localtime"
  578. }
  579. menu_hostname() {
  580. while true; do
  581. DIALOG --inputbox "Set the machine hostname:" ${INPUTSIZE}
  582. if [ $? -eq 0 ]; then
  583. set_option HOSTNAME "$(cat $ANSWER)"
  584. HOSTNAME_DONE=1
  585. break
  586. else
  587. return
  588. fi
  589. done
  590. }
  591. set_hostname() {
  592. local hostname="$(get_option HOSTNAME)"
  593. echo "${hostname:-void}" > $TARGETDIR/etc/hostname
  594. }
  595. menu_rootpassword() {
  596. local _firstpass _secondpass _again _desc
  597. while true; do
  598. if [ -z "${_firstpass}" ]; then
  599. _desc="Enter the root password"
  600. else
  601. _again=" again"
  602. fi
  603. DIALOG --insecure --passwordbox "${_desc}${_again}" ${INPUTSIZE}
  604. if [ $? -eq 0 ]; then
  605. if [ -z "${_firstpass}" ]; then
  606. _firstpass="$(cat $ANSWER)"
  607. else
  608. _secondpass="$(cat $ANSWER)"
  609. fi
  610. if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
  611. if [ "${_firstpass}" != "${_secondpass}" ]; then
  612. INFOBOX "Passwords do not match! Please enter again." 6 60
  613. unset _firstpass _secondpass _again
  614. sleep 2 && clear && continue
  615. fi
  616. set_option ROOTPASSWORD "${_firstpass}"
  617. ROOTPASSWORD_DONE=1
  618. break
  619. fi
  620. else
  621. return
  622. fi
  623. done
  624. }
  625. set_rootpassword() {
  626. echo "root:$(get_option ROOTPASSWORD)" | chroot $TARGETDIR chpasswd -c SHA512
  627. }
  628. menu_useraccount() {
  629. local _firstpass _secondpass _desc _again
  630. local _groups _status _group _checklist
  631. local _preset _userlogin
  632. while true; do
  633. _preset=$(get_option USERLOGIN)
  634. [ -z "$_preset" ] && _preset="void"
  635. DIALOG --inputbox "Enter a primary login name:" ${INPUTSIZE} "$_preset"
  636. if [ $? -eq 0 ]; then
  637. _userlogin="$(cat $ANSWER)"
  638. # based on useradd(8) § Caveats
  639. if [ "${#_userlogin}" -le 32 ] && [[ "${_userlogin}" =~ ^[a-z_][a-z0-9_-]*[$]?$ ]]; then
  640. set_option USERLOGIN "${_userlogin}"
  641. USERLOGIN_DONE=1
  642. break
  643. else
  644. INFOBOX "Invalid login name! Please try again." 6 60
  645. unset _userlogin
  646. sleep 2 && clear && continue
  647. fi
  648. else
  649. return
  650. fi
  651. done
  652. while true; do
  653. _preset=$(get_option USERNAME)
  654. [ -z "$_preset" ] && _preset="Void User"
  655. DIALOG --inputbox "Enter a display name for login '$(get_option USERLOGIN)' :" \
  656. ${INPUTSIZE} "$_preset"
  657. if [ $? -eq 0 ]; then
  658. set_option USERNAME "$(cat $ANSWER)"
  659. USERNAME_DONE=1
  660. break
  661. else
  662. return
  663. fi
  664. done
  665. while true; do
  666. if [ -z "${_firstpass}" ]; then
  667. _desc="Enter the password for login '$(get_option USERLOGIN)'"
  668. else
  669. _again=" again"
  670. fi
  671. DIALOG --insecure --passwordbox "${_desc}${_again}" ${INPUTSIZE}
  672. if [ $? -eq 0 ]; then
  673. if [ -z "${_firstpass}" ]; then
  674. _firstpass="$(cat $ANSWER)"
  675. else
  676. _secondpass="$(cat $ANSWER)"
  677. fi
  678. if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
  679. if [ "${_firstpass}" != "${_secondpass}" ]; then
  680. INFOBOX "Passwords do not match! Please enter again." 6 60
  681. unset _firstpass _secondpass _again
  682. sleep 2 && clear && continue
  683. fi
  684. set_option USERPASSWORD "${_firstpass}"
  685. USERPASSWORD_DONE=1
  686. break
  687. fi
  688. else
  689. return
  690. fi
  691. done
  692. _groups="wheel,audio,video,floppy,cdrom,optical,kvm,xbuilder"
  693. while true; do
  694. _desc="Select group membership for login '$(get_option USERLOGIN)':"
  695. for _group in $(cat /etc/group); do
  696. _gid="$(echo ${_group} | cut -d: -f3)"
  697. _group="$(echo ${_group} | cut -d: -f1)"
  698. _status="$(echo ${_groups} | grep -w ${_group})"
  699. if [ -z "${_status}" ]; then
  700. _status=off
  701. else
  702. _status=on
  703. fi
  704. # ignore the groups of root, existing users, and package groups
  705. if [[ "${_gid}" -ge 1000 || "${_group}" = "_"* || "${_group}" = "root" ]]; then
  706. continue
  707. fi
  708. if [ -z "${_checklist}" ]; then
  709. _checklist="${_group} ${_group}:${_gid} ${_status}"
  710. else
  711. _checklist="${_checklist} ${_group} ${_group}:${_gid} ${_status}"
  712. fi
  713. done
  714. DIALOG --no-tags --checklist "${_desc}" 20 60 18 ${_checklist}
  715. if [ $? -eq 0 ]; then
  716. set_option USERGROUPS $(cat $ANSWER | sed -e's| |,|g')
  717. USERGROUPS_DONE=1
  718. break
  719. else
  720. return
  721. fi
  722. done
  723. }
  724. set_useraccount() {
  725. [ -z "$USERACCOUNT_DONE" ] && return
  726. chroot $TARGETDIR useradd -m -G "$(get_option USERGROUPS)" \
  727. -c "$(get_option USERNAME)" "$(get_option USERLOGIN)"
  728. echo "$(get_option USERLOGIN):$(get_option USERPASSWORD)" | \
  729. chroot $TARGETDIR chpasswd -c SHA512
  730. }
  731. menu_bootloader() {
  732. while true; do
  733. DIALOG --title " Select the disk to install the bootloader" \
  734. --menu "$MENULABEL" ${MENUSIZE} $(show_disks) none "Manage bootloader otherwise"
  735. if [ $? -eq 0 ]; then
  736. set_option BOOTLOADER "$(cat $ANSWER)"
  737. BOOTLOADER_DONE=1
  738. break
  739. else
  740. return
  741. fi
  742. done
  743. while true; do
  744. DIALOG --yesno "Use a graphical terminal for the boot loader?" ${YESNOSIZE}
  745. if [ $? -eq 0 ]; then
  746. set_option TEXTCONSOLE 0
  747. break
  748. elif [ $? -eq 1 ]; then
  749. set_option TEXTCONSOLE 1
  750. break
  751. else
  752. return
  753. fi
  754. done
  755. }
  756. set_bootloader() {
  757. local dev=$(get_option BOOTLOADER) grub_args=
  758. if [ "$dev" = "none" ]; then return; fi
  759. # Check if it's an EFI system via efivars module.
  760. if [ -n "$EFI_SYSTEM" ]; then
  761. grub_args="--target=$EFI_TARGET --efi-directory=/boot/efi --bootloader-id=void_grub --recheck"
  762. fi
  763. echo "Running grub-install $grub_args $dev..." >$LOG
  764. chroot $TARGETDIR grub-install $grub_args $dev >$LOG 2>&1
  765. if [ $? -ne 0 ]; then
  766. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  767. failed to install GRUB to $dev!\nCheck $LOG for errors." ${MSGBOXSIZE}
  768. DIE 1
  769. fi
  770. echo "Running grub-mkconfig on $TARGETDIR..." >$LOG
  771. chroot $TARGETDIR grub-mkconfig -o /boot/grub/grub.cfg >$LOG 2>&1
  772. if [ $? -ne 0 ]; then
  773. DIALOG --msgbox "${BOLD}${RED}ERROR${RESET}: \
  774. failed to run grub-mkconfig!\nCheck $LOG for errors." ${MSGBOXSIZE}
  775. DIE 1
  776. fi
  777. }
  778. test_network() {
  779. rm -f otime && \
  780. xbps-uhelper fetch https://repo-default.voidlinux.org/current/otime >$LOG 2>&1
  781. if [ $? -eq 0 ]; then
  782. DIALOG --msgbox "Network is working properly!" ${MSGBOXSIZE}
  783. NETWORK_DONE=1
  784. return 1
  785. fi
  786. if [ "$1" = "nm" ]; then
  787. DIALOG --msgbox "Network Manager is enabled but network is inaccessible, please set it up externally with nmcli, nmtui, or the Network Manager tray applet." ${MSGBOXSIZE}
  788. else
  789. DIALOG --msgbox "Network is inaccessible, please set it up properly." ${MSGBOXSIZE}
  790. fi
  791. }
  792. configure_wifi() {
  793. local dev="$1" ssid enc pass _wpasupconf=/etc/wpa_supplicant/wpa_supplicant.conf
  794. DIALOG --form "Wireless configuration for ${dev}\n(encryption type: wep or wpa)" 0 0 0 \
  795. "SSID:" 1 1 "" 1 16 30 0 \
  796. "Encryption:" 2 1 "" 2 16 4 3 \
  797. "Password:" 3 1 "" 3 16 63 0 || return 1
  798. readarray -t values <<<$(cat $ANSWER)
  799. ssid="${values[0]}"; enc="${values[1]}"; pass="${values[2]}"
  800. if [ -z "$ssid" ]; then
  801. DIALOG --msgbox "Invalid SSID." ${MSGBOXSIZE}
  802. return 1
  803. elif [ -z "$enc" -o "$enc" != "wep" -a "$enc" != "wpa" ]; then
  804. DIALOG --msgbox "Invalid encryption type (possible values: wep or wpa)." ${MSGBOXSIZE}
  805. return 1
  806. elif [ -z "$pass" ]; then
  807. DIALOG --msgbox "Invalid AP password." ${MSGBOXSIZE}
  808. fi
  809. # reset the configuration to the default, if necessary
  810. # otherwise backup the configuration
  811. if [ -f ${_wpasupconf}.orig ]; then
  812. cp -f ${_wpasupconf}.orig ${_wpasupconf}
  813. else
  814. cp -f ${_wpasupconf} ${_wpasupconf}.orig
  815. fi
  816. if [ "$enc" = "wep" ]; then
  817. cat << EOF >> ${_wpasupconf}
  818. network={
  819. ssid="$ssid"
  820. wep_key0="$pass"
  821. wep_tx_keyidx=0
  822. auth_alg=SHARED
  823. }
  824. EOF
  825. else
  826. wpa_passphrase "$ssid" "$pass" >> ${_wpasupconf}
  827. fi
  828. sv restart wpa_supplicant
  829. configure_net_dhcp $dev
  830. return $?
  831. }
  832. configure_net() {
  833. local dev="$1" rval
  834. DIALOG --yesno "Do you want to use DHCP for $dev?" ${YESNOSIZE}
  835. rval=$?
  836. if [ $rval -eq 0 ]; then
  837. configure_net_dhcp $dev
  838. elif [ $rval -eq 1 ]; then
  839. configure_net_static $dev
  840. fi
  841. }
  842. iface_setup() {
  843. ip addr show dev $1 | grep -q -e 'inet ' -e 'inet6 '
  844. return $?
  845. }
  846. configure_net_dhcp() {
  847. local dev="$1"
  848. iface_setup $dev
  849. if [ $? -eq 1 ]; then
  850. sv restart dhcpcd 2>&1 | tee $LOG | \
  851. DIALOG --progressbox "Initializing $dev via DHCP..." ${WIDGET_SIZE}
  852. if [ $? -ne 0 ]; then
  853. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} failed to run dhcpcd. See $LOG for details." ${MSGBOXSIZE}
  854. return 1
  855. fi
  856. export -f iface_setup
  857. timeout 10s bash -c "while true; do iface_setup $dev; sleep 0.25; done"
  858. if [ $? -eq 1 ]; then
  859. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} DHCP request failed for $dev. Check $LOG for errors." ${MSGBOXSIZE}
  860. return 1
  861. fi
  862. fi
  863. test_network
  864. if [ $? -eq 1 ]; then
  865. set_option NETWORK "${dev} dhcp"
  866. fi
  867. }
  868. configure_net_static() {
  869. local ip gw dns1 dns2 dev=$1
  870. DIALOG --form "Static IP configuration for $dev:" 0 0 0 \
  871. "IP address:" 1 1 "192.168.0.2" 1 21 20 0 \
  872. "Gateway:" 2 1 "192.168.0.1" 2 21 20 0 \
  873. "DNS Primary" 3 1 "8.8.8.8" 3 21 20 0 \
  874. "DNS Secondary" 4 1 "8.8.4.4" 4 21 20 0 || return 1
  875. set -- $(cat $ANSWER)
  876. ip=$1; gw=$2; dns1=$3; dns2=$4
  877. echo "running: ip link set dev $dev up" >$LOG
  878. ip link set dev $dev up >$LOG 2>&1
  879. if [ $? -ne 0 ]; then
  880. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} Failed to bring $dev interface." ${MSGBOXSIZE}
  881. return 1
  882. fi
  883. echo "running: ip addr add $ip dev $dev" >$LOG
  884. ip addr add $ip dev $dev >$LOG 2>&1
  885. if [ $? -ne 0 ]; then
  886. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} Failed to set ip to the $dev interface." ${MSGBOXSIZE}
  887. return 1
  888. fi
  889. ip route add default via $gw >$LOG 2>&1
  890. if [ $? -ne 0 ]; then
  891. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} failed to setup your gateway." ${MSGBOXSIZE}
  892. return 1
  893. fi
  894. echo "nameserver $dns1" >/etc/resolv.conf
  895. echo "nameserver $dns2" >>/etc/resolv.conf
  896. test_network
  897. if [ $? -eq 1 ]; then
  898. set_option NETWORK "${dev} static $ip $gw $dns1 $dns2"
  899. fi
  900. }
  901. menu_network() {
  902. local dev addr f DEVICES
  903. if [ -e /var/service/NetworkManager ]; then
  904. test_network nm
  905. return
  906. fi
  907. for f in $(ls /sys/class/net); do
  908. [ "$f" = "lo" ] && continue
  909. addr=$(cat /sys/class/net/$f/address)
  910. DEVICES="$DEVICES $f $addr"
  911. done
  912. DIALOG --title " Select the network interface to configure " \
  913. --menu "$MENULABEL" ${MENUSIZE} ${DEVICES}
  914. if [ $? -eq 0 ]; then
  915. dev=$(cat $ANSWER)
  916. if $(echo $dev|egrep -q "^wl.*" 2>/dev/null); then
  917. configure_wifi $dev
  918. else
  919. configure_net $dev
  920. fi
  921. fi
  922. }
  923. validate_useraccount() {
  924. # don't check that USERNAME has been set because it can be empty
  925. local USERLOGIN=$(get_option USERLOGIN)
  926. local USERPASSWORD=$(get_option USERPASSWORD)
  927. local USERGROUPS=$(get_option USERGROUPS)
  928. if [ -n "$USERLOGIN" ] && [ -n "$USERPASSWORD" ] && [ -n "$USERGROUPS" ]; then
  929. USERACCOUNT_DONE=1
  930. fi
  931. }
  932. validate_filesystems() {
  933. local mnts dev size fstype mntpt mkfs rootfound fmt
  934. local usrfound efi_system_partition
  935. local bootdev=$(get_option BOOTLOADER)
  936. unset TARGETFS
  937. mnts=$(grep -E '^MOUNTPOINT.*' $CONF_FILE)
  938. set -- ${mnts}
  939. while [ $# -ne 0 ]; do
  940. fmt=""
  941. dev=$2; fstype=$3; size=$4; mntpt="$5"; mkfs=$6
  942. shift 6
  943. if [ "$mntpt" = "/" ]; then
  944. rootfound=1
  945. elif [ "$mntpt" = "/usr" ]; then
  946. usrfound=1
  947. elif [ "$fstype" = "vfat" -a "$mntpt" = "/boot/efi" ]; then
  948. efi_system_partition=1
  949. fi
  950. if [ "$mkfs" -eq 1 ]; then
  951. fmt="NEW FILESYSTEM: "
  952. fi
  953. if [ -z "$TARGETFS" ]; then
  954. TARGETFS="${fmt}$dev ($size) mounted on $mntpt as ${fstype}\n"
  955. else
  956. TARGETFS="${TARGETFS}${fmt}${dev} ($size) mounted on $mntpt as ${fstype}\n"
  957. fi
  958. done
  959. if [ -z "$rootfound" ]; then
  960. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  961. the mount point for the root filesystem (/) has not yet been configured." ${MSGBOXSIZE}
  962. return 1
  963. elif [ -n "$usrfound" ]; then
  964. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  965. /usr mount point has been configured but is not supported, please remove it to continue." ${MSGBOXSIZE}
  966. return 1
  967. elif [ -n "$EFI_SYSTEM" -a "$bootdev" != "none" -a -z "$efi_system_partition" ]; then
  968. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  969. The EFI System Partition has not yet been configured, please create it\n
  970. as FAT32, mountpoint /boot/efi and at least with 100MB of size." ${MSGBOXSIZE}
  971. return 1
  972. fi
  973. FILESYSTEMS_DONE=1
  974. }
  975. create_filesystems() {
  976. local mnts dev mntpt fstype fspassno mkfs size rv uuid
  977. mnts=$(grep -E '^MOUNTPOINT.*' $CONF_FILE | sort -k 5)
  978. set -- ${mnts}
  979. while [ $# -ne 0 ]; do
  980. dev=$2; fstype=$3; mntpt="$5"; mkfs=$6
  981. shift 6
  982. # swap partitions
  983. if [ "$fstype" = "swap" ]; then
  984. swapoff $dev >/dev/null 2>&1
  985. if [ "$mkfs" -eq 1 ]; then
  986. mkswap $dev >$LOG 2>&1
  987. if [ $? -ne 0 ]; then
  988. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  989. failed to create swap on ${dev}!\ncheck $LOG for errors." ${MSGBOXSIZE}
  990. DIE 1
  991. fi
  992. fi
  993. swapon $dev >$LOG 2>&1
  994. if [ $? -ne 0 ]; then
  995. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  996. failed to activate swap on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE}
  997. DIE 1
  998. fi
  999. # Add entry for target fstab
  1000. uuid=$(blkid -o value -s UUID "$dev")
  1001. echo "UUID=$uuid none swap defaults 0 0" >>$TARGET_FSTAB
  1002. continue
  1003. fi
  1004. if [ "$mkfs" -eq 1 ]; then
  1005. case "$fstype" in
  1006. btrfs) MKFS="mkfs.btrfs -f"; modprobe btrfs >$LOG 2>&1;;
  1007. ext2) MKFS="mke2fs -F"; modprobe ext2 >$LOG 2>&1;;
  1008. ext3) MKFS="mke2fs -F -j"; modprobe ext3 >$LOG 2>&1;;
  1009. ext4) MKFS="mke2fs -F -t ext4"; modprobe ext4 >$LOG 2>&1;;
  1010. f2fs) MKFS="mkfs.f2fs -f"; modprobe f2fs >$LOG 2>&1;;
  1011. vfat) MKFS="mkfs.vfat -F32"; modprobe vfat >$LOG 2>&1;;
  1012. xfs) MKFS="mkfs.xfs -f -i sparse=0"; modprobe xfs >$LOG 2>&1;;
  1013. esac
  1014. TITLE="Check $LOG for details ..."
  1015. INFOBOX "Creating filesystem $fstype on $dev for $mntpt ..." 8 60
  1016. echo "Running $MKFS $dev..." >$LOG
  1017. $MKFS $dev >$LOG 2>&1; rv=$?
  1018. if [ $rv -ne 0 ]; then
  1019. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  1020. failed to create filesystem $fstype on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE}
  1021. DIE 1
  1022. fi
  1023. fi
  1024. # Mount rootfs the first one.
  1025. [ "$mntpt" != "/" ] && continue
  1026. mkdir -p $TARGETDIR
  1027. echo "Mounting $dev on $mntpt ($fstype)..." >$LOG
  1028. mount -t $fstype $dev $TARGETDIR >$LOG 2>&1
  1029. if [ $? -ne 0 ]; then
  1030. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  1031. failed to mount $dev on ${mntpt}! check $LOG for errors." ${MSGBOXSIZE}
  1032. DIE 1
  1033. fi
  1034. # Add entry to target fstab
  1035. uuid=$(blkid -o value -s UUID "$dev")
  1036. if [ "$fstype" = "f2fs" -o "$fstype" = "btrfs" -o "$fstype" = "xfs" ]; then
  1037. fspassno=0
  1038. else
  1039. fspassno=1
  1040. fi
  1041. echo "UUID=$uuid $mntpt $fstype defaults 0 $fspassno" >>$TARGET_FSTAB
  1042. done
  1043. # mount all filesystems in target rootfs
  1044. mnts=$(grep -E '^MOUNTPOINT.*' $CONF_FILE | sort -k 5)
  1045. set -- ${mnts}
  1046. while [ $# -ne 0 ]; do
  1047. dev=$2; fstype=$3; mntpt="$5"
  1048. shift 6
  1049. [ "$mntpt" = "/" -o "$fstype" = "swap" ] && continue
  1050. mkdir -p ${TARGETDIR}${mntpt}
  1051. echo "Mounting $dev on $mntpt ($fstype)..." >$LOG
  1052. mount -t $fstype $dev ${TARGETDIR}${mntpt} >$LOG 2>&1
  1053. if [ $? -ne 0 ]; then
  1054. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  1055. failed to mount $dev on $mntpt! check $LOG for errors." ${MSGBOXSIZE}
  1056. DIE
  1057. fi
  1058. # Add entry to target fstab
  1059. uuid=$(blkid -o value -s UUID "$dev")
  1060. if [ "$fstype" = "f2fs" -o "$fstype" = "btrfs" -o "$fstype" = "xfs" ]; then
  1061. fspassno=0
  1062. else
  1063. fspassno=2
  1064. fi
  1065. echo "UUID=$uuid $mntpt $fstype defaults 0 $fspassno" >>$TARGET_FSTAB
  1066. done
  1067. }
  1068. mount_filesystems() {
  1069. for f in sys proc dev; do
  1070. [ ! -d $TARGETDIR/$f ] && mkdir $TARGETDIR/$f
  1071. echo "Mounting $TARGETDIR/$f..." >$LOG
  1072. mount --rbind /$f $TARGETDIR/$f >$LOG 2>&1
  1073. done
  1074. }
  1075. umount_filesystems() {
  1076. local mnts="$(grep -E '^MOUNTPOINT.*swap.*$' $CONF_FILE | sort -r -k 5)"
  1077. set -- ${mnts}
  1078. while [ $# -ne 0 ]; do
  1079. local dev=$2; local fstype=$3
  1080. shift 6
  1081. if [ "$fstype" = "swap" ]; then
  1082. echo "Disabling swap space on $dev..." >$LOG
  1083. swapoff $dev >$LOG 2>&1
  1084. continue
  1085. fi
  1086. done
  1087. echo "Unmounting $TARGETDIR..." >$LOG
  1088. umount -R $TARGETDIR >$LOG 2>&1
  1089. }
  1090. log_and_count() {
  1091. local progress whole tenth
  1092. while read line; do
  1093. echo "$line" >$LOG
  1094. copy_count=$((copy_count + 1))
  1095. progress=$((1000 * copy_count / copy_total))
  1096. if [ "$progress" != "$copy_progress" ]; then
  1097. whole=$((progress / 10))
  1098. tenth=$((progress % 10))
  1099. printf "Progress: %d.%d%% (%d of %d files)\n" $whole $tenth $copy_count $copy_total
  1100. copy_progress=$progress
  1101. fi
  1102. done
  1103. }
  1104. copy_rootfs() {
  1105. local tar_in="--create --one-file-system --xattrs"
  1106. TITLE="Check $LOG for details ..."
  1107. INFOBOX "Counting files, please be patient ..." 4 60
  1108. copy_total=$(tar ${tar_in} -v -f /dev/null / 2>/dev/null | wc -l)
  1109. export copy_total copy_count=0 copy_progress=
  1110. clear
  1111. tar ${tar_in} -f - / 2>/dev/null | \
  1112. tar --extract --xattrs --xattrs-include='*' --preserve-permissions -v -f - -C $TARGETDIR | \
  1113. log_and_count | \
  1114. DIALOG --title "${TITLE}" \
  1115. --progressbox "Copying live image to target rootfs." 5 60
  1116. if [ $? -ne 0 ]; then
  1117. DIE 1
  1118. fi
  1119. unset copy_total copy_count copy_percent
  1120. }
  1121. install_packages() {
  1122. local _grub= _syspkg=
  1123. if [ -n "$EFI_SYSTEM" ]; then
  1124. if [ $EFI_FW_BITS -eq 32 ]; then
  1125. _grub="grub-i386-efi"
  1126. else
  1127. _grub="grub-x86_64-efi"
  1128. fi
  1129. else
  1130. _grub="grub"
  1131. fi
  1132. _syspkg="base-system"
  1133. mkdir -p $TARGETDIR/var/db/xbps/keys $TARGETDIR/usr/share
  1134. cp -a /usr/share/xbps.d $TARGETDIR/usr/share/
  1135. cp /var/db/xbps/keys/*.plist $TARGETDIR/var/db/xbps/keys
  1136. if [ -n "$MIRROR_DONE" ]; then
  1137. mkdir -p $TARGETDIR/etc
  1138. cp -a /etc/xbps.d $TARGETDIR/etc
  1139. fi
  1140. mkdir -p $TARGETDIR/boot/grub
  1141. _arch=$(xbps-uhelper arch)
  1142. stdbuf -oL env XBPS_ARCH=${_arch} \
  1143. xbps-install -r $TARGETDIR -SyU ${_syspkg} ${_grub} 2>&1 | \
  1144. DIALOG --title "Installing base system packages..." \
  1145. --programbox 24 80
  1146. if [ $? -ne 0 ]; then
  1147. DIE 1
  1148. fi
  1149. xbps-reconfigure -r $TARGETDIR -f base-files >/dev/null 2>&1
  1150. chroot $TARGETDIR xbps-reconfigure -a
  1151. }
  1152. enable_service() {
  1153. ln -sf /etc/sv/$1 $TARGETDIR/etc/runit/runsvdir/default/$1
  1154. }
  1155. menu_install() {
  1156. ROOTPASSWORD_DONE="$(get_option ROOTPASSWORD)"
  1157. BOOTLOADER_DONE="$(get_option BOOTLOADER)"
  1158. if [ -z "$ROOTPASSWORD_DONE" ]; then
  1159. DIALOG --msgbox "${BOLD}The root password has not been configured, \
  1160. please do so before starting the installation.${RESET}" ${MSGBOXSIZE}
  1161. return 1
  1162. elif [ -z "$BOOTLOADER_DONE" ]; then
  1163. DIALOG --msgbox "${BOLD}The disk to install the bootloader has not been \
  1164. configured, please do so before starting the installation.${RESET}" ${MSGBOXSIZE}
  1165. return 1
  1166. fi
  1167. # Validate filesystems after making sure bootloader is done,
  1168. # so that specific checks can be made based on the selection
  1169. validate_filesystems || return 1
  1170. if [ -z "$FILESYSTEMS_DONE" ]; then
  1171. DIALOG --msgbox "${BOLD}Required filesystems were not configured, \
  1172. please do so before starting the installation.${RESET}" ${MSGBOXSIZE}
  1173. return 1
  1174. fi
  1175. # Validate useraccount. All parameters must be set (name, password, login name, groups).
  1176. validate_useraccount
  1177. if [ -z "$USERACCOUNT_DONE" ]; then
  1178. DIALOG --yesno "${BOLD}The user account is not set up properly.${RESET}\n\n
  1179. ${BOLD}${RED}WARNING: no user will be created. You will only be able to login \
  1180. with the root user in your new system.${RESET}\n\n
  1181. ${BOLD}Do you want to continue?${RESET}" 10 60 || return
  1182. fi
  1183. DIALOG --yesno "${BOLD}The following operations will be executed:${RESET}\n\n
  1184. ${BOLD}${TARGETFS}${RESET}\n
  1185. ${BOLD}${RED}WARNING: data on partitions will be COMPLETELY DESTROYED for new \
  1186. filesystems.${RESET}\n\n
  1187. ${BOLD}Do you want to continue?${RESET}" 20 80 || return
  1188. unset TARGETFS
  1189. # Create and mount filesystems
  1190. create_filesystems
  1191. # If source not set use defaults.
  1192. if [ "$(get_option SOURCE)" = "local" -o -z "$SOURCE_DONE" ]; then
  1193. copy_rootfs
  1194. . /etc/default/live.conf
  1195. rm -f $TARGETDIR/etc/motd
  1196. rm -f $TARGETDIR/etc/issue
  1197. rm -f $TARGETDIR/usr/sbin/void-installer
  1198. # Remove modified sddm.conf to let sddm use the defaults.
  1199. rm -f $TARGETDIR/etc/sddm.conf
  1200. # Remove live user.
  1201. echo "Removing $USERNAME live user from targetdir ..." >$LOG
  1202. chroot $TARGETDIR userdel -r $USERNAME >$LOG 2>&1
  1203. rm -f $TARGETDIR/etc/sudoers.d/99-void-live
  1204. sed -i "s,GETTY_ARGS=\"--noclear -a $USERNAME\",GETTY_ARGS=\"--noclear\",g" $TARGETDIR/etc/sv/agetty-tty1/conf
  1205. TITLE="Check $LOG for details ..."
  1206. INFOBOX "Rebuilding initramfs for target ..." 4 60
  1207. echo "Rebuilding initramfs for target ..." >$LOG
  1208. # mount required fs
  1209. mount_filesystems
  1210. chroot $TARGETDIR dracut --no-hostonly --add-drivers "ahci" --force >>$LOG 2>&1
  1211. INFOBOX "Removing temporary packages from target ..." 4 60
  1212. echo "Removing temporary packages from target ..." >$LOG
  1213. xbps-remove -r $TARGETDIR -Ry dialog xtools-minimal xmirror >>$LOG 2>&1
  1214. rmdir $TARGETDIR/mnt/target
  1215. else
  1216. # mount required fs
  1217. mount_filesystems
  1218. # network install, use packages.
  1219. install_packages
  1220. fi
  1221. INFOBOX "Applying installer settings..." 4 60
  1222. # copy target fstab.
  1223. install -Dm644 $TARGET_FSTAB $TARGETDIR/etc/fstab
  1224. # Mount /tmp as tmpfs.
  1225. echo "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0" >> $TARGETDIR/etc/fstab
  1226. # set up keymap, locale, timezone, hostname, root passwd and user account.
  1227. set_keymap
  1228. set_locale
  1229. set_timezone
  1230. set_hostname
  1231. set_rootpassword
  1232. set_useraccount
  1233. # Copy /etc/skel files for root.
  1234. cp $TARGETDIR/etc/skel/.[bix]* $TARGETDIR/root
  1235. # network settings for target
  1236. if [ -n "$NETWORK_DONE" ]; then
  1237. local net="$(get_option NETWORK)"
  1238. set -- ${net}
  1239. local _dev="$1" _type="$2" _ip="$3" _gw="$4" _dns1="$5" _dns2="$6"
  1240. if [ -z "$_type" ]; then
  1241. # network type empty??!!!
  1242. :
  1243. elif [ "$_type" = "dhcp" ]; then
  1244. if $(echo $_dev|egrep -q "^wl.*" 2>/dev/null); then
  1245. cp /etc/wpa_supplicant/wpa_supplicant.conf $TARGETDIR/etc/wpa_supplicant
  1246. ln -sf /etc/sv/wpa_supplicant $TARGETDIR/etc/runit/runsvdir/default/wpa_supplicant
  1247. fi
  1248. enable_service dhcpcd
  1249. elif [ -n "$_dev" -a "$_type" = "static" ]; then
  1250. # static IP through dhcpcd.
  1251. mv $TARGETDIR/etc/dhcpcd.conf $TARGETDIR/etc/dhcpcd.conf.orig
  1252. echo "# Static IP configuration set by the void-installer for $_dev." \
  1253. >$TARGETDIR/etc/dhcpcd.conf
  1254. echo "interface $_dev" >>$TARGETDIR/etc/dhcpcd.conf
  1255. echo "static ip_address=$_ip" >>$TARGETDIR/etc/dhcpcd.conf
  1256. echo "static routers=$_gw" >>$TARGETDIR/etc/dhcpcd.conf
  1257. echo "static domain_name_servers=$_dns1 $_dns2" >>$TARGETDIR/etc/dhcpcd.conf
  1258. enable_service dhcpcd
  1259. fi
  1260. fi
  1261. if [ -d $TARGETDIR/etc/sudoers.d ]; then
  1262. USERLOGIN="$(get_option USERLOGIN)"
  1263. if [ -z "$(echo $(get_option USERGROUPS) | grep -w wheel)" -a -n "$USERLOGIN" ]; then
  1264. # enable sudo for primary user USERLOGIN who is not member of wheel
  1265. echo "# Enable sudo for login '$USERLOGIN'" > "$TARGETDIR/etc/sudoers.d/$USERLOGIN"
  1266. echo "$USERLOGIN ALL=(ALL:ALL) ALL" >> "$TARGETDIR/etc/sudoers.d/$USERLOGIN"
  1267. else
  1268. # enable the sudoers entry for members of group wheel
  1269. echo "%wheel ALL=(ALL:ALL) ALL" > "$TARGETDIR/etc/sudoers.d/wheel"
  1270. fi
  1271. unset USERLOGIN
  1272. fi
  1273. # clean up polkit rule - it's only useful in live systems
  1274. rm -f $TARGETDIR/etc/polkit-1/rules.d/void-live.rules
  1275. # enable text console for grub if chosen
  1276. if [ "$(get_option TEXTCONSOLE)" = "1" ]; then
  1277. sed -i $TARGETDIR/etc/default/grub \
  1278. -e 's|#\(GRUB_TERMINAL_INPUT\).*|\1=console|' \
  1279. -e 's|#\(GRUB_TERMINAL_OUTPUT\).*|\1=console|'
  1280. fi
  1281. # install bootloader.
  1282. set_bootloader
  1283. sync && sync && sync
  1284. # unmount all filesystems.
  1285. umount_filesystems
  1286. # installed successfully.
  1287. DIALOG --yesno "${BOLD}Void Linux has been installed successfully!${RESET}\n
  1288. Do you want to reboot the system?" ${YESNOSIZE}
  1289. if [ $? -eq 0 ]; then
  1290. shutdown -r now
  1291. else
  1292. return
  1293. fi
  1294. }
  1295. menu_source() {
  1296. local src=
  1297. DIALOG --title " Select installation source " \
  1298. --menu "$MENULABEL" 8 70 0 \
  1299. "Local" "Packages from ISO image" \
  1300. "Network" "Base system only, downloaded from official repository"
  1301. case "$(cat $ANSWER)" in
  1302. "Local") src="local";;
  1303. "Network") src="net";
  1304. if [ -z "$NETWORK_DONE" ]; then
  1305. if test_network; then
  1306. menu_network
  1307. fi
  1308. fi;;
  1309. *) return 1;;
  1310. esac
  1311. SOURCE_DONE=1
  1312. set_option SOURCE $src
  1313. }
  1314. menu_mirror() {
  1315. xmirror 2>$LOG && MIRROR_DONE=1
  1316. }
  1317. menu() {
  1318. local AFTER_HOSTNAME
  1319. if [ -z "$DEFITEM" ]; then
  1320. DEFITEM="Keyboard"
  1321. fi
  1322. if xbps-uhelper arch | grep -qe '-musl$'; then
  1323. AFTER_HOSTNAME="Timezone"
  1324. DIALOG --default-item $DEFITEM \
  1325. --extra-button --extra-label "Settings" \
  1326. --title " Void Linux installation menu " \
  1327. --menu "$MENULABEL" 10 70 0 \
  1328. "Keyboard" "Set system keyboard" \
  1329. "Network" "Set up the network" \
  1330. "Source" "Set source installation" \
  1331. "Mirror" "Select XBPS mirror" \
  1332. "Hostname" "Set system hostname" \
  1333. "Timezone" "Set system time zone" \
  1334. "RootPassword" "Set system root password" \
  1335. "UserAccount" "Set primary user name and password" \
  1336. "BootLoader" "Set disk to install bootloader" \
  1337. "Partition" "Partition disk(s)" \
  1338. "Filesystems" "Configure filesystems and mount points" \
  1339. "Install" "Start installation with saved settings" \
  1340. "Exit" "Exit installation"
  1341. else
  1342. AFTER_HOSTNAME="Locale"
  1343. DIALOG --default-item $DEFITEM \
  1344. --extra-button --extra-label "Settings" \
  1345. --title " Void Linux installation menu " \
  1346. --menu "$MENULABEL" 10 70 0 \
  1347. "Keyboard" "Set system keyboard" \
  1348. "Network" "Set up the network" \
  1349. "Source" "Set source installation" \
  1350. "Mirror" "Select XBPS mirror" \
  1351. "Hostname" "Set system hostname" \
  1352. "Locale" "Set system locale" \
  1353. "Timezone" "Set system time zone" \
  1354. "RootPassword" "Set system root password" \
  1355. "UserAccount" "Set primary user name and password" \
  1356. "BootLoader" "Set disk to install bootloader" \
  1357. "Partition" "Partition disk(s)" \
  1358. "Filesystems" "Configure filesystems and mount points" \
  1359. "Install" "Start installation with saved settings" \
  1360. "Exit" "Exit installation"
  1361. fi
  1362. if [ $? -eq 3 ]; then
  1363. # Show settings
  1364. cp $CONF_FILE /tmp/conf_hidden.$$;
  1365. sed -i "s/^ROOTPASSWORD.*/ROOTPASSWORD <-hidden->/" /tmp/conf_hidden.$$
  1366. sed -i "s/^USERPASSWORD.*/USERPASSWORD <-hidden->/" /tmp/conf_hidden.$$
  1367. DIALOG --title "Saved settings for installation" --textbox /tmp/conf_hidden.$$ 14 60
  1368. rm /tmp/conf_hidden.$$
  1369. return
  1370. fi
  1371. case $(cat $ANSWER) in
  1372. "Keyboard") menu_keymap && [ -n "$KEYBOARD_DONE" ] && DEFITEM="Network";;
  1373. "Network") menu_network && [ -n "$NETWORK_DONE" ] && DEFITEM="Source";;
  1374. "Source") menu_source && [ -n "$SOURCE_DONE" ] && DEFITEM="Mirror";;
  1375. "Mirror") menu_mirror && [ -n "$MIRROR_DONE" ] && DEFITEM="Hostname";;
  1376. "Hostname") menu_hostname && [ -n "$HOSTNAME_DONE" ] && DEFITEM="$AFTER_HOSTNAME";;
  1377. "Locale") menu_locale && [ -n "$LOCALE_DONE" ] && DEFITEM="Timezone";;
  1378. "Timezone") menu_timezone && [ -n "$TIMEZONE_DONE" ] && DEFITEM="RootPassword";;
  1379. "RootPassword") menu_rootpassword && [ -n "$ROOTPASSWORD_DONE" ] && DEFITEM="UserAccount";;
  1380. "UserAccount") menu_useraccount && [ -n "$USERLOGIN_DONE" ] && [ -n "$USERPASSWORD_DONE" ] \
  1381. && DEFITEM="BootLoader";;
  1382. "BootLoader") menu_bootloader && [ -n "$BOOTLOADER_DONE" ] && DEFITEM="Partition";;
  1383. "Partition") menu_partitions && [ -n "$PARTITIONS_DONE" ] && DEFITEM="Filesystems";;
  1384. "Filesystems") menu_filesystems && [ -n "$FILESYSTEMS_DONE" ] && DEFITEM="Install";;
  1385. "Install") menu_install;;
  1386. "Exit") DIE;;
  1387. *) DIALOG --yesno "Abort Installation?" ${YESNOSIZE} && DIE
  1388. esac
  1389. }
  1390. if ! command -v dialog >/dev/null; then
  1391. echo "ERROR: missing dialog command, exiting..."
  1392. exit 1
  1393. fi
  1394. if [ "$(id -u)" != "0" ]; then
  1395. echo "void-installer must run as root" 1>&2
  1396. exit 1
  1397. fi
  1398. #
  1399. # main()
  1400. #
  1401. DIALOG --title "${BOLD}${RED} Enter the void ... ${RESET}" --msgbox "\n
  1402. Welcome to the Void Linux installation. A simple and minimal \
  1403. Linux distribution made from scratch and built from the source package tree \
  1404. available for XBPS, a new alternative binary package system.\n\n
  1405. The installation should be pretty straightforward. If you are in trouble \
  1406. please join us at ${BOLD}#voidlinux${RESET} on ${BOLD}irc.libera.chat${RESET}.\n\n
  1407. ${BOLD}https://www.voidlinux.org${RESET}\n\n" 16 80
  1408. while true; do
  1409. menu
  1410. done
  1411. exit 0
  1412. # vim: set ts=4 sw=4 et: