kickstart-builder/isos/samples/lvm/ks.default

194 lines
3.9 KiB
Plaintext

#System language
lang en_US
#Language modules to install
langsupport en_US
#System keyboard
keyboard us
#System mouse
mouse
#System timezone
timezone America/Los_Angeles
#Root password
rootpw ubuntu
#Initial user
user --disabled
#Reboot after installation
reboot
#Use text mode install
text
#Install OS instead of upgrade
install
#Use CDROM installation media
cdrom
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr yes
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype ext2 --size=500
part pv.01 --size=1 --grow
volgroup vg_root pv.01
logvol / --vgname=vg_root --name=lv_root --size 1 --grow
#System authorization infomation
auth --useshadow --enablemd5
#Network information
network --bootproto=dhcp --device=eth0
#Firewall configuration
firewall --disabled
#Do not configure the X Window System
skipx
%packages
openssh-server
vim
htop
%post
# Add arbitrary shell code to execute in the installer environment below here
# Ubuntu user
useradd --create-home --groups sudo --shell /bin/bash ubuntu
echo "ubuntu:ubuntu" | chpasswd
touch /home/ubuntu/.sudo_as_admin_successful
# First time startup script
cat <<"EOF" > /usr/local/sbin/vm-firstboot.sh
#!/bin/bash
set +x
sed -i -E "s/^#?PermitRootLogin .+/PermitRootLogin yes/" /etc/ssh/sshd_config
apt-get update
apt-get dist-upgrade -y
apt-get install -y open-vm-tools dirmngr
rm /etc/firstboot
reboot
EOF
chmod +x /usr/local/sbin/vm-firstboot.sh
# and systemd unit to call it
cat <<"EOF" > /etc/systemd/system/vm-firstboot.service
[Unit]
Description=Initialize this template-created VM
ConditionPathExists=/etc/firstboot
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/vm-firstboot.sh
[Install]
WantedBy=multi-user.target
EOF
ln -s /etc/systemd/system/vm-firstboot.service /etc/systemd/system/multi-user.target.wants/vm-firstboot.service
touch /etc/firstboot
# Template cleanup helper script
cat <<"EOF" > /usr/local/sbin/vm-clean.sh
#!/bin/bash
touch /etc/firstboot
rm -f /etc/ssh/*key*
rm -f /etc/machine-id
EOF
chmod +x /usr/local/sbin/vm-clean.sh
# First boot ssh key regen
cat <<"EOF" > /lib/systemd/system/ssh.service
[Unit]
Description=OpenBSD Secure Shell server
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
[Service]
EnvironmentFile=-/etc/default/ssh
ExecStartPre=/bin/bash -c "test -f /etc/ssh/ssh_host_rsa_key || ssh-keygen -A"
ExecStartPre=/usr/sbin/sshd -t
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/usr/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify
RuntimeDirectory=sshd
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target
Alias=sshd.service
EOF
# First boot machine uuidgen
cat <<"EOF" > /etc/systemd/system/machineidgen.service
[Unit]
Description=Regen machine-id on first boot
Before=systemd-networkd.service systemd-journald.service
After=local-fs.target
ConditionPathExists=!/etc/machine-id
[Service]
Type=oneshot
ExecStart=/bin/systemd-machine-id-setup
[Install]
WantedBy=multi-user.target
EOF
ln -s /etc/systemd/system/machineidgen.service /etc/systemd/system/multi-user.target.wants/machineidgen.service
rm /etc/machine-id
# Show IP address on console
cp /etc/issue /etc/issue.tpl
cat <<"EOF" > /usr/local/sbin/console-set-ip.sh
#!/bin/bash
cat /etc/issue.tpl > /etc/issue
(ip addr | grep inet | awk '{print $2}' | grep -vE '^(::|fe80|127\.0\.0)') 2>&1 >> /etc/issue
echo "" >> /etc/issue
EOF
chmod +x /usr/local/sbin/console-set-ip.sh
cat <<"EOF" > /etc/systemd/system/consoleip.service
[Unit]
Description=Display machine ip on console
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/console-set-ip.sh
[Install]
WantedBy=multi-user.target
EOF
ln -s /etc/systemd/system/consoleip.service /etc/systemd/system/multi-user.target.wants/consoleip.service
rm -f /etc/update-motd.d/50-motd-news /etc/update-motd.d/80-livepatch