-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
386 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
### Base system installation | ||
d-i base-installer/kernel/override-image string linux-server | ||
|
||
### Account setup | ||
d-i passwd/user-fullname string vagrant | ||
d-i passwd/username string vagrant | ||
d-i passwd/user-password password vagrant | ||
d-i passwd/user-password-again password vagrant | ||
d-i user-setup/allow-password-weak boolean true | ||
d-i user-setup/encrypt-home boolean false | ||
|
||
### Clock and time zone setup | ||
d-i clock-setup/utc boolean true | ||
d-i time/zone string UTC | ||
#d-i time/zone string Asia/Tokyo | ||
|
||
### Partitioning | ||
d-i partman-auto/method string lvm | ||
d-i partman-lvm/confirm_nooverwrite boolean true | ||
d-i partman-auto-lvm/guided_size string max | ||
d-i partman/choose_partition select finish | ||
d-i partman/confirm_nooverwrite boolean true | ||
|
||
### Mirror settings | ||
#d-i mirror/country string JP | ||
d-i mirror/http/proxy string | ||
|
||
### Package selection | ||
tasksel tasksel/first multiselect standard | ||
d-i pkgsel/update-policy select none | ||
d-i pkgsel/include string openssh-server | ||
d-i pkgsel/install-language-support boolean false | ||
|
||
### Boot loader installation | ||
d-i grub-installer/only_debian boolean true | ||
|
||
### Finishing up the installation | ||
d-i finish-install/reboot_in_progress note |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,74 @@ | ||
#!/bin/bash | ||
#!/bin/bash -eu | ||
|
||
SSH_USER=${SSH_USERNAME:-vagrant} | ||
|
||
# Make sure udev does not block our network - http://6.ptmc.org/?p=164 | ||
echo "==> Cleaning up udev rules" | ||
rm -rf /dev/.udev/ | ||
rm -f /lib/udev/rules.d/75-persistent-net-generator.rules | ||
|
||
echo "==> Cleaning up leftover dhcp leases" | ||
# Ubuntu 10.04 | ||
if [ -d "/var/lib/dhcp3" ]; then | ||
rm /var/lib/dhcp3/* | ||
fi | ||
# Ubuntu 12.04 & 14.04 | ||
if [ -d "/var/lib/dhcp" ]; then | ||
rm /var/lib/dhcp/* | ||
fi | ||
|
||
# Add delay to prevent "vagrant reload" from failing | ||
echo "pre-up sleep 2" >> /etc/network/interfaces | ||
|
||
echo "==> Cleaning up tmp" | ||
rm -rf /tmp/* | ||
|
||
# Cleanup apt cache | ||
apt-get -y autoremove --purge | ||
apt-get -y clean | ||
|
||
echo "==> Installed packages" | ||
dpkg --get-selections | grep -v deinstall | ||
|
||
DISK_USAGE_BEFORE_CLEANUP=$(df -h) | ||
|
||
# Remove Bash history | ||
unset HISTFILE | ||
rm -f /root/.bash_history | ||
rm -f /home/${SSH_USER}/.bash_history | ||
|
||
# Clean up log files | ||
find /var/log -type f | while read f; do echo -ne '' > "${f}"; done; | ||
|
||
echo "==> Clearing last login information" | ||
>/var/log/lastlog | ||
>/var/log/wtmp | ||
>/var/log/btmp | ||
|
||
echo '==> Clear out swap and disable until reboot' | ||
set +e | ||
swapuuid=$(/sbin/blkid -o value -l -s UUID -t TYPE=swap) | ||
case "$?" in | ||
2|0) ;; | ||
*) exit 1 ;; | ||
esac | ||
set -e | ||
set -x | ||
if [ "x${swapuuid}" != "x" ]; then | ||
# Whiteout the swap partition to reduce box size | ||
# Swap is disabled till reboot | ||
swappart=$(readlink -f /dev/disk/by-uuid/$swapuuid) | ||
/sbin/swapoff "${swappart}" | ||
dd if=/dev/zero of="${swappart}" bs=1M || echo "dd exit code $? is suppressed" | ||
/sbin/mkswap -U "${swapuuid}" "${swappart}" | ||
fi | ||
|
||
# Zero out the free space to save space in the final image | ||
dd if=/dev/zero of=/EMPTY bs=1M || echo "dd exit code $? is suppressed" | ||
rm -f /EMPTY | ||
sync | ||
|
||
echo "==> Disk usage before cleanup" | ||
echo ${DISK_USAGE_BEFORE_CLEANUP} | ||
|
||
sudo apt-get clean | ||
echo "==> Disk usage after cleanup" | ||
df -h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash -eu | ||
|
||
if [[ "$DESKTOP" =~ ^(true|yes|on|1|TRUE|YES|ON])$ ]]; then | ||
exit | ||
fi | ||
|
||
echo "==> Disk usage before minimization" | ||
df -h | ||
|
||
echo "==> Installed packages before cleanup" | ||
dpkg --get-selections | grep -v deinstall | ||
|
||
# Remove some packages to get a minimal install | ||
echo "==> Removing all linux kernels except the currrent one" | ||
#dpkg --list | awk '{ print $2 }' | grep 'linux-image-3.*-generic' | grep -v $(uname -r) | xargs apt-get -y purge | ||
apt-get -y purge `ls /boot/vmlinuz-* | sed -e '$d' | sed s/.*vmlinuz/linux-image/` | ||
apt-get -y purge $(dpkg --list |egrep 'linux-image-[0-9]' |awk '{print $3,$2}' |sort -nr |tail -n +2 |grep -v $(uname -r) |awk '{ print $2}') | ||
apt-get -y purge $(dpkg --list |grep '^rc' |awk '{print $2}') | ||
echo "==> Removing linux source" | ||
dpkg --list | awk '{ print $2 }' | grep linux-source | xargs apt-get -y purge | ||
echo "==> Removing documentation" | ||
dpkg --list | awk '{ print $2 }' | grep -- '-doc$' | xargs apt-get -y purge | ||
#echo "==> Removing development packages" | ||
#dpkg --list | awk '{ print $2 }' | grep -- '-dev$' | xargs apt-get -y purge | ||
#echo "==> Removing development tools" | ||
#dpkg --list | grep -i compiler | awk '{ print $2 }' | xargs apt-get -y purge | ||
#apt-get -y purge cpp gcc g++ | ||
#apt-get -y purge build-essential git | ||
#echo "==> Removing default system Ruby" | ||
#apt-get -y purge ruby ri doc | ||
#echo "==> Removing default system Python" | ||
#apt-get -y purge python-dbus libnl1 python-smartpm python-twisted-core libiw30 python-twisted-bin libdbus-glib-1-2 python-pexpect python-pycurl python-serial python-gobject python-pam python-openssl libffi5 | ||
echo "==> Removing X11 libraries" | ||
apt-get -y purge libx11-data xauth libxmuu1 libxcb1 libx11-6 libxext6 | ||
echo "==> Removing other oddities" | ||
apt-get -y purge popularity-contest installation-report landscape-common wireless-tools wpasupplicant ubuntu-serverguide | ||
apt-get -y purge nano | ||
|
||
# Clean up the apt cache | ||
apt-get -y autoremove --purge | ||
apt-get -y clean | ||
|
||
# Clean up orphaned packages with deborphan | ||
apt-get -y install deborphan | ||
while [ -n "$(deborphan --guess-all --libdevel)" ]; do | ||
deborphan --guess-all --libdevel | xargs apt-get -y purge | ||
done | ||
apt-get -y purge deborphan dialog | ||
|
||
echo "==> Removing man pages" | ||
rm -rf /usr/share/man/* | ||
echo "==> Removing APT files" | ||
find /var/lib/apt -type f | xargs rm -f | ||
echo "==> Removing any docs" | ||
rm -rf /usr/share/doc/* | ||
echo "==> Removing caches" | ||
find /var/cache -type f -exec rm -rf {} \; | ||
|
||
echo "==> Disk usage after cleanup" | ||
df -h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash -eu | ||
|
||
# locale | ||
echo "==> Configuring locales" | ||
apt-get -y purge language-pack-en language-pack-gnome-en | ||
sed -i -e '/^[^# ]/s/^/# /' /etc/locale.gen | ||
LANG=en_US.UTF-8 | ||
LC_ALL=$LANG | ||
locale-gen --purge $LANG | ||
update-locale LANG=$LANG LC_ALL=$LC_ALL | ||
|
||
# Disable the release upgrader | ||
echo "==> Disabling the release upgrader" | ||
sed -i.bak 's/^Prompt=.*$/Prompt=never/' /etc/update-manager/release-upgrades | ||
|
||
echo "==> Disabling apt.daily.service" | ||
systemctl stop apt-daily.timer | ||
systemctl disable apt-daily.timer | ||
systemctl mask apt-daily.service | ||
systemctl daemon-reload | ||
|
||
# install packages and upgrade | ||
echo "==> Updating list of repositories" | ||
apt-get -y update | ||
if [[ $UPDATE =~ true || $UPDATE =~ 1 || $UPDATE =~ yes ]]; then | ||
apt-get -y dist-upgrade | ||
apt-get -y autoremove --purge | ||
fi | ||
apt-get -y install build-essential linux-headers-generic | ||
apt-get -y install ssh nfs-common vim curl perl git | ||
apt-get -y autoclean | ||
apt-get -y clean | ||
|
||
# Disable IPv6 | ||
echo "==> Disabling IPv6" | ||
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf | ||
echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf | ||
sysctl -p | ||
|
||
# Remove 5s grub timeout to speed up booting | ||
sed -i -e 's/^GRUB_TIMEOUT=.*/GRUB_TIMEOUT=0/' \ | ||
-e 's/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="quiet nosplash"/' \ | ||
/etc/default/grub | ||
update-grub | ||
# SSH tweaks | ||
echo "UseDNS no" >> /etc/ssh/sshd_config | ||
|
||
# reboot | ||
echo "====> Shutting down the SSHD service and rebooting..." | ||
systemctl stop sshd.service | ||
nohup shutdown -r now < /dev/null > /dev/null 2>&1 & | ||
sleep 120 | ||
exit 0 |
Oops, something went wrong.