Commit d4c54f78 by Heechul Kim

fai reloated files committed.

parent 3d6ea658
Showing with 2451 additions and 0 deletions
#! /bin/bash
# mk-basefile, create basefiles for some distributions
#
# Thomas Lange, Uni Koeln, 2011-2015
# based on the Makefile implementation of Michael Goetze
#
# Usage example: ./mk-basefile -J SQUEEZE64
# This will create a SQUEEZE64.tar.xz basefile.
# Supported distributions (each i386/amd64):
# Debian GNU/Linux
# Ubuntu 14.04/16.04
# CentOS 5/6/7
# Scientific Linux Cern 5/6
#
# Packages you might want to install to use this command:
# debootstrap, rinse, xz-utils
# Define your local mirros here
# For the first stage, set the CentOS/SLC mirror in /etc/rinse/rinse.conf
MIRROR_DEBIAN=http://httpredir.debian.org/debian/
#MIRROR_DEBIAN=http://localmirror/debian/
MIRROR_UBUNTU=http://mirror.netcologne.de/ubuntu/
MIRROR_CENTOS=http://mirror.netcologne.de/
#MIRROR_CENTOS=http://localmirror
#MIRROR_SLC=http://localmirror
EXCLUDE_SQUEEZE=isc-dhcp-client,isc-dhcp-common,info,tasksel,tasksel-data
EXCLUDE_WHEEZY=isc-dhcp-client,isc-dhcp-common,info,tasksel,tasksel-data
EXCLUDE_JESSIE=isc-dhcp-client,isc-dhcp-common,info,tasksel,tasksel-data
EXCLUDE_TRUSTY=dhcp3-client,dhcp3-common,info
EXCLUDE_XENIAL=isc-dhcp-client,isc-dhcp-common,udhcpc,dibbler-client,dhcpcd5,info,tasksel,tasksel-data
INCLUDE_DEBIAN=aptitude
setarch() {
l32=
if [ X$1 = Xi386 ]; then
l32=linux32
fi
}
check() {
if [ `id -u` != 0 ]; then
echo "You must be root to create chroots."
exit 1
fi
mknod $xtmp/test-dev-null c 1 3
if [ $? -eq 1 ]; then
echo "Cannot create device files on $xtmp, aborting."
echo "Perhaps this directory is mounted with option nodev."
rm -rf $xtmp
exit 1
fi
echo test > $xtmp/test-dev-null
if [ $? -eq 1 ]; then
echo "Cannot create device files on $xtmp, aborting."
echo "Perhaps this directory is mounted with option nodev."
rm -rf $xtmp
exit 1
fi
rm -f $xtmp/test-dev-null
}
mkpost-centos() {
[ -z "$MIRROR_CENTOS" ] && return
cat <<EOM > $xtmp/post
#! /bin/sh
mkdir -p $xtmp/etc/yum.repos.d/orig
cp -p $xtmp/etc/yum.repos.d/*.repo $xtmp/etc/yum.repos.d/orig
perl -pi -e 's,mirrorlist=,#mirrorlist=,; s,#baseurl=http://mirror.centos.org,baseurl=$MIRROR_CENTOS,;' $xtmp/etc/yum.repos.d/CentOS-Base.repo
EOM
chmod 555 $xtmp/post
}
mkpost-slc() {
ver=$1
[ -z "$MIRROR_SLC" ] && return
cat <<EOM > $xtmp/post
#! /bin/sh
mkdir -p $xtmp/etc/yum.repos.d/orig
cp -p $xtmp/etc/yum.repos.d/*.repo $xtmp/etc/yum.repos.d/orig
perl -pi -e 's,baseurl=http://linuxsoft.cern.ch,baseurl=$MIRROR_SLC,;' $xtmp/etc/yum.repos.d/slc$ver-os.repo
perl -pi -e 's,baseurl=http://linuxsoft.cern.ch,baseurl=$MIRROR_SLC,;' $xtmp/etc/yum.repos.d/slc$ver-updates.repo
EOM
chmod 555 $xtmp/post
}
cleanup-deb() {
chroot $xtmp aptitude clean
rm -f $xtmp/etc/hostname $xtmp/etc/resolv.conf $xtmp/etc/machine-id
rm $xtmp/var/lib/apt/lists/*_*
rm -f $xtmp/etc/udev/rules.d/70-persistent-net.rules
}
cleanup-rinse() {
# check if chroot works
echo "Installed packages in chroot:"
chroot $xtmp rpm -qa|sort
echo -n "CHROOT rpm -qa: "
chroot $xtmp rpm -qa|wc -l
rm -f $xtmp/etc/resolv.conf $xtmp/post
if [ -d $xtmp/etc/yum.repos.d/orig ]; then
mv $xtmp/etc/yum.repos.d/orig/* $xtmp/etc/yum.repos.d/
rm -rf $xtmp/etc/yum.repos.d/orig
fi
}
tarit() {
tar --xattrs --selinux --acl --one-file-system -C $xtmp -cf - . | $zip > $target.$ext
}
centos() {
local arch=$1
local vers=$2
local domain=$(domainname)
check
setarch $arch
mkpost-centos
$l32 rinse --directory $xtmp --distribution centos-$vers --arch $arch --before-post-install $xtmp/post
domainname $domain # workaround for #613377
cleanup-rinse
tarit
}
slc() {
local arch=$1
local vers=$2
check
setarch $arch
mkpost-slc $vers
$l32 rinse --directory $xtmp --distribution slc-$vers --arch $arch --before-post-install $xtmp/post
cleanup-rinse
tarit
}
squeeze() {
local arch=$1
check
debootstrap --arch $arch --exclude=${EXCLUDE_SQUEEZE} squeeze $xtmp ${MIRROR_DEBIAN}
cleanup-deb
tarit
}
wheezy() {
local arch=$1
check
debootstrap --arch $arch --exclude=${EXCLUDE_WHEEZY} wheezy $xtmp ${MIRROR_DEBIAN}
cleanup-deb
tarit
}
jessie() {
local arch=$1
check
debootstrap --arch $arch --exclude=${EXCLUDE_JESSIE} --include=${INCLUDE_DEBIAN} jessie $xtmp ${MIRROR_DEBIAN}
cleanup-deb
tarit
}
trusty() {
local arch=$1
check
debootstrap --arch $arch --exclude=${EXCLUDE_TRUSTY} --include=${INCLUDE_DEBIAN} trusty $xtmp ${MIRROR_UBUNTU}
cleanup-deb
tarit
}
xenial() {
local arch=$1
check
debootstrap --arch $arch --exclude=${EXCLUDE_XENIAL} --include=${INCLUDE_DEBIAN} xenial $xtmp ${MIRROR_UBUNTU}
cleanup-deb
tarit
}
unknown() {
echo "Unknown distribution. Aborting."
echo "Available:
CENTOS5_32 CENTOS5_64
CENTOS6_32 CENTOS6_64
CENTOS7_32 CENTOS7_64
SLC5_32 SLC5_64
SLC6_32 SLC6_64
SLC7_64
TRUSTY32 TRUSTY64
XENIAL32 XENIAL64
SQUEEZE32 SQUEEZE64
WHEEZY32 WHEEZY64
JESSIE32 JESSIE64
"
exit 99
}
# main routine
ext=tar
zip=cat
tmpdir=/var/tmp
while getopts zJd: opt ; do
case "$opt" in
d) tmpdir=$OPTARG ;;
z) zip="gzip -9"; ext=tar.gz ;;
J) zip="xz -8" ext=tar.xz ;;
esac
done
shift $(($OPTIND - 1))
xtmp=$(mktemp -d $tmpdir/basefiles.XXXXXXXX)
if [ $? -eq 1 ]; then
echo "mktemp failed. Aborting."
exit 2
fi
target=$1 # also the name of the output file
case "$target" in
CENTOS5_32) centos i386 5 ;;
CENTOS5_64) centos amd64 5 ;;
CENTOS6_32) centos i386 6 ;;
CENTOS6_64) centos amd64 6 ;;
CENTOS7_32) centos i386 7 ;;
CENTOS7_64) centos amd64 7 ;;
SLC5_32) slc i386 5 ;;
SLC5_64) slc amd64 5 ;;
SLC6_32) slc i386 6 ;;
SLC6_64) slc amd64 6 ;;
SLC7_64) slc amd64 7 ;;
TRUSTY32) trusty i386 ;;
TRUSTY64) trusty amd64 ;;
XENIAL32) xenial i386 ;;
XENIAL64) xenial amd64 ;;
SQUEEZE32) squeeze i386 ;;
SQUEEZE64) squeeze amd64 ;;
WHEEZY32) wheezy i386 ;;
WHEEZY64) wheezy amd64 ;;
JESSIE32) jessie i386 ;;
JESSIE64) jessie amd64 ;;
*) unknown ;;
esac
# cleanup
rm -rf $xtmp
#! /bin/bash
# Echo architecture and OS name in uppercase. Do NOT remove these two lines.
uname -s | tr '[:lower:]' '[:upper:]'
[ -x "`which dpkg`" ] && dpkg --print-architecture | tr a-z A-Z
# determin if we are a DHCP client or not
# count the : chars in the argument of ip=
n="${ip//[^:]}"
if [[ $ip =~ ^(on|any|dhcp)$ ]]; then
echo DHCPC
elif [ ${#n} -lt 6 ]; then
echo DHCPC
fi
exit 0
#! /bin/bash
# (c) Thomas Lange, 2002-2013, lange@informatik.uni-koeln.de
# NOTE: Files named *.sh will be evaluated, but their output ignored.
[ $do_init_tasks -eq 1 ] || return 0 # Do only execute when doing install
echo 0 > /proc/sys/kernel/printk
#kernelmodules=
# here, you can load modules depending on the kernel version
case $(uname -r) in
2.6*) kernelmodules="$kernelmodules mptspi dm-mod md-mod aes dm-crypt" ;;
3*) kernelmodules="$kernelmodules mptspi dm-mod md-mod aes dm-crypt" ;;
4*) kernelmodules="$kernelmodules mptspi dm-mod md-mod aes dm-crypt" ;;
esac
for mod in $kernelmodules; do
[ "$verbose" ] && echo Loading kernel module $mod
modprobe -a $mod 1>/dev/null 2>&1
done
ip ad show up | egrep -iv 'loopback|127.0.0.1|::1/128|_lft'
echo $printk > /proc/sys/kernel/printk
odisklist=$disklist
set_disk_info # recalculate list of available disks
if [ "$disklist" != "$odisklist" ]; then
echo New disklist: $disklist
echo disklist=\"$disklist\" >> $LOGDIR/additional.var
fi
save_dmesg # save new boot messages (from loading modules)
#! /bin/bash
# parse *.profile and build a curses menu, so the user can select a profile
#
# (c) 2015 by Thomas Lange, lange@informatik.uni-koeln.de
# Universitaet zu Koeln
if [ X$FAI_ACTION = Xinstall -o X$FAI_ACTION = Xdirinstall -o X$FAI_ACTION = X ]; then
:
else
return
fi
[ "$flag_menu" ] || return 0
out=$(tty)
tempfile=`(tempfile) 2>/dev/null`
tempfile2=`(tempfile) 2>/dev/null`
trap "rm -f $tempfile $tempfile2" EXIT INT QUIT
# declare the data structure, use associative arrays
declare -A arshort
declare -A ardesc
declare -A arlong
declare -A arclasses
declare -a list
parse_profile() {
# read a profile and add all info to the data structure
local short
local long
local desc
local name
local classes
local lflag=0
# disable word splitting when reading a line, this helps reading a keyword without a value
local OIF=$IFS
IFS=
while read -r line || [[ -n $line ]]; do
if [[ $line =~ "Name: " ]]; then
if [ -n "$long" ]; then
arlong[$name]="$long"
fi
short=
desc=
long=
classes=
lflag=0
name=${line##Name: }
[ $debug ] && echo "XX NAME $name found"
list+=("$name") # add new item to list
continue
fi
if [[ $line =~ "Description: " ]]; then
lflag=0
desc=${line##Description: }
[ $debug ] && echo "XX $desc found"
ardesc[$name]="$desc"
continue
fi
if [[ $line =~ "Short: " ]]; then
lflag=0
short=${line##Short: }
[ $debug ] && echo "XX $short found"
arshort[$name]="$short"
continue
fi
if [[ $line =~ "Classes: " ]]; then
lflag=0
classes=${line##Classes: }
[ $debug ] && echo "XX classes found"
arclasses[$name]="$classes"
continue
fi
if [[ $line =~ "Long: " ]]; then
lflag=1
long=${line##Long: }
[ $debug ] && echo "XX long found"
# else it's another long line
elif [ $lflag -eq 1 ]; then
long+="\n$line"
fi
if [[ $line =~ "Default: " ]]; then
lflag=0
default=${line##Default: }
continue
fi
done < $1
if [ -n "$long" ]; then
arlong[$name]="$long"
fi
IFS=$OIF
}
prtresult() {
# set newclasses which is used by fai-class(1)
local res=$(<$tempfile)
echo "$BASH_SOURCE defined new classes: ${arclasses[$res]}"
newclasses="${arclasses[$res]}"
}
# read all files with name matching *.profile
_parsed=0
shopt -s nullglob
for _f in *.profile; do
parse_profile $_f
_parsed=1
done
unset _f
# do nothing if no profile was read
if [ $_parsed -eq 0 ]; then
unset _parsed
return 0
fi
# create the argument list containing the menu entries
# and the help text file
for i in "${list[@]}"; do
par+=("$i")
par+=("${ardesc[${i}]}")
par+=("${arshort[${i}]}")
echo "Name: ${i}" >> $tempfile2
echo -e ${arlong[${i}]} >> $tempfile2
echo -e "Classes: " ${arclasses[${i}]} "\n" >> $tempfile2
done
unset i
while true; do
dialog --clear --item-help --title "FAI - Fully Automatic Installation" --help-button \
--default-item "$default" \
--menu "\nSelect your FAI profile\n\nThe profile will define a list of classes,\nwhich are used by FAI.\n\n\n"\
15 70 0 "${par[@]}" 2> $tempfile 1> $out
_retval=$?
case $_retval in
0)
prtresult
break ;;
1)
echo "No profile selected."
break ;;
2)
dialog --title "Description of all profiles" --textbox $tempfile2 0 0 1> $out;;
esac
done
unset par ardesc arshort arlong arclasses list tempfile tempfile2 _parsed _retval line
#! /bin/bash
# assign classes to hosts based on their hostname
# do not use this if a menu will be presented
[ "$flag_menu" ] && exit 0
# use a list of classes for our demo machine
#OS=$(/usr/bin/curl http://porch/porch/$HOSTNAME/faiclass/)
OS=$(/usr/bin/curl http://porch:8000/api/fai/class/$HOSTNAME)
case $OS in
faiserver)
echo "FAIBASE DEBIAN DEMO FAISERVER" ;;
CENTOS7)
echo "FAIBASE CENTOS" # you may want to add class XORG here
ifclass AMD64 && echo CENTOS7_64
echo PORCH
exit 0 ;; # CentOS does not use the GRUB class
CENTOS6)
echo "FAIBASE CENTOS" # you may want to add class XORG here
ifclass AMD64 && echo CENTOS6_64
echo PORCH
exit 0 ;; # CentOS does not use the GRUB class
JESSIE)
echo "FAIBASE DEBIAN"
ifclass AMD64 && echo JESSIE64
echo PORCH
exit 0 ;;
UXENOS)
echo "FAIBASE DEBIAN"
ifclass AMD64 && echo JESSIE64
echo UXENOS
echo PORCH
exit 0 ;;
TRUSTY)
echo "FAIBASE UBUNTU"
ifclass AMD64 && echo TRUSTY64
echo PORCH
exit 0 ;;
XENIAL)
echo "FAIBASE UBUNTU"
ifclass AMD64 && echo XENIAL64
echo PORCH
exit 0 ;;
esac
#! /bin/bash
ifclass -o CENTOS SLC && exit 0
ifclass -o I386 AMD64 && echo GRUB_PC
CONSOLEFONT=lat9v-16
KEYMAP=us
DEFAULTLOCALE=en_US.UTF-8
SUPPORTEDLOCALE=en_US.UTF-8:en_US:en
# if you install much software and have only few RAM, use the RAM disk
# not for var/cache/yum
#FAI_RAMDISKS="$target/var/lib/rpm $target/var/cache/yum"
FAI_RAMDISKS="$target/var/lib/rpm"
CONSOLEFONT=
KEYMAP=us-latin1
# MODULESLIST contains modules that will be loaded by the new system,
# not during installation these modules will be written to /etc/modules
# If you need a module during installation, add it to $kernelmodules
# in 20-hwdetect.sh.
MODULESLIST="usbhid psmouse"
# if you have enough RAM (>2GB) you may want to enable this line. It
# also puts /var/cache into a ramdisk.
#FAI_RAMDISKS="$target/var/lib/dpkg $target/var/cache"
# if you want to use the faiserver as APT proxy
#APTPROXY=http://faiserver:3142
# default values for installation. You can override them in your *.var files
# allow installation of packages from unsigned repositories
FAI_ALLOW_UNSIGNED=1
# Set UTC=yes if your system clock is set to UTC (GMT), and UTC=no if not.
UTC=yes
TIMEZONE=Europe/Berlin
# the hash of the root password for the new installed linux system
# pw is "fai"
ROOTPW='$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1'
# errors in tasks greater than this value will cause the installation to stop
STOP_ON_ERROR=700
# set parameter for install_packges(8)
MAXPACKAGES=800
# german environment (for Debian)
KEYMAP=de-latin1-nodeadkeys
# default values for PORCH
# Set TIMEZONE to Asia/Seoul
TIMEZONE=Asia/Seoul
# SHA512 hashed root password
# Created by mkpasswd which is in whois deb package.(apt-get install whois)
# 1. create a file with plain text.
# vi myplaintext
# 2. create sha-512 password.
# cat myplaintext | mkpasswd -m sha-512 -s > mysha512text
# 3. delete a file
# rm myplaintext
# 4. Copy and Paste the mysha512text into ROOTPW below.
#ROOTPW='$6$HbKVGvMck$3ypb1bvIu38j2vVgPzGJzrzHS3xNRla9G0fqMmgmZoJHMjlTJGKoICp4PDxWQwQoOmqV7UUCS2TglZ3D0X/s6.'
# Set UBUNTU dist (trusty or xenial)
# GET dist from http://porch/porch/$HOSTNAME/faiclass/
DIST=$(/usr/bin/curl http://porch/porch/$HOSTNAME/faiclass/)
# make DIST to lowercase.
DIST=$(echo "$DIST" | tr '[:upper:]' '[:lower:]')
dist=$DIST
Default: Xfce
Name: Simple
Description: My first FAI installation
Short: just a very simple example, no xorg, an account called demo
Long: This is the demohost example of FAI.
Additional account called demo with password: fai, root password: fai
All needed packages are already on the CD or USB stick.
Classes: INSTALL FAIBASE DEBIAN DEMO
Name: Xfce
Description: Xfce desktop, LVM partitioning
Short: A fancy Xfce desktop will be installed, the user account is demo
Long: This is the Xfce desktop example. Additional account called
demo with password: fai, root password: fai
All needed packages are already on the CD or USB stick.
Classes: INSTALL FAIBASE DEBIAN DEMO XORG XFCE LVM
Name: Gnome
Description: Gnome desktop installation
Short: A Gnome desktop, no LVM, You will get an account called demo
Long: This is the Gnome desktop example. Additional account called
demo with password: fai, root password: fai
You should have a fast network connection, because most packages are
downloaded from the internet.
Classes: INSTALL FAIBASE DEBIAN DEMO XORG GNOME
Name: CentOS 7
Description: CentOS 7 with Xfce desktop
Short: A normal Xfce desktop, running CentOS 7
Long: We use the Debian nfsroot for installing the CentOS 7 OS.
You should have a fast network connection, because most packages are
downloaded from the internet.
Classes: INSTALL FAIBASE CENTOS CENTOS7_64 XORG
Name: Ubuntu
Description: Ubuntu 14.04 desktop installation
Short: Unity desktop
Long: We use the Debian nfsroot for installing the Ubuntu OS.
You should have a fast network connection, because most packages are
downloaded from the internet.
Classes: INSTALL FAIBASE DEMO DEBIAN UBUNTU TRUSTY TRUSTY64 XORG
Name: Inventory
Description: Show hardware info
Short: Show some basic hardware infos
Long: Execute commands for showing hardware info
Classes: INVENTORY
Name: Sysinfo
Description: Show defailed system information
Short: Show detailed hardware and system information
Long: Execute a lot of commands for collecting system information
Classes: SYSINFO
Name: dummy
Description: A dummy profile
Short: This is the short one liner text for the dummy menu, Shown at the bottom of the menu
Long: Here you can add more lines to describe details of you
profile. A profile is only a list of FAI classes. Those classes can
then define the disk partitioning scheme, the list of packages to be
installed, the variables to defined and other things.
In the end, a profile is just a list of FAI classes combined with some description.
Classes: A B C E
#!/bin/sh
tar cvf fai-JESSIE-config.tar class debconf disk_config files hooks package_config scripts pubkeys saltkey basefiles/JESSIE64.tar.xz
tar cvf fai-XENIAL-config.tar class debconf disk_config files hooks package_config scripts pubkeys saltkey basefiles/XENIAL64.tar.xz
tar cvf fai-CENTOS7-config.tar class debconf disk_config files hooks package_config scripts pubkeys saltkey basefiles/CENTOS7_64.tar.xz
exim4-config exim4/dc_eximconfig_configtype select local delivery only; not on a network
locales locales/default_environment_locale select en_US.UTF-8
locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
keyboard-configuration keyboard-configuration/modelcode string pc105
keyboard-configuration keyboard-configuration/xkb-keymap select us
keyboard-configuration keyboard-configuration/variant select USA
keyboard-configuration keyboard-configuration/model select Generic 105-key (Intl) PC
keyboard-configuration keyboard-configuration/layoutcode string us
keyboard-configuration keyboard-configuration/optionscode string ctrl:nocaps,terminate:ctrl_alt_bksp
locales locales/default_environment_locale select de_DE.UTF-8
locales locales/locales_to_be_generated multiselect de_DE.UTF-8 UTF-8
keyboard-configuration keyboard-configuration/modelcode string pc105
keyboard-configuration keyboard-configuration/xkb-keymap select de
keyboard-configuration keyboard-configuration/variant select Germany
keyboard-configuration keyboard-configuration/model select Generic 105-key (Intl) PC
keyboard-configuration keyboard-configuration/layoutcode string de
keyboard-configuration keyboard-configuration/optionscode string ctrl:nocaps,terminate:ctrl_alt_bksp
debian-installer debian-installer/locale string ko_KR
localechooser localechooser/supported-locales multiselect en_US.UTF-8 ko_KR.UTF-8
finish-install finish-install/reboot_in_progress note
# example of new config file for setup-storage
#
# <type> <mountpoint> <size> <fs type> <mount options> <misc options>
disk_config disk1 disklabel:msdos bootable:1 fstabkey:label
# Note that the CentOS 5 version of GRUB cannot read from ext3 filesystems with inode_size > 128
# CentOS 5.6 needs /boot as ext3, so we use ext3 for /
#primary / 350 ext3 rw,noatime,errors=remount-ro createopts="-L ROOT -I 128"
# use following line for CentOS 7
primary / 4G-10G ext4 rw,noatime,errors=remount-ro createopts="-L ROOT"
logical swap 200-1000 swap sw createopts="-L SWAP"
logical /tmp 100-1G ext4 rw,noatime,nosuid,nodev createopts="-L TMP -m 0" tuneopts="-c 0 -i 0"
logical /home 100-50% ext4 rw,noatime,nosuid,nodev createopts="-L HOME -m 1" tuneopts="-c 0 -i 0"
# example of new config file for setup-storage
#
# <type> <mountpoint> <size> <fs type> <mount options> <misc options>
disk_config disk1 disklabel:msdos bootable:1 fstabkey:uuid
primary / 2G-15G ext4 rw,noatime,errors=remount-ro
logical swap 200-1G swap sw
logical /tmp 100-1G ext4 rw,noatime,nosuid,nodev createopts="-L tmp -m 0" tuneopts="-c 0 -i 0"
logical /home 100-50% ext4 rw,noatime,nosuid,nodev createopts="-L home -m 1" tuneopts="-c 0 -i 0"
# config file for an FAI install server
#
# <type> <mountpoint> <size> <fs type> <mount options> <misc options>
disk_config disk1 disklabel:msdos fstabkey:uuid
primary / 2G-15G ext4 rw,noatime,errors=remount-ro
logical swap 200-1000 swap sw
logical /tmp 100-1000 ext4 rw,noatime,nosuid,nodev createopts="-m 0" tuneopts="-c 0 -i 0"
logical /home 100-40% ext4 rw,noatime,nosuid,nodev createopts="-m 1" tuneopts="-c 0 -i 0"
logical /srv 1G-50% ext4 rw,noatime createopts="-m 1" tuneopts="-c 0 -i 0"
# <type> <mountpoint> <size> <fs type> <mount options> <misc options>
# entire disk with LVM, separate /home
disk_config disk1 fstabkey:uuid align-at:1M
primary /boot 200 ext2 rw,noatime
primary - 4G- - -
disk_config lvm
vg vg1 disk1.2
vg1-root / 3G-15G ext4 noatime,rw
vg1-swap swap 200-4G swap sw
vg1-home /home 600- ext4 noatime,nosuid,nodev,rw
# <type> <mountpoint> <size> <fs type> <mount options> <misc options>
disk_config disk1 disklabel:msdos bootable:2 fstabkey:uuid
primary swap 1G swap sw
primary / 2G- ext4 rw,noatime,errors=remount-ro
# <type> <mountpoint> <size> <fs type> <mount options> <misc options>
disk_config disk1 disklabel:msdos bootable:2 fstabkey:uuid
primary swap 1G swap sw
primary / 5G ext4 rw,noatime,errors=remount-ro
primary /data 4G xfs rw
#primary - 5G- - -
#disk_config lvm
#vg docker xvda4
deb http://httpredir.debian.org/debian jessie main contrib non-free
deb http://httpredir.debian.org/debian-security jessie/updates main contrib non-free
# dhcpd.conf for a fai installation server
# replace faiserver with the name of your install server
ignore-client-uids on;
deny unknown-clients;
option dhcp-max-message-size 2048;
use-host-decl-names on;
#always-reply-rfc1048 on;
subnet 192.168.33.0 netmask 255.255.255.0 {
option routers 192.168.33.1;
option domain-name "fai.example";
option domain-name-servers 192.168.33.250;
option time-servers faiserver;
# option ntp-servers faiserver;
server-name faiserver;
next-server faiserver;
filename "fai/pxelinux.0";
allow unknown-clients;
pool {
range 192.168.33.100 192.168.33.150;
}
}
# generate a lot of entries with:
# perl -e 'for (1..10) {printf "host client%02s {hardware ethernet XXX:$_;fixed-address client%02s;}\n",$_,$_;}'
# then replace XXX with the hardware addresses of your clients
deb http://httpredir.debian.org/debian jessie main contrib non-free
deb http://security.debian.org/debian-security jessie/updates main contrib non-free
# repository that may contain newer fai packages for jessie
deb http://fai-project.org/download jessie koeln
# See fai.conf(5) for detailed information.
# Account for saving log files and calling fai-chboot.
LOGUSER=fai
# URL to access the fai config space
# If undefined, use default nfs://<install server>/$FAI_CONFIGDIR
FAI_CONFIG_SRC=nfs://faiserver/srv/fai/config
# For a detailed description see nfsroot.conf(5)
# "<suite> <mirror>" for debootstrap
FAI_DEBOOTSTRAP="jessie http://httpredir.debian.org/debian"
FAI_ROOTPW='$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1'
NFSROOT=/srv/fai/nfsroot
TFTPROOT=/srv/tftp/fai
NFSROOT_HOOKS=/etc/fai/nfsroot-hooks/
FAI_DEBOOTSTRAP_OPTS="--exclude=info --include=aptitude"
# Configuration space
FAI_CONFIGDIR=/srv/fai/config
NFSROOT_ETC_HOSTS="192.168.33.250 faiserver"
Plan your installation, and FAI installs your plan.
#! /bin/bash
# setup script that is only run once at boot time
# set up an FAI install server
NORMAL='\E(B\E[m'
RED='\E[31m'
GREEN='\E[32m'
set -o pipefail
# setup network
ifup eth0
sleep 8
[ -x /etc/init.d/nscd ] && /etc/init.d/nscd restart
echo "=================================" >/dev/console
echo "Setting up the FAI install server" >/dev/console
echo "This will take a few minutes" >/dev/console
echo "=================================" >/dev/console
. /etc/fai/fai.conf
. /etc/fai/nfsroot.conf
# copy the simple examples and pimp my config space
if [ ! -d "$FAI_CONFIGDIR/class" ]; then
mkdir -p $FAI_CONFIGDIR
cp -a /usr/share/doc/fai-doc/examples/simple/* $FAI_CONFIGDIR
ainsl /srv/fai/config/class/FAIBASE.var "^LOGUSER=fai"
myip=$(ip addr show up| grep -w inet | cut -d t -f 2 | cut -d ' ' -f 2 | cut -d / -f 1 | grep -v 127.0.0.1)
echo "APTPROXY=http://$myip:3142" >> /srv/fai/config/class/DEBIAN.var
# determine a fast mirror for Ubuntu
list=$(curl -s http://mirrors.ubuntu.com/mirrors.txt)
mirror=$(netselect $list | awk '{print $2}')
sed -i -e "s#MIRRORURL#$mirror#" /srv/fai/config/files/etc/apt/sources.list/UBUNTU
fi
# set the LOGUSER, wo we get all the logs from our install clients
ainsl /etc/fai/fai.conf "^LOGUSER=fai"
# make index, then import the packages from the CD mirror
apt-get update
curl -fs 'http://127.0.0.1:3142/acng-report.html?doImport=Start+Import&calcSize=cs&asNeeded=an#bottom' >/dev/null
# setup the FAI server, including creating the nfsroot, use my own proxy
export APTPROXY="http://127.0.0.1:3142"
fai-setup -fvB /var/tmp/base.tar.xz 2>&1
if [ $? -eq 0 ]; then
rm /var/tmp/base.tar.xz
echo ""
echo "================================================" >/dev/console
echo -e "Setting up the FAI server was ${GREEN}successful${NORMAL}" >/dev/console
echo "================================================" >/dev/console
echo ""
sleep 10
else
echo ""
echo "==================================================" >/dev/console
echo -e "${RED}ERROR${NORMAL}: Setting up the FAI install server ${RED}FAILED${NORMAL}!" >/dev/console
echo "Read /var/log/fai/fai-setup.log for more debugging" >/dev/console
echo "==================================================" >/dev/console
echo ""
sleep 10
exit 99
fi
cat <<EOF >> /srv/fai/nfsroot/etc/fai/fai.conf
# use short hostname instead of FQDN
export HOSTNAME=\${HOSTNAME%%.*}
echo \$HOSTNAME > /proc/sys/kernel/hostname
EOF
# create default pxelinux boot configuration
fai-chboot -o default
# create a template for booting the installation
fai-chboot -Iv -f verbose,sshd,createvt,menu -u nfs://faiserver/srv/fai/config jessie.tmpl
# Since we do not know the MAC address, our DHCP cannot provide the hostname.
# Therefore we do explicitly set the hostname
fai-chboot -Iv -f verbose,sshd,createvt,menu -u nfs://faiserver/srv/fai/config -k hostname=xfcehost xfcehost
fai-chboot -Iv -f verbose,sshd,createvt,menu -u nfs://faiserver/srv/fai/config -k hostname=demohost demohost
for c in {01..10}; do
fai-chboot -Iv -f verbose,sshd,createvt,menu -u nfs://faiserver/srv/fai/config -k hostname=client$c client$c
done
fai-monitor > /var/log/fai/fai-monitor.log &
# move me away
mv $0 /var/tmp
exit 0
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
# SETLOCALDEFS= Check local definition changes
#! /bin/bash
skiptask debconf
#! /bin/bash
# hook for installing a file system image (tar file)
# this works for Ubuntu 14.04
#
# Copyright (C) 2015 Thomas Lange, lange@informatik.uni-koeln.de
# I use this tar command to create the image of an already running and configured machine
# tar -cf /tmp/IMAGE.tar --exclude /tmp/\* --exclude /run/\* --exclude /proc/\* --exclude /sys/\* --exclude /dev/\* /
# add --xattrs --selinux --acl if needed (for CentOS 7)
# Then copy this image to /srv/fai/config/basefiles/IMAGE.tar and make sure your client belongs to the class IMAGE
skiptask extrbase debconf repository updatebase instsoft
skiptask configure # do not run the usual configure scripts
# we assume, that the new host will get its hostname and IP via DHCP
# remove old hostname
fgrep -v 127.0.1.1 $target/etc/hosts >> /tmp/fai/hosts
mv /tmp/fai/hosts $target/etc/hosts
rm $target/etc/hostname
#install grub
mount -t proc proc $FAI_ROOT/proc
mount -t sysfs sysfs $FAI_ROOT/sys
mount --bind /dev $FAI_ROOT/dev
if [ -f $target/etc/debian_version ]; then
$ROOTCMD grub-install $BOOT_DEVICE
$ROOTCMD update-grub
fi
if [ -f $target/etc/centos-release ]; then
rm $target/etc/grub2/device.map
$FAI/scripts/CENTOS/40-install-grub
$FAI/scripts/CENTOS/30-mkinitrd
$ROOTCMD fixfiles onboot # this fixes the SELinux security contexts during the first boot
fi
# things that may be adjusted:
#
# MAC address ?? (not needed for Ubuntu, it uses iftab(5)
# /etc/hosts may contain the IP and name of the original host
# /etc/hostname (for Ubuntu just remove it)
# /var/lib/NetworkManager/dhclient-eth0.conf?
#! /bin/bash
# if package locales will be installed, then install it early, before
# other packages
if [ $FAI_ACTION != "install" ]; then
exit 0
fi
fcopy -Bi /etc/apt/apt.conf.d/force_confdef
ainsl -av /etc/ucf.conf "^conf_force_conffold=YES"
install_packages -l 2>/dev/null | egrep -q ' locales|locales '
if [ $? -eq 0 ]; then
$ROOTCMD apt-get -y install locales
fi
#! /bin/bash
# (c) Michael Goetze, 2010-2011, mgoetze@mgoetze.net
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
if [ $FAI_ACTION = "install" ]; then
mount -t proc proc $target/proc
mount -t sysfs sysfs $target/sys
[ -L $target/etc/mtab ] || cp /etc/mtab $target/etc/mtab
cat > $target/etc/sysconfig/network <<-EOF
NETWORKING=yes
HOSTNAME=$HOSTNAME.$DOMAIN
EOF
echo "127.0.0.1 localhost" > $target/etc/hosts
ifclass DHCPC || ainsl -s /etc/hosts "$IPADDR $HOSTNAME.$DOMAIN $HOSTNAME"
cp /etc/resolv.conf $target/etc
fi
mkdir $target/dev/pts
mknod -m 000 $target/dev/pts/ptmx c 5 2
fcopy -riv /etc/yum.repos.d/
# disable the fastestmirror plugin
#sed -i -e 's/enabled=1/enabled=0/' $target/etc/yum/pluginconf.d/fastestmirror.conf
skiptask repository
exit $error
#! /bin/bash
# parse all log files for error messages
# print errors and warnings found to error.log
# WARNING: This will only work with english error messages!
errfile=$LOGDIR/error.log
# Define grep patterns. Do not start or end with an empty line!
globalerrorpatterns="error
fail
warn
bad
no space
syntax
Couldn't stat
Cannot access
conflict
is bigger than the limit
did not exist
non existent
not found
couldn't
can't
E: Sorry, broken packages
operator expected
ambiguous redirect
No previous regular expression
No such
Device or resource busy
unknown option
[a-z]\+\.log:E:
No candidate version found
segfault
Couldn't find any package whose name or description matched
cannot create
The following packages have unmet dependencies"
globalignorepatterns="[a-z]\+\.log:#
Error: Driver 'pcspkr' is already registered, aborting
: bytes packets errors dropped
:+ error=0
:+ trap error=
task_error_func=
STOP_ON_ERROR=
courier-webadmin
plugins-bad
Enabling conf localized-error-pages
ibwebadmin
kernel-patch-badram
kolab-webadmin
kolabadmin
gstreamer0.10-plugins-really-bad
liberrors.so
gsambad
libad
libtest-nowarnings-perl
libtest-warn-perl
libclass-errorhandler-perl
zope-ploneerrorreporting
libroxen-errormessage
liberror-perl
libgpg-error-dev
libgpg-error0
^fstab.\+errors=remount
Opts: errors=remount-ro
[RT]X packets:
WARNING: unexpected IO-APIC
warned about = ( )
daemon.warn
kern.warn
rw,errors=
Expect some cache
no error
failmsg
RPC call returned error 101
deverror.out
(floppy), sector 0
mount version older than kernel
Can't locate module
Warning only 896MB will be used.
hostname: Host name lookup failure
I can't tell the difference.
warning, not much extra random data, consider using the -rand option
confC._FILE
Warning: 3 database(s) sources
were not found, (but were created)
removing exim
The home dir you specified already exists.
No Rule for /usr/lib/ispell/default.hash.
/usr/sbin/update-fonts-.\+: warning: absolute path
hostname: Unknown server error
EXT2-fs warning: checktime reached
RPC: sendmsg returned error 101
can't print them to stdout. Define these classes
warning: downgrading
suppress emacs errors
echo Error:
Can't open dependencies file
documents in /usr/doc are no longer supported
if you have both a SCSI and an IDE CD-ROM
Warning: /proc/ide/hd?/settings interface is obsolete, and will be removed soon
Monitoring disabled
Error: only one processor found.
Error Recovery Strategy:
sector 0 does not have an
syslogin_perform_logout: logout() returned an error
grub is not in an XFS filesystem.
grub-install: line 374:
grub-probe: error: Cannot open \`/boot/grub/device.map'
is harmless
not updating .\+ font directory data.
register_serial(): autoconfig failed
Fontconfig error: Cannot load default config file
asking for cache data failed
However, I can not read the target:
Warning: The partition table looks like it was made
task_error=0
^info: Trying to set
warning: /usr/lib/X11/fonts
can't read /etc/udev/rules.d/z25_persistent-net.rules
/cow': No such file or directory
Dummy start-stop-daemon called
X: bytes packets errors
ACPI Error
ACPI Warning
AE_NOT_FOUND
conflicts with ACPI region
cannot stat \`/etc/modprobe.d/\*.conf'
cdrom: open failed.
libgpg-error
process \`kudzu' used the deprecated sysctl system call
PM: Resume from disk failed
JBD: barrier-based sync failed
aufs: module is from the staging directory, the quality is unknown
warning: linuxlogo stop runlevel arguments (none) do not match
insserv: warning: script .\+ missing LSB tags and overrides
live-premount.\+ If this fails
cannot read table of mounted file systems
error: no alternatives for
ERST: Error Record Serialization Table (ERST) support is initialized
ERST: Table is not found
HEST: Table not found
failed to stat /dev/pts
Failed to connect to socket /var/run/dbus/system_bus_socket
fail to add MMCONFIG information
can't initialize iptables table
can't initialize ip6tables table
Authentication warning overridden
update-alternatives: warning: skip creation of
update-rc.d: warning: start and stop actions are no longer supported"
# add pattern on some conditions
if [ -n $FAI_ALLOW_UNSIGNED ] ; then
globalignorepatterns="$globalignorepatterns
WARNING: untrusted versions
Ignoring these trust violations"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Here you can define your own patterns. Put one pattern in a line,
# do not create empty lines.
myerrorpatterns="X_X-X_XX"
myignorepatterns="X_X-X_XX"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# The main routine
errorpatterns="$globalerrorpatterns
$myerrorpatterns"
ignorepatterns="$globalignorepatterns
$myignorepatterns"
cd $LOGDIR || exit 3
if [ -s $errfile ]; then
echo "Errorfile already exists. Aborting." >&2
exit
fi
grep -i "$errorpatterns" *.log | grep -vi "$ignorepatterns" > $errfile
if [ "$verbose" ]; then
egrep -v '^software.log:' $errfile > $LOGDIR/tempfile
mv $LOGDIR/tempfile $errfile
fi
if [ -s $errfile ]; then
echo "ERRORS found in log files. See $errfile" >&2
else
echo "Congratulations! No errors found in log files."
fi
#! /bin/bash
# use short hostname instead of FQDN
export HOSTNAME=${HOSTNAME%%.*}
# n.b. use $action instead of $FAI_ACTION
# as the latter is apparently unset at this point in dirinstall
if [ "$action" = "dirinstall" ] ; then
:
else
echo $HOSTNAME > /proc/sys/kernel/hostname
fi
#! /bin/bash
if [ ! -f $target/etc/resolv.conf ]; then
cp /etc/resolv.conf $target/etc
fi
if [ "$verbose" ]; then
echo "Updating base"
$ROOTCMD yum -y update 2>&1 | tee -a $LOGDIR/software.log
else
$ROOTCMD yum -y update >> $LOGDIR/software.log
fi
skiptask updatebase
#! /bin/bash
if [ -n "$APTPROXY" ]; then
echo "Acquire::http::Proxy \"$APTPROXY\";" > $target/etc/apt/apt.conf.d/02proxy
else
rm -f $target/etc/apt/apt.conf.d/02proxy
fi
echo force-unsafe-io > $target/etc/dpkg/dpkg.cfg.d/unsafe-io
# you may want to add i386 arch to amd64 hosts
# if ifclass AMD64; then
# $ROOTCMD dpkg --add-architecture i386
# fi
#! /bin/bash
# use external mirror, remove this script when using a mirror from CD
echo $dist
cat <<EOM > $target/etc/apt/sources.list
# external mirror
deb MIRRORURL $dist main restricted universe multiverse
deb MIRRORURL $dist-updates main restricted universe multiverse
deb MIRRORURL $dist-security main restricted universe multiverse
EOM
# determine a fast mirror for Ubuntu
list=$(curl -s http://mirrors.ubuntu.com/mirrors.txt)
mirror=$(netselect $list | awk '{print $2}')
sed -i -e "s#MIRRORURL#$mirror#" $target/etc/apt/sources.list
PACKAGES yumgroup
core
#PACKAGES yumgroup XORG
#gnome-desktop base-x # slc5/CentOS 5
#basic-desktop x11 fonts #slc6/CentOS 6
#gnome-desktop # CentOS 7
PACKAGES yumi
authconfig
kernel
# sysvinit-tools grub # CentOS 5 and 6
grub2 # CentOS 7
less
openssh
openssh-clients
openssh-server
vim-enhanced
man
curl
screen
unzip
which
nfs-utils
pakchois
ncurses-base # currently missing in the base file
ntp
#sendmail # only for C5 and C6
PACKAGES yumi LVM
lvm2
PACKAGES yumi PORCH
pyliblzma
PACKAGES install I386
linux-image-686-pae initramfs-tools
memtest86+
PACKAGES install CHROOT
linux-image-686-pae-
linux-image-amd64-
PACKAGES install AMD64
linux-image-amd64 initramfs-tools
memtest86+
PACKAGES install DHCPC
isc-dhcp-client
PACKAGES install GRUB_PC
grub-pc grub-legacy- lilo-
PACKAGES install LVM
lvm2
PACKAGES install PORCH
nano-
curl
# some packages we need on a demo machine
PACKAGES aptitude
fortune-mod fortunes
rstat-client #rstatd
# only when also class XORG is defined
PACKAGES aptitude XORG
bb xpenguins
#frozen-bubble
PACKAGES aptitude DEBIAN
fai-client
cron
debconf-utils
file
less
linuxlogo
rdate
rsync
openssh-client openssh-server
strace
time
procinfo
nullmailer
eject
locales
console-setup kbd
pciutils usbutils
PACKAGES aptitude
fai-quickstart
isc-dhcp-client
debmirror tcpdump
xorriso grub-pc
lftp curl
netselect
syslinux-common pxelinux
apt-cacher-ng
nscd psmisc
bind9 dnsutils
iptables-persistent
emacs24-nox
PACKAGES aptitude
task-german
PACKAGES aptitude GNOME
iceweasel-l10n-de icedove-l10n-de
PACKAGES aptitude
iceweasel
#icedove
menu gdm3
gnome-core
gconf-editor
gnome-screensaver gnome-system-monitor gnome-system-tools
gnome-network-admin
libgnomevfs2-bin
PACKAGES install I386
linux-image-generic initramfs-tools
memtest86+
PACKAGES install CHROOT
linux-image-generic-
PACKAGES install AMD64
linux-image-generic initramfs-tools
memtest86+
PACKAGES install DHCPC
isc-dhcp-client
PACKAGES install GRUB_PC
grub-pc
PACKAGES aptitude-r XORG
ubuntu-desktop
ubuntu-standard
ubuntu-minimal
PACKAGES install
openssh-server
openssh-client
PACKAGES install PORCH
curl
PACKAGES install
less
sudo
openssh-server
xen-linux-system-amd64
initramfs-tools
ocaml-nox
bridge-utils
python
python-lxml
python-dev
python-pip
ifenslave-2.6
file
rsync
ntfs-3g
kpartx
parted
xfsprogs
rpm
rdate
build-essential
debconf-utils
telnet
vim
lshw
dstat
lsof
lvm2
ethtool
tcpdump
aoetools
subversion
ntpdate
ntp
git-core
initramfs-tools
seabios
libspice-protocol-dev
libspice-server1
libspice-server-dev
libusbredirhost-dev
libusbredirparser-dev
libxen-4.4
libxen-dev
linux-image-3.16.0-4-amd64
linux-headers-3.16.0-4-amd64
linux-kbuild-3.16
#linux-image-3.16.0-4-amd64-dbg
blktap-dkms
libusb-1.0-0-dev
libseccomp-dev
qemu-system-x86
qemu-utils
blktap-utils
libssl1.0.0
libssl-dev
openssl
irqbalance
sysv-rc-conf
drbd8-utils
openvswitch-switch
multipath-tools
ocfs2-tools
open-iscsi
nfs-common
ipmitool
openipmi
kexec-tools
makedumpfile
kdump-tools
crash
#mcelog
PACKAGES aptitude
xfce4 # base system
xfce4-goodies # additional tools
lightdm
iceweasel
PACKAGES aptitude DEBIAN
xorg xserver-xorg-video-all xserver-xorg-input-all
ttf-freefont
xscreensaver
xscreensaver-gl
xterm
desktop-base
#! /bin/bash
# (c) Michael Goetze, 2010-11, mgoetze@mgoetze.net
# Thomas Lange, 2015
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
$ROOTCMD authconfig --enableshadow --enablemd5 \
--enablelocauthorize --updateall
$ROOTCMD usermod -p $ROOTPW root
fcopy -v /etc/selinux/config
$ROOTCMD fixfiles onboot # this fixes the SELinux security contexts during the first boot
chmod a+rx $target
exit $error
#! /bin/bash
# (c) Michael Goetze, 2010-2011, mgoetze@mgoetze.net
# (c) Thomas Lange, 2011, Uni Koeln
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
ainsl -v /etc/fstab "proc /proc proc defaults 0 0"
ainsl -v /etc/fstab "sysfs /sys sysfs auto 0 0"
version=`$ROOTCMD rpm -qv kernel | cut -d- -f2-`
use_mkinitrd() {
# CentOS 5 uses mkinitrd
$ROOTCMD kudzu -q -k $version
# Unfortunately mkinitrd is horrible at guessing which modules to include,
# especially when the running kernel is different than the kernel for which
# we are creating an initrd...
drivers=""
for bus in pci virtio; do
for dr in `$ROOTCMD kudzu -p -k $version -b $bus|grep driver:|cut -d' ' -f2|sort -u`; do
found=`find $target/lib/modules/$version/ -name $dr.ko 2>/dev/null`
if [ -n "$found" ]; then
# add driver only if it's available as .ko module in the destination kernel
drivers+=" --with=$dr"
fi
done
done
$ROOTCMD mkinitrd -f -v $drivers /boot/initrd-$version.img $version
if [ $? -eq 1 ]; then
echo "WARNING: generating initrd with list of drivers failed. Trying without."
$ROOTCMD mkinitrd -f -v /boot/initrd-$version.img $version
fi
}
# CentOS 5 uses mkinitrd
if [ -f $target/sbin/mkinitrd ]; then
use_mkinitrd
fi
if [ -f $target/etc/lvm/lvm.conf ]; then
sed -i -e 's/use_lvmetad = 1/use_lvmetad = 0/' $target/etc/lvm/lvm.conf
ainsl -av /etc/dracut.conf.d/fai.conf 'add_dracutmodules+=" lvm "'
fi
# call dracut for CentOS 7
if [ -f $target/usr/sbin/dracut ]; then
# add filesystem driver into initrd
ainsl -av /etc/dracut.conf.d/fai.conf 'filesystems+="ext4"'
$ROOTCMD dracut -v --kver $version --force
fi
# call dracut for CentOS 6
if [ -f $target/sbin/dracut ]; then
# add filesystem driver into initrd
ainsl -av /etc/dracut.conf.d/fai.conf 'filesystems+="ext4"'
$ROOTCMD dracut -v $version
fi
exit $error
#! /bin/bash
# (c) Michael Goetze, 2011, mgoetze@mgoetze.net
# (c) Thomas Lange 2014
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
if [ -r $LOGDIR/disk_var.sh ] ; then
. $LOGDIR/disk_var.sh
else
echo "disk_var.sh not found!"
exit 1
fi
# CentOS 7 does not have a device.map file, so generate one
if [ -d $target/boot/grub2 -a ! -f $target/boot/grub2/device.map ]; then
echo "# Generated by FAI" >> $target/boot/grub2/device.map
centosdisks=$(awk '/[sv]d.$/ {print $4}' /proc/partitions | sort)
dcount=0
for d in $centosdisks; do
echo "(hd$dcount) /dev/$d" >> $target/boot/grub2/device.map
dcount=$((dcount + 1))
done
fi
bootdev=`device2grub $BOOT_DEVICE`
bootpart=`device2grub $BOOT_PARTITION`
version=`$ROOTCMD rpm -qv kernel | cut -d- -f2-`
if grep '[[:space:]]/boot[[:space:]]' $LOGDIR/fstab; then
bootdir=''
else
bootdir='/boot'
fi
mount -o bind /dev $target/dev
if [ -f $target/usr/sbin/grub2-install ]; then
# CentOS 7
$ROOTCMD grub2-install --no-floppy "$BOOT_DEVICE"
$ROOTCMD grub2-mkconfig --output=/boot/grub2/grub.cfg
else
$ROOTCMD grub-install --just-copy
$ROOTCMD grub --device-map=/dev/null --no-floppy --batch <<-EOF
device $bootdev $BOOT_DEVICE
root $bootpart
setup $bootdev
quit
EOF
ln -s ./menu.lst $target/boot/grub/grub.conf
if [ -f $target/boot/grub/splash.xpm.gz ]; then
pretty="splashimage=$bootpart$bootdir/grub/splash.xpm.gz"
else
pretty="color cyan/blue white/blue"
fi
if [ -f $target/sbin/dracut -o -f $target/usr/sbin/dracut ]; then
# CentOS 6
iname=initramfs
else
# CentOS 5
iname=initrd
fi
title=`head -1 $target/etc/redhat-release`
cat > $target/boot/grub/grub.conf <<-EOF
timeout 5
default 0
$pretty
hiddenmenu
title $title
root $bootpart
kernel $bootdir/vmlinuz-$version root=$ROOT_PARTITION ro
initrd $bootdir/$iname-$version.img
EOF
fi
umount $target/dev
echo ""
echo "Grub installed on $BOOT_DEVICE = $bootdev"
echo "Grub boot partition is $BOOT_PARTITION = $bootpart"
echo "Root partition is $ROOT_PARTITION"
echo "Boot kernel: $version"
exit $error
#! /bin/bash
# (c) Michael Goetze, 2011, mgoetze@mgoetze.net
error=0 ; trap "error=$((error|1))" ERR
cat > $target/etc/sysconfig/clock <<-EOF
UTC=$UTC
ZONE=$TIMEZONE
EOF
cat > $target/etc/sysconfig/i18n <<-EOF
LANG="$DEFAULTLOCALE"
SUPPORTED="$SUPPORTEDLOCALE"
SYSFONT="$CONSOLEFONT"
EOF
cat > $target/etc/sysconfig/keyboard <<-EOF
KEYBOARDTYPE="pc"
KEYTABLE="$KEYMAP"
EOF
if [ -f $target/usr/lib/locale/locale-archive.tmpl \
-a ! -s $target/usr/lib/locale/locale-archive ]; then
mv $target/usr/lib/locale/locale-archive.tmpl $target/usr/lib/locale/locale-archive
fi
fcopy -iv /etc/sysconfig/i18n /etc/sysconfig/keyboard
exit $error
#! /bin/bash
# (c) Michael Goetze, 2011, mgoetze@mgoetze.net
error=0 ; trap "error=$((error|1))" ERR
# Note: Kudzu will automatically configure eth0 for DHCP
#if [ $FAI_ACTION != "softupdate" ] && ! ifclass DHCPC
if [ $FAI_ACTION != "softupdate" ]
then
ainsl -v /etc/sysconfig/network "^GATEWAY=$GATEWAYS_1\$"
[ -n "$IPADDR" ] && cat > $target/etc/sysconfig/network-scripts/ifcfg-eth0 <<-EOF
# generated by FAI
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
HWADDR=`ip l sh dev eth0 | tail -1 | cut -d" " -f6`
IPADDR=$IPADDR
NETMASK=$NETMASK
GATEWAY=$GATEWAYS
EOF
# Kudzu for some reason won't write eth0 into /etc/sysconfig/hwconf
# from within the chroot. The following hack puts it in there
# so that Kudzu doesn't overwrite our config on first boot.
if [ -f $target/sbin/kudzu ]; then
grep eth0 $target/etc/sysconfig/hwconf || $ROOTCMD kudzu -c NETWORK -p \
>> $target/etc/sysconfig/hwconf
fi
fi
# Set hostname
[ -n "$HOSTNAME" ] && echo $HOSTNAME > $target/etc/hostname
# enable ntpd and ntpdate
$ROOTCMD systemctl enable ntpd ntpdate
# mask NetworkManager - Never run NetworkManager on the server.
$ROOTCMD systemctl mask NetworkManager
fcopy -iv /etc/sysconfig/network /etc/resolv.conf /etc/networks
fcopy -ivr /etc/sysconfig/network-scripts
exit $error
#! /bin/bash
## Disable entire script by Heechul Kim
exit 0
error=0 ; trap "error=$((error|1))" ERR
# add a demo user account
if ! $ROOTCMD getent passwd demo ; then
$ROOTCMD adduser -c "fai demo user" demo
$ROOTCMD usermod -p "$ROOTPW" demo
fi
# enable graphical login screen, make run level 5 as default
if [ -f $target/usr/sbin/gdm ]; then
sed -i -e 's/id:3:initdefault:/id:5:initdefault:/' $target/etc/inittab
# do not run this tool
echo "RUN_FIRSTBOOT=NO" > $target/etc/sysconfig/firstboot
fi
exit $error
#! /bin/bash
$ROOTCMD yum clean all
#! /bin/bash
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
# set root password
$ROOTCMD usermod -p $ROOTPW root
exit $error
#!/bin/bash
#
# Capabilities get lost when creating the fai base.tar.xz image.
# Restore them here.
#
set -e
if [ ! -x $target/sbin/setcap ] ; then
exit 0
fi
for FILE in /bin/ping /bin/ping6 /usr/bin/fping /usr/bin/fping6; do
if [ -x $target/$FILE ] ; then
if $ROOTCMD /sbin/setcap cap_net_raw+ep $FILE; then
echo "Setcap worked! $FILE is not suid!"
fi
fi
done
if [ -x $target/usr/bin/systemd-detect-virt ] ; then
$ROOTCMD /sbin/setcap cap_dac_override,cap_sys_ptrace+ep /usr/bin/systemd-detect-virt
fi
#! /bin/bash
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
if ifclass DHCPC && [ $FAI_ACTION = "install" -o $FAI_ACTION = "dirinstall" ]
then
cat > $target/etc/network/interfaces <<-EOF
# generated by FAI
auto lo $NIC1
iface lo inet loopback
iface $NIC1 inet dhcp
EOF
elif [ $FAI_ACTION = "install" -o $FAI_ACTION = "dirinstall" ]
then
[ -n "$IPADDR" ] && cat > $target/etc/network/interfaces <<-EOF
# generated by FAI
auto lo $NIC1
iface lo inet loopback
iface $NIC1 inet static
address $IPADDR
netmask $NETMASK
broadcast $BROADCAST
gateway $GATEWAYS
EOF
[ -n "$NETWORK" ] && echo "localnet $NETWORK" > $target/etc/networks
if [ ! -L $target/etc/resolv.conf -a -e /etc/resolv.conf ]; then
cp -p /etc/resolv.conf $target/etc
fi
fi
# here fcopy is mostly used, when installing a client for running in a
# different subnet than during the installation
fcopy -iM /etc/resolv.conf
fcopy -iM /etc/network/interfaces /etc/networks
exit $error
#! /bin/bash
# (c) Thomas Lange, 2001-2015, lange@debian.org
# (c) Michael Goetze, 2010-2011, mgoetze@mgoetze.net
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
# a list of modules which are loaded at boot time
for module in $MODULESLIST; do
ainsl -a /etc/modules "^$module$"
done
fcopy -Mv /etc/hostname || echo $HOSTNAME > $target/etc/hostname
ainsl -av /etc/mailname ${HOSTNAME}
if [ ! -e $target/etc/adjtime ]; then
printf "0.0 0 0.0\n0\nUTC" > $target/etc/adjtime
fi
if [ "$UTC" = "yes" ]; then
sed -i -e 's:^LOCAL$:UTC:' $target/etc/adjtime
else
sed -i -e 's:^UTC$:LOCAL:' $target/etc/adjtime
fi
# enable linuxlogo
if [ -f $target/etc/inittab ]; then
sed -i -e 's#/sbin/getty 38400#/sbin/getty -f /etc/issue.linuxlogo 38400#' ${target}/etc/inittab
elif [ -f $target/lib/systemd/system/getty@.service ]; then
sed -i -e 's#sbin/agetty --noclear#sbin/agetty -f /etc/issue.linuxlogo --noclear#' $target/lib/systemd/system/getty@.service
fi
if [ ! -f $target/etc/machine-id -a -f $target/bin/systemd-machine-id-setup ]; then
$ROOTCMD systemd-machine-id-setup
fi
ln -fs /proc/mounts $target/etc/mtab
rm -f $target/etc/dpkg/dpkg.cfg.d/fai
[ $FAI_ACTION = "install" -a -f /etc/fai/fai.conf ] && cp /etc/fai/fai.conf $target/etc/fai/fai.conf
ainsl -av /etc/fai/fai.conf "FAI_CONFIG_SRC=$FAI_CONFIG_SRC"
fcopy -Miv /etc/fai/fai.conf
exit $error
#! /bin/bash
# (c) Thomas Lange, 2001-2013, lange@debian.org
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
ifclass XORG && {
fcopy -M /etc/X11/xorg.conf
}
if ifclass UBUNTU; then
groups="adm cdrom sudo dip plugdev lpadmin sambashare"
$ROOTCMD addgroup --system lpadmin || true
$ROOTCMD addgroup --system sambashare || true
fi
# add a demo user account
if ! $ROOTCMD getent passwd demo ; then
$ROOTCMD adduser --disabled-login --gecos "fai demo user" demo
$ROOTCMD usermod -p "$ROOTPW" demo
for g in $groups; do
$ROOTCMD adduser demo $g
done
fi
#! /bin/bash
# (c) Thomas Lange, 2001-2012, lange@debian.org
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
echo $TIMEZONE > $target/etc/timezone
cp -f /usr/share/zoneinfo/${TIMEZONE} $target/etc/localtime
if [ -n "$IPADDR" ]; then
ifclass DHCPC || ainsl -s /etc/hosts "$IPADDR $HOSTNAME.$DOMAIN $HOSTNAME"
else
ifclass DHCPC && ainsl -s /etc/hosts "127.0.0.1 $HOSTNAME"
fi
fcopy -iM /etc/hosts /etc/motd
# make /root accessible only by root
chmod -c 0700 $target/root
chown -c root:root $target/root
# copy default dotfiles for root account
fcopy -ir /root
chmod -c 1777 ${target}/tmp
chown -c 0:0 ${target}/tmp
exit $error
#! /bin/bash
# (c) Thomas Lange, 2006,2009, lange@debian.org
# create entries for removable media in fstab and directories in /media
[ -b $target/dev/fd0 ] && ainsl /etc/fstab "/dev/fd0 /media/floppy auto users,noauto 0 0"
cdromlist() {
[ -f /proc/sys/dev/cdrom/info ] || return
devs=$(grep 'drive name:' /proc/sys/dev/cdrom/info | cut -d ":" -f 2)
for d in $devs; do
echo $d
done
}
fstabline () {
line=$(printf "%-15s %-15s %-7s %-15s %-7s %s\n" "$1" "$2" "$3" "$4" "$5" "$6")
ainsl /etc/fstab "$line"
}
i=0
for cdrom in $(cdromlist | tac); do
[ $i -eq 0 ] && ln -sfn cdrom0 $target/media/cdrom
mkdir -p $target/media/cdrom$i
fstabline /dev/$cdrom /media/cdrom$i udf,iso9660 ro,user,noauto 0 0
i=$(($i + 1))
done
#! /bin/bash
fcopy -Bvr /etc/fai
fcopy -Bv /etc/fai/apt/sources.list /etc/dhcp/dhcpd.conf
fcopy -v /etc/rc.local
if [ $FAI_ACTION = "install" ]; then
# use the same sources.list for the server itself and the clients
cp -a $target/etc/fai/apt $target/etc/
if ifclass DHCPC; then
rm -f $target/etc/resolv.conf
else
echo 127.0.0.1 > $target/etc/resolv.conf
fi
# faiserver uses its own apt cache
ainsl -av /etc/apt/apt.conf.d/02proxy 'Acquire::http::Proxy "http://127.0.0.1:3142";'
# create some host entries
myip=$(ip addr show up| grep -w inet | cut -d t -f 2 | cut -d ' ' -f 2 | cut -d / -f 1 | grep -v 127.0.0.1)
ainsl /etc/hosts "$myip faiserver" # that's me
ainsl /etc/hosts "192.168.33.100 demohost"
ainsl /etc/hosts "192.168.33.101 xfcehost"
# add entries for 10 hosts called client 01 .. 10
perl -e 'for (1..10) {printf "192.168.33.%s client%02s\n",101+$_,$_;}' >> $target/etc/hosts
sed -i -e '/# ReuseConnections: 1/d' $target/etc/apt-cacher-ng/acng.conf
ainsl -v /etc/apt-cacher-ng/acng.conf "ReuseConnections: 0"
# copy base file for faster building of nfsroot
cp -p /var/tmp/base.tar.xz $target/var/tmp
if [ -d /media/mirror/pool ]; then
mkdir $target/var/cache/apt-cacher-ng/_import
cp -p /media/mirror/pool/*/*/*/*.deb $target/var/cache/apt-cacher-ng/_import
$ROOTCMD chown -R apt-cacher-ng.apt-cacher-ng /var/cache/apt-cacher-ng/_import
fi
# copy basefiles from CD to config space
if [ -d $FAI/basefiles ]; then
mkdir -p $target/srv/fai/config/basefiles
cp -vp $FAI/basefiles/*.tar.* $target/srv/fai/config/basefiles 2>/dev/null
fi
fi
#! /bin/bash
# support for GRUB version 2
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
set -a
# during softupdate use this file
[ -r $LOGDIR/disk_var.sh ] && . $LOGDIR/disk_var.sh
if [ -z "$BOOT_DEVICE" ]; then
exit 189
fi
# disable os-prober because of #788062
ainsl /etc/default/grub 'GRUB_DISABLE_OS_PROBER=true'
# skip the rest, if not an initial installation
if [ $FAI_ACTION != "install" ]; then
$ROOTCMD update-grub
exit $error
fi
$ROOTCMD grub-mkdevicemap --no-floppy
GROOT=$($ROOTCMD grub-probe -tdrive -d $BOOT_DEVICE)
# Check if RAID is used for the boot device
if [[ $BOOT_DEVICE =~ '/dev/md' ]]; then
raiddev=${BOOT_DEVICE#/dev/}
# install grub on all members of RAID
for device in `LC_ALL=C perl -ne 'if(/^'$raiddev'\s.+raid\d+\s(.+)/){ $_=$1; s/\d+\[\d+\]//g; print }' /proc/mdstat`; do
echo Install grub on /dev/$device
$ROOTCMD grub-install --no-floppy "/dev/$device"
done
else
$ROOTCMD grub-install --no-floppy "$GROOT"
if [ $? -eq 0 ]; then
echo "Grub installed on $BOOT_DEVICE = $GROOT"
fi
fi
$ROOTCMD update-grub
exit $error
#! /bin/bash
# copyright Thomas Lange 2001-2015, lange@debian.org
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
if [ "$FAI_ACTION" = "dirinstall" ] ; then
:
else
# check if mdadm has been forgotten
if grep -q active /proc/mdstat 2>/dev/null; then
if [ ! -d $target/etc/mdadm ]; then
echo ERROR: Found Software RAID, but the mdadm package was not installed
error=1
fi
fi
usedm=$(dmsetup ls | egrep -v '^live-rw|^live-base|^No devices found' | wc -l)
if [ $usedm -ne 0 ]; then
if [ ! -d $target/etc/lvm ]; then
echo ERROR: Found lvm devices, but the lvm2 package was not installed
error=1
fi
fi
fi
# remove backup files from cfengine, but only if cfengine is installed
if [ -x /usr/sbin/cfagent ] || [ -x $target/usr/sbin/cfagent ] ; then
dirs="root etc var"
for path in $dirs; do
find $target/$path -maxdepth 20 -name \*.cfedited -o -name \*.cfsaved | xargs -r rm
done
fi
[ "$FAI_DEBMIRROR" ] &&
ainsl /etc/fstab "#$FAI_DEBMIRROR $MNTPOINT nfs ro 0 0"
# set bios clock
if [ $do_init_tasks -eq 1 ] ; then
case "$UTC" in
no|"") hwopt="--localtime" ;;
yes) hwopt="--utc" ;;
esac
hwclock $hwopt --systohc || true
fi
# Make sure everything is configured properly
if ifclass DEBIAN ; then
echo "Running \"apt-get -f install\" for the last time."
$ROOTCMD apt-get -f install
fi
if [ $FAI_ACTION = "install" ]; then
lskernels=$(echo $target/boot/vmlinu*)
[ -f ${lskernels%% *} ] || echo "ERROR: No kernel was installed. Have a look at shell.log" >&2
fi
# copy sources.list
fcopy -iM /etc/apt/sources.list
exit $error
#! /bin/bash
# Disable root user password
# Create private/public keys
# Copy the public key to root's authorized_keys on the newly installed system
#
# Heechul Kim, jijisa@iorchard.net
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
# Copy porch's pubkey to root's authorized_keys
if [ -f $FAI/pubkeys/authorized_keys ]
then
# lock the root password
$ROOTCMD usermod -L root
mkdir -p $target/root/.ssh && chmod 700 $target/root/.ssh
cat $FAI/pubkeys/authorized_keys > $target/root/.ssh/authorized_keys
chmod 600 $target/root/.ssh/authorized_keys
else
echo "No ssh pubkey so do nothing."
fi
#! /bin/bash
# 20-saltminion
# Install salt-minion
#
# Heechul Kim, jijisa@iorchard.net
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
# temporarily disabled.
exit 0
# Get install_salt.sh
$ROOTCMD curl -L https://bootstrap.saltstack.com -o /root/install_salt.sh
# Install salt-minion (-P: pip-based install, -X: not run after install)
$ROOTCMD sh /root/install_salt.sh -P -X
# minion configuration
# Add master
ainsl -v /etc/salt/minion "master: ${NTPSRVS}" "^master:"
# Add master key fingerprint ($FAI/saltkey/master.finger)
FINGER=$(cat $FAI/saltkey/master.finger)
ainsl -v /etc/salt/minion "master_finger: '${FINGER}'" "^master_finger:"
# Add hash_type: sha256
ainsl -v /etc/salt/minion "hash_type: sha256" "^hash_type:"
# remove install_salt.sh
$ROOTCMD rm /root/install_salt.sh
#! /bin/bash
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
# set root password
$ROOTCMD usermod -p $ROOTPW root
exit $error
#!/bin/bash
#
# Capabilities get lost when creating the fai base.tar.xz image.
# Restore them here.
#
set -e
if [ ! -x $target/sbin/setcap ] ; then
exit 0
fi
for FILE in /bin/ping /bin/ping6 /usr/bin/fping /usr/bin/fping6; do
if [ -x $target/$FILE ] ; then
if $ROOTCMD /sbin/setcap cap_net_raw+ep $FILE; then
echo "Setcap worked! $FILE is not suid!"
fi
fi
done
if [ -x $target/usr/bin/systemd-detect-virt ] ; then
$ROOTCMD /sbin/setcap cap_dac_override,cap_sys_ptrace+ep /usr/bin/systemd-detect-virt
fi
#! /bin/bash
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
if ifclass DHCPC && [ $FAI_ACTION = "install" -o $FAI_ACTION = "dirinstall" ]
then
cat > $target/etc/network/interfaces <<-EOF
# generated by FAI
auto lo $NIC1
iface lo inet loopback
iface $NIC1 inet dhcp
EOF
elif [ $FAI_ACTION = "install" -o $FAI_ACTION = "dirinstall" ]
then
[ -n "$IPADDR" ] && cat > $target/etc/network/interfaces <<-EOF
# generated by FAI
auto lo $NIC1
iface lo inet loopback
iface $NIC1 inet static
address $IPADDR
netmask $NETMASK
broadcast $BROADCAST
gateway $GATEWAYS
EOF
[ -n "$NETWORK" ] && echo "localnet $NETWORK" > $target/etc/networks
if [ ! -L $target/etc/resolv.conf -a -e /etc/resolv.conf ]; then
cp -p /etc/resolv.conf $target/etc
fi
fi
# here fcopy is mostly used, when installing a client for running in a
# different subnet than during the installation
fcopy -iM /etc/resolv.conf
fcopy -iM /etc/network/interfaces /etc/networks
exit $error
#! /bin/bash
# (c) Thomas Lange, 2001-2015, lange@debian.org
# (c) Michael Goetze, 2010-2011, mgoetze@mgoetze.net
error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
# a list of modules which are loaded at boot time
for module in $MODULESLIST; do
ainsl -a /etc/modules "^$module$"
done
fcopy -Mv /etc/hostname || echo $HOSTNAME > $target/etc/hostname
ainsl -av /etc/mailname ${HOSTNAME}
if [ ! -e $target/etc/adjtime ]; then
printf "0.0 0 0.0\n0\nUTC" > $target/etc/adjtime
fi
if [ "$UTC" = "yes" ]; then
sed -i -e 's:^LOCAL$:UTC:' $target/etc/adjtime
else
sed -i -e 's:^UTC$:LOCAL:' $target/etc/adjtime
fi
# enable linuxlogo
if [ -f $target/etc/inittab ]; then
sed -i -e 's#/sbin/getty 38400#/sbin/getty -f /etc/issue.linuxlogo 38400#' ${target}/etc/inittab
elif [ -f $target/lib/systemd/system/getty@.service ]; then
sed -i -e 's#sbin/agetty --noclear#sbin/agetty -f /etc/issue.linuxlogo --noclear#' $target/lib/systemd/system/getty@.service
fi
if [ ! -f $target/etc/machine-id -a -f $target/bin/systemd-machine-id-setup ]; then
$ROOTCMD systemd-machine-id-setup
fi
ln -fs /proc/mounts $target/etc/mtab
rm -f $target/etc/dpkg/dpkg.cfg.d/fai
[ $FAI_ACTION = "install" -a -f /etc/fai/fai.conf ] && cp /etc/fai/fai.conf $target/etc/fai/fai.conf
ainsl -av /etc/fai/fai.conf "FAI_CONFIG_SRC=$FAI_CONFIG_SRC"
fcopy -Miv /etc/fai/fai.conf
exit $error
#! /bin/bash
# check if we already use an external mirror
grep -q "external mirror" $target/etc/apt/sources.list && exit 0
echo $dist
cat <<EOM > $target/etc/apt/sources.list
# external mirror
deb MIRRORURL $dist main restricted universe multiverse
deb MIRRORURL $dist-updates main restricted universe multiverse
deb MIRRORURL $dist-security main restricted universe multiverse
EOM
# determine a fast mirror for Ubuntu
list=$(curl -s http://mirrors.ubuntu.com/mirrors.txt)
mirror=$(netselect $list | awk '{print $2}')
sed -i -e "s#MIRRORURL#$mirror#" $target/etc/apt/sources.list
#! /usr/bin/perl
use strict;
use warnings;
use Faitest;
package FAITEST;
setup_test();
# - - - - - - - - - - - - - - - - - - - - - - - - - -
# now comes the test itself
my $dev = &getDevByMount("/target/home");
&checkE2fsAttribute($dev,"Filesystem volume name","home");
&checkE2fsAttribute($dev,"Maximum mount count","-1");
&checkE2fsAttribute($dev,"Check interval","0 (<none>)");
exit printresult();
# - - - - - - - - - - - - - - - - - - - - - - - - - -
__END__
=head1 NAME
FAIBASE_TEST - regression test for setup-storage disk layout FAIBASE
=head1 SYNOPSIS
FAIBASE_TEST checks some important aspects of setup-storage. The
disk_config/FAIBASE tunes some filesystem parameters upon creation. We
check only the last partition since we expect prior errors to make
creation of the last partition fail.
Options:
-help simple help
-verbose=n increase verbosity of test script
=head1 OPTIONS
=over 8
=item B<-help>
simple help
=item B<-verbose>
increase verbosity of test script
#! /usr/bin/perl
# Subroutines for automatic tests
#
# Copyright (C) 2009 Thomas Lange, lange@informatik.uni-koeln.de
# Based on the first version by Sebastian Hetze, 08/2008
package FAITEST;
my $errors = 0;
use strict;
use Getopt::Long;
use Pod::Usage;
# - - - - - - - - - - - - - - - - - - - - - - - - - -
sub setup_test {
my $verbose = 0;
my $help = 0;
my $man = 0;
$verbose = $ENV{'debug'} if $ENV{'debug'};
my $result = GetOptions (
"verbose=i" => \$verbose,
"help" => \$help,
"man" => \$man,
);
pod2usage(1) if $help;
pod2usage(-exitstatus => 0, -verbose => 2) if $man;
open(LOGFILE,">> $ENV{LOGDIR}/test.log") || die "Can't open test.log. $!";
print LOGFILE "------------ Test $0 starting ------------\n";
}
sub printresult {
# write test result and set next test
my ($nexttest) = @_;
if ($errors > 0) {
print STDERR "\n===> $0 FAILED with $errors errors\n";
print LOGFILE "\n===> $0 FAILED with $errors errors\n";
} else {
print STDERR "\n===> $0 PASSED successfully\n";
print LOGFILE "\n===> $0 PASSED successfully\n";
print LOGFILE "NEXTTEST=$nexttest\n" if $nexttest;
}
close (LOGFILE);
return $errors;
}
sub getDevByMount {
my $mount = shift;
my $dev = qx#mount|grep $mount|cut -d' ' -f1#;
chomp $dev;
return $dev
}
sub checkMdStat {
my ($device, $expected) = @_;
my ($value) = qx#grep -i "^$device\\b" /proc/mdstat# =~ m/$device\s*:\s*(.*)/i;
if ($value eq $expected) {
print LOGFILE "Check raid $device success\n";
return 0;
} else {
print LOGFILE "Check raid $device FAILED.\n Expect <$expected>\n Found <$value>\n";
$errors++;
return 1;
}
}
sub checkE2fsAttribute {
my ($device, $attribute, $expected) = @_;
# since attribute is a space separated list of attributes, IMO we must loop over
# the list. Ask Sebastian again
my ($value) = qx#tune2fs -l $device |grep -i "$attribute"# =~ m/$attribute:\s+(.*)/i;
if ($value eq $expected) {
print LOGFILE "Check $attribute for $device success\n";
return 0;
} else {
print LOGFILE "Check $attribute for $device FAILED.\n Expect <$expected>\n Found <$value>\n";
$errors++;
return 1;
}
}
1;
#!ipxe
echo ${net0/mac}
chain http://192.168.24.50:8000/api/fai/pxe/${net0/mac}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment