installer.sh 53 KB

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