Skip to content

Instantly share code, notes, and snippets.

@mrmichalis
Last active September 28, 2016 17:38
Show Gist options
  • Save mrmichalis/5792328 to your computer and use it in GitHub Desktop.
Save mrmichalis/5792328 to your computer and use it in GitHub Desktop.
Ubuntu 12.04 LTS kickstart
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled --trust=eth0 --ssh
# Install OS instead of upgrade
install
# Use CDROM installation media
cdrom
# Root password
rootpw --iscrypted $1$dhsnLjk9$4Xx./mgXqMvEssQENwwZz.
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
# System keyboard
keyboard us
# System language
lang en_US.UTF-8
# SELinux configuration
# selinux --disabled
# Do not configure the X Window System
skipx
# Installation logging level
logging --level=info
# Reboot the machine after the installation is complete
# and attempt to eject the CD/DVD/Bootdisk
reboot --eject
# System timezone
timezone --isUtc Europe/London
# Network information
network --onboot=on --device=eth0 --noipv6 --bootproto=dhcp
#network --onboot=no --device=eth1 --noipv4 --noipv6
#network --onboot=no --device=eth2 --noipv4 --noipv6
#network --onboot=no --device=eth3 --noipv4 --noipv6
# System services
services --disabled="atd,auditd,cgred,cups,kdump,netfs,postfix,nfs,nfslock,restorecond,rpcbind,rpcgssd,rpcidmapd,rpcsvcgssd,vsftpd" --enabled="crond,ksm,ksmtuned,ntpd,rsyslog,sshd,sysstat"
firstboot --disabled
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part swap --fstype=swap --recommended --asprimary --fsoptions="noatime,nodiratime"
part /boot --fstype="ext4" --size=1024 --asprimary
part / --fstype="ext4" --grow --size=1 --asprimary --fsoptions="noatime,nodiratime"
#%packages --ignoremissing
#build-essential
#openssh-server
#curl
#wget
%end
%post --interpreter=/bin/bash --logfile /root/ks-post.log
IPADDR=$(ip -f inet addr show dev eth0|awk '$1~/inet/{print $2}'|cut -d/ -f1)
NETMASK=$(ifconfig eth0|awk -F"Mask:" '$1~/inet /{print $2}')
HWADDR="$(ifconfig eth0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}')"
HOSTNAME="$(echo $IPADDR | tr '.' '-')"
DN="lunix.co"
FQDN="$HOSTNAME.$DN"
GATEWAY=$(route | grep default | cut -b 17-32 | cut -d " " -f 1)
cp /etc/network/interfaces /etc/network/interfaces.backup.$(date "+%Y-%m-%d")
echo "$IPADDR $FQDN $HOSTNAME" >> /etc/hosts
echo "$HOSTNAME" > /etc/hostname
cat << EOF > /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address $IPADDR
netmask $NETMASK
gateway $GATEWAY
dns-nameservers 8.8.8.8 8.8.4.4
dns-search lunix.co
pre-up sleep 2
EOF
cat << EOF >> /etc/hosts
$IPADDR $FQDN $HOSTNAME
EOF
cat << EOF >> /etc/hostname
$HOSTNAME
EOF
exec < /dev/tty3 > /dev/tty3
chvt 3
echo
echo "################################"
echo "# Running Post Configuration #"
echo "################################"
(
wget "https://github.com/mrmichalis/hadoop-cdh/raw/master/linux/noarch/post-install.sh" -O - | bash
) 2>&1 | /usr/bin/tee /root/post-install.log
chvt 1
%end
choose-mirror-bin mirror/http/proxy string
d-i base-installer/kernel/override-image string linux-server
d-i clock-setup/utc boolean true
d-i clock-setup/utc-auto boolean true
d-i finish-install/reboot_in_progress note
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
#d-i partman-auto-lvm/guided_size string max
#d-i partman-auto/choose_recipe select atomic
#d-i partman-auto/method string lvm
#d-i partman-lvm/confirm boolean true
#d-i partman-lvm/confirm boolean true
#d-i partman-lvm/confirm_nooverwrite boolean true
#d-i partman-lvm/device_remove_lvm boolean true
#d-i partman/choose_partition select finish
#d-i partman/confirm boolean true
#d-i partman/confirm_nooverwrite boolean true
#d-i partman/confirm_write_new_label boolean true
d-i passwd/user-fullname string vagrant
d-i passwd/user-uid string 900
d-i passwd/user-password password vagrant
d-i passwd/user-password-again password vagrant
d-i clock-setup/utc boolean true
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string ntp.ubuntu.com
d-i passwd/username string vagrant
d-i pkgsel/include string openssh-server cryptsetup screen ntp build-essential libssl-dev git-core libreadline-dev zlib1g-dev linux-source python-mysqldb libmysqlclient-dev curl dkms build-essential python-setuptools python-imaging python-memcache libmysqlclient-dev postgresql-server-dev-9.1
d-i pkgsel/install-language-support boolean false
d-i pkgsel/update-policy select unattended-upgrades
d-i pkgsel/upgrade select full-upgrade
d-i time/zone string UTC
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
d-i cdrom-detect/eject boolean true
tasksel tasksel/first multiselect standard, ubuntu-server
#!/usr/bin/env bash
#https://github.com/opscode/bento/blob/master/definitions/.ubuntu/preseed.cfg
#ks=http://lunix.co/ks-u.cfg preseed/url=http://lunix.co/preseed.cfg
IPADDR=$(ip -f inet addr show dev eth0|awk '$1~/inet/{print $2}'|cut -d/ -f1)
NETMASK=$(ifconfig eth0|awk -F"Mask:" '$1~/inet /{print $2}')
HWADDR="$(ifconfig eth0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}')"
HOSTNAME="$(echo $IPADDR | tr '.' '-')"
DN="lunix.co"
FQDN="$HOSTNAME.$DN"
GATEWAY=$(route | grep default | cut -b 17-32 | cut -d " " -f 1)
cp /etc/network/interfaces /etc/network/interfaces.backup.$(date "+%Y-%m-%d")
echo "$IPADDR $FQDN $HOSTNAME" >> /etc/hosts
echo "$HOSTNAME" > /etc/hostname
cat << EOF > /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address $IPADDR
netmask $NETMASK
gateway $GATEWAY
dns-nameservers 8.8.8.8 8.8.4.4
dns-search lunix.co
pre-up sleep 2
EOF
echo "* Installing SSH keys..."
mkdir -p ~/.ssh
chmod 700 ~/.ssh
wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -O ~/.ssh/authorized_keys
wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant' -O ~/.ssh/id_rsa
wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -O ~/.ssh/id_rsa.pub
chmod 600 ~/.ssh/authorized_keys ~/.ssh/id_rsa ~/.ssh/id_rsa.pub
chown -R vagrant ~/.ssh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment