-
Notifications
You must be signed in to change notification settings - Fork 87
/
rpool-install.sh
79 lines (67 loc) · 1.91 KB
/
rpool-install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/bash
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2017 OmniTI Computer Consulting, Inc. All rights reserved.
#
RPOOL=${1:-rpool}
ZFS_IMAGE=/root/*.zfs.bz2
keyboard_layout=${2:-US-English}
zpool list $RPOOL >& /dev/null
if [[ $? != 0 ]]; then
echo "Cannot find root pool $RPOOL"
echo "Press RETURN to exit"
read
exit 1
fi
echo "Installing from ZFS image $ZFS_IMAGE"
. /kayak/disk_help.sh
. /kayak/install_help.sh
reality_check() {
# Make sure $1 (hostname) is a legit one.
echo $1 | egrep '^[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]$' > /dev/null
if [[ $? != 0 ]]; then
echo "[$1] is not a legitimate hostname."
return -1
fi
return 0
}
# Select a host name
NEWHOST="unknown"
until [[ $NEWHOST == "" ]]; do
HOSTNAME=$NEWHOST
echo -n "Please enter a hostname or press RETURN if you want [$HOSTNAME]: "
read NEWHOST
if [[ $NEWHOST != "" ]]; then
reality_check $NEWHOST
if [[ $? != 0 ]]; then
NEWHOST=$HOSTNAME
fi
fi
done
# Select a timezone.
tzselect |& tee /tmp/tz.$$
TZ=$(tail -1 /tmp/tz.$$)
rm -f /tmp/tz.$$
# Because of kayak's small miniroot, just use C as the language for now.
LANG=C
BuildBE $RPOOL $ZFS_IMAGE
ApplyChanges $HOSTNAME $TZ $LANG $keyboard_layout
MakeBootable $RPOOL
zpool list -v $RPOOL
echo ""
beadm list
echo ""
echo "$RPOOL now has a working and mounted boot environment, per above."
echo "Once back at the main menu, you can reboot from there, or"
echo "re-enter the shell to modify your new BE before its first boot."
echo -n "Press RETURN to go back to the menu: "
read