installer.sh 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569
  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. get_partfs() {
  347. # Get fs type from configuration if available. This ensures
  348. # that the user is shown the proper fs type if they install the system.
  349. local part="$1"
  350. local default="${2:-none}"
  351. local fstype=$(grep "MOUNTPOINT ${part}" "$CONF_FILE"|awk '{print $3}')
  352. echo "${fstype:-$default}"
  353. }
  354. show_partitions() {
  355. local dev fstype fssize p part
  356. set -- $(show_disks)
  357. while [ $# -ne 0 ]; do
  358. disk=$(basename $1)
  359. shift 2
  360. # ATA/SCSI/SATA
  361. for p in /sys/block/$disk/$disk*; do
  362. if [ -d $p ]; then
  363. part=$(basename $p)
  364. fstype=$(lsblk -nfr /dev/$part|awk '{print $2}'|head -1)
  365. [ "$fstype" = "iso9660" ] && continue
  366. [ "$fstype" = "crypto_LUKS" ] && continue
  367. [ "$fstype" = "LVM2_member" ] && continue
  368. fssize=$(lsblk -nr /dev/$part|awk '{print $4}'|head -1)
  369. echo "/dev/$part"
  370. echo "size:${fssize:-unknown};fstype:$(get_partfs "/dev/$part")"
  371. fi
  372. done
  373. done
  374. # Device Mapper
  375. for p in /dev/mapper/*; do
  376. part=$(basename $p)
  377. [ "${part}" = "live-rw" ] && continue
  378. [ "${part}" = "live-base" ] && continue
  379. [ "${part}" = "control" ] && continue
  380. fstype=$(lsblk -nfr $p|awk '{print $2}'|head -1)
  381. fssize=$(lsblk -nr $p|awk '{print $4}'|head -1)
  382. echo "${p}"
  383. echo "size:${fssize:-unknown};fstype:$(get_partfs "$p")"
  384. done
  385. # Software raid (md)
  386. for p in $(ls -d /dev/md* 2>/dev/null|grep '[0-9]'); do
  387. part=$(basename $p)
  388. if cat /proc/mdstat|grep -qw $part; then
  389. fstype=$(lsblk -nfr /dev/$part|awk '{print $2}')
  390. [ "$fstype" = "crypto_LUKS" ] && continue
  391. [ "$fstype" = "LVM2_member" ] && continue
  392. fssize=$(lsblk -nr /dev/$part|awk '{print $4}')
  393. echo "$p"
  394. echo "size:${fssize:-unknown};fstype:$(get_partfs "$p")"
  395. fi
  396. done
  397. # cciss(4) devices
  398. for part in $(ls /dev/cciss 2>/dev/null|grep -E 'c[0-9]d[0-9]p[0-9]+'); do
  399. fstype=$(lsblk -nfr /dev/cciss/$part|awk '{print $2}')
  400. [ "$fstype" = "crypto_LUKS" ] && continue
  401. [ "$fstype" = "LVM2_member" ] && continue
  402. fssize=$(lsblk -nr /dev/cciss/$part|awk '{print $4}')
  403. echo "/dev/cciss/$part"
  404. echo "size:${fssize:-unknown};fstype:$(get_partfs "/dev/cciss/$part")"
  405. done
  406. if [ -e /sbin/lvs ]; then
  407. # LVM
  408. lvs --noheadings|while read lvname vgname perms size; do
  409. echo "/dev/mapper/${vgname}-${lvname}"
  410. echo "size:${size};fstype:$(get_partfs "/dev/mapper/${vgname}-${lvname}" lvm)"
  411. done
  412. fi
  413. }
  414. menu_filesystems() {
  415. local dev fstype fssize mntpoint reformat
  416. while true; do
  417. DIALOG --ok-label "Change" --cancel-label "Done" \
  418. --title " Select the partition to edit " --menu "$MENULABEL" \
  419. ${MENUSIZE} $(show_partitions)
  420. [ $? -ne 0 ] && return
  421. dev=$(cat $ANSWER)
  422. DIALOG --title " Select the filesystem type for $dev " \
  423. --menu "$MENULABEL" ${MENUSIZE} \
  424. "btrfs" "Oracle's Btrfs" \
  425. "ext2" "Linux ext2 (no journaling)" \
  426. "ext3" "Linux ext3 (journal)" \
  427. "ext4" "Linux ext4 (journal)" \
  428. "f2fs" "Flash-Friendly Filesystem" \
  429. "swap" "Linux swap" \
  430. "vfat" "FAT32" \
  431. "xfs" "SGI's XFS"
  432. if [ $? -eq 0 ]; then
  433. fstype=$(cat $ANSWER)
  434. else
  435. continue
  436. fi
  437. if [ "$fstype" != "swap" ]; then
  438. DIALOG --inputbox "Please specify the mount point for $dev:" ${INPUTSIZE}
  439. if [ $? -eq 0 ]; then
  440. mntpoint=$(cat $ANSWER)
  441. elif [ $? -eq 1 ]; then
  442. continue
  443. fi
  444. else
  445. mntpoint=swap
  446. fi
  447. DIALOG --yesno "Do you want to create a new filesystem on $dev?" ${YESNOSIZE}
  448. if [ $? -eq 0 ]; then
  449. reformat=1
  450. elif [ $? -eq 1 ]; then
  451. reformat=0
  452. else
  453. continue
  454. fi
  455. fssize=$(lsblk -nr $dev|awk '{print $4}')
  456. set -- "$fstype" "$fssize" "$mntpoint" "$reformat"
  457. if [ -n "$1" -a -n "$2" -a -n "$3" -a -n "$4" ]; then
  458. local bdev=$(basename $dev)
  459. local ddev=$(basename $(dirname $dev))
  460. if [ "$ddev" != "dev" ]; then
  461. sed -i -e "/^MOUNTPOINT \/dev\/${ddev}\/${bdev}.*/d" $CONF_FILE
  462. else
  463. sed -i -e "/^MOUNTPOINT \/dev\/${bdev}.*/d" $CONF_FILE
  464. fi
  465. echo "MOUNTPOINT $dev $1 $2 $3 $4" >>$CONF_FILE
  466. fi
  467. done
  468. FILESYSTEMS_DONE=1
  469. }
  470. menu_partitions() {
  471. DIALOG --title " Select the disk to partition " \
  472. --menu "$MENULABEL" ${MENUSIZE} $(show_disks)
  473. if [ $? -eq 0 ]; then
  474. local device=$(cat $ANSWER)
  475. DIALOG --title " Select the software for partitioning " \
  476. --menu "$MENULABEL" ${MENUSIZE} \
  477. "cfdisk" "Easy to use" \
  478. "fdisk" "More advanced"
  479. if [ $? -eq 0 ]; then
  480. local software=$(cat $ANSWER)
  481. DIALOG --title "Modify Partition Table on $device" --msgbox "\n
  482. ${BOLD}${software} will be executed in disk $device.${RESET}\n\n
  483. For BIOS systems, MBR or GPT partition tables are supported. To use GPT\n
  484. on PC BIOS systems, an empty partition of 1MB must be added at the first\n
  485. 2GB of the disk with the partition type \`BIOS Boot'.\n
  486. ${BOLD}NOTE: you don't need this on EFI systems.${RESET}\n\n
  487. For EFI systems, GPT is mandatory and a FAT32 partition with at least 100MB\n
  488. must be created with the partition type \`EFI System'. This will be used as\n
  489. the EFI System Partition. This partition must have the mountpoint \`/boot/efi'.\n\n
  490. At least 1 partition is required for the rootfs (/). For this partition,\n
  491. at least 2GB is required, but more is recommended. The rootfs partition\n
  492. should have the partition type \`Linux Filesystem'. For swap, RAM*2\n
  493. should be enough and the partition type \`Linux swap' should be used.\n\n
  494. ${BOLD}WARNING: /usr is not supported as a separate partition.${RESET}\n
  495. ${RESET}\n" 23 80
  496. if [ $? -eq 0 ]; then
  497. while true; do
  498. clear; $software $device; PARTITIONS_DONE=1
  499. break
  500. done
  501. else
  502. return
  503. fi
  504. fi
  505. fi
  506. }
  507. menu_keymap() {
  508. local _keymaps="$(find /usr/share/kbd/keymaps/ -type f -iname "*.map.gz" -printf "%f\n" | sed 's|.map.gz||g' | sort)"
  509. local _KEYMAPS=
  510. for f in ${_keymaps}; do
  511. _KEYMAPS="${_KEYMAPS} ${f} -"
  512. done
  513. while true; do
  514. DIALOG --title " Select your keymap " --menu "$MENULABEL" 14 70 14 ${_KEYMAPS}
  515. if [ $? -eq 0 ]; then
  516. set_option KEYMAP "$(cat $ANSWER)"
  517. loadkeys "$(cat $ANSWER)"
  518. KEYBOARD_DONE=1
  519. break
  520. else
  521. return
  522. fi
  523. done
  524. }
  525. set_keymap() {
  526. local KEYMAP=$(get_option KEYMAP)
  527. if [ -f /etc/vconsole.conf ]; then
  528. sed -i -e "s|KEYMAP=.*|KEYMAP=$KEYMAP|g" $TARGETDIR/etc/vconsole.conf
  529. else
  530. sed -i -e "s|#\?KEYMAP=.*|KEYMAP=$KEYMAP|g" $TARGETDIR/etc/rc.conf
  531. fi
  532. }
  533. menu_locale() {
  534. local _locales="$(grep -E '\.UTF-8' /etc/default/libc-locales|awk '{print $1}'|sed -e 's/^#//')"
  535. local LOCALES ISO639 ISO3166
  536. local TMPFILE=$(mktemp -t vinstall-XXXXXXXX || exit 1)
  537. INFOBOX "Scanning locales ..." 4 60
  538. for f in ${_locales}; do
  539. eval $(echo $f | awk 'BEGIN { FS="." } \
  540. { FS="_"; split($1, a); printf "ISO639=%s ISO3166=%s\n", a[1], a[2] }')
  541. echo "$f|$(iso639_language $ISO639) ($(iso3166_country $ISO3166))|" >> $TMPFILE
  542. done
  543. clear
  544. # Sort by ISO-639 language names
  545. LOCALES=$(sort -t '|' -k 2 < $TMPFILE | xargs | sed -e's/| /|/g')
  546. rm -f $TMPFILE
  547. while true; do
  548. (IFS="|"; DIALOG --title " Select your locale " --menu "$MENULABEL" 18 70 18 ${LOCALES})
  549. if [ $? -eq 0 ]; then
  550. set_option LOCALE "$(cat $ANSWER)"
  551. LOCALE_DONE=1
  552. break
  553. else
  554. return
  555. fi
  556. done
  557. }
  558. set_locale() {
  559. if [ -f $TARGETDIR/etc/default/libc-locales ]; then
  560. local LOCALE="$(get_option LOCALE)"
  561. : "${LOCALE:=C.UTF-8}"
  562. sed -i -e "s|LANG=.*|LANG=$LOCALE|g" $TARGETDIR/etc/locale.conf
  563. # Uncomment locale from /etc/default/libc-locales and regenerate it.
  564. sed -e "/${LOCALE}/s/^\#//" -i $TARGETDIR/etc/default/libc-locales
  565. echo "Running xbps-reconfigure -f glibc-locales ..." >$LOG
  566. chroot $TARGETDIR xbps-reconfigure -f glibc-locales >$LOG 2>&1
  567. fi
  568. }
  569. menu_timezone() {
  570. local areas=(Africa America Antarctica Arctic Asia Atlantic Australia Europe Indian Pacific)
  571. local area locations location
  572. while (IFS='|'; DIALOG ${area:+--default-item|"$area"} --title " Select area " --menu "$MENULABEL" 19 51 19 $(printf '%s||' "${areas[@]}")); do
  573. area=$(cat $ANSWER)
  574. read -a locations -d '\n' < <(find /usr/share/zoneinfo/$area -type f -printf '%P\n' | sort)
  575. if (IFS='|'; DIALOG --title " Select location (${area}) " --menu "$MENULABEL" 19 51 19 $(printf '%s||' "${locations[@]//_/ }")); then
  576. location=$(tr ' ' '_' < $ANSWER)
  577. set_option TIMEZONE "$area/$location"
  578. TIMEZONE_DONE=1
  579. return 0
  580. else
  581. continue
  582. fi
  583. done
  584. return 1
  585. }
  586. set_timezone() {
  587. local TIMEZONE="$(get_option TIMEZONE)"
  588. ln -sf "/usr/share/zoneinfo/${TIMEZONE}" "${TARGETDIR}/etc/localtime"
  589. }
  590. menu_hostname() {
  591. while true; do
  592. DIALOG --inputbox "Set the machine hostname:" ${INPUTSIZE}
  593. if [ $? -eq 0 ]; then
  594. set_option HOSTNAME "$(cat $ANSWER)"
  595. HOSTNAME_DONE=1
  596. break
  597. else
  598. return
  599. fi
  600. done
  601. }
  602. set_hostname() {
  603. local hostname="$(get_option HOSTNAME)"
  604. echo "${hostname:-void}" > $TARGETDIR/etc/hostname
  605. }
  606. menu_rootpassword() {
  607. local _firstpass _secondpass _again _desc
  608. while true; do
  609. if [ -z "${_firstpass}" ]; then
  610. _desc="Enter the root password"
  611. else
  612. _again=" again"
  613. fi
  614. DIALOG --insecure --passwordbox "${_desc}${_again}" ${INPUTSIZE}
  615. if [ $? -eq 0 ]; then
  616. if [ -z "${_firstpass}" ]; then
  617. _firstpass="$(cat $ANSWER)"
  618. else
  619. _secondpass="$(cat $ANSWER)"
  620. fi
  621. if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
  622. if [ "${_firstpass}" != "${_secondpass}" ]; then
  623. INFOBOX "Passwords do not match! Please enter again." 6 60
  624. unset _firstpass _secondpass _again
  625. sleep 2 && clear && continue
  626. fi
  627. set_option ROOTPASSWORD "${_firstpass}"
  628. ROOTPASSWORD_DONE=1
  629. break
  630. fi
  631. else
  632. return
  633. fi
  634. done
  635. }
  636. set_rootpassword() {
  637. echo "root:$(get_option ROOTPASSWORD)" | chroot $TARGETDIR chpasswd -c SHA512
  638. }
  639. menu_useraccount() {
  640. local _firstpass _secondpass _desc _again
  641. local _groups _status _group _checklist
  642. local _preset _userlogin
  643. while true; do
  644. _preset=$(get_option USERLOGIN)
  645. [ -z "$_preset" ] && _preset="void"
  646. DIALOG --inputbox "Enter a primary login name:" ${INPUTSIZE} "$_preset"
  647. if [ $? -eq 0 ]; then
  648. _userlogin="$(cat $ANSWER)"
  649. # based on useradd(8) § Caveats
  650. if [ "${#_userlogin}" -le 32 ] && [[ "${_userlogin}" =~ ^[a-z_][a-z0-9_-]*[$]?$ ]]; then
  651. set_option USERLOGIN "${_userlogin}"
  652. USERLOGIN_DONE=1
  653. break
  654. else
  655. INFOBOX "Invalid login name! Please try again." 6 60
  656. unset _userlogin
  657. sleep 2 && clear && continue
  658. fi
  659. else
  660. return
  661. fi
  662. done
  663. while true; do
  664. _preset=$(get_option USERNAME)
  665. [ -z "$_preset" ] && _preset="Void User"
  666. DIALOG --inputbox "Enter a display name for login '$(get_option USERLOGIN)' :" \
  667. ${INPUTSIZE} "$_preset"
  668. if [ $? -eq 0 ]; then
  669. set_option USERNAME "$(cat $ANSWER)"
  670. USERNAME_DONE=1
  671. break
  672. else
  673. return
  674. fi
  675. done
  676. while true; do
  677. if [ -z "${_firstpass}" ]; then
  678. _desc="Enter the password for login '$(get_option USERLOGIN)'"
  679. else
  680. _again=" again"
  681. fi
  682. DIALOG --insecure --passwordbox "${_desc}${_again}" ${INPUTSIZE}
  683. if [ $? -eq 0 ]; then
  684. if [ -z "${_firstpass}" ]; then
  685. _firstpass="$(cat $ANSWER)"
  686. else
  687. _secondpass="$(cat $ANSWER)"
  688. fi
  689. if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
  690. if [ "${_firstpass}" != "${_secondpass}" ]; then
  691. INFOBOX "Passwords do not match! Please enter again." 6 60
  692. unset _firstpass _secondpass _again
  693. sleep 2 && clear && continue
  694. fi
  695. set_option USERPASSWORD "${_firstpass}"
  696. USERPASSWORD_DONE=1
  697. break
  698. fi
  699. else
  700. return
  701. fi
  702. done
  703. _groups="wheel,audio,video,floppy,cdrom,optical,kvm,users,xbuilder"
  704. while true; do
  705. _desc="Select group membership for login '$(get_option USERLOGIN)':"
  706. for _group in $(cat /etc/group); do
  707. _gid="$(echo ${_group} | cut -d: -f3)"
  708. _group="$(echo ${_group} | cut -d: -f1)"
  709. _status="$(echo ${_groups} | grep -w ${_group})"
  710. if [ -z "${_status}" ]; then
  711. _status=off
  712. else
  713. _status=on
  714. fi
  715. # ignore the groups of root, existing users, and package groups
  716. if [[ "${_gid}" -ge 1000 || "${_group}" = "_"* || "${_group}" =~ ^(root|nogroup|chrony|dbus|lightdm|polkitd)$ ]]; then
  717. continue
  718. fi
  719. if [ -z "${_checklist}" ]; then
  720. _checklist="${_group} ${_group}:${_gid} ${_status}"
  721. else
  722. _checklist="${_checklist} ${_group} ${_group}:${_gid} ${_status}"
  723. fi
  724. done
  725. DIALOG --no-tags --checklist "${_desc}" 20 60 18 ${_checklist}
  726. if [ $? -eq 0 ]; then
  727. set_option USERGROUPS $(cat $ANSWER | sed -e's| |,|g')
  728. USERGROUPS_DONE=1
  729. break
  730. else
  731. return
  732. fi
  733. done
  734. }
  735. set_useraccount() {
  736. [ -z "$USERACCOUNT_DONE" ] && return
  737. chroot $TARGETDIR useradd -m -G "$(get_option USERGROUPS)" \
  738. -c "$(get_option USERNAME)" "$(get_option USERLOGIN)"
  739. echo "$(get_option USERLOGIN):$(get_option USERPASSWORD)" | \
  740. chroot $TARGETDIR chpasswd -c SHA512
  741. }
  742. menu_bootloader() {
  743. while true; do
  744. DIALOG --title " Select the disk to install the bootloader" \
  745. --menu "$MENULABEL" ${MENUSIZE} $(show_disks) none "Manage bootloader otherwise"
  746. if [ $? -eq 0 ]; then
  747. set_option BOOTLOADER "$(cat $ANSWER)"
  748. BOOTLOADER_DONE=1
  749. break
  750. else
  751. return
  752. fi
  753. done
  754. while true; do
  755. DIALOG --yesno "Use a graphical terminal for the boot loader?" ${YESNOSIZE}
  756. if [ $? -eq 0 ]; then
  757. set_option TEXTCONSOLE 0
  758. break
  759. elif [ $? -eq 1 ]; then
  760. set_option TEXTCONSOLE 1
  761. break
  762. else
  763. return
  764. fi
  765. done
  766. }
  767. set_bootloader() {
  768. local dev=$(get_option BOOTLOADER) grub_args=
  769. if [ "$dev" = "none" ]; then return; fi
  770. # Check if it's an EFI system via efivars module.
  771. if [ -n "$EFI_SYSTEM" ]; then
  772. grub_args="--target=$EFI_TARGET --efi-directory=/boot/efi --bootloader-id=void_grub --recheck"
  773. fi
  774. echo "Running grub-install $grub_args $dev..." >$LOG
  775. chroot $TARGETDIR grub-install $grub_args $dev >$LOG 2>&1
  776. if [ $? -ne 0 ]; then
  777. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  778. failed to install GRUB to $dev!\nCheck $LOG for errors." ${MSGBOXSIZE}
  779. DIE 1
  780. fi
  781. echo "Running grub-mkconfig on $TARGETDIR..." >$LOG
  782. chroot $TARGETDIR grub-mkconfig -o /boot/grub/grub.cfg >$LOG 2>&1
  783. if [ $? -ne 0 ]; then
  784. DIALOG --msgbox "${BOLD}${RED}ERROR${RESET}: \
  785. failed to run grub-mkconfig!\nCheck $LOG for errors." ${MSGBOXSIZE}
  786. DIE 1
  787. fi
  788. }
  789. test_network() {
  790. # Reset the global variable to ensure that network is accessible for this test.
  791. NETWORK_DONE=
  792. rm -f otime && \
  793. xbps-uhelper fetch https://repo-default.voidlinux.org/current/otime >$LOG 2>&1
  794. local status=$?
  795. rm -f otime
  796. if [ "$status" -eq 0 ]; then
  797. DIALOG --msgbox "Network is working properly!" ${MSGBOXSIZE}
  798. NETWORK_DONE=1
  799. return 1
  800. fi
  801. if [ "$1" = "nm" ]; then
  802. 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}
  803. else
  804. DIALOG --msgbox "Network is inaccessible, please set it up properly." ${MSGBOXSIZE}
  805. fi
  806. }
  807. configure_wifi() {
  808. local dev="$1" ssid enc pass _wpasupconf=/etc/wpa_supplicant/wpa_supplicant.conf
  809. DIALOG --form "Wireless configuration for ${dev}\n(encryption type: wep or wpa)" 0 0 0 \
  810. "SSID:" 1 1 "" 1 16 30 0 \
  811. "Encryption:" 2 1 "" 2 16 4 3 \
  812. "Password:" 3 1 "" 3 16 63 0 || return 1
  813. readarray -t values <<<$(cat $ANSWER)
  814. ssid="${values[0]}"; enc="${values[1]}"; pass="${values[2]}"
  815. if [ -z "$ssid" ]; then
  816. DIALOG --msgbox "Invalid SSID." ${MSGBOXSIZE}
  817. return 1
  818. elif [ -z "$enc" -o "$enc" != "wep" -a "$enc" != "wpa" ]; then
  819. DIALOG --msgbox "Invalid encryption type (possible values: wep or wpa)." ${MSGBOXSIZE}
  820. return 1
  821. elif [ -z "$pass" ]; then
  822. DIALOG --msgbox "Invalid AP password." ${MSGBOXSIZE}
  823. fi
  824. # reset the configuration to the default, if necessary
  825. # otherwise backup the configuration
  826. if [ -f ${_wpasupconf}.orig ]; then
  827. cp -f ${_wpasupconf}.orig ${_wpasupconf}
  828. else
  829. cp -f ${_wpasupconf} ${_wpasupconf}.orig
  830. fi
  831. if [ "$enc" = "wep" ]; then
  832. cat << EOF >> ${_wpasupconf}
  833. network={
  834. ssid="$ssid"
  835. wep_key0="$pass"
  836. wep_tx_keyidx=0
  837. auth_alg=SHARED
  838. }
  839. EOF
  840. else
  841. wpa_passphrase "$ssid" "$pass" >> ${_wpasupconf}
  842. fi
  843. sv restart wpa_supplicant
  844. configure_net_dhcp $dev
  845. return $?
  846. }
  847. configure_net() {
  848. local dev="$1" rval
  849. DIALOG --yesno "Do you want to use DHCP for $dev?" ${YESNOSIZE}
  850. rval=$?
  851. if [ $rval -eq 0 ]; then
  852. configure_net_dhcp $dev
  853. elif [ $rval -eq 1 ]; then
  854. configure_net_static $dev
  855. fi
  856. }
  857. iface_setup() {
  858. ip addr show dev $1 | grep -q -e 'inet ' -e 'inet6 '
  859. return $?
  860. }
  861. configure_net_dhcp() {
  862. local dev="$1"
  863. iface_setup $dev
  864. if [ $? -eq 1 ]; then
  865. sv restart dhcpcd 2>&1 | tee $LOG | \
  866. DIALOG --progressbox "Initializing $dev via DHCP..." ${WIDGET_SIZE}
  867. if [ $? -ne 0 ]; then
  868. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} failed to run dhcpcd. See $LOG for details." ${MSGBOXSIZE}
  869. return 1
  870. fi
  871. export -f iface_setup
  872. timeout 10s bash -c "while true; do iface_setup $dev; sleep 0.25; done"
  873. if [ $? -eq 1 ]; then
  874. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} DHCP request failed for $dev. Check $LOG for errors." ${MSGBOXSIZE}
  875. return 1
  876. fi
  877. fi
  878. test_network
  879. if [ $? -eq 1 ]; then
  880. set_option NETWORK "${dev} dhcp"
  881. fi
  882. }
  883. configure_net_static() {
  884. local ip gw dns1 dns2 dev=$1
  885. DIALOG --form "Static IP configuration for $dev:" 0 0 0 \
  886. "IP address:" 1 1 "192.168.0.2" 1 21 20 0 \
  887. "Gateway:" 2 1 "192.168.0.1" 2 21 20 0 \
  888. "DNS Primary" 3 1 "8.8.8.8" 3 21 20 0 \
  889. "DNS Secondary" 4 1 "8.8.4.4" 4 21 20 0 || return 1
  890. set -- $(cat $ANSWER)
  891. ip=$1; gw=$2; dns1=$3; dns2=$4
  892. echo "running: ip link set dev $dev up" >$LOG
  893. ip link set dev $dev up >$LOG 2>&1
  894. if [ $? -ne 0 ]; then
  895. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} Failed to bring $dev interface." ${MSGBOXSIZE}
  896. return 1
  897. fi
  898. echo "running: ip addr add $ip dev $dev" >$LOG
  899. ip addr add $ip dev $dev >$LOG 2>&1
  900. if [ $? -ne 0 ]; then
  901. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} Failed to set ip to the $dev interface." ${MSGBOXSIZE}
  902. return 1
  903. fi
  904. ip route add default via $gw >$LOG 2>&1
  905. if [ $? -ne 0 ]; then
  906. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} failed to setup your gateway." ${MSGBOXSIZE}
  907. return 1
  908. fi
  909. echo "nameserver $dns1" >/etc/resolv.conf
  910. echo "nameserver $dns2" >>/etc/resolv.conf
  911. test_network
  912. if [ $? -eq 1 ]; then
  913. set_option NETWORK "${dev} static $ip $gw $dns1 $dns2"
  914. fi
  915. }
  916. menu_network() {
  917. local dev addr f DEVICES
  918. if [ -e /var/service/NetworkManager ]; then
  919. test_network nm
  920. return
  921. fi
  922. for f in $(ls /sys/class/net); do
  923. [ "$f" = "lo" ] && continue
  924. addr=$(cat /sys/class/net/$f/address)
  925. DEVICES="$DEVICES $f $addr"
  926. done
  927. DIALOG --title " Select the network interface to configure " \
  928. --menu "$MENULABEL" ${MENUSIZE} ${DEVICES}
  929. if [ $? -eq 0 ]; then
  930. dev=$(cat $ANSWER)
  931. if $(echo $dev|egrep -q "^wl.*" 2>/dev/null); then
  932. configure_wifi $dev
  933. else
  934. configure_net $dev
  935. fi
  936. fi
  937. }
  938. validate_useraccount() {
  939. # don't check that USERNAME has been set because it can be empty
  940. local USERLOGIN=$(get_option USERLOGIN)
  941. local USERPASSWORD=$(get_option USERPASSWORD)
  942. local USERGROUPS=$(get_option USERGROUPS)
  943. if [ -n "$USERLOGIN" ] && [ -n "$USERPASSWORD" ] && [ -n "$USERGROUPS" ]; then
  944. USERACCOUNT_DONE=1
  945. fi
  946. }
  947. validate_filesystems() {
  948. local mnts dev size fstype mntpt mkfs rootfound fmt
  949. local usrfound efi_system_partition
  950. local bootdev=$(get_option BOOTLOADER)
  951. unset TARGETFS
  952. mnts=$(grep -E '^MOUNTPOINT.*' $CONF_FILE)
  953. set -- ${mnts}
  954. while [ $# -ne 0 ]; do
  955. fmt=""
  956. dev=$2; fstype=$3; size=$4; mntpt="$5"; mkfs=$6
  957. shift 6
  958. if [ "$mntpt" = "/" ]; then
  959. rootfound=1
  960. elif [ "$mntpt" = "/usr" ]; then
  961. usrfound=1
  962. elif [ "$fstype" = "vfat" -a "$mntpt" = "/boot/efi" ]; then
  963. efi_system_partition=1
  964. fi
  965. if [ "$mkfs" -eq 1 ]; then
  966. fmt="NEW FILESYSTEM: "
  967. fi
  968. if [ -z "$TARGETFS" ]; then
  969. TARGETFS="${fmt}$dev ($size) mounted on $mntpt as ${fstype}\n"
  970. else
  971. TARGETFS="${TARGETFS}${fmt}${dev} ($size) mounted on $mntpt as ${fstype}\n"
  972. fi
  973. done
  974. if [ -z "$rootfound" ]; then
  975. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  976. the mount point for the root filesystem (/) has not yet been configured." ${MSGBOXSIZE}
  977. return 1
  978. elif [ -n "$usrfound" ]; then
  979. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  980. /usr mount point has been configured but is not supported, please remove it to continue." ${MSGBOXSIZE}
  981. return 1
  982. elif [ -n "$EFI_SYSTEM" -a "$bootdev" != "none" -a -z "$efi_system_partition" ]; then
  983. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  984. The EFI System Partition has not yet been configured, please create it\n
  985. as FAT32, mountpoint /boot/efi and at least with 100MB of size." ${MSGBOXSIZE}
  986. return 1
  987. fi
  988. FILESYSTEMS_DONE=1
  989. }
  990. create_filesystems() {
  991. local mnts dev mntpt fstype fspassno mkfs size rv uuid
  992. mnts=$(grep -E '^MOUNTPOINT.*' $CONF_FILE | sort -k 5)
  993. set -- ${mnts}
  994. while [ $# -ne 0 ]; do
  995. dev=$2; fstype=$3; mntpt="$5"; mkfs=$6
  996. shift 6
  997. # swap partitions
  998. if [ "$fstype" = "swap" ]; then
  999. swapoff $dev >/dev/null 2>&1
  1000. if [ "$mkfs" -eq 1 ]; then
  1001. mkswap $dev >$LOG 2>&1
  1002. if [ $? -ne 0 ]; then
  1003. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  1004. failed to create swap on ${dev}!\ncheck $LOG for errors." ${MSGBOXSIZE}
  1005. DIE 1
  1006. fi
  1007. fi
  1008. swapon $dev >$LOG 2>&1
  1009. if [ $? -ne 0 ]; then
  1010. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  1011. failed to activate swap on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE}
  1012. DIE 1
  1013. fi
  1014. # Add entry for target fstab
  1015. uuid=$(blkid -o value -s UUID "$dev")
  1016. echo "UUID=$uuid none swap defaults 0 0" >>$TARGET_FSTAB
  1017. continue
  1018. fi
  1019. if [ "$mkfs" -eq 1 ]; then
  1020. case "$fstype" in
  1021. btrfs) MKFS="mkfs.btrfs -f"; modprobe btrfs >$LOG 2>&1;;
  1022. ext2) MKFS="mke2fs -F"; modprobe ext2 >$LOG 2>&1;;
  1023. ext3) MKFS="mke2fs -F -j"; modprobe ext3 >$LOG 2>&1;;
  1024. ext4) MKFS="mke2fs -F -t ext4"; modprobe ext4 >$LOG 2>&1;;
  1025. f2fs) MKFS="mkfs.f2fs -f"; modprobe f2fs >$LOG 2>&1;;
  1026. vfat) MKFS="mkfs.vfat -F32"; modprobe vfat >$LOG 2>&1;;
  1027. xfs) MKFS="mkfs.xfs -f -i sparse=0"; modprobe xfs >$LOG 2>&1;;
  1028. esac
  1029. TITLE="Check $LOG for details ..."
  1030. INFOBOX "Creating filesystem $fstype on $dev for $mntpt ..." 8 60
  1031. echo "Running $MKFS $dev..." >$LOG
  1032. $MKFS $dev >$LOG 2>&1; rv=$?
  1033. if [ $rv -ne 0 ]; then
  1034. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  1035. failed to create filesystem $fstype on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE}
  1036. DIE 1
  1037. fi
  1038. fi
  1039. # Mount rootfs the first one.
  1040. [ "$mntpt" != "/" ] && continue
  1041. mkdir -p $TARGETDIR
  1042. echo "Mounting $dev on $mntpt ($fstype)..." >$LOG
  1043. mount -t $fstype $dev $TARGETDIR >$LOG 2>&1
  1044. if [ $? -ne 0 ]; then
  1045. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  1046. failed to mount $dev on ${mntpt}! check $LOG for errors." ${MSGBOXSIZE}
  1047. DIE 1
  1048. fi
  1049. # Add entry to target fstab
  1050. uuid=$(blkid -o value -s UUID "$dev")
  1051. if [ "$fstype" = "f2fs" -o "$fstype" = "btrfs" -o "$fstype" = "xfs" ]; then
  1052. fspassno=0
  1053. else
  1054. fspassno=1
  1055. fi
  1056. echo "UUID=$uuid $mntpt $fstype defaults 0 $fspassno" >>$TARGET_FSTAB
  1057. done
  1058. # mount all filesystems in target rootfs
  1059. mnts=$(grep -E '^MOUNTPOINT.*' $CONF_FILE | sort -k 5)
  1060. set -- ${mnts}
  1061. while [ $# -ne 0 ]; do
  1062. dev=$2; fstype=$3; mntpt="$5"
  1063. shift 6
  1064. [ "$mntpt" = "/" -o "$fstype" = "swap" ] && continue
  1065. mkdir -p ${TARGETDIR}${mntpt}
  1066. echo "Mounting $dev on $mntpt ($fstype)..." >$LOG
  1067. mount -t $fstype $dev ${TARGETDIR}${mntpt} >$LOG 2>&1
  1068. if [ $? -ne 0 ]; then
  1069. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  1070. failed to mount $dev on $mntpt! check $LOG for errors." ${MSGBOXSIZE}
  1071. DIE
  1072. fi
  1073. # Add entry to target fstab
  1074. uuid=$(blkid -o value -s UUID "$dev")
  1075. if [ "$fstype" = "f2fs" -o "$fstype" = "btrfs" -o "$fstype" = "xfs" ]; then
  1076. fspassno=0
  1077. else
  1078. fspassno=2
  1079. fi
  1080. echo "UUID=$uuid $mntpt $fstype defaults 0 $fspassno" >>$TARGET_FSTAB
  1081. done
  1082. }
  1083. mount_filesystems() {
  1084. for f in sys proc dev; do
  1085. [ ! -d $TARGETDIR/$f ] && mkdir $TARGETDIR/$f
  1086. echo "Mounting $TARGETDIR/$f..." >$LOG
  1087. mount --rbind /$f $TARGETDIR/$f >$LOG 2>&1
  1088. done
  1089. }
  1090. umount_filesystems() {
  1091. local mnts="$(grep -E '^MOUNTPOINT.*swap.*$' $CONF_FILE | sort -r -k 5)"
  1092. set -- ${mnts}
  1093. while [ $# -ne 0 ]; do
  1094. local dev=$2; local fstype=$3
  1095. shift 6
  1096. if [ "$fstype" = "swap" ]; then
  1097. echo "Disabling swap space on $dev..." >$LOG
  1098. swapoff $dev >$LOG 2>&1
  1099. continue
  1100. fi
  1101. done
  1102. echo "Unmounting $TARGETDIR..." >$LOG
  1103. umount -R $TARGETDIR >$LOG 2>&1
  1104. }
  1105. log_and_count() {
  1106. local progress whole tenth
  1107. while read line; do
  1108. echo "$line" >$LOG
  1109. copy_count=$((copy_count + 1))
  1110. progress=$((1000 * copy_count / copy_total))
  1111. if [ "$progress" != "$copy_progress" ]; then
  1112. whole=$((progress / 10))
  1113. tenth=$((progress % 10))
  1114. printf "Progress: %d.%d%% (%d of %d files)\n" $whole $tenth $copy_count $copy_total
  1115. copy_progress=$progress
  1116. fi
  1117. done
  1118. }
  1119. copy_rootfs() {
  1120. local tar_in="--create --one-file-system --xattrs"
  1121. TITLE="Check $LOG for details ..."
  1122. INFOBOX "Counting files, please be patient ..." 4 60
  1123. copy_total=$(tar ${tar_in} -v -f /dev/null / 2>/dev/null | wc -l)
  1124. export copy_total copy_count=0 copy_progress=
  1125. clear
  1126. tar ${tar_in} -f - / 2>/dev/null | \
  1127. tar --extract --xattrs --xattrs-include='*' --preserve-permissions -v -f - -C $TARGETDIR | \
  1128. log_and_count | \
  1129. DIALOG --title "${TITLE}" \
  1130. --progressbox "Copying live image to target rootfs." 5 60
  1131. if [ $? -ne 0 ]; then
  1132. DIE 1
  1133. fi
  1134. unset copy_total copy_count copy_percent
  1135. }
  1136. install_packages() {
  1137. local _grub= _syspkg=
  1138. if [ "$(get_option BOOTLOADER)" != none ]; then
  1139. if [ -n "$EFI_SYSTEM" ]; then
  1140. if [ $EFI_FW_BITS -eq 32 ]; then
  1141. _grub="grub-i386-efi"
  1142. else
  1143. _grub="grub-x86_64-efi"
  1144. fi
  1145. else
  1146. _grub="grub"
  1147. fi
  1148. fi
  1149. _syspkg="base-system"
  1150. mkdir -p $TARGETDIR/var/db/xbps/keys $TARGETDIR/usr/share
  1151. cp -a /usr/share/xbps.d $TARGETDIR/usr/share/
  1152. cp /var/db/xbps/keys/*.plist $TARGETDIR/var/db/xbps/keys
  1153. if [ -n "$MIRROR_DONE" ]; then
  1154. mkdir -p $TARGETDIR/etc
  1155. cp -a /etc/xbps.d $TARGETDIR/etc
  1156. fi
  1157. mkdir -p $TARGETDIR/boot/grub
  1158. _arch=$(xbps-uhelper arch)
  1159. stdbuf -oL env XBPS_ARCH=${_arch} \
  1160. xbps-install -r $TARGETDIR -SyU ${_syspkg} ${_grub} 2>&1 | \
  1161. DIALOG --title "Installing base system packages..." \
  1162. --programbox 24 80
  1163. if [ $? -ne 0 ]; then
  1164. DIE 1
  1165. fi
  1166. xbps-reconfigure -r $TARGETDIR -f base-files >/dev/null 2>&1
  1167. chroot $TARGETDIR xbps-reconfigure -a
  1168. }
  1169. enable_service() {
  1170. ln -sf /etc/sv/$1 $TARGETDIR/etc/runit/runsvdir/default/$1
  1171. }
  1172. menu_install() {
  1173. ROOTPASSWORD_DONE="$(get_option ROOTPASSWORD)"
  1174. BOOTLOADER_DONE="$(get_option BOOTLOADER)"
  1175. if [ -z "$ROOTPASSWORD_DONE" ]; then
  1176. DIALOG --msgbox "${BOLD}The root password has not been configured, \
  1177. please do so before starting the installation.${RESET}" ${MSGBOXSIZE}
  1178. return 1
  1179. elif [ -z "$BOOTLOADER_DONE" ]; then
  1180. DIALOG --msgbox "${BOLD}The disk to install the bootloader has not been \
  1181. configured, please do so before starting the installation.${RESET}" ${MSGBOXSIZE}
  1182. return 1
  1183. fi
  1184. # Validate filesystems after making sure bootloader is done,
  1185. # so that specific checks can be made based on the selection
  1186. validate_filesystems || return 1
  1187. if [ -z "$FILESYSTEMS_DONE" ]; then
  1188. DIALOG --msgbox "${BOLD}Required filesystems were not configured, \
  1189. please do so before starting the installation.${RESET}" ${MSGBOXSIZE}
  1190. return 1
  1191. fi
  1192. # Validate useraccount. All parameters must be set (name, password, login name, groups).
  1193. validate_useraccount
  1194. if [ -z "$USERACCOUNT_DONE" ]; then
  1195. DIALOG --yesno "${BOLD}The user account is not set up properly.${RESET}\n\n
  1196. ${BOLD}${RED}WARNING: no user will be created. You will only be able to login \
  1197. with the root user in your new system.${RESET}\n\n
  1198. ${BOLD}Do you want to continue?${RESET}" 10 60 || return
  1199. fi
  1200. DIALOG --yesno "${BOLD}The following operations will be executed:${RESET}\n\n
  1201. ${BOLD}${TARGETFS}${RESET}\n
  1202. ${BOLD}${RED}WARNING: data on partitions will be COMPLETELY DESTROYED for new \
  1203. filesystems.${RESET}\n\n
  1204. ${BOLD}Do you want to continue?${RESET}" 20 80 || return
  1205. unset TARGETFS
  1206. # Create and mount filesystems
  1207. create_filesystems
  1208. SOURCE_DONE="$(get_option SOURCE)"
  1209. # If source not set use defaults.
  1210. if [ "$(get_option SOURCE)" = "local" -o -z "$SOURCE_DONE" ]; then
  1211. copy_rootfs
  1212. . /etc/default/live.conf
  1213. rm -f $TARGETDIR/etc/motd
  1214. rm -f $TARGETDIR/etc/issue
  1215. rm -f $TARGETDIR/usr/sbin/void-installer
  1216. # Remove modified sddm.conf to let sddm use the defaults.
  1217. rm -f $TARGETDIR/etc/sddm.conf
  1218. # Remove live user.
  1219. echo "Removing $USERNAME live user from targetdir ..." >$LOG
  1220. chroot $TARGETDIR userdel -r $USERNAME >$LOG 2>&1
  1221. rm -f $TARGETDIR/etc/sudoers.d/99-void-live
  1222. sed -i "s,GETTY_ARGS=\"--noclear -a $USERNAME\",GETTY_ARGS=\"--noclear\",g" $TARGETDIR/etc/sv/agetty-tty1/conf
  1223. TITLE="Check $LOG for details ..."
  1224. INFOBOX "Rebuilding initramfs for target ..." 4 60
  1225. echo "Rebuilding initramfs for target ..." >$LOG
  1226. # mount required fs
  1227. mount_filesystems
  1228. chroot $TARGETDIR dracut --no-hostonly --add-drivers "ahci" --force >>$LOG 2>&1
  1229. INFOBOX "Removing temporary packages from target ..." 4 60
  1230. echo "Removing temporary packages from target ..." >$LOG
  1231. TO_REMOVE="dialog xtools-minimal xmirror"
  1232. # only remove espeakup and brltty if it wasn't enabled in the live environment
  1233. if ! [ -e "/var/service/espeakup" ]; then
  1234. TO_REMOVE+=" espeakup"
  1235. fi
  1236. if ! [ -e "/var/service/brltty" ]; then
  1237. TO_REMOVE+=" brltty"
  1238. fi
  1239. if [ "$(get_option BOOTLOADER)" = none ]; then
  1240. TO_REMOVE+=" grub-x86_64-efi grub-i386-efi grub"
  1241. fi
  1242. # uninstall separately to minimise errors
  1243. for pkg in $TO_REMOVE; do
  1244. xbps-remove -r $TARGETDIR -Ry "$pkg" >>$LOG 2>&1
  1245. done
  1246. rmdir $TARGETDIR/mnt/target
  1247. else
  1248. # mount required fs
  1249. mount_filesystems
  1250. # network install, use packages.
  1251. install_packages
  1252. fi
  1253. INFOBOX "Applying installer settings..." 4 60
  1254. # copy target fstab.
  1255. install -Dm644 $TARGET_FSTAB $TARGETDIR/etc/fstab
  1256. # Mount /tmp as tmpfs.
  1257. echo "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0" >> $TARGETDIR/etc/fstab
  1258. # set up keymap, locale, timezone, hostname, root passwd and user account.
  1259. set_keymap
  1260. set_locale
  1261. set_timezone
  1262. set_hostname
  1263. set_rootpassword
  1264. set_useraccount
  1265. # Copy /etc/skel files for root.
  1266. cp $TARGETDIR/etc/skel/.[bix]* $TARGETDIR/root
  1267. NETWORK_DONE="$(get_option NETWORK)"
  1268. # network settings for target
  1269. if [ -n "$NETWORK_DONE" ]; then
  1270. local net="$(get_option NETWORK)"
  1271. set -- ${net}
  1272. local _dev="$1" _type="$2" _ip="$3" _gw="$4" _dns1="$5" _dns2="$6"
  1273. if [ -z "$_type" ]; then
  1274. # network type empty??!!!
  1275. :
  1276. elif [ "$_type" = "dhcp" ]; then
  1277. if $(echo $_dev|egrep -q "^wl.*" 2>/dev/null); then
  1278. cp /etc/wpa_supplicant/wpa_supplicant.conf $TARGETDIR/etc/wpa_supplicant
  1279. ln -sf /etc/sv/wpa_supplicant $TARGETDIR/etc/runit/runsvdir/default/wpa_supplicant
  1280. fi
  1281. enable_service dhcpcd
  1282. elif [ -n "$_dev" -a "$_type" = "static" ]; then
  1283. # static IP through dhcpcd.
  1284. mv $TARGETDIR/etc/dhcpcd.conf $TARGETDIR/etc/dhcpcd.conf.orig
  1285. echo "# Static IP configuration set by the void-installer for $_dev." \
  1286. >$TARGETDIR/etc/dhcpcd.conf
  1287. echo "interface $_dev" >>$TARGETDIR/etc/dhcpcd.conf
  1288. echo "static ip_address=$_ip" >>$TARGETDIR/etc/dhcpcd.conf
  1289. echo "static routers=$_gw" >>$TARGETDIR/etc/dhcpcd.conf
  1290. echo "static domain_name_servers=$_dns1 $_dns2" >>$TARGETDIR/etc/dhcpcd.conf
  1291. enable_service dhcpcd
  1292. fi
  1293. fi
  1294. if [ -d $TARGETDIR/etc/sudoers.d ]; then
  1295. USERLOGIN="$(get_option USERLOGIN)"
  1296. if [ -z "$(echo $(get_option USERGROUPS) | grep -w wheel)" -a -n "$USERLOGIN" ]; then
  1297. # enable sudo for primary user USERLOGIN who is not member of wheel
  1298. echo "# Enable sudo for login '$USERLOGIN'" > "$TARGETDIR/etc/sudoers.d/$USERLOGIN"
  1299. echo "$USERLOGIN ALL=(ALL:ALL) ALL" >> "$TARGETDIR/etc/sudoers.d/$USERLOGIN"
  1300. else
  1301. # enable the sudoers entry for members of group wheel
  1302. echo "%wheel ALL=(ALL:ALL) ALL" > "$TARGETDIR/etc/sudoers.d/wheel"
  1303. fi
  1304. unset USERLOGIN
  1305. fi
  1306. # clean up polkit rule - it's only useful in live systems
  1307. rm -f $TARGETDIR/etc/polkit-1/rules.d/void-live.rules
  1308. # enable text console for grub if chosen
  1309. if [ "$(get_option TEXTCONSOLE)" = "1" ]; then
  1310. sed -i $TARGETDIR/etc/default/grub \
  1311. -e 's|#\(GRUB_TERMINAL_INPUT\).*|\1=console|' \
  1312. -e 's|#\(GRUB_TERMINAL_OUTPUT\).*|\1=console|'
  1313. fi
  1314. # install bootloader.
  1315. set_bootloader
  1316. sync && sync && sync
  1317. # unmount all filesystems.
  1318. umount_filesystems
  1319. # installed successfully.
  1320. DIALOG --yesno "${BOLD}Void Linux has been installed successfully!${RESET}\n
  1321. Do you want to reboot the system?" ${YESNOSIZE}
  1322. if [ $? -eq 0 ]; then
  1323. shutdown -r now
  1324. else
  1325. return
  1326. fi
  1327. }
  1328. menu_source() {
  1329. local src=
  1330. DIALOG --title " Select installation source " \
  1331. --menu "$MENULABEL" 8 70 0 \
  1332. "Local" "Packages from ISO image" \
  1333. "Network" "Base system only, downloaded from official repository"
  1334. case "$(cat $ANSWER)" in
  1335. "Local") src="local";;
  1336. "Network") src="net";
  1337. if [ -z "$NETWORK_DONE" ]; then
  1338. if test_network; then
  1339. menu_network
  1340. fi
  1341. fi;;
  1342. *) return 1;;
  1343. esac
  1344. SOURCE_DONE=1
  1345. set_option SOURCE $src
  1346. }
  1347. menu_mirror() {
  1348. xmirror 2>$LOG && MIRROR_DONE=1
  1349. }
  1350. menu() {
  1351. local AFTER_HOSTNAME
  1352. if [ -z "$DEFITEM" ]; then
  1353. DEFITEM="Keyboard"
  1354. fi
  1355. if xbps-uhelper arch | grep -qe '-musl$'; then
  1356. AFTER_HOSTNAME="Timezone"
  1357. DIALOG --default-item $DEFITEM \
  1358. --extra-button --extra-label "Settings" \
  1359. --title " Void Linux installation menu " \
  1360. --menu "$MENULABEL" 10 70 0 \
  1361. "Keyboard" "Set system keyboard" \
  1362. "Network" "Set up the network" \
  1363. "Source" "Set source installation" \
  1364. "Mirror" "Select XBPS mirror" \
  1365. "Hostname" "Set system hostname" \
  1366. "Timezone" "Set system time zone" \
  1367. "RootPassword" "Set system root password" \
  1368. "UserAccount" "Set primary user name and password" \
  1369. "BootLoader" "Set disk to install bootloader" \
  1370. "Partition" "Partition disk(s)" \
  1371. "Filesystems" "Configure filesystems and mount points" \
  1372. "Install" "Start installation with saved settings" \
  1373. "Exit" "Exit installation"
  1374. else
  1375. AFTER_HOSTNAME="Locale"
  1376. DIALOG --default-item $DEFITEM \
  1377. --extra-button --extra-label "Settings" \
  1378. --title " Void Linux installation menu " \
  1379. --menu "$MENULABEL" 10 70 0 \
  1380. "Keyboard" "Set system keyboard" \
  1381. "Network" "Set up the network" \
  1382. "Source" "Set source installation" \
  1383. "Mirror" "Select XBPS mirror" \
  1384. "Hostname" "Set system hostname" \
  1385. "Locale" "Set system locale" \
  1386. "Timezone" "Set system time zone" \
  1387. "RootPassword" "Set system root password" \
  1388. "UserAccount" "Set primary user name and password" \
  1389. "BootLoader" "Set disk to install bootloader" \
  1390. "Partition" "Partition disk(s)" \
  1391. "Filesystems" "Configure filesystems and mount points" \
  1392. "Install" "Start installation with saved settings" \
  1393. "Exit" "Exit installation"
  1394. fi
  1395. if [ $? -eq 3 ]; then
  1396. # Show settings
  1397. cp $CONF_FILE /tmp/conf_hidden.$$;
  1398. sed -i "s/^ROOTPASSWORD.*/ROOTPASSWORD <-hidden->/" /tmp/conf_hidden.$$
  1399. sed -i "s/^USERPASSWORD.*/USERPASSWORD <-hidden->/" /tmp/conf_hidden.$$
  1400. DIALOG --title "Saved settings for installation" --textbox /tmp/conf_hidden.$$ 14 60
  1401. rm /tmp/conf_hidden.$$
  1402. return
  1403. fi
  1404. case $(cat $ANSWER) in
  1405. "Keyboard") menu_keymap && [ -n "$KEYBOARD_DONE" ] && DEFITEM="Network";;
  1406. "Network") menu_network && [ -n "$NETWORK_DONE" ] && DEFITEM="Source";;
  1407. "Source") menu_source && [ -n "$SOURCE_DONE" ] && DEFITEM="Mirror";;
  1408. "Mirror") menu_mirror && [ -n "$MIRROR_DONE" ] && DEFITEM="Hostname";;
  1409. "Hostname") menu_hostname && [ -n "$HOSTNAME_DONE" ] && DEFITEM="$AFTER_HOSTNAME";;
  1410. "Locale") menu_locale && [ -n "$LOCALE_DONE" ] && DEFITEM="Timezone";;
  1411. "Timezone") menu_timezone && [ -n "$TIMEZONE_DONE" ] && DEFITEM="RootPassword";;
  1412. "RootPassword") menu_rootpassword && [ -n "$ROOTPASSWORD_DONE" ] && DEFITEM="UserAccount";;
  1413. "UserAccount") menu_useraccount && [ -n "$USERLOGIN_DONE" ] && [ -n "$USERPASSWORD_DONE" ] \
  1414. && DEFITEM="BootLoader";;
  1415. "BootLoader") menu_bootloader && [ -n "$BOOTLOADER_DONE" ] && DEFITEM="Partition";;
  1416. "Partition") menu_partitions && [ -n "$PARTITIONS_DONE" ] && DEFITEM="Filesystems";;
  1417. "Filesystems") menu_filesystems && [ -n "$FILESYSTEMS_DONE" ] && DEFITEM="Install";;
  1418. "Install") menu_install;;
  1419. "Exit") DIE;;
  1420. *) DIALOG --yesno "Abort Installation?" ${YESNOSIZE} && DIE
  1421. esac
  1422. }
  1423. if ! command -v dialog >/dev/null; then
  1424. echo "ERROR: missing dialog command, exiting..."
  1425. exit 1
  1426. fi
  1427. if [ "$(id -u)" != "0" ]; then
  1428. echo "void-installer must run as root" 1>&2
  1429. exit 1
  1430. fi
  1431. #
  1432. # main()
  1433. #
  1434. DIALOG --title "${BOLD}${RED} Enter the void ... ${RESET}" --msgbox "\n
  1435. Welcome to the Void Linux installation. A simple and minimal \
  1436. Linux distribution made from scratch and built from the source package tree \
  1437. available for XBPS, a new alternative binary package system.\n\n
  1438. The installation should be pretty straightforward. If you are in trouble \
  1439. please join us at ${BOLD}#voidlinux${RESET} on ${BOLD}irc.libera.chat${RESET}.\n\n
  1440. ${BOLD}https://www.voidlinux.org${RESET}\n\n" 16 80
  1441. while true; do
  1442. menu
  1443. done
  1444. exit 0
  1445. # vim: set ts=4 sw=4 et: