avoid copying more useless dirs to miniroot
[unleashed-kayak.git] / install.sh
blob5ff686d2097716f7a2a457b38b502497579d9d0f
1 #!/bin/ksh -e
3 if ! [ -f /.cdrom/.volsetid ]; then
4 devfsadm
5 mkdir -p /.cdrom
6 /mount_media unleashed-installer || {
7 echo "Error: Unable to mount install media. Exiting." >&2
8 exit 1
10 # diskinfo can fail to list virtio devices on the first run, so run it here
11 # for what seems no reason
12 diskinfo >/dev/null
15 while :; do
16 read 'hostname?System hostname? '
17 if [ -n "$hostname" ]; then break; fi
18 done
19 while :; do
20 availdisks=$(diskinfo -H | awk '{ printf $2 " " }')
21 if [ -z "$availdisks" ]; then
22 availdisks="none"
23 defdisk=
24 else
25 availdisks="${availdisks% }"
26 defdisk=${availdisks%% *}
28 echo "Available disks are: ${availdisks}."
29 read "disks?Which disks should be used for installation? [$defdisk] ('?' for details) "
30 case "$disks" in
31 '?') diskinfo; continue;;
32 '') disks=$defdisk; if [ -z "$defdisk" ]; then continue; fi; break;;
33 esac;
34 for d in $disks; do
35 for ad in $availdisks; do
36 if [ $d = $ad ]; then continue 2; fi
37 done
38 echo "'$d' is not a valid disk."
39 continue 2
40 done
41 break
42 done
43 case $disks in
44 *" "*) disks="mirror $disks" ;;
45 esac
46 zpool create -O compression=on -f rpool $disks
47 zfs create -o canmount=off -o mountpoint=legacy rpool/ROOT
48 echo "Installing image."
49 pv -B 128m -w 78 < /.cdrom/unleashed.zfs | zfs receive -u rpool/ROOT/unleashed
50 zfs destroy rpool/ROOT/unleashed@kayak
51 zfs set canmount=noauto mountpoint=legacy rpool/ROOT/unleashed
52 zfs create -o mountpoint=/home rpool/home
53 beadm mount unleashed /mnt >/dev/null
54 devfsadm -r /mnt
55 echo "$hostname" >/mnt/etc/nodename
56 ln -sf generic_limited_net.xml /mnt/etc/svc/profile/generic.xml
57 # empty string password
58 sed -i '' 's,^root:NP:,root:$2b$06$./nqDdz5G40L1hjMLByHSOpA7GLmRJb4xU2n/ncw0jBKd3It8kcWm:,' /mnt/etc/shadow
59 bootadm install-bootloader -M -f -R /mnt -P rpool
60 bootadm update-archive -R /mnt
61 umount /mnt
62 zpool set bootfs=rpool/ROOT/unleashed rpool
63 beadm activate unleashed >/dev/null
64 cat <<EOF
66 Congratulations, your $(uname -sr) installation has successfully completed.
68 Type 'reboot' at the prompt to boot the new system.
69 EOF