-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·78 lines (58 loc) · 1.95 KB
/
setup.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
#!/bin/bash
COMMANDS=$(cat <<'EOF'
root
EOF
)
while IFS= read -r command; do
if [[ -n "$command" ]]; then
tmux send-keys -t freebsd-vm-base "$command" C-m
sleep 1
fi
done <<< "$COMMANDS"
COMMANDS=$(cat <<EOF
KEYMAP="us" &&
kbdcontrol -l /usr/share/syscons/keymaps/${KEYMAP}.kbd &&
TARGET_DISK="vtbd0" &&
gpart destroy -F ${TARGET_DISK} >/dev/null 2>&1 &&
gpart create -s GPT ${TARGET_DISK} &&
gpart add -t freebsd-boot -s 512k ${TARGET_DISK} &&
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ${TARGET_DISK} &&
gpart add -t freebsd-zfs -l zfsroot -a 1m ${TARGET_DISK} &&
kldload zfs &&
zpool create -f -o ashift=12 \
-O compression=lz4 \
-O atime=off \
-O mountpoint=none \
zroot /dev/gpt/zfsroot
&&
zfs create -o mountpoint=none zroot/ROOT &&
zfs create -o mountpoint=/mnt zroot/ROOT/default &&
zfs set reservation=none zroot &&
zfs set refquota=none zroot &&
zfs set refreservation=none zroot &&
zpool set bootfs=zroot/ROOT/default zroot &&
zfs create -o mountpoint=/mnt/tmp zroot/tmp &&
zfs create -o mountpoint=/mnt/usr zroot/usr &&
zfs create -o mountpoint=/mnt/var zroot/var &&
chmod 1777 /mnt/tmp &&
DISTRIBUTIONS="base.txz kernel.txz" &&
bsdinstall fetch &&
bsdinstall install /mnt ${DISTRIBUTIONS} &&
echo 'zfs_load="YES"' >> /mnt/boot/loader.conf &&
echo 'vfs.root.mountfrom="zfs:zroot/ROOT/default"' >> /mnt/boot/loader.conf &&
touch /mnt/etc/fstab &&
echo 'hostname="freebsd"' > /mnt/etc/rc.conf &&
echo 'sshd_enable="YES"' >> /mnt/etc/rc.conf &&
echo 'zfs_enable="YES"' >> /mnt/etc/rc.conf &&
ROOT_PASSWORD="freebsd" &&
chroot /mnt /bin/sh -c "echo 'root:${ROOT_PASSWORD}' | chpasswd" &&
USER="bsd"
PASSWORD="freebsd"
chroot /mnt /bin/sh -c "pw useradd ${USER} -m -s /bin/sh -h 0 -G wheel"
chroot /mnt /bin/sh -c "echo '${USER}:${PASSWORD}' | chpasswd"
zfs umount -a &&
zfs set mountpoint=legacy zroot/ROOT/default &&
zpool export zroot
EOF
)
tmux send-keys -t freebsd-vm-base "$COMMANDS" C-m