summaryrefslogtreecommitdiffstats
path: root/vagrant/definitions/tails-builder/postinstall.sh
blob: d8b68fc47d6d5caf662be780d308aba7949e9aca (plain)
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
#!/bin/sh

date > /etc/vagrant_box_build_time

# Set up sudo
cp /etc/sudoers /etc/sudoers.orig
sed -i -e 's/^%sudo\W.*$/%sudo ALL=NOPASSWD:ALL/' /etc/sudoers

# Install vagrant keys
mkdir -p /home/vagrant/.ssh
chmod 700 /home/vagrant/.ssh
curl -Lo /home/vagrant/.ssh/authorized_keys \
  'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub'
chmod 0600 /home/vagrant/.ssh/authorized_keys
chown -R vagrant:vagrant /home/vagrant/.ssh

# Tweak sshd to prevent DNS resolution (speed up logins)
echo 'UseDNS no' >> /etc/ssh/sshd_config

# Customize the message of the day
echo 'Welcome to your Vagrant-built virtual machine.' > /var/run/motd

# Removing leftover DHCP leases
rm /var/lib/dhcp/*.leases

# Deactivate name persistence for network interfaces
dpkg-divert --divert /lib/udev/write_net_rules \
            --rename /lib/udev/write_net_rules.udev
cp /bin/true /lib/udev/write_net_rules
rm -f /etc/udev/rules.d/70-persistent-net.rules

# Adding a 2 sec delay to the interface up, to make the dhclient happy
echo "pre-up sleep 5" >> /etc/network/interfaces

# Clean downloaded APT packages
apt-get clean

# Remove HTTP proxy configuration
sed -e '/http::Proxy/d' -i /etc/apt/apt.conf

# Remove installation logs
rm -rf /var/log/installer

# Zero out the free space to save space in the final image:
dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY

exit 0