Installmage komplett

Aus xinux.net
Zur Navigation springen Zur Suche springen

/etc/dhcp/dhcpd.conf

ddns-update-style interim;
local-address 172.28.252.20;
option domain-search "taribo.lan";
default-lease-time 6000;
max-lease-time 7200;
authoritative;
log-facility local7;
shared-network networks_ether0 {
        subnet 172.28.252.0 netmask 255.255.255.0 {
                range 172.28.252.101 172.28.252.150;
                option domain-name-servers 172.28.252.20;
                option routers 172.28.252.1;
                next-server 172.28.252.20;
                filename "pxelinux.0";
                option root-path "172.28.252.20:/var/pxeroot";
        }

}
 group {
         host node-1 { hardware ethernet 52:54:00:00:00:41; fixed-address 172.28.252.41;}
         host node-2 { hardware ethernet 52:54:00:00:00:42; fixed-address 172.28.252.42;}
         host node-3 { hardware ethernet 52:54:00:00:00:43; fixed-address 172.28.252.43;}
     }
group {
         next-server 172.28.252.20;
         filename "ubuntu/pxelinux.0";
         host ubu-1 { hardware ethernet 52:54:00:00:00:61; fixed-address 172.28.252.61;}
         host ubu-2 { hardware ethernet 52:54:00:00:00:62; fixed-address 172.28.252.62;}
         host ubu-3 { hardware ethernet 52:54:00:00:00:63; fixed-address 172.28.252.63;}
     }
key "rndc-key" {
        algorithm hmac-md5;
        secret "1EBOXhNmlPSp5hZnVwcWqA==";
};
zone taribo.lan {
primary 172.28.252.20;
key rndc-key;
}
zone 252.168.192.in-addr.arpa. {
primary 172.28.252.20;
key rndc-key;
}

/var/pxeroot/usr/local/sbin/mkauto

#!/bin/bash
source /usr/local/lib/mksystem.lib
source /root/config.dat
echo $SYSTEM
test -z "$SYSTEM" && SYSTEM="ubuntu"
test -z "$HN"     && HN="rumburak"
test -z "$IP"     && IP="192.168.252.69"
NM="255.255.255.0"
GW="192.168.252.1"
DN="192.168.252.20"
SE="taribo.lan xinux.org"
PA="iptraf"
US="stunk"
PW="oimel"
GR="sudo"
RD="/mnt/new"
CR="chroot $RD"
part_format
echo $SYSTEM
case $SYSTEM in
ubuntu)
echo ubuntu
SY="ubuntu-14.04-v5.tgz"
UR="http://doom.xinux.lan/images/$SY"
mount_build
ubuntu_netmodify
ubuntu_modify
;;
centos)
SY="centos-7-v2.tgz"
UR="http://doom.xinux.lan/images/$SY"
mount_build
centos_netmodify
centos_modify
;;
arch)
SY="archlinux-bootstrap-2015.10.01-x86_64.tar.gz"
UR="http://doom.xinux.lan/images/$SY"
mount_build
#centos_netmodify
#centos_modify
;;
esac

#unmount

/var/pxeroot/usr/local/lib/mksystem.lib

#!/bin/bash

function centos_grub.cfg() {
cat<<HERE
set pager=1
if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="${saved_entry}"
fi
if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi
export menuentry_id_option
if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi
function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}
function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}
terminal_output console
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
else
  set timeout=5
fi

set tuned_params=""
menuentry 'CentOS Linux 7 (Core), with Linux 3.10.0-229.el7.x86_64' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-3d94095a-3fea-474e-8b78-90b999fa4868' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos2'
        linux16 /boot/vmlinuz-3.10.0-229.el7.x86_64 root=/dev/vda2 ro crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0
        initrd16 /boot/initramfs-3.10.0-229.el7.x86_64.img
}
menuentry 'CentOS Linux 7 (Core), with Linux 0-rescue-1cd4592e60244977a7b5b4b10ee0db06' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-1cd4592e60244977a7b5b4b10ee0db06-advanced-3d94095a-3fea-474e-8b78-90b999fa4868' {
        load_video
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos2'
        linux16 /boot/vmlinuz-0-rescue-1cd4592e60244977a7b5b4b10ee0db06 root=/dev/vda2 ro crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0
        initrd16 /boot/initramfs-0-rescue-1cd4592e60244977a7b5b4b10ee0db06.img
}
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
HERE
}


function part_format() {
echo "mklabel"
parted -s  /dev/vda mklabel msdos
echo "mkpart swap"
parted -s  /dev/vda mkpart primary linux-swap 1 2000
echo "mkpart /"
parted -s  /dev/vda mkpart primary ext2  2000 100%
echo "mkswap"
mkswap /dev/vda1 > /dev/null 2>&1
echo "mkfs.ext4"
mkfs.ext4 /dev/vda2 > /dev/null 2>&1
test -d $RD || mkdir $RD
}

function mount_build() {
echo "mount new filesystem"
mount /dev/vda2 $RD
echo "unpackings system - wait"
wget -q -O -  $UR | tar -C $RD -xzf -
echo "mount /dev /proc /sys"
mount -o bind /dev  $RD/dev
mount -o bind /sys  $RD/sys
mount -o bind /proc  $RD/proc
}


function unmount() {
umount $RD/proc
umount $RD/sys
umount $RD/dev
umount $RD
}


function ubuntu_netmodify() {
echo $HN > $RD/etc/hostname

if test -z  "IP"
then
cat<<HERE > "$RD/etc/network/interfaces"
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
HERE
else

cat<<HERE > "$RD/etc/network/interfaces"
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
 address $IP
 netmask $NM
 gateway $GW
 dns-nameservers $DN
 dns-search $SE
HERE
fi
}

function centos_netmodify() {
echo $HN > $RD/etc/hostname
if test -z  "IP"
then
:
else

cat<<HERE > "$RD/etc/sysconfig/network-scripts/ifcfg-eth0"
TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
NAME="eth0"
UUID="56aa41e7-7911-49a4-aa24-98375f52522e"
DEVICE="eth0"
ONBOOT="yes"
DNS1=$DN
DOMAIN=$SE
IPADDR=$IP
PREFIX="24"
GATEWAY=$GW
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_PRIVACY="no"
HERE
echo "nameserver $DN" > $RD/etc/resolv.conf
echo "search $SE" >> $RD/etc/resolv.conf
fi
}

function ubuntu_modify() {
mv $RD/etc/resolv.conf $RD/etc/resolv.conf.org
echo "nameserver 8.8.8.8" > $RD/etc/resolv.conf
$CR apt-get update
$CR apt-get -y install $PA
$CR useradd -m -s /bin/bash -G $GR $US
echo "$US:$PW" | $CR chpasswd
echo "grub-install"
grub-install --root-directory=$RD --boot-directory=$RD/boot /dev/vda
echo "update-grub"
$CR update-grub
rm $RD/etc/resolv.conf
mv $RD/etc/resolv.conf.org $RD/etc/resolv.conf
}


function centos_modify() {
mv $RD/etc/resolv.conf $RD/etc/resolv.conf.org
echo "nameserver 8.8.8.8" > $RD/etc/resolv.conf
$CR yum -y update
$CR yum -y install $PA
echo "GRUB_DISABLE_LINUX_UUID=true" >>  $RD/etc/default/grub
echo "GRUB_ENABLE_LINUX_LABEL=true" >>  $RD/etc/default/grub
echo "SELINUX=disabled" > $RD/etc/sysconfig/selinux
echo "SELINUXTYPE=targeted" >> $RD/etc/sysconfig/selinux
sed -i.org -e   '/GRUB_CMDLINE_LINUX/s/.$/ net.ifnames=0 biosdevname=0"/' $RD/etc/default/grub
echo "grub-install"
$CR  grub2-install /dev/vda
echo "update-grub"
$CR  grub2-mkconfig -o /boot/grub2/grub.cfg
$CR useradd -m -s /bin/bash  $US
echo "$US:$PW" | $CR chpasswd
rm $RD/etc/resolv.conf
mv $RD/etc/resolv.conf.org $RD/etc/resolv.conf
}

/var/lib/tftpboot/pxelinux.cfg/default

default menu.c32
prompt 0
timeout 300
ONTIMEOUT local

MENU TITLE PXE Menu


LABEL normal
    MENU LABEL ^normal
    kernel nfs-vmlinuz
    append vga=normal initrd=initrd.img ramdisk_size=14332 root=/dev/nfs nfsroot=172.28.252.20:/var/pxeroot ip=dhcp os=normal rw --

LABEL ubuntu
    MENU LABEL ^ubuntu
    kernel nfs-vmlinuz
    append vga=normal initrd=initrd.img ramdisk_size=14332 root=/dev/nfs nfsroot=172.28.252.20:/var/pxeroot ip=dhcp os=ubuntu rw --


LABEL centos
    MENU LABEL ^centos
    kernel nfs-vmlinuz
    append vga=normal initrd=initrd.img ramdisk_size=14332 root=/dev/nfs nfsroot=172.28.252.20:/var/pxeroot ip=dhcp os=centos rw --

LABEL arch
    MENU LABEL ^arch
    kernel nfs-vmlinuz
    append vga=normal initrd=initrd.img ramdisk_size=14332 root=/dev/nfs nfsroot=172.28.252.20:/var/pxeroot ip=dhcp os=arch rw --

LABEL loop
  MENU LABEL ^loop
  kernel loop-vmlinuz
  append vga=normal initrd=loop-initrd ramdisk_size=1024000  root=/dev/ram0 rw --

LABEL loop-gz
  MENU LABEL loop-^gz
  kernel loop-vmlinuz
  append vga=normal initrd=loop-initrd.gz ramdisk_size=1024000  root=/dev/ram0 rw --

LABEL ram-gz
  MENU LABEL ^ram-gz
  kernel ram-vmlinuz
  append vga=normal initrd=ram-initrd.gz ramdisk_size=800000  root=/dev/ram0 rw --



LABEL ubuntu-netinstall
  MENU LABEL ubuntu-^netinstall
  kernel /ubuntu/ubuntu-installer/amd64/linux
  append initrd=/ubuntu/ubuntu-installer/amd64/initrd.gz vga=normal ramdisk_size=16384 root=/dev/ram rw preseed/url=http://waka.xinux.org/trusty.seed debian-installer/locale=de_DE keyboard-configuration/layoutcode=de localechooser/translation/warn-light=true localechooser/translation/warn-severe=true netcfg/choose_interface=auto netcfg/get_hostname=ubuntu --


LABEL window-pe
  MENU LABEL ^windows-pe
  kernel memdisk
  initrd winpe.iso
  append iso

LABEL win7
  MENU LABEL win7
  kernel memdisk
  initrd win7_amd64.iso
  append iso

LABEL ubuntu-iso
  MENU LABEL ubuntu-iso
  kernel memdisk
  initrd ubuntu.iso
  append iso