installer.sh 51 KB

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