forked from TritonDataCenter/freebsd-kvm-image-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installerconfig
executable file
·122 lines (93 loc) · 3.28 KB
/
installerconfig
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
PARTITIONS=vtbd0
DISTRIBUTIONS="kernel.txz base.txz triton.txz"
BSDINSTALL_DISTSITE=ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/12.0-RELEASE
#!/bin/sh
set -o xtrace
echo "==> Running installerconfig"
# Enable serial and internal consoles
echo "==> Enabling serial and internal consoles"
echo "-Dhv" > /boot.config
echo "cuau0 \"/usr/libexec/getty std.38400\" xterm on secure" >> /etc/ttys
echo "==> Adding boot loader settings"
cat << BOOT > /boot/loader.conf
autoboot_delay="5"
verbose_loading="YES"
hw.snd.default_auto=0
hw.usb.disable_enumeration=1
hw.usb.no_boot_wait=1
hw.usb.no_shutdown_wait=1
BOOT
echo "==> Setting up rc.conf"
cat > /etc/rc.conf << RC_CONF
fsck_y_enable="YES"
# Enable Triton support. Do not remove.
triton_enable="YES"
sshd_enable="YES"
ntpd_enable="YES"
ntpd_sync_on_start="YES"
RC_CONF
# Set Time Zone to UTC
echo "==> Setting Time Zone to UTC"
/bin/cp /usr/share/zoneinfo/UTC /etc/localtime
/usr/bin/touch /etc/wall_cmos_clock
/sbin/adjkerntz -a
# Fetch and install binary updates. Ensures we have the latest security fixes.
echo "==> Running freebsd-update fetch and freebsd-update install"
# Remove src from update since it's not installed
# See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198030
sed -i.bak -e s/Components\ src\ world\ kernel/Components\ world\ kernel/g /etc/freebsd-update.conf
cat << FREEBSDUPDATE > /tmp/freebsd-update.conf
KeyPrint 800651ef4b4c71c27e60786d7b487188970f4b4169cc055784e21eb71d410cc5
ServerName update.FreeBSD.org
Components world/base kernel
IgnorePaths
IDSIgnorePaths /usr/share/man/cat
IDSIgnorePaths /usr/share/man/whatis
IDSIgnorePaths /var/db/locate.database
IDSIgnorePaths /var/log
UpdateIfUnmodified /etc/ /var/ /root/ /.cshrc /.profile
MergeChanges /etc/ /boot/device.hints
BackupKernel no
FREEBSDUPDATE
env PAGER=cat freebsd-update -f /tmp/freebsd-update.conf fetch
env PAGER=cat freebsd-update -f /tmp/freebsd-update.conf install
echo "==> Installing packages"
env ASSUME_ALWAYS_YES=YES pkg update -f
env ASSUME_ALWAYS_YES=YES pkg upgrade -q -y
env ASSUME_ALWAYS_YES=YES pkg install -q -y bash curl node npm wget
env ASSUME_ALWAYS_YES=YES pkg autoremove
env ASSUME_ALWAYS_YES=YES pkg clean -a
echo "==> Enable root login via ssh"
sed -i.bak -e s/#PermitRootLogin\ no/PermitRootLogin\ without-password/g /etc/ssh/sshd_config
## Build date used for motd and product file
BUILDDATE=$(date +%Y%m%d)
RELEASE="12.0-RELEASE"
DOC_URL="https://docs.joyent.com/images/kvm/freebsd"
# Create MOTD
echo "Creating /etc/motd"
mv /etc/motd /etc/motd-backup
cat << MOTD > /etc/motd
__ . .
_| |_ | .-. . . .-. :--. |-
|_ _| ;| || |(.-' | | |
|__| \`--' \`-' \`;-| \`-' ' ' \`-'
/ ; Instance (FreeBSD $RELEASE $BUILDDATE)
\`-' $DOC_URL
MOTD
# Create product file
echo "Creating /etc/product file"
cat << PRODUCT > /etc/product
Name: Joyent Instance
Image: FreeBSD $RELEASE $BUILDDATE
Documentation: $DOC_URL
Description: FreeBSD $RELEASE 64-bit image with just essential packages \
installed. Ideal for users who are comfortable with setting up their \
own environment and tools.
PRODUCT
echo "Cleaning up"
rm -rf /tmp/installscript
rm -rf /var/db/freebsd-update/*
rm -rf /tmp/freebsd-update.conf
echo "End of installerconfig"
# Shutdown/Poweroff
poweroff