Skip to content

Instantly share code, notes, and snippets.

@kelp
Created October 23, 2008 23:16
Show Gist options
  • Save kelp/19265 to your computer and use it in GitHub Desktop.
Save kelp/19265 to your computer and use it in GitHub Desktop.
#### Contents of the preconfiguration file
### Localization
# Locale sets language and country.
d-i debian-installer/locale string en_US
# Keyboard selection.
# Disable automatic (interactive) keymap detection.
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us
### Network configuration
# netcfg will choose an interface that has link if possible. This makes it
# skip displaying a list if there is more than one interface.
d-i netcfg/choose_interface select auto
# To pick a particular interface instead:
#d-i netcfg/choose_interface select eth1
# If you prefer to configure the network manually, uncomment this line and
# the static network configuration below.
d-i netcfg/disable_dhcp boolean true
# If you want the preconfiguration file to work on systems both with and
# without a dhcp server, uncomment these lines and the static network
# configuration below.
d-i netcfg/dhcp_failed note
d-i netcfg/dhcp_options select Configure network manually
# Static network configuration. This is a template meant to be edited
# with the ubuntunboot script: http://gist.github.com/9789
d-i netcfg/get_nameservers string 10.1.0.5 10.1.0.6 10.1.0.7
d-i netcfg/get_ipaddress string _IP_
d-i netcfg/get_netmask string _NETMASK_
d-i netcfg/get_gateway string _GW_
d-i netcfg/confirm_static boolean true
# Any hostname and domain names assigned from dhcp take precedence over
# values set here. However, setting the values still prevents the questions
# from being shown, even if values come from dhcp.
d-i netcfg/get_hostname string _HOST_
d-i netcfg/get_domain string example.com
# Disable that annoying WEP key dialog.
d-i netcfg/wireless_wep string
### Mirror settings
d-i mirror/country string enter information manually
# Lets try our local mirror
d-i mirror/http/hostname string server
d-i mirror/http/directory string /apt-cacher/ubuntu.secs.oakland.edu/
d-i mirror/http/proxy string
# Suite to install.
d-i mirror/suite string hardy
### Partitioning
# If the system has free space you can choose to only partition that space.
# Note: this must be preseeded with a localized (translated) value.
#d-i partman-auto/init_automatically_partition \
# select Guided - use the largest continuous free space
# Alternatively, you can specify a disk to partition. The device name
# must be given in traditional non-devfs format.
# For example, to use the first SCSI hard disk:
d-i partman-auto/disk string /dev/sda
# In addition, you'll need to specify the method to use.
# The presently available methods are: "regular", "lvm" and "crypto"
d-i partman-auto/method string lvm
# On hardy this is required to purge an existing lvm config.
# Without this the install will fail if lvm was already setup on the drive.
d-i partman-lvm/device_remove_lvm boolean true
# And the same goes for the confirmation to write the lvm partitions.
d-i partman-lvm/confirm boolean true
# This partition layout was created with a 250GB drive in mind.
# Creates separate / /boot swap /tmp and /home partitions.
# swap, and uses the rest of the space for the root partition:
d-i partman-auto/expert_recipe string \
boot-root :: \
256 256 512 ext3 \
$primary{ } $bootable{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext3 } \
mountpoint{ /boot } \
options/relatime{ relatime } \
. \
2048 2048 300% linux-swap \
lvmok{} \
method{ swap } format{ } \
options/relatime{ relatime } \
. \
12288 16384 24576 ext3 \
lvmok{} \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext3 } \
mountpoint{ / } \
options/relatime{ relatime } \
. \
8192 8192 8192 ext3 \
lvmok{} \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext3 } \
mountpoint{ /tmp } \
options/relatime{ relatime } \
. \
12288 12288 1000000000 ext3 \
lvmok{} \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext3 } \
mountpoint{ /home } \
options/relatime{ relatime } \
.
# This makes partman automatically partition without confirmation.
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition \
select Finish partitioning and write changes to disk
d-i partman/confirm boolean true
### Clock and time zone setup
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true
# You may set this to any valid setting for $TZ; see the contents of
# /usr/share/zoneinfo/ for valid values.
d-i time/zone string US/Pacific
### Apt setup
# You can choose to install restricted and universe software, or to install
# software from the backports repository.
d-i apt-setup/restricted boolean true
d-i apt-setup/universe boolean true
d-i apt-setup/backports boolean false
# Additional repositories, local[0-9] available
d-i apt-setup/local0/repository string \
http://server/ubuntu/ ./
d-i apt-setup/local0/comment string local server
# URL to the public key of the local repository; you must provide a key or
# apt will complain about the unauthenticated repository and so the
# sources.list line will be left commented out
d-i apt-setup/local0/key string http://server/user.asc
# By default the installer requires that repositories be authenticated
# using a known gpg key. This setting can be used to disable that
# authentication. Warning: Insecure, not recommended.
#d-i debian-installer/allow_unauthenticated string true
### Account setup
# Skip creation of a root account (normal user account will be able to
# use sudo). The default is false; preseed this to true if you want to set
# a root password.
d-i passwd/root-login boolean true
# Alternatively, to skip creation of a normal user account.
d-i passwd/make-user boolean false
# Root password, either in clear text
#d-i passwd/root-password password r00tme
#d-i passwd/root-password-again password r00tme
# or encrypted using an MD5 hash.
d-i passwd/root-password-crypted password XXXXXXXXXXXXXXXX
### Base system installation
# Always install the server kernel.
d-i base-installer/kernel/override-image string linux-server
# Don't install usplash.
d-i base-installer/kernel/linux/extra-packages-2.6 string
### Boot loader installation
# This is fairly safe to set, it makes grub install automatically to the MBR
# if no other operating system is detected on the machine.
d-i grub-installer/only_debian boolean true
# This one makes grub-installer install to the MBR if it also finds some other
# OS, which is less safe as it might not be able to boot that other OS.
d-i grub-installer/with_other_os boolean true
### Package selection
tasksel tasksel/first multiselect standard
# Individual additional packages to install
d-i pkgsel/include string ssh build-essential ruby rubygems dselect ntp nfs-kernel-server zsh curl wget lvm2 acct mdadm powernowd subversion-tools nscd postfix mailx
# Pressed Postfix
postfix postfix/root_address string root@example.com
postfix postfix/mailname string _HOST_.ilike.com
postfix postfix/main_mailer_type select Satellite system
postfix postfix/relayhost string smtp.example.com
# Some versions of the installer can report back on what software you have
# installed, and what software you use. The default is not to report back,
# but sending reports helps the project determine what software is most
# popular and include it on CDs.
popularity-contest popularity-contest/participate boolean true
### Finishing up the first stage install
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note
#### Advanced options
### Running custom commands during the installation
# d-i preseeding is inherently not secure. Nothing in the installer checks
# for attempts at buffer overflows or other exploits of the values of a
# preconfiguration file like this one. Only use preconfiguration files from
# trusted locations! To drive that home, and because it's generally useful,
# here's a way to run any shell command you'd like inside the installer,
# automatically.
# This first command is run as early as possible, just after
# preseeding is read.
d-i preseed/early_command string wget -O /tmp/pressed-early.sh http://10.1.1.1/preseed-early; /bin/sh /tmp/pressed-early.sh
# This command is run just before the install finishes, but when there is
# still a usable /target directory. You can chroot to /target and use it
# directly, or use the apt-install and in-target commands to easily install
# packages and run commands in the target system.
d-i preseed/late_command string wget -O /tmp/pressed-late.sh http://10.1.1.1/preseed-late; /bin/sh /tmp/pressed-late.sh
#!/bin/sh
#
# Run the last bits of setup on a new autoinstalled system.
#
. /target/etc/lsb-release
printf "\n\t\t\tiLike - $DISTRIB_DESCRIPTION $DISTRIB_CODENAME\n\n\n" > /target/etc/motd.tail
wget -O /target/etc/apt/sources.list http://10.1.1.1/sources.list
in-target apt-get update
mkdir -pm 700 /target/root/.ssh/
wget -O /target/root/.ssh/authorized_keys http://10.1.1.1/authorized_keys
wget -O /target/etc/apt/preferences http://10.1.1.1/apt-preferences
apt-install puppet
wget -O /target/etc/default/puppet http://10.1.1.1/defaults-puppet
in-target update-rc.d -f puppet remove
in-target update-rc.d puppet defaults 99
touch /target/etc/puppet-firstrun
killall.sh dhclient
netcfg
SERIAL 0 9600 0
DISPLAY ubuntu-installer/amd64/boot-screens/boot.txt
F1 ubuntu-installer/amd64/boot-screens/f1.txt
F2 ubuntu-installer/amd64/boot-screens/f2.txt
F3 ubuntu-installer/amd64/boot-screens/f3.txt
F4 ubuntu-installer/amd64/boot-screens/f4.txt
F5 ubuntu-installer/amd64/boot-screens/f5.txt
F6 ubuntu-installer/amd64/boot-screens/f6.txt
F7 ubuntu-installer/amd64/boot-screens/f7.txt
F8 ubuntu-installer/amd64/boot-screens/f8.txt
F9 ubuntu-installer/amd64/boot-screens/f9.txt
F0 ubuntu-installer/amd64/boot-screens/f10.txt
DEFAULT auto
LABEL auto
kernel ubuntu-installer/amd64/linux
append tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false vga=normal initrd=ubuntu-installer/amd64/initrd.gz interface=auto netcfg/dhcp_timeout=60 console-setup/ask_detect=false console-setup/layoutcode=us console-setup/charmap=UTF-8 auto=true console-setup/variantcode= locale=en_US url=http://10.1.1.1/preseed/hardy-preseed-_HOST_.txt hostname=_HOST_ domain=example.com -- console=ttyS1,9600n8
PROMPT 1
TIMEOUT 1
#!/bin/bash
#
# Generate the pxelinux config for new systems.
#
#set -e
usage(){
cat << EOF
Usage: $0 --host=<hostname> --ip=<ip> --netmask=<netmask> --gateway=<gateway>
Options:
--host=<hostname> Name for new host
--ip=<ip> ip for new host
--netmask=<netmask> Netmask for new host
--gateway=<gateway> Gateway for new host
--i386 Set the arch to i386, default is amd64
--verbose Verbose mode. Silent without this
--help Print this help
EOF
exit 1
}
if [ $# -lt 4 ]; then
usage
fi
host=""
ip=""
netmask=""
gateway=""
verbose=""
arch=""
SHORTOPTS="H:i:n:g:vhI"
LONGOPTS="host:,ip:,netmask:,gateway:,i386,verbose,help"
OPTS=$(getopt -o $SHORTOPTS --long $LONGOPTS -n "$progname" -- "$@")
while [ $# -gt 0 ]; do
case $1 in
-H|--host)
host="$2"
shift 2;;
-i|--ip)
ip="$2"
shift 2;;
-n|--netmask)
netmask=$2
shift 2;;
-g|--gateway)
gw=$2
shift 2;;
-v|--verbose)
verbose="true"
shift;;
-I|--i386)
arch=".i386"
shift;;
-h|--help)
usage;;
--)
shift
break;;
*)
usage;;
esac
done
if [[ -z "$host" || -z "$ip" || -z "$netmask" || -z "$gw" ]]; then
usage
fi
if [ "$verbose" = "true" ]; then
set -x
fi
# Templates to generate configs for new hosts
PXETEMPLATE=/var/lib/tftpboot/hardy${arch}/pxelinux.cfg/default.template
SEEDTEMPLATE=/var/www/preseed/hardy-preseed.template
NAMESERVERS="10.1.0.52 10.1.0.51 10.1.0.84"
PRESEED="/var/www/preseed/hardy-preseed-${host}.txt"
for i in $(echo ${ip}| sed -e "s/\./ /g"); do
HEXIP=${HEXIP}`printf '%02X' $i`
done
sed "s/_HOST_/${host}/g" $PXETEMPLATE > /var/lib/tftpboot/hardy${arch}/pxelinux.cfg/$HEXIP
sed "s/_HOST_/${host}/" $SEEDTEMPLATE > $PRESEED
sed -i "s/_IP_/${ip}/" $PRESEED
sed -i "s/_NETMASK_/${netmask}/" $PRESEED
sed -i "s/_GW_/${gw}/" $PRESEED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment