forked from pin/debian-vm-install
-
Notifications
You must be signed in to change notification settings - Fork 1
/
default-postinst.sh
36 lines (30 loc) · 1.21 KB
/
default-postinst.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
#!/bin/sh
# This script is run by debian installer using preseed/late_command
# directive, see preseed.cfg
BUILD_TYPE="VM_TYPE"
# Setup console, remove timeout on boot.
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0"/g; s/TIMEOUT=5/TIMEOUT=0/g' /etc/default/grub
update-grub
# Members of `sudo` group are not asked for password.
sed -i 's/%sudo\tALL=(ALL:ALL) ALL/%sudo\tALL=(ALL:ALL) NOPASSWD:ALL/g' /etc/sudoers
# Empty message of the day.
echo -n > /etc/motd
# Unpack postinst tarball.
tar -x -v -z -C/tmp -f /tmp/postinst.tar.gz
# Install SSH key for PS_USERNAME.
mkdir -m700 /home/PS_USERNAME/.ssh
cat /tmp/postinst/authorized_keys > /home/PS_USERNAME/.ssh/authorized_keys
chown -R PS_USERNAME:PS_USERNAME /home/PS_USERNAME/.ssh
# Remove some non-essential packages.
DEBIAN_FRONTEND=noninteractive apt-get purge -y nano laptop-detect tasksel dictionaries-common emacsen-common iamerican ibritish ienglish-common ispell
# Install basic tools
apt-get update && apt-get install net-tools git vim screen curl -yy
# Install services based off the type.
case "$BUILD_TYPE" in
nginx)
apt-get install nginx -yy
;;
apache)
apt-get install apache2 -yy
;;
esac