installer.sh.in 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083
  1. #!/bin/sh
  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. USERNAME_DONE=
  35. USERPASSWORD_DONE=
  36. BOOTLOADER_DONE=
  37. PARTITIONS_DONE=
  38. NETWORK_DONE=
  39. FILESYSTEMS_DONE=
  40. TARGETDIR=/mnt/target
  41. LOG=/dev/tty8
  42. CONF_FILE=/tmp/.void-installer.conf
  43. if [ ! -f $CONF_FILE ]; then
  44. touch -f $CONF_FILE
  45. fi
  46. ANSWER=$(mktemp -t vinstall-XXXXXXXX || exit 1)
  47. TARGET_FSTAB=$(mktemp -t vinstall-fstab-XXXXXXXX || exit 1)
  48. trap "DIE" INT TERM QUIT
  49. # disable printk
  50. if [ -w /proc/sys/kernel/printk ]; then
  51. echo 0 >/proc/sys/kernel/printk
  52. fi
  53. # Detect if this is an EFI system.
  54. if [ -e /sys/firmware/efi/systab ]; then
  55. EFI_SYSTEM=1
  56. fi
  57. # dialog colors
  58. BLACK="\Z0"
  59. RED="\Z1"
  60. GREEN="\Z2"
  61. YELLOW="\Z3"
  62. BLUE="\Z4"
  63. MAGENTA="\Z5"
  64. CYAN="\Z6"
  65. WHITE="\Z7"
  66. BOLD="\Zb"
  67. REVERSE="\Zr"
  68. UNDERLINE="\Zu"
  69. RESET="\Zn"
  70. # Properties shared per widget.
  71. MENULABEL="${BOLD}Use UP and DOWN keys to navigate \
  72. menus. Use TAB to switch between buttons and ENTER to select.${RESET}"
  73. MENUSIZE="14 60 0"
  74. INPUTSIZE="8 60"
  75. MSGBOXSIZE="8 70"
  76. YESNOSIZE="$INPUTSIZE"
  77. WIDGET_SIZE="10 70"
  78. DIALOG() {
  79. rm -f $ANSWER
  80. dialog --colors --keep-tite --no-shadow --no-mouse \
  81. --backtitle "${BOLD}${WHITE}Void Linux installation -- http://www.voidlinux.eu/ (@@MKLIVE_VERSION@@)${RESET}" \
  82. --cancel-label "Back" --aspect 20 "$@" 2>$ANSWER
  83. return $?
  84. }
  85. DIE() {
  86. rval=$1
  87. [ -z "$rval" ] && rval=0
  88. clear
  89. rm -f $ANSWER $TARGET_FSTAB
  90. # reenable printk
  91. if [ -w /proc/sys/kernel/printk ]; then
  92. echo 4 >/proc/sys/kernel/printk
  93. fi
  94. umount_filesystems
  95. exit $rval
  96. }
  97. set_option() {
  98. if grep -Eq "^${1}.*" $CONF_FILE; then
  99. sed -i -e "/^${1}.*/d" $CONF_FILE
  100. fi
  101. echo "${1} ${2}" >>$CONF_FILE
  102. }
  103. get_option() {
  104. echo $(grep -E "^${1}.*" $CONF_FILE|sed -e "s|${1}||")
  105. }
  106. show_disks() {
  107. local dev size sectorsize gbytes
  108. # IDE
  109. for dev in $(ls /sys/block|grep -E '^hd'); do
  110. if [ "$(cat /sys/block/$dev/device/media)" = "disk" ]; then
  111. # Find out nr sectors and bytes per sector;
  112. echo "/dev/$dev"
  113. size=$(cat /sys/block/$dev/size)
  114. sectorsize=$(cat /sys/block/$dev/queue/hw_sector_size)
  115. gbytes="$(($size * $sectorsize / 1024 / 1024 / 1024))"
  116. echo "size:${gbytes}GB;sector_size:$sectorsize"
  117. fi
  118. done
  119. # SATA/SCSI and Virtual disks (virtio)
  120. for dev in $(ls /sys/block|grep -E '^([sv]|xv)d|mmcblk'); do
  121. echo "/dev/$dev"
  122. size=$(cat /sys/block/$dev/size)
  123. sectorsize=$(cat /sys/block/$dev/queue/hw_sector_size)
  124. gbytes="$(($size * $sectorsize / 1024 / 1024 / 1024))"
  125. echo "size:${gbytes}GB;sector_size:$sectorsize"
  126. done
  127. # cciss(4) devices
  128. for dev in $(ls /dev/cciss 2>/dev/null|grep -E 'c[0-9]d[0-9]$'); do
  129. echo "/dev/cciss/$dev"
  130. size=$(cat /sys/block/cciss\!$dev/size)
  131. sectorsize=$(cat /sys/block/cciss\!$dev/queue/hw_sector_size)
  132. gbytes="$(($size * $sectorsize / 1024 / 1024 / 1024))"
  133. echo "size:${gbytes}GB;sector_size:$sectorsize"
  134. done
  135. }
  136. show_partitions() {
  137. local dev fstype fssize p part
  138. set -- $(show_disks)
  139. while [ $# -ne 0 ]; do
  140. disk=$(basename $1)
  141. shift 2
  142. # ATA/SCSI/SATA
  143. for p in /sys/block/$disk/$disk*; do
  144. if [ -d $p ]; then
  145. part=$(basename $p)
  146. fstype=$(lsblk -nfr /dev/$part|awk '{print $2}'|head -1)
  147. [ "$fstype" = "iso9660" ] && continue
  148. [ "$fstype" = "crypto_LUKS" ] && continue
  149. [ "$fstype" = "LVM2_member" ] && continue
  150. fssize=$(lsblk -nr /dev/$part|awk '{print $4}'|head -1)
  151. echo "/dev/$part"
  152. echo "size:${fssize:-unknown};fstype:${fstype:-none}"
  153. fi
  154. done
  155. done
  156. # Software raid (md)
  157. for p in $(ls -d /dev/md* 2>/dev/null|grep '[0-9]'); do
  158. part=$(basename $p)
  159. if cat /proc/mdstat|grep -qw $part; then
  160. fstype=$(lsblk -nfr /dev/$part|awk '{print $2}')
  161. [ "$fstype" = "crypto_LUKS" ] && continue
  162. [ "$fstype" = "LVM2_member" ] && continue
  163. fssize=$(lsblk -nr /dev/$part|awk '{print $4}')
  164. echo "$p"
  165. echo "size:${fssize:-unknown};fstype:${fstype:-none}"
  166. fi
  167. done
  168. # cciss(4) devices
  169. for part in $(ls /dev/cciss 2>/dev/null|grep -E 'c[0-9]d[0-9]p[0-9]+'); do
  170. fstype=$(lsblk -nfr /dev/cciss/$part|awk '{print $2}')
  171. [ "$fstype" = "crypto_LUKS" ] && continue
  172. [ "$fstype" = "LVM2_member" ] && continue
  173. fssize=$(lsblk -nr /dev/cciss/$part|awk '{print $4}')
  174. echo "/dev/cciss/$part"
  175. echo "size:${fssize:-unknown};fstype:${fstype:-none}"
  176. done
  177. if [ -e /sbin/lvs ]; then
  178. # LVM
  179. lvs --noheadings|while read lvname vgname perms size; do
  180. echo "/dev/mapper/${vgname}-${lvname}"
  181. echo "size:${size};fstype:lvm"
  182. done
  183. fi
  184. }
  185. menu_filesystems() {
  186. local dev fstype fssize mntpoint reformat
  187. while true; do
  188. DIALOG --title " Select the partition to edit " --menu "$MENULABEL" \
  189. ${MENUSIZE} $(show_partitions)
  190. [ $? -ne 0 ] && return
  191. dev=$(cat $ANSWER)
  192. DIALOG --title " Select the filesystem type for $dev " \
  193. --menu "$MENULABEL" ${MENUSIZE} \
  194. "btrfs" "Oracle's Btrfs" \
  195. "ext2" "Linux ext2 (no journaling)" \
  196. "ext3" "Linux ext3 (journal)" \
  197. "ext4" "Linux ext4 (journal)" \
  198. "f2fs" "Flash-Friendly Filesystem" \
  199. "swap" "Linux swap" \
  200. "vfat" "FAT32" \
  201. "xfs" "SGI's XFS"
  202. if [ $? -eq 0 ]; then
  203. fstype=$(cat $ANSWER)
  204. else
  205. continue
  206. fi
  207. if [ "$fstype" != "swap" ]; then
  208. DIALOG --inputbox "Please specify the mount point for $dev:" ${INPUTSIZE}
  209. if [ $? -eq 0 ]; then
  210. mntpoint=$(cat $ANSWER)
  211. elif [ $? -eq 1 ]; then
  212. continue
  213. fi
  214. else
  215. mntpoint=swap
  216. fi
  217. DIALOG --yesno "Do you want to create a new filesystem on $dev?" ${YESNOSIZE}
  218. if [ $? -eq 0 ]; then
  219. reformat=1
  220. elif [ $? -eq 1 ]; then
  221. reformat=0
  222. else
  223. continue
  224. fi
  225. fssize=$(lsblk -nr $dev|awk '{print $4}')
  226. set -- "$fstype" "$fssize" "$mntpoint" "$reformat"
  227. if [ -n "$1" -a -n "$2" -a -n "$3" -a -n "$4" ]; then
  228. local bdev=$(basename $dev)
  229. local ddev=$(basename $(dirname $dev))
  230. if [ "$ddev" != "dev" ]; then
  231. sed -i -e "/^MOUNTPOINT \/dev\/${ddev}\/${bdev}.*/d" $CONF_FILE
  232. else
  233. sed -i -e "/^MOUNTPOINT \/dev\/${bdev}.*/d" $CONF_FILE
  234. fi
  235. echo "MOUNTPOINT $dev $1 $2 $3 $4" >>$CONF_FILE
  236. fi
  237. done
  238. }
  239. menu_partitions() {
  240. DIALOG --title " Select the disk to partition " \
  241. --menu "$MENULABEL" ${MENUSIZE} $(show_disks)
  242. if [ $? -eq 0 ]; then
  243. local device=$(cat $ANSWER)
  244. DIALOG --title "Modify Partition Table on $device" --msgbox "\n
  245. ${BOLD}cfdisk will be executed in disk $device.${RESET}\n\n
  246. For BIOS systems, MBR or GPT partition tables are supported.\n
  247. To use GPT on PC BIOS systems an empty partition of 1MB must be added\n
  248. at the first 2GB of the disk with the TOGGLE \`bios_grub' enabled.\n
  249. ${BOLD}NOTE: you don't need this on EFI systems.${RESET}\n\n
  250. For EFI systems GPT is mandatory and a FAT32 partition with at least\n
  251. 100MB must be created with the TOGGLE \`boot', this will be used as\n
  252. EFI System Partition. This partition must have mountpoint as \`/boot/efi'.\n\n
  253. At least 1 partitions is required for the rootfs (/).\n
  254. For swap, RAM*2 must be really enough. For / 600MB are required.\n\n
  255. ${BOLD}WARNING: /usr is not supported as a separate partition.${RESET}\n
  256. ${RESET}\n" 18 80
  257. if [ $? -eq 0 ]; then
  258. while true; do
  259. clear; cfdisk $device; PARTITIONS_DONE=1
  260. break
  261. done
  262. else
  263. return
  264. fi
  265. fi
  266. }
  267. menu_keymap() {
  268. local _keymaps="$(find /usr/share/kbd/keymaps/ -type f -iname "*.map.gz" -printf "%f\n" | sed 's|.map.gz||g' | sort)"
  269. local _KEYMAPS=
  270. for f in ${_keymaps}; do
  271. _KEYMAPS="${_KEYMAPS} ${f} -"
  272. done
  273. while true; do
  274. DIALOG --title " Select your keymap " --menu "$MENULABEL" 14 70 14 ${_KEYMAPS}
  275. if [ $? -eq 0 ]; then
  276. set_option KEYMAP "$(cat $ANSWER)"
  277. loadkeys "$(cat $ANSWER)"
  278. KEYBOARD_DONE=1
  279. break
  280. else
  281. return
  282. fi
  283. done
  284. }
  285. set_keymap() {
  286. local KEYMAP=$(get_option KEYMAP)
  287. if [ -f /etc/vconsole.conf ]; then
  288. sed -i -e "s|KEYMAP=.*|KEYMAP=$KEYMAP|g" $TARGETDIR/etc/vconsole.conf
  289. else
  290. sed -i -e "s|#\?KEYMAP=.*|KEYMAP=$KEYMAP|g" $TARGETDIR/etc/rc.conf
  291. fi
  292. }
  293. menu_locale() {
  294. local _locales="$(grep -E '\.UTF-8' /etc/default/libc-locales|awk '{print $1}'|sed -e 's/^#//')"
  295. local _LOCALES=
  296. for f in ${_locales}; do
  297. _LOCALES="${_LOCALES} ${f} -"
  298. done
  299. while true; do
  300. DIALOG --title " Select your locale " --menu "$MENULABEL" 14 70 14 ${_LOCALES}
  301. if [ $? -eq 0 ]; then
  302. set_option LOCALE "$(cat $ANSWER)"
  303. LOCALE_DONE=1
  304. break
  305. else
  306. return
  307. fi
  308. done
  309. }
  310. set_locale() {
  311. if [ -f $TARGETDIR/etc/default/libc-locales ]; then
  312. local LOCALE=$(get_option LOCALE)
  313. sed -i -e "s|LANG=.*|LANG=$LOCALE|g" $TARGETDIR/etc/locale.conf
  314. # Uncomment locale from /etc/default/libc-locales and regenerate it.
  315. sed -e "/${LOCALE}/s/^\#//" -i $TARGETDIR/etc/default/libc-locales
  316. echo "Running xbps-reconfigure -f glibc-locales ..." >$LOG
  317. chroot $TARGETDIR xbps-reconfigure -f glibc-locales >$LOG 2>&1
  318. fi
  319. }
  320. menu_timezone() {
  321. local _tzones="$(cd /usr/share/zoneinfo; find Africa/ America/ Antarctica/ Arctic/ Asia/ Atlantic/ Australia/ Europe/ Indian/ Pacific/ posix/ -type f | sort)"
  322. local _TIMEZONES=
  323. for f in ${_tzones}; do
  324. _TIMEZONES="${_TIMEZONES} ${f} -"
  325. done
  326. while true; do
  327. DIALOG --title " Select your timezone " --menu "$MENULABEL" 14 70 14 ${_TIMEZONES}
  328. if [ $? -eq 0 ]; then
  329. set_option TIMEZONE "$(cat $ANSWER)"
  330. TIMEZONE_DONE=1
  331. break
  332. else
  333. return
  334. fi
  335. done
  336. }
  337. set_timezone() {
  338. local TIMEZONE="$(get_option TIMEZONE)"
  339. sed -i -e "s|#TIMEZONE=.*|TIMEZONE=$TIMEZONE|g" $TARGETDIR/etc/rc.conf
  340. }
  341. menu_hostname() {
  342. while true; do
  343. DIALOG --inputbox "Set the machine hostname:" ${INPUTSIZE}
  344. if [ $? -eq 0 ]; then
  345. set_option HOSTNAME "$(cat $ANSWER)"
  346. HOSTNAME_DONE=1
  347. break
  348. else
  349. return
  350. fi
  351. done
  352. }
  353. set_hostname() {
  354. echo $(get_option HOSTNAME) > $TARGETDIR/etc/hostname
  355. }
  356. menu_rootpassword() {
  357. local _firstpass= _secondpass= _desc=
  358. while true; do
  359. if [ -n "${_firstpass}" ]; then
  360. _desc="Enter the root password again (password won't be displayed)"
  361. else
  362. _desc="Enter the root password (password won't be displayed)"
  363. fi
  364. DIALOG --passwordbox "${_desc}" ${MSGBOXSIZE}
  365. if [ $? -eq 0 ]; then
  366. if [ -z "${_firstpass}" ]; then
  367. _firstpass="$(cat $ANSWER)"
  368. else
  369. _secondpass="$(cat $ANSWER)"
  370. fi
  371. if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
  372. if [ "${_firstpass}" != "${_secondpass}" ]; then
  373. DIALOG --infobox "Passwords do not match! please reenter it again" 6 80
  374. unset _firstpass _secondpass
  375. sleep 2 && continue
  376. fi
  377. set_option ROOTPASSWORD "${_firstpass}"
  378. ROOTPASSWORD_DONE=1
  379. break
  380. fi
  381. else
  382. return
  383. fi
  384. done
  385. }
  386. set_rootpassword() {
  387. echo "root:$(get_option ROOTPASSWORD)" | chpasswd -R $TARGETDIR -c SHA512
  388. }
  389. menu_useraccount() {
  390. local _firstpass= _secondpass= _desc=
  391. while true; do
  392. DIALOG --inputbox "Select primary user name:" ${INPUTSIZE} "void"
  393. if [ $? -eq 0 ]; then
  394. set_option USERNAME "$(cat $ANSWER)"
  395. USERNAME_DONE=1
  396. break
  397. else
  398. return
  399. fi
  400. done
  401. while true; do
  402. if [ -n "${_firstpass}" ]; then
  403. _desc="Enter the password for '$(get_option USERNAME)' again (password won't be displayed)"
  404. else
  405. _desc="Enter the password for '$(get_option USERNAME)' (password won't be displayed)"
  406. fi
  407. DIALOG --passwordbox "${_desc}" ${MSGBOXSIZE}
  408. if [ $? -eq 0 ]; then
  409. if [ -z "${_firstpass}" ]; then
  410. _firstpass="$(cat $ANSWER)"
  411. else
  412. _secondpass="$(cat $ANSWER)"
  413. fi
  414. if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
  415. if [ "${_firstpass}" != "${_secondpass}" ]; then
  416. DIALOG --infobox "Passwords do not match! please reenter it again" 6 80
  417. unset _firstpass _secondpass
  418. sleep 2 && continue
  419. fi
  420. set_option USERPASSWORD "${_firstpass}"
  421. USERPASSWORD_DONE=1
  422. break
  423. fi
  424. else
  425. return
  426. fi
  427. done
  428. }
  429. set_useraccount() {
  430. useradd -R $TARGETDIR -m -G wheel,audio,video,floppy,cdrom,optical,kvm,xbuilder \
  431. "$(get_option USERNAME)"
  432. echo "$(get_option USERNAME):$(get_option USERPASSWORD)" | chpasswd -R $TARGETDIR -c SHA512
  433. }
  434. menu_bootloader() {
  435. while true; do
  436. DIALOG --title " Select the disk to install the bootloader" \
  437. --menu "$MENULABEL" ${MENUSIZE} $(show_disks) none "Manage bootloader otherwise"
  438. if [ $? -eq 0 ]; then
  439. set_option BOOTLOADER "$(cat $ANSWER)"
  440. BOOTLOADER_DONE=1
  441. break
  442. else
  443. return
  444. fi
  445. done
  446. }
  447. set_bootloader() {
  448. local dev=$(get_option BOOTLOADER) grub_args=
  449. if [ "$dev" = "none" ]; then return; fi
  450. # Check if it's an EFI system via efivars module.
  451. if [ -n "$EFI_SYSTEM" ]; then
  452. grub_args="--target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=void_grub --recheck"
  453. fi
  454. echo "Running grub-install $grub_args $dev..." >$LOG
  455. chroot $TARGETDIR grub-install $grub_args $dev >$LOG 2>&1
  456. if [ $? -ne 0 ]; then
  457. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  458. failed to install GRUB to $dev!\nCheck $LOG for errors." ${MSGBOXSIZE}
  459. DIE 1
  460. fi
  461. echo "Running grub-mkconfig on $TARGETDIR..." >$LOG
  462. chroot $TARGETDIR grub-mkconfig -o /boot/grub/grub.cfg >$LOG 2>&1
  463. if [ $? -ne 0 ]; then
  464. DIALOG --msgbox "${BOLD}${RED}ERROR${RESET}: \
  465. failed to run grub-mkconfig!\nCheck $LOG for errors." ${MSGBOXSIZE}
  466. DIE 1
  467. fi
  468. }
  469. test_network() {
  470. rm -f xtraeme.asc && \
  471. xbps-uhelper fetch http://repo.voidlinux.eu/live/xtraeme.asc >$LOG 2>&1
  472. if [ $? -eq 0 ]; then
  473. DIALOG --msgbox "Network is working properly!" ${MSGBOXSIZE}
  474. NETWORK_DONE=1
  475. return 1
  476. fi
  477. DIALOG --msgbox "Network is unaccessible, please setup it properly." ${MSGBOXSIZE}
  478. }
  479. configure_wifi() {
  480. local dev="$1" ssid enc pass _wpasupconf=/etc/wpa_supplicant/wpa_supplicant.conf
  481. DIALOG --form "Wireless configuration for ${dev}\n(encryption type: wep or wpa)" 0 0 0 \
  482. "SSID:" 1 1 "" 1 16 30 0 \
  483. "Encryption:" 2 1 "" 2 16 4 3 \
  484. "Password:" 3 1 "" 3 16 50 0 || return 1
  485. set -- $(cat $ANSWER)
  486. ssid="$1"; enc="$2"; pass="$3";
  487. if [ -z "$ssid" ]; then
  488. DIALOG --msgbox "Invalid SSID." ${MSGBOXSIZE}
  489. return 1
  490. elif [ -z "$enc" -o "$enc" != "wep" -a "$enc" != "wpa" ]; then
  491. DIALOG --msgbox "Invalid encryption type (possible values: wep or wpa)." ${MSXBOXSIZE}
  492. return 1
  493. elif [ -z "$pass" ]; then
  494. DIALOG --msgbox "Invalid AP password." ${MSGBOXSIZE}
  495. fi
  496. rm -f ${_wpasupconf%.conf}-${dev}.conf
  497. cp -f ${_wpasupconf} ${_wpasupconf%.conf}-${dev}.conf
  498. if [ "$enc" = "wep" ]; then
  499. echo "network={" >> ${_wpasupconf%.conf}-${dev}.conf
  500. echo " ssid=\"$ssid\"" >> ${_wpasupconf%.conf}-${dev}.conf
  501. echo " wep_key0=\"$pass\"" >> ${_wpasupconf%.conf}-${dev}.conf
  502. echo " wep_tx_keyidx=0" >> ${_wpasupconf%.conf}-${dev}.conf
  503. echo " auth_alg=SHARED" >> ${_wpasupconf%.conf}-${dev}.conf
  504. echo "}" >> ${_wpasupconf%.conf}-${dev}.conf
  505. else
  506. wpa_passphrase "$ssid" "$pass" >> ${_wpasupconf%.conf}-${dev}.conf
  507. fi
  508. configure_net_dhcp $dev
  509. return $?
  510. }
  511. configure_net() {
  512. local dev="$1" rval
  513. DIALOG --yesno "Do you want to use DHCP for $dev?" ${YESNOSIZE}
  514. rval=$?
  515. if [ $rval -eq 0 ]; then
  516. configure_net_dhcp $dev
  517. elif [ $rval -eq 1 ]; then
  518. configure_net_static $dev
  519. fi
  520. }
  521. iface_setup() {
  522. ip addr show dev $1|grep -q 'inet '
  523. return $?
  524. }
  525. configure_net_dhcp() {
  526. local dev="$1"
  527. iface_setup $dev
  528. if [ $? -eq 1 ]; then
  529. dhcpcd -t 10 -w -4 -L $dev -e "wpa_supplicant_conf=/etc/wpa_supplicant/wpa_supplicant-${dev}.conf" 2>&1 | tee $LOG | \
  530. DIALOG --progressbox "Initializing $dev via DHCP..." ${WIDGET_SIZE}
  531. if [ $? -ne 0 ]; then
  532. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} failed to run dhcpcd. See $LOG for details." ${MSGBOXSIZE}
  533. return 1
  534. fi
  535. iface_setup $dev
  536. if [ $? -eq 1 ]; then
  537. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} DHCP request failed for $dev. Check $LOG for errors." ${MSGBOXSIZE}
  538. return 1
  539. fi
  540. fi
  541. test_network
  542. if [ $? -eq 1 ]; then
  543. set_option NETWORK "${dev} dhcp"
  544. fi
  545. }
  546. configure_net_static() {
  547. local ip gw dns1 dns2 dev=$1
  548. DIALOG --form "Static IP configuration for $dev:" 0 0 0 \
  549. "IP address:" 1 1 "192.168.0.2" 1 21 20 0 \
  550. "Gateway:" 2 1 "192.168.0.1" 2 21 20 0 \
  551. "DNS Primary" 3 1 "8.8.8.8" 3 21 20 0 \
  552. "DNS Secondary" 4 1 "8.8.4.4" 4 21 20 0 || return 1
  553. set -- $(cat $ANSWER)
  554. ip=$1; gw=$2; dns1=$3; dns2=$4
  555. echo "running: ip link set dev $dev up" >$LOG
  556. ip link set dev $dev up >$LOG 2>&1
  557. if [ $? -ne 0 ]; then
  558. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} Failed to bring $dev interface." ${MSGBOXSIZE}
  559. return 1
  560. fi
  561. echo "running: ip addr add $ip dev $dev"
  562. ip addr add $ip dev $dev >$LOG 2>&1
  563. if [ $? -ne 0 ]; then
  564. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} Failed to set ip to the $dev interface." ${MSGBOXSIZE}
  565. return 1
  566. fi
  567. ip route add $gw dev $dev >$LOG 2>&1
  568. if [ $? -ne 0 ]; then
  569. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} failed to setup your gateway." ${MSGBOXSIZE}
  570. return 1
  571. fi
  572. echo "nameserver $dns1" >/etc/resolv.conf
  573. echo "nameserver $dns2" >>/etc/resolv.conf
  574. test_network
  575. if [ $? -eq 1 ]; then
  576. set_option NETWORK "${dev} static $ip $gw $dns1 $dns2"
  577. fi
  578. }
  579. menu_network() {
  580. local dev addr f DEVICES
  581. for f in $(ls /sys/class/net); do
  582. [ "$f" = "lo" ] && continue
  583. addr=$(cat /sys/class/net/$f/address)
  584. DEVICES="$DEVICES $f $addr"
  585. done
  586. DIALOG --title " Select the network interface to configure " \
  587. --menu "$MENULABEL" ${MENUSIZE} ${DEVICES}
  588. if [ $? -eq 0 ]; then
  589. dev=$(cat $ANSWER)
  590. if $(echo $dev|egrep -q "^wl.*" 2>/dev/null); then
  591. configure_wifi $dev
  592. else
  593. configure_net $dev
  594. fi
  595. fi
  596. }
  597. validate_filesystems() {
  598. local mnts dev size fstype mntpt mkfs rootfound fmt
  599. local usrfound efi_system_partition
  600. unset TARGETFS
  601. mnts=$(grep -E '^MOUNTPOINT.*' $CONF_FILE)
  602. set -- ${mnts}
  603. while [ $# -ne 0 ]; do
  604. dev=$2; fstype=$3; size=$4; mntpt="$5"; mkfs=$6
  605. shift 6
  606. if [ "$mntpt" = "/" ]; then
  607. rootfound=1
  608. elif [ "$mntpt" = "/usr" ]; then
  609. usrfound=1
  610. elif [ "$fstype" = "vfat" -a "$mntpt" = "/boot/efi" ]; then
  611. efi_system_partition=1
  612. fi
  613. if [ "$mkfs" -eq 1 ]; then
  614. fmt="NEW FILESYSTEM: "
  615. fi
  616. if [ -z "$TARGETFS" ]; then
  617. TARGETFS="${fmt}$dev ($size) mounted on $mntpt as ${fstype}\n"
  618. else
  619. TARGETFS="${TARGETFS}${fmt}${dev} ($size) mounted on $mntpt as ${fstype}\n"
  620. fi
  621. done
  622. if [ -z "$rootfound" ]; then
  623. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  624. the mount point for the root filesystem (/) has not yet been configured." ${MSGBOXSIZE}
  625. return 1
  626. elif [ -n "$usrfound" ]; then
  627. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  628. /usr mount point has been configured but is not supported, please remove it to continue." ${MSGBOXSIZE}
  629. return 1
  630. elif [ -n "$EFI_SYSTEM" -a -z "$efi_system_partition" ]; then
  631. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  632. The EFI System Partition has not yet been configured, please create it\n
  633. as FAT32, mountpoint /boot/efi and at least with 100MB of size." ${MSGBOXSIZE}
  634. fi
  635. FILESYSTEMS_DONE=1
  636. }
  637. create_filesystems() {
  638. local mnts dev mntpt fstype fspassno mkfs size rv uuid
  639. mnts=$(grep -E '^MOUNTPOINT.*' $CONF_FILE)
  640. set -- ${mnts}
  641. while [ $# -ne 0 ]; do
  642. dev=$2; fstype=$3; mntpt="$5"; mkfs=$6
  643. shift 6
  644. # swap partitions
  645. if [ "$fstype" = "swap" ]; then
  646. swapoff $dev >/dev/null 2>&1
  647. if [ "$mkfs" -eq 1 ]; then
  648. mkswap $dev >$LOG 2>&1
  649. if [ $? -ne 0 ]; then
  650. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  651. failed to create swap on ${dev}!\ncheck $LOG for errors." ${MSGBOXSIZE}
  652. DIE 1
  653. fi
  654. fi
  655. swapon $dev >$LOG 2>&1
  656. if [ $? -ne 0 ]; then
  657. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  658. failed to activate swap on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE}
  659. DIE 1
  660. fi
  661. # Add entry for target fstab
  662. uuid=$(blkid -o value -s UUID "$dev")
  663. echo "UUID=$uuid none swap sw 0 0" >>$TARGET_FSTAB
  664. continue
  665. fi
  666. if [ "$mkfs" -eq 1 ]; then
  667. case "$fstype" in
  668. btrfs) MKFS="mkfs.btrfs -f"; modprobe btrfs >$LOG 2>&1;;
  669. ext2) MKFS="mke2fs -F"; modprobe ext2 >$LOG 2>&1;;
  670. ext3) MKFS="mke2fs -F -j"; modprobe ext3 >$LOG 2>&1;;
  671. ext4) MKFS="mke2fs -F -t ext4"; modprobe ext4 >$LOG 2>&1;;
  672. f2fs) MKFS="mkfs.f2fs"; modprobe f2fs >$LOG 2>&1;;
  673. vfat) MKFS="mkfs.vfat -F32"; modprobe vfat >$LOG 2>&1;;
  674. xfs) MKFS="mkfs.xfs -f"; modprobe xfs >$LOG 2>&1;;
  675. esac
  676. DIALOG --infobox "Creating filesystem $fstype on $dev for $mntpt ..." 8 60
  677. echo "Running $MKFS $dev..." >$LOG
  678. $MKFS $dev >$LOG 2>&1; rv=$?
  679. if [ $rv -ne 0 ]; then
  680. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  681. failed to create filesystem $fstype on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE}
  682. DIE 1
  683. fi
  684. fi
  685. # Mount rootfs the first one.
  686. [ "$mntpt" != "/" ] && continue
  687. mkdir -p $TARGETDIR
  688. echo "Mounting $dev on $mntpt ($fstype)..." >$LOG
  689. mount -t $fstype $dev $TARGETDIR >$LOG 2>&1
  690. if [ $? -ne 0 ]; then
  691. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  692. failed to mount $dev on ${mntpt}! check $LOG for errors." ${MSGBOXSIZE}
  693. DIE 1
  694. fi
  695. # Add entry to target fstab
  696. uuid=$(blkid -o value -s UUID "$dev")
  697. if [ "$fstype" = "f2fs" ]; then
  698. fspassno=0
  699. else
  700. fspassno=1
  701. fi
  702. echo "UUID=$uuid $mntpt $fstype defaults 0 $fspassno" >>$TARGET_FSTAB
  703. done
  704. # mount all filesystems in target rootfs
  705. mnts=$(grep -E '^MOUNTPOINT.*' $CONF_FILE)
  706. set -- ${mnts}
  707. while [ $# -ne 0 ]; do
  708. dev=$2; fstype=$3; mntpt="$5"
  709. shift 6
  710. [ "$mntpt" = "/" -o "$fstype" = "swap" ] && continue
  711. mkdir -p ${TARGETDIR}${mntpt}
  712. echo "Mounting $dev on $mntpt ($fstype)..." >$LOG
  713. mount -t $fstype $dev ${TARGETDIR}${mntpt} >$LOG 2>&1
  714. if [ $? -ne 0 ]; then
  715. DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
  716. failed to mount $dev on $mntpt! check $LOG for errors." ${MSGBOXSIZE}
  717. DIE
  718. fi
  719. # Add entry to target fstab
  720. uuid=$(blkid -o value -s UUID "$dev")
  721. echo "UUID=$uuid $mntpt $fstype defaults 0 2" >>$TARGET_FSTAB
  722. done
  723. }
  724. mount_filesystems() {
  725. for f in sys proc dev; do
  726. [ ! -d $TARGETDIR/$f ] && mkdir $TARGETDIR/$f
  727. echo "Mounting $TARGETDIR/$f..." >$LOG
  728. mount --bind /$f $TARGETDIR/$f >$LOG 2>&1
  729. done
  730. }
  731. umount_filesystems() {
  732. local f
  733. for f in sys/fs/fuse/connections sys proc dev; do
  734. echo "Unmounting $TARGETDIR/$f..." >$LOG
  735. umount $TARGETDIR/$f >$LOG 2>&1
  736. done
  737. local mnts="$(grep -E '^MOUNTPOINT.*$' $CONF_FILE)"
  738. set -- ${mnts}
  739. while [ $# -ne 0 ]; do
  740. local dev=$2; local fstype=$3; local mntpt=$5
  741. shift 6
  742. if [ "$fstype" = "swap" ]; then
  743. echo "Disabling swap space on $dev..." >$LOG
  744. swapoff $dev >$LOG 2>&1
  745. continue
  746. fi
  747. if [ "$mntpt" != "/" ]; then
  748. echo "Unmounting $TARGETDIR/$mntpt..." >$LOG
  749. umount $TARGETDIR/$mntpt >$LOG 2>&1
  750. fi
  751. done
  752. echo "Unmounting $TARGETDIR..." >$LOG
  753. umount $TARGETDIR >$LOG 2>&1
  754. }
  755. copy_rootfs() {
  756. DIALOG --title "Check $LOG for details" \
  757. --infobox "Copying live image to target rootfs, please wait ..." 4 60
  758. LANG=C cp -axvnu / $TARGETDIR >$LOG 2>&1
  759. if [ $? -ne 0 ]; then
  760. DIE 1
  761. fi
  762. }
  763. install_packages() {
  764. local _grub= _syspkg=
  765. if [ -n "$EFI_SYSTEM" ]; then
  766. _grub="grub-x86_64-efi"
  767. else
  768. _grub="grub"
  769. fi
  770. _syspkg="base-system"
  771. mkdir -p $TARGETDIR/var/db/xbps/keys $TARGETDIR/usr/share
  772. cp -a /usr/share/xbps.d $TARGETDIR/usr/share/
  773. cp /var/db/xbps/keys/*.plist $TARGETDIR/var/db/xbps/keys
  774. mkdir -p $TARGETDIR/boot/grub
  775. _arch=$(xbps-uhelper arch)
  776. stdbuf -oL env XBPS_ARCH=${_arch} \
  777. xbps-install -r $TARGETDIR -SyU ${_syspkg} ${_grub} 2>&1 | \
  778. DIALOG --title "Installing base system packages..." \
  779. --programbox 24 80
  780. if [ $? -ne 0 ]; then
  781. DIE 1
  782. fi
  783. xbps-reconfigure -r $TARGETDIR -f base-files >/dev/null 2>&1
  784. chroot $TARGETDIR xbps-reconfigure -a
  785. }
  786. enable_dhcpd() {
  787. ln -sf /etc/sv/dhcpcd $TARGETDIR/etc/runit/runsvdir/default/dhcpcd
  788. }
  789. menu_install() {
  790. # Don't continue if filesystems are not ready.
  791. validate_filesystems || return 1
  792. ROOTPASSWORD_DONE="$(get_option ROOTPASSWORD)"
  793. BOOTLOADER_DONE="$(get_option BOOTLOADER)"
  794. if [ -z "$FILESYSTEMS_DONE" ]; then
  795. DIALOG --msgbox "${BOLD}Required filesystems were not configured, \
  796. please do so before starting the installation.${RESET}" ${MSGBOXSIZE}
  797. return 1
  798. elif [ -z "$ROOTPASSWORD_DONE" ]; then
  799. DIALOG --msgbox "${BOLD}The root password has not been configured, \
  800. please do so before starting the installation.${RESET}" ${MSGBOXSIZE}
  801. return 1
  802. elif [ -z "$BOOTLOADER_DONE" ]; then
  803. DIALOG --msgbox "${BOLD}The disk to install the bootloader has not been \
  804. configured, please do so before starting the installation.${RESET}" ${MSGBOXSIZE}
  805. return 1
  806. fi
  807. DIALOG --yesno "${BOLD}The following operations will be executed:${RESET}\n\n
  808. ${BOLD}${TARGETFS}${RESET}\n
  809. ${BOLD}${RED}WARNING: data on partitions will be COMPLETELY DESTROYED for new \
  810. filesystems.${RESET}\n\n
  811. ${BOLD}Do you want to continue?${RESET}" 20 80 || return
  812. unset TARGETFS
  813. # Create and mount filesystems
  814. create_filesystems
  815. # If source not set use defaults.
  816. if [ "$(get_option SOURCE)" = "local" -o -z "$SOURCE_DONE" ]; then
  817. copy_rootfs
  818. . /etc/default/live.conf
  819. rm -f $TARGETDIR/etc/motd
  820. rm -f $TARGETDIR/etc/issue
  821. rm -f $TARGETDIR/usr/sbin/void-installer
  822. # Remove live user.
  823. echo "Removing $USERNAME live user from targetdir ..." >$LOG
  824. chroot $TARGETDIR userdel -r $USERNAME >$LOG 2>&1
  825. sed -i -e "/$USERNAME ALL=.*/d" $TARGETDIR/etc/sudoers
  826. DIALOG --title "Check $LOG for details" \
  827. --infobox "Rebuilding initramfs for target ..." 4 60
  828. echo "Rebuilding initramfs for target ..." >$LOG
  829. # mount required fs
  830. mount_filesystems
  831. chroot $TARGETDIR dracut --no-hostonly --add-drivers "ahci" --force >>$LOG 2>&1
  832. DIALOG --title "Check $LOG for details" \
  833. --infobox "Removing temporary packages from target ..." 4 60
  834. echo "Removing temporary packages from target ..." >$LOG
  835. xbps-remove -r $TARGETDIR -Ry dialog >>$LOG 2>&1
  836. rmdir $TARGETDIR/mnt/target
  837. else
  838. # mount required fs
  839. mount_filesystems
  840. # network install, use packages.
  841. install_packages
  842. fi
  843. DIALOG --infobox "Applying installer settings..." 4 60
  844. # copy target fstab.
  845. install -Dm644 $TARGET_FSTAB $TARGETDIR/etc/fstab
  846. # Mount /tmp as tmpfs.
  847. echo "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0" >> $TARGETDIR/etc/fstab
  848. # set up keymap, locale, timezone, hostname and root passwd.
  849. set_keymap
  850. set_locale
  851. set_timezone
  852. set_hostname
  853. set_rootpassword
  854. set_useraccount
  855. # Copy /etc/skel files for root.
  856. cp $TARGETDIR/etc/skel/.[bix]* $TARGETDIR/root
  857. # network settings for target
  858. if [ -n "$NETWORK_DONE" ]; then
  859. local net="$(get_option NETWORK)"
  860. set -- ${net}
  861. local _dev="$1" _type="$2" _ip="$3" _gw="$4" _dns1="$5" _dns2="$6"
  862. if [ -z "$_type" ]; then
  863. # network type empty??!!!
  864. :
  865. elif [ "$_type" = "dhcp" ]; then
  866. if [ -f /etc/wpa_supplicant/wpa_supplicant-${_dev}.conf ]; then
  867. cp /etc/wpa_supplicant/wpa_supplicant-${_dev}.conf $TARGETDIR/etc/wpa_supplicant
  868. ln -sf /etc/sv/dhcpcd-${_dev} $TARGETDIR/etc/runit/runsvdir/default/dhcpcd-${_dev}
  869. else
  870. enable_dhcpd
  871. fi
  872. elif [ -n "$_dev" -a "$_type" = "static" ]; then
  873. # static IP through dhcpcd.
  874. mv $TARGETDIR/etc/dhcpcd.conf $TARGETDIR/etc/dhdpcd.conf.orig
  875. echo "# Static IP configuration set by the void-installer for $_dev." \
  876. >$TARGETDIR/etc/dhcpcd.conf
  877. echo "interface $_dev" >>$TARGETDIR/etc/dhcpcd.conf
  878. echo "static ip_address=$_ip" >>$TARGETDIR/etc/dhcpcd.conf
  879. echo "static routers=$_gw" >>$TARGETDIR/etc/dhcpcd.conf
  880. echo "static domain_name_servers=$_dns1 $_dns2" >>$TARGETDIR/etc/dhcpcd.conf
  881. enable_dhcpd
  882. fi
  883. fi
  884. # install bootloader.
  885. set_bootloader
  886. sync && sync && sync
  887. # unmount all filesystems.
  888. umount_filesystems
  889. # installed successfully.
  890. DIALOG --yesno "${BOLD}Void Linux has been installed successfully!${RESET}\n
  891. Do you want to reboot the system?" ${YESNOSIZE}
  892. if [ $? -eq 0 ]; then
  893. shutdown -r now
  894. else
  895. return
  896. fi
  897. }
  898. menu_source() {
  899. local src=
  900. DIALOG --title " Select installation source " \
  901. --menu "$MENULABEL" 8 70 0 \
  902. "Local" "Packages from ISO image" \
  903. "Network" "Packages from official remote reposity"
  904. case "$(cat $ANSWER)" in
  905. "Local") src="local";;
  906. "Network") src="net";
  907. if [ -z "$NETWORK_DONE" ]; then
  908. menu_network;
  909. fi;;
  910. *) return 1;;
  911. esac
  912. SOURCE_DONE=1
  913. set_option SOURCE $src
  914. }
  915. menu() {
  916. if [ -z "$DEFITEM" ]; then
  917. DEFITEM="Keyboard"
  918. fi
  919. DIALOG --default-item $DEFITEM \
  920. --extra-button --extra-label "Settings" \
  921. --title " Void Linux installation menu " \
  922. --menu "$MENULABEL" 10 70 0 \
  923. "Keyboard" "Set system keyboard" \
  924. "Network" "Set up the network" \
  925. "Source" "Set source installation" \
  926. "Hostname" "Set system hostname" \
  927. "Locale" "Set system locale" \
  928. "Timezone" "Set system time zone" \
  929. "RootPassword" "Set system root password" \
  930. "UserAccount" "Set primary user name and password" \
  931. "BootLoader" "Set disk to install bootloader" \
  932. "Partition" "Partition disk(s)" \
  933. "Filesystems" "Configure filesystems and mount points" \
  934. "Install" "Start installation with saved settings" \
  935. "Exit" "Exit installation"
  936. if [ $? -eq 3 ]; then
  937. # Show settings
  938. cp $CONF_FILE /tmp/conf_hidden.$$;
  939. sed -i "s/^ROOTPASSWORD.*/ROOTPASSWORD <-hidden->/" /tmp/conf_hidden.$$
  940. DIALOG --title "Saved settings for installation" --textbox /tmp/conf_hidden.$$ 14 60
  941. rm /tmp/conf_hidden.$$
  942. return
  943. fi
  944. case $(cat $ANSWER) in
  945. "Keyboard") menu_keymap && [ -n "$KEYBOARD_DONE" ] && DEFITEM="Network";;
  946. "Network") menu_network && [ -n "$NETWORK_DONE" ] && DEFITEM="Source";;
  947. "Source") menu_source && [ -n "$SOURCE_DONE" ] && DEFITEM="Hostname";;
  948. "Hostname") menu_hostname && [ -n "$HOSTNAME_DONE" ] && DEFITEM="Locale";;
  949. "Locale") menu_locale && [ -n "$LOCALE_DONE" ] && DEFITEM="Timezone";;
  950. "Timezone") menu_timezone && [ -n "$TIMEZONE_DONE" ] && DEFITEM="RootPassword";;
  951. "RootPassword") menu_rootpassword && [ -n "$ROOTPASSWORD_DONE" ] && DEFITEM="UserAccount";;
  952. "UserAccount") menu_useraccount && [ -n "$USERNAME_DONE" ] && [ -n "$USERPASSWORD_DONE" ] \
  953. && DEFITEM="BootLoader";;
  954. "BootLoader") menu_bootloader && [ -n "$BOOTLOADER_DONE" ] && DEFITEM="Partition";;
  955. "Partition") menu_partitions && [ -n "$PARTITIONS_DONE" ] && DEFITEM="Filesystems";;
  956. "Filesystems") menu_filesystems && [ -n "$FILESYSTEMS_DONE" ] && DEFITEM="Install";;
  957. "Install") menu_install;;
  958. "Exit") DIE;;
  959. *) DIALOG --yesno "Abort Installation?" ${YESNOSIZE} && DIE
  960. esac
  961. }
  962. if [ ! -x /bin/dialog ]; then
  963. echo "ERROR: missing dialog command, exiting..."
  964. exit 1
  965. fi
  966. #
  967. # main()
  968. #
  969. DIALOG --title "${BOLD}${RED} Enter the void ... ${RESET}" --msgbox "\n
  970. Welcome to the Void Linux installation. A simple and minimal \
  971. Linux distribution made from scratch and built from the source package tree \
  972. available for XBPS, a new alternative binary package system.\n\n
  973. The installation should be pretty straightforward, if you are in trouble \
  974. please join us at ${BOLD}#xbps on irc.freenode.org${RESET}.\n\n
  975. ${BOLD}http://www.voidlinux.eu${RESET}\n\n" 16 80
  976. while true; do
  977. menu
  978. done
  979. exit 0
  980. # vim: set ts=4 sw=4 et: