diff options
-rw-r--r-- | authorized_keys | 4 | ||||
-rw-r--r-- | authorized_keys.csa | 4 | ||||
-rwxr-xr-x | bootcd/build.sh | 78 | ||||
-rw-r--r-- | bootcd/isolinux-centos.cfg | 81 | ||||
-rw-r--r-- | bootcd/isolinux-fedora.cfg | 63 | ||||
-rw-r--r-- | centos/index.php | 8 | ||||
-rw-r--r-- | cidr.php | 36 | ||||
-rw-r--r-- | config.php | 99 | ||||
-rw-r--r-- | fedora/index.php | 8 | ||||
-rw-r--r-- | index.php | 226 | ||||
-rw-r--r-- | ipe.ks | 138 | ||||
-rw-r--r-- | ipekatrin-v4.ks | 101 | ||||
-rw-r--r-- | templates/hdd | 5 | ||||
-rw-r--r-- | templates/raid0 | 10 | ||||
-rw-r--r-- | templates/raid1 | 11 |
15 files changed, 872 insertions, 0 deletions
diff --git a/authorized_keys b/authorized_keys new file mode 100644 index 0000000..f7b2526 --- /dev/null +++ b/authorized_keys @@ -0,0 +1,4 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGNetzktlBAcbsrdYEDim7x1JAbcN9n4W6BZKJsB3fim csa@styx +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQD0r0MkNhJ3ooBNlz2GNfwGCULhmwzVyfWXlogS0E96dUUKSsvVQGbHHq+Ig8fkFNSAXIuIouAVN/IzWZesAXDd6oIsW880cJkfoGhJfFHa9gmOT9hgzybByhSxk+ovPWv2kqpGaqF8WbXlWwrjeMqRN5gbKwS4BcH3nb4Xt6ghOXAaCm1LTMFmmq8xfW0RWFFKm8tmORcUtEwtj4X1lUtMJ64arGLkyhIPu2PTbgeS6yPqkdws4xTczw9ngOyGw6RXb2Pyrs2igUAfRlrYK6vZrmzFn6yjPWY7WMkgO7BHR009fFAKzF8d4kVmGNkiuQE36IajEg+Idpo5a5sJc+WSok7oaxg3/blCY6rPkx3YHAdi7eTbqLea9j27gxJUzaIqu/loGU3gn/ddm+4vwsEiE/ZM368WOyetvrOz7sskjLCI+BhiKXbyTd8dFPDQQMgIrOlipqC3ikIDHKzruYzNGpplI5Yua0y1SvM3dVLumR0hCjUiw9Ew4M2eFGR2HNH7f4rq00bSMPhZmoIzPYhaAqS1QKKNx+TlFqfu30jckfHiBNFZ0bBwG+dNg+dG2GpWaOWLFKeoyV1xNJ/m8pCY4eRSdMUFtRH0Dq9vP5NoFQHzxwAREly/OZbNSAFWGYKKDX+ZGQR33qGfkicl0g/8Ul6zP5mjsRaHiIWvL4W3wQ== csa@styx +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIsJNm47UfzMUWMPAereBiqHQwvtKowirnp0pzCILSRztEWkKurnwyQmV9r4ZXibFS0dgN8aMgOoingLZOJnDUeelBMYZraEphAaQ3zkkYroZo7oJ9Ouuv5xYrhlKNKtrRDBpVuEcmmfNesRFB9Snb9QR3H90AlKh9KJmJcRPPGboCgyeGqTPVu6hJBwePqn4d8DPSGLCl8YP6XXhMMfVTxC4BBuKFvfIrD3yeyvnBVCIael6swytss6IK28BF3z/lahA2uNjhiy0rNKx2WHAAiUxaCRyLrmnJpCblvjlJ9OkwqDWrumVC8K0bVXeoyvZi2iICS2AZoKc0hREpJKo7 csa@gpg +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXdXQHy2GMS467G1yorHyMnjj6Wo3jVYqVLlN3pYBRGkPZOhyaAFXsEOH0roeg4h+0cFgha+d9+naB6d0dKhfw131wb05yZih+H6+eWOTpl1u+gkkOdMmwyKd7ymSSGFueDGQyVAx3WDPgoUgz9Y2SJsKe0cJPOON9kdPFwGN7tfHt3GJ2VoqwUnuFvQ2deCTPzvir2kC4RyuhasbZtY69/rOpxo99eZFMgChG/ftqeLOl0xyJ2If5u9sZeyR5i9ytvHsq59FGF6BpKJtLmC0wkqBvImUYQWXYmClT5Lo7vZfkbJnWjeuQH5JJ75mcl4XTtdjx+QIK8aSeznclLDlN Android diff --git a/authorized_keys.csa b/authorized_keys.csa new file mode 100644 index 0000000..f7b2526 --- /dev/null +++ b/authorized_keys.csa @@ -0,0 +1,4 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGNetzktlBAcbsrdYEDim7x1JAbcN9n4W6BZKJsB3fim csa@styx +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQD0r0MkNhJ3ooBNlz2GNfwGCULhmwzVyfWXlogS0E96dUUKSsvVQGbHHq+Ig8fkFNSAXIuIouAVN/IzWZesAXDd6oIsW880cJkfoGhJfFHa9gmOT9hgzybByhSxk+ovPWv2kqpGaqF8WbXlWwrjeMqRN5gbKwS4BcH3nb4Xt6ghOXAaCm1LTMFmmq8xfW0RWFFKm8tmORcUtEwtj4X1lUtMJ64arGLkyhIPu2PTbgeS6yPqkdws4xTczw9ngOyGw6RXb2Pyrs2igUAfRlrYK6vZrmzFn6yjPWY7WMkgO7BHR009fFAKzF8d4kVmGNkiuQE36IajEg+Idpo5a5sJc+WSok7oaxg3/blCY6rPkx3YHAdi7eTbqLea9j27gxJUzaIqu/loGU3gn/ddm+4vwsEiE/ZM368WOyetvrOz7sskjLCI+BhiKXbyTd8dFPDQQMgIrOlipqC3ikIDHKzruYzNGpplI5Yua0y1SvM3dVLumR0hCjUiw9Ew4M2eFGR2HNH7f4rq00bSMPhZmoIzPYhaAqS1QKKNx+TlFqfu30jckfHiBNFZ0bBwG+dNg+dG2GpWaOWLFKeoyV1xNJ/m8pCY4eRSdMUFtRH0Dq9vP5NoFQHzxwAREly/OZbNSAFWGYKKDX+ZGQR33qGfkicl0g/8Ul6zP5mjsRaHiIWvL4W3wQ== csa@styx +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIsJNm47UfzMUWMPAereBiqHQwvtKowirnp0pzCILSRztEWkKurnwyQmV9r4ZXibFS0dgN8aMgOoingLZOJnDUeelBMYZraEphAaQ3zkkYroZo7oJ9Ouuv5xYrhlKNKtrRDBpVuEcmmfNesRFB9Snb9QR3H90AlKh9KJmJcRPPGboCgyeGqTPVu6hJBwePqn4d8DPSGLCl8YP6XXhMMfVTxC4BBuKFvfIrD3yeyvnBVCIael6swytss6IK28BF3z/lahA2uNjhiy0rNKx2WHAAiUxaCRyLrmnJpCblvjlJ9OkwqDWrumVC8K0bVXeoyvZi2iICS2AZoKc0hREpJKo7 csa@gpg +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXdXQHy2GMS467G1yorHyMnjj6Wo3jVYqVLlN3pYBRGkPZOhyaAFXsEOH0roeg4h+0cFgha+d9+naB6d0dKhfw131wb05yZih+H6+eWOTpl1u+gkkOdMmwyKd7ymSSGFueDGQyVAx3WDPgoUgz9Y2SJsKe0cJPOON9kdPFwGN7tfHt3GJ2VoqwUnuFvQ2deCTPzvir2kC4RyuhasbZtY69/rOpxo99eZFMgChG/ftqeLOl0xyJ2If5u9sZeyR5i9ytvHsq59FGF6BpKJtLmC0wkqBvImUYQWXYmClT5Lo7vZfkbJnWjeuQH5JJ75mcl4XTtdjx+QIK8aSeznclLDlN Android diff --git a/bootcd/build.sh b/bootcd/build.sh new file mode 100755 index 0000000..153ecf0 --- /dev/null +++ b/bootcd/build.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +#inst.stage2 in isolinux.cfg needs to match the label of ISO, to get lable use 'file <name.iso>' or 'isoinfo -d -i <name.iso>' +#Lantronix Spider does not provide CDROM labels (we can add inst.stage2=cdrom, but this may break booting on multicd systems) +centos74_label="CentOS 7 x86_64" +centos75_label="CentOS 7 x86_64" +fedora28_label="Fedora-S-dvd-x86_64-28" + +die() { echo "$*" 1>&2 ; exit 1; } +usage() { echo "Usage: $0 <distrib> [--cdrom]"; } + +[ $# -gt 0 ] || { usage; exit 1; } + +distrib=$(echo $1 | grep -oP '[\w\d_\-]+') +label_arg=$(echo ${distrib}_label) +label_std=${!label_arg} + +[ -d $distrib ] || die "$distrib is not found" +[ -n "$label_std" ] || die "Label for $distrib is not configured" + +shift + +ver=1 +rhver=$(echo $distrib | grep -oP '\d+') +dname=$(echo $distrib | grep -oP '[^\d]+') + + +extra="" +isoname="$distrib-ands$(if [ $ver -gt 1 ]; then echo $ver ; fi)" + +while [ $# -gt 0 ]; do + case "$1" in + --cdrom) + media=$(if [[ "$2" =~ ^[[:alnum:]] ]]; then echo $2; else echo "cdrom"; fi) + extra="$extra inst.stage2=$media" + isoname="$isoname-$media" + echo $media + shift $(if [[ "$2" =~ ^[[:alnum:]] ]]; then echo 2; else echo 1; fi) + ;; + h | *) usage; exit 0 ;; + esac +done + + +isolinux="isolinux-${distrib}.cfg" +[ -f $isolinux ] || isolinux="isolinux-${dname}.cfg" +[ -f $isolinux ] || die "Configuration $isolinux is not found" + +echo "Building ${isoname}.iso with extra parameters \"$extra\" and the label \"$label_std\"" +echo "Using configuration: $isolinux" + +#Generating config +chmod +w $distrib/isolinux +chmod +w $distrib/isolinux/isolinux.cfg +sed -e "s/@EXTRA@/$extra/g" $isolinux > $distrib/isolinux/isolinux.cfg || die "Can't overwrite the configuration" + +#Creating output folder +mkdir -p iso + +#Building ISO +( + cd $distrib || die "Can't chdir" + chmod 664 isolinux/isolinux.bin + + rm -f iso/${isoname}.iso + +# On Forums Disc1 label is recommended, but it is not recognized (at least by Fedora) +# mkisofs -o ../iso/${isoname}.iso -A "$label_std" -V "$label_std Disc 1" -volset "$label_std" \ + + mkisofs -o ../iso/${isoname}.iso -A "$label_std" -V "$label_std" -volset "$label_std" \ + -U -J -joliet-long -r -v -T \ + -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table \ + -eltorito-alt-boot -e images/efiboot.img -no-emul-boot \ + . +) + +#Installing +scp iso/${isoname}.iso root@192.168.26.134:/virtual/images/ diff --git a/bootcd/isolinux-centos.cfg b/bootcd/isolinux-centos.cfg new file mode 100644 index 0000000..54f3a26 --- /dev/null +++ b/bootcd/isolinux-centos.cfg @@ -0,0 +1,81 @@ +#ui vesamenu.c32 +#prompt 0 +#display boot.msg + +default auto +timeout 10 + +# Second port, 115200 baud +#serial 1 115200 + +label auto + menu label ^Kickstart CentOS 7 for Ands + kernel vmlinuz + append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 @EXTRA@ console=tty1 console=ttyS1,115200 earlyprint=serial,ttyS1,115200 ip=dhcp inst.vnc inst.vncpassword=ipepdv inst.ks=http://ufo.kit.edu/ands/kickstart/centos/ inst.ks.sendsn inst.ks.sendmac +# append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 @EXTRA@ nomodeset text console=tty1 console=ttyS1,115200 earlyprint=serial,ttyS1,115200 ip=dhcp inst.vnc inst.vncpassword=ipepdv inst.ks=http://ufo.kit.edu/ands/kickstart/ inst.ks.sendsn inst.ks.sendmac + +label local + menu label ^Kickstart CentOS 7 for Ands + kernel vmlinuz + append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 @EXTRA@ console=tty1 console=ttyS1,115200 earlyprint=serial,ttyS1,115200 ip=dhcp inst.ks=http://ufo.kit.edu/ands/kickstart/centos/ inst.ks.sendsn inst.ks.sendmac xdriver=vesa nomodeset + +label linux + menu label ^Install CentOS 7 + kernel vmlinuz + append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 @EXTRA@ + +label check + menu label Test this ^media & install CentOS 7 + menu default + kernel vmlinuz + append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 @EXTRA@ rd.live.check + +menu separator # insert an empty line + +# utilities submenu +menu begin ^Troubleshooting + menu title Troubleshooting + +label vesa + menu indent count 5 + menu label Install CentOS 7 in ^basic graphics mode + text help + Try this option out if you're having trouble installing + CentOS 7. + endtext + kernel vmlinuz + append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 @EXTRA@ xdriver=vesa nomodeset + +label rescue + menu indent count 5 + menu label ^Rescue a CentOS system + text help + If the system will not boot, this lets you access files + and edit config files to try to get it booting again. + endtext + kernel vmlinuz + append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 @EXTRA@ rescue + +label memtest + menu label Run a ^memory test + text help + If your system is having issues, a problem with your + system's memory may be the cause. Use this utility to + see if the memory is working correctly. + endtext + kernel memtest + +menu separator # insert an empty line + +label hdd + menu label Boot from ^local drive + localboot 0xffff + +menu separator # insert an empty line +menu separator # insert an empty line + +label returntomain + menu label Return to ^main menu + menu exit + +menu end diff --git a/bootcd/isolinux-fedora.cfg b/bootcd/isolinux-fedora.cfg new file mode 100644 index 0000000..2580b41 --- /dev/null +++ b/bootcd/isolinux-fedora.cfg @@ -0,0 +1,63 @@ +#default vesamenu.c32 +default auto +# Now in 0.1s (i.e. 100 = 10s) +timeout 100 + +# Second port, 115200 baud +#serial 1 115200 + + +label auto + menu label ^Kickstart Fedora 28 + kernel vmlinuz + append initrd=initrd.img inst.stage2=hd:LABEL=Fedora-S-dvd-x86_64-28 @EXTRA@ console=tty1 console=ttyS1,115200 earlyprint=serial,ttyS1,115200 ip=dhcp inst.vnc inst.vncpassword=ipepdv inst.ks=http://ufo.kit.edu/ands/kickstart/fedora/ inst.ks.sendsn inst.ks.sendmac + +label local + menu label ^Kickstart Locally Fedora 28 + kernel vmlinuz + append initrd=initrd.img inst.stage2=hd:LABEL=Fedora-S-dvd-x86_64-28 @EXTRA@ console=tty1 console=ttyS1,115200 earlyprint=serial,ttyS1,115200 ip=dhcp inst.ks=http://ufo.kit.edu/ands/kickstart/fedora/ inst.ks.sendsn inst.ks.sendmac + +label linux + menu label ^Install Fedora 28 + kernel vmlinuz + append initrd=initrd.img inst.stage2=hd:LABEL=Fedora-S-dvd-x86_64-28 @EXTRA@ + +label check + menu label Test this ^media & install Fedora 28 + menu default + kernel vmlinuz + append initrd=initrd.img inst.stage2=hd:LABEL=Fedora-S-dvd-x86_64-28 @EXTRA@ rd.live.check + +label vesa + menu indent count 5 + menu label Install Fedora 28 in ^basic graphics mode + text help + Try this option out if you're having trouble installing + Fedora 28. + endtext + kernel vmlinuz + append initrd=initrd.img inst.stage2=hd:LABEL=Fedora-S-dvd-x86_64-28 @EXTRA@ nomodeset + +label rescue + menu indent count 5 + menu label ^Rescue a Fedora system + text help + If the system will not boot, this lets you access files + and edit config files to try to get it booting again. + endtext + kernel vmlinuz + append initrd=initrd.img inst.stage2=hd:LABEL=Fedora-S-dvd-x86_64-28 @EXTRA@ rescue + +label memtest + menu label Run a ^memory test + text help + If your system is having issues, a problem with your + system's memory may be the cause. Use this utility to + see if the memory is working correctly. + endtext + kernel memtest + +label hdd + menu label Boot from ^local drive + localboot 0xffff + diff --git a/centos/index.php b/centos/index.php new file mode 100644 index 0000000..00e5b3e --- /dev/null +++ b/centos/index.php @@ -0,0 +1,8 @@ +<?php + +$DISTRIBUTION="centos"; + +chdir(".."); +require "index.php"; + +?>
\ No newline at end of file diff --git a/cidr.php b/cidr.php new file mode 100644 index 0000000..87417d8 --- /dev/null +++ b/cidr.php @@ -0,0 +1,36 @@ +<?php +$NETMASK = array( + 1 => "128.0.0.0", + 2 => "192.0.0.0", + 3 => "224.0.0.0", + 4 => "240.0.0.0", + 5 => "248.0.0.0", + 6 => "252.0.0.0", + 7 => "254.0.0.0", + 8 => "255.0.0.0", + 9 => "255.128.0.0", + 10 => "255.192.0.0", + 11 => "255.224.0.0", + 12 => "255.240.0.0", + 13 => "255.248.0.0", + 14 => "255.252.0.0", + 15 => "255.254.0.0", + 16 => "255.255.0.0", + 17 => "255.255.128.0", + 18 => "255.255.192.0", + 19 => "255.255.224.0", + 20 => "255.255.240.0", + 21 => "255.255.248.0", + 22 => "255.255.252.0", + 23 => "255.255.254.0", + 24 => "255.255.255.0", + 25 => "255.255.255.128", + 26 => "255.255.255.192", + 27 => "255.255.255.224", + 28 => "255.255.255.240", + 29 => "255.255.255.248", + 30 => "255.255.255.252", + 31 => "255.255.255.254", + 32 => "255.255.255.255" +); +?> diff --git a/config.php b/config.php new file mode 100644 index 0000000..3c08ee4 --- /dev/null +++ b/config.php @@ -0,0 +1,99 @@ +<?php + +//$DEFAULT_SERVER = "ipecamera4"; +$DISTRIBUTIONS=array("centos", "fedora"); + +# disks will be synchronized with k3 +$KATRIN_SERVERS = array( + "ks" => "ipekatrin-v4.ks", + "templates" => "templates", + "domain" => "ipe.kit.edu", + "cidr" => 23, + "gw" => "141.52.64.207", + "ns" => "141.52.3.3,141.52.8.18", + "time" => "141.52.8.18", + "sysdisks" => "sdb,sdc", + "append_sol" => "console=tty1 console=ttyS1,115200 earlyprint=serial,ttyS1,115200", + "raid" => "RAID1", + "size" => "80000", + "bootsize" => "2048", + "eth" => array("enp3s0f1", "enp3s0f0"), +); + +$IPE_SERVERS = array_merge($KATRIN_SERVERS, array( + "ks" => "ipe.ks", + "cidr" => 24, + "base_net" => "192.168.26.", + "gw" => "192.168.26.117", + "sysdisks" => "sda,sdb", + "append_sol" => "", + "raid" => "RAID1", + "size" => "200000", + "home_size" => "800000", + "bootsize" => "2048", + "eth" => array("eth0", "eth1"), + "skip_security" => true, + "skip_minimal" => false, + "skip_home" => false, +)); + + +$CAMERA_SERVERS = array_merge($IPE_SERVERS, array( + "raid" => "RAID0", + "append_sol" => "console=tty1 console=ttyS1,115200 earlyprint=serial,ttyS1,115200", + "eth" => array("eno1", "eno2"), + "base_ip" => 80 +)); + +$STUDENT_SERVERS = array_merge($IPE_SERVERS, array( + "eth" => array("enp9s0", "enp6s0"), + "base_ip" => 60 +)); + + +$SERVER_LIST = array( + "ipecsavm" => array_merge($KATRIN_SERVERS, array( + "ks" => "ipekatrin-v4.ks", + "macs" => array("66:66:66:13:13:00"), + "ip" => "192.168.26.254", + "netmask" => "255.255.255.0", + "gw" => "192.168.26.117", + "sysdisks" => "sda,sdb", + "raid" => "RAID0", + "size" => "60000", + "ethdev" => "link", + )), +/* "ipechilinga2" => array_merge($KATRIN_SERVERS, array( + "domain" => "ka.fzk.de", + "macs" => array("48:5b:39:75:fe:ec"), + "headers" => array( + "REMOTE_ADDR" => array("141.52.64.104") + ) + )),*/ + "ipekatrin1" => array_merge($KATRIN_SERVERS, array( + "macs" => array("0c:c4:7a:de:f1:08", "0c:c4:7a:de:f1:09") + )), + "ipekatrin2" => array_merge($KATRIN_SERVERS, array( + "macs" => array("0c:c4:7a:de:f0:e6", "0c:c4:7a:de:f0:e7") + )), + "ipekatrin3" => array_merge($KATRIN_SERVERS, array( + "macs" => array("0c:c4:7a:a8:81:3e", "0c:c4:7a:a8:81:3f"), + "eth" => array("eno2", "eno1"), + )), + "ands1" => array_merge($KATRIN_SERVERS, array( + "macs" => array("00:25:90:da:82:58", "00:25:90:da:82:59"), + "eth" => array("enp9s0", "enp10s0"), + )), + "ipecamera3" => array_merge($CAMERA_SERVERS, array( + "macs" => array("0c:c4:7a:32:72:20", "0c:c4:7a:32:72:21"), + )), + "ipecamera4" => array_merge($CAMERA_SERVERS, array( + "macs" => array("0c:c4:7a:32:72:1e", "0c:c4:7a:32:72:1f"), + )), + "ipecluster6" => array_merge($STUDENT_SERVERS, array( + "macs" => array("74:D0:2B:97:F3:2A", "74:D0:2B:97:F3:2B"), + )), + +); + +?>
\ No newline at end of file diff --git a/fedora/index.php b/fedora/index.php new file mode 100644 index 0000000..d38cad4 --- /dev/null +++ b/fedora/index.php @@ -0,0 +1,8 @@ +<?php + +$DISTRIBUTION="fedora"; + +chdir(".."); +require "index.php"; + +?> diff --git a/index.php b/index.php new file mode 100644 index 0000000..61f4650 --- /dev/null +++ b/index.php @@ -0,0 +1,226 @@ +<?php +#$VERBOSE = 1; + +require "cidr.php"; +require "config.php"; + +function get_templates(&$server) { + $templates = array(); + foreach (glob("{$server['templates']}/*") as $ffn) { + $fn = basename($ffn); + $templates[$fn] = file_get_contents($ffn); + } + + if ((isset($server["disk2"]))&&($server["raid"] !== false)) { + $raid = $server["raid"]; + if (preg_match("/RAID(\d+)/i", $raid, $m)) $raid = $m[1]; + $templates['storage_config'] = $templates["raid{$raid}"]; + } else { + $templates['storage_config'] = $templates['hdd']; + } + + unset($server['templates']); + + return $templates; +} + +function get_server($srvid) { + global $SERVER_LIST; + global $NETMASK; + + $server = $SERVER_LIST[$srvid]; + + if (!isset($server["fqdn"])) + $server["fqdn"] = "{$srvid}.{$server['domain']}"; + + if (!isset($server["ip"])) { + if (isset($server["base_ip"])&&($server["base_net"])) { + if (preg_match("/(\d+)$/", $srvid, $m)) { + $server["ip"] = $server["base_net"] . ($server["base_ip"] + $m[1]); + } else { + $server["ip"] = false; + } + } else { + $ip = gethostbyname($server["fqdn"]); + if ($ip == $server["fqdn"]) + $server["ip"] = false; + else + $server["ip"] = $ip; + } + } + + if ($server["ip"]) { + $server["skip_ip"] = false; + } else { + $server["skip_ip"] = true; + } + + if (!isset($server["netmask"])) { + if (isset($server["cidr"])) { + $server["netmask"] = $NETMASK[$server["cidr"]]; + } + } + + $eths = $server["eth"]; + if ((isset($eths[0]))&&(!isset($server["ethdev"]))) + $server["ethdev"] = $eths[0]; + if ((isset($eths[1]))&&(!isset($server["ethdev2"]))) + $server["ethdev2"] = $eths[1]; + + $disks = explode(",", $server["sysdisks"]); + if (!isset($server["bootdisk"])) + $server["bootdisk"] = $disks[0]; + + if (!isset($server["disk1"])) + $server["disk1"] = $disks[0]; + + if ((isset($disks[1]))&&(!isset($server["disk2"]))) + $server["disk2"] = $disks[1]; + + unset($server["eths"]); + unset($server["macs"]); + unset($server["headers"]); + + return $server; +} + +function find_mac($macs, $mac_header) { + if (!is_array($macs)) $macs = array($macs); + + foreach ($macs as $mac) { + if (preg_match("/$mac/", $mac_header)) + return true; + } + return false; +} + +function find_server_by_mac($mac_header) { + global $SERVER_LIST; + + foreach ($SERVER_LIST as $srvid => $server) { + if (find_mac($server['macs'], $mac_header)) + return get_server($srvid); + } + return false; +} + +function find_server_by_header($http_header, $value) { + global $SERVER_LIST; + + foreach ($SERVER_LIST as $srvid => $server) { + if ((is_array($server["headers"]))&&(isset($server["headers"][$http_header]))) { + $expected = $server["headers"][$http_header]; + if (!is_array($expected)) $expected = array($expected); + foreach ($expected as $re) { + if (preg_match("/$re/", $value)) + return get_server($srvid); + } + } + } + return false; +} + +function find_server() { + global $DEFAULT_SERVER; + global $_SERVER; + + $headers = getallheaders(); + for ($i = 0; $i < 10; $i++) { + $if = "X-RHN-Provisioning-MAC-$i"; + if (!isset($headers[$if])) break; + + $server = find_server_by_mac($headers[$if]); + if ($server) return $server; + } + + foreach ($_SERVER as $header => $value) { + $server = find_server_by_header($header, $value); + if ($server) return $server; + } + + if (isset($DEFAULT_SERVER)) { + return get_server($DEFAULT_SERVER); + } + + return false; +} + + + + +$server = find_server(); + +$f = fopen("/srv/www/htdocs/ands/logs/kickstart.log", "a+"); +if ($f) { + fprintf($f, "%s %s\n", $_SERVER["REMOTE_ADDR"], ($server?$server["fqdn"]:"-")); + fclose($f); +} + +if (!$server) { + $f = fopen("/srv/www/htdocs/ands/logs/kickstart-new.log", "a+"); + if ($f) { + fwrite($f, print_r($_SERVER, true)); + fwrite($f, print_r(getallheaders(), true)); + fclose($f); + } + return; +} + +$templates = get_templates($server); + +$ks = file_get_contents($server["ks"]); + + +$patterns=array(); $values=array(); +foreach ($templates as $key => $val) { + array_push($patterns, "/@" . strtoupper($key) . "@/"); + array_push($values, $val); +} +$ks = preg_replace($patterns, $values, $ks); + + +$patterns=array(); $values=array(); +foreach ($server as $key => $val) { + array_push($patterns, "/@" . strtoupper($key) . "@/"); + if (is_bool($val)) { + if (preg_match("/^skip_/", $key)) { + if ($val) $val = "#"; + else $val = ""; + } elseif (preg_match("/^enable_/", $key)) { + if ($val) $val = ""; + else $val = "#"; + } else { + if ($val) $val = 1; + else $val = 0; + } + } + array_push($values, $val); +} + +foreach ($DISTRIBUTIONS as $distrib) { + array_push($patterns, "/@" . strtoupper($distrib) . "@/"); + array_push($values, (strcasecmp($distrib, $DISTRIBUTION)?"#":"")); +} + +//print_r($patterns); + +$ks = preg_replace($patterns, $values, $ks); + +if ($VERBOSE) { + $f = fopen("/srv/www/htdocs/ands/logs/kickstart-verbose.log", "a+"); + if ($f) { + fwrite($f, "-----------------------------------------------------\n"); + fwrite($f, print_r($server, true)); + fwrite($f, print_r($_SERVER, true)); + fwrite($f, print_r(getallheaders(), true)); + fwrite($f, "-----------------------------------------------------\n"); + fwrite($f, $ks); + fwrite($f, "=====================================================\n"); + fclose($f); + } +} + +header("Content-type: text/plain"); +echo $ks; + +?> @@ -0,0 +1,138 @@ +#version=DEVEL + +# System authorization information +auth --enableshadow --passalgo=sha512 + +# Use CDROM installation media +cdrom + +# Use graphical install (graphical is enforce by vnc requested at kernel args) +#text +graphical + +# Run the Setup Agent on first boot +firstboot --enable +ignoredisk --only-use=@SYSDISKS@ +# Keyboard layouts +keyboard --vckeymap=us --xlayouts='us' +# System language +lang en_US.UTF-8 + +# Network information (device=link signifies first device link active) +network --device=@ETHDEV@ --bootproto=dhcp --noipv6 --onboot=on --activate +#This still doesn't work +#@SKIP_IP@network --device=@ETHDEV@:1 --bootproto=static --ip=@IP@ --netmask=@NETMASK@ --noipv6 --onboot=on --activate +network --hostname=@FQDN@ + + +# Partition clearing information +clearpart --all --drives=@SYSDISKS@ +zerombr + +# System bootloader configuration +bootloader --location=mbr --driveorder=@SYSDISKS@ --boot-drive=@BOOTDISK@ --append=" crashkernel=auto @APPEND_SOL@" + +#autopart --type=lvm +#reqpart --add-boot + +@STORAGE_CONFIG@ + +logvol / --vgname=sysvg --size=@SIZE@ --name=lv_root --fstype=ext4 +@SKIP_HOME@logvol /home --vgname=sysvg --size=@HOME_SIZE@ --name=lv_home --fstype=ext4 --grow + + +# Root password (new) +rootpw --iscrypted $6$ihAbktYN$T36KRAmi8ccjNrE5Y0gEl11Rb/dl3GjemejAJyHVzrAL51/st7aMZ0dqnMIkhubX/gUcPe5LdTlJODC9D/60h0 +# Root passowrd (old) +#rootpw --iscrypted $6$ioKrEQSxzYypx2HZ$jiynrl6knbmhbL066k.HjmxcwvQwBsT53LPlp2fRdkg2E1E7Gy4gwxaZ0m86rbD6q4dTaWdYfKhDVSij6N1Y7. + +# System services +services --enabled="chronyd" +# System timezone +timezone Europe/Berlin --isUtc --ntpservers=@TIME@ +user --groups=wheel --name=csa --gecos="Suren A. Chilingaryan" + +# SELinux configuration +@SKIP_SECURITY@selinux --disabled + +# Do not configure the X Window System +@SKIP_MINIMAL@skipx + +install +poweroff + + +%packages +@CENTOS@@^minimal +@core +chrony +curl + +# Python2 required for ansible (and is not installed on Fedora) +python +@FEDORA@python-dnf +%end + +%anaconda +pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty +pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok +pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty +%end + + +%pre --log=/var/log/ks01.log + +# Stop all md devices +for name in /dev/md?*; do + dev=$(basename $name) + echo "Stopping $dev" + mdadm --manage -S $name +done + +ls -la /dev/sd* +ls -la /dev/md* + +# Remove md superblocks +if [ -b /dev/@DISK1@ ]; then + for name in /dev/@DISK1@?*; do + echo "Removing md superblock on $name" + mdadm --misc --zero-superblock $name + dd if=/dev/zero of=$name bs=512 seek=$(( $(blockdev --getsz $name) - 1024 )) count=1024 + done +fi +if [ -b /dev/@DISK2@ ]; then + for name in /dev/@DISK2@?*; do + echo "Removing md superblock on $name" + mdadm --misc --zero-superblock $name + dd if=/dev/zero of=$name bs=512 seek=$(( $(blockdev --getsz $name) - 1024 )) count=1024 + done +fi + +%end + +%post --log=/var/log/ks02.log +yum install -y unzip + +mkdir /root/.ssh +chmod 0700 /root/.ssh +curl http://ufo.kit.edu/ands/kickstart/authorized_keys -o /root/.ssh/authorized_keys +chmod 0600 /root/.ssh/authorized_keys + +mkdir /home/csa/.ssh +chmod 0700 /home/csa/.ssh +curl http://ufo.kit.edu/ands/kickstart/authorized_keys.csa -o /home/csa/.ssh/authorized_keys +chown -R csa:user /home/csa/.ssh +chmod 0600 /home/csa/.ssh/authorized_keys + +#Doesn't work either +#con=$(nmcli d show eno1 | grep CONNECTION | cut -d ':' -f 2- | sed -E -e 's/^[[:space:]]+//' | grep '^[[:alpha:]]') +#@SKIP_IP@nmcli connection modify "$con" +ipv4.address @IP@/@CIDR@ + +cat <<EOF >>/etc/sysconfig/network-scripts/ifcfg-@ETHDEV@ +IPADDR=@IP@ +PREFIX=@CIDR@ +#IPADDR1= +#PREFEX1= +EOF + +%end diff --git a/ipekatrin-v4.ks b/ipekatrin-v4.ks new file mode 100644 index 0000000..80ce7a8 --- /dev/null +++ b/ipekatrin-v4.ks @@ -0,0 +1,101 @@ +#version=DEVEL + +# System authorization information +auth --enableshadow --passalgo=sha512 + +# Use CDROM installation media +cdrom + +# Use graphical install (graphical is enforce by vnc requested at kernel args) +#text +graphical + +# Run the Setup Agent on first boot +firstboot --enable +ignoredisk --only-use=@SYSDISKS@ +# Keyboard layouts +keyboard --vckeymap=us --xlayouts='us' +# System language +lang en_US.UTF-8 + +# Network information (device=link signifies first device link active) +network --device=@ETHDEV@ --bootproto=static --ip=@IP@ --netmask=@NETMASK@ --gateway=@GW@ --nameserver=@NS@ --noipv6 --onboot=on --activate +#network --device=@ETHDEV2@ --bootproto=static --ip=@IP@ --netmask=@NETMASK@ --gateway=@GW@ --nameserver=@NS@ --noipv6 --onboot=off --activate +#network --bootproto=dhcp --device=eth0 --ipv6=auto --activate +network --hostname=@FQDN@ + + +# Partition clearing information +clearpart --all --drives=@SYSDISKS@ +zerombr + +# System bootloader configuration +bootloader --location=mbr --driveorder=@SYSDISKS@ --boot-drive=@BOOTDISK@ --append=" crashkernel=auto @APPEND_SOL@" + +#autopart --type=lvm +#reqpart --add-boot +part raid.01 --ondisk=@DISK1@ --asprimary --size @BOOTSIZE@ +part raid.02 --ondisk=@DISK2@ --asprimary --size @BOOTSIZE@ +part swap --ondisk=@DISK1@ --asprimary --fstype=swap --recommended +part swap --ondisk=@DISK2@ --asprimary --fstype=swap --recommended +part raid.03 --ondisk=@DISK1@ --asprimary --size @SIZE@ --grow +part raid.04 --ondisk=@DISK2@ --asprimary --size @SIZE@ --grow +raid /boot --level=@RAID@ --device md0 raid.01 raid.02 --fstype=ext4 +raid pv.01 --level=@RAID@ --device=md1 raid.03 raid.04 +volgroup sysvg pv.01 +logvol / --vgname=sysvg --size=@SIZE@ --name=lv_root --fstype=ext4 + +# Root password (new) +rootpw --iscrypted $6$ihAbktYN$T36KRAmi8ccjNrE5Y0gEl11Rb/dl3GjemejAJyHVzrAL51/st7aMZ0dqnMIkhubX/gUcPe5LdTlJODC9D/60h0 +# Root passowrd (old) +#rootpw --iscrypted $6$ioKrEQSxzYypx2HZ$jiynrl6knbmhbL066k.HjmxcwvQwBsT53LPlp2fRdkg2E1E7Gy4gwxaZ0m86rbD6q4dTaWdYfKhDVSij6N1Y7. + +# System services +services --enabled="chronyd" +# System timezone +timezone Europe/Berlin --isUtc --ntpservers=@TIME@ +user --groups=wheel --name=csa --gecos="Suren A. Chilingaryan" + +# SELinux configuration +#selinux --disabled + +# Do not configure the X Window System +skipx + +install +poweroff + + +%packages +@^minimal +@core +chrony +kexec-tools +curl +%end + +#This is not supported on last Fedora any more +%addon com_redhat_kdump --enable --reserve-mb='auto' +%end + +%anaconda +pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty +pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok +pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty +%end + + +%post --log=/var/log/ks01.log +yum install -y unzip + +mkdir /root/.ssh +chmod 0700 /root/.ssh +curl http://ufo.kit.edu/ands/kickstart/authorized_keys -o /root/.ssh/authorized_keys +chmod 0600 /root/.ssh/authorized_keys + +mkdir /home/csa/.ssh +chmod 0700 /home/csa/.ssh +curl http://ufo.kit.edu/ands/kickstart/authorized_keys.csa -o /home/csa/.ssh/authorized_keys +chown -R csa:user /home/csa/.ssh +chmod 0600 /home/csa/.ssh/authorized_keys +%end diff --git a/templates/hdd b/templates/hdd new file mode 100644 index 0000000..531581f --- /dev/null +++ b/templates/hdd @@ -0,0 +1,5 @@ +part biosboot --ondisk=@DISK1@ --asprimary --size=1 --fstype=biosboot +part /boot --ondisk=@DISK1@ --asprimary --size @BOOTSIZE@ --fstype=ext4 +part swap --ondisk=@DISK1@ --asprimary --fstype=swap --recommended +part lvm.01 --ondisk=@DISK1@ --asprimary --size @SIZE@ --grow +volgroup sysvg lvm.01 diff --git a/templates/raid0 b/templates/raid0 new file mode 100644 index 0000000..f612fa2 --- /dev/null +++ b/templates/raid0 @@ -0,0 +1,10 @@ +part biosboot --ondisk=@DISK1@ --asprimary --size=1 --fstype=biosboot +part biosboot --ondisk=@DISK2@ --asprimary --size=1 --fstype=biosboot +part raid.01 --ondisk=@DISK1@ --asprimary --size @BOOTSIZE@ +part raid.02 --ondisk=@DISK2@ --asprimary --size @BOOTSIZE@ +part swap --ondisk=@DISK1@ --asprimary --fstype=swap --recommended +part swap --ondisk=@DISK2@ --asprimary --fstype=swap --recommended +part pv.01 --ondisk=@DISK1@ --asprimary --size @SIZE@ --grow +part pv.02 --ondisk=@DISK2@ --asprimary --size @SIZE@ --grow +raid /boot --level=RAID1 --device=md0 raid.01 raid.02 --fstype=ext4 +volgroup sysvg pv.01 pv.02 diff --git a/templates/raid1 b/templates/raid1 new file mode 100644 index 0000000..bcdb1c7 --- /dev/null +++ b/templates/raid1 @@ -0,0 +1,11 @@ +part biosboot --ondisk=@DISK1@ --asprimary --size=1 --fstype=biosboot +part biosboot --ondisk=@DISK2@ --asprimary --size=1 --fstype=biosboot +part raid.01 --ondisk=@DISK1@ --asprimary --size @BOOTSIZE@ +part raid.02 --ondisk=@DISK2@ --asprimary --size @BOOTSIZE@ +part swap --ondisk=@DISK1@ --asprimary --fstype=swap --recommended +part swap --ondisk=@DISK2@ --asprimary --fstype=swap --recommended +part raid.03 --ondisk=@DISK1@ --asprimary --size @SIZE@ --grow +part raid.04 --ondisk=@DISK2@ --asprimary --size @SIZE@ --grow +raid /boot --level=RAID1 --device=md0 raid.01 raid.02 --fstype=ext4 +raid pv.01 --level=@RAID@ --device=md1 raid.03 raid.04 +volgroup sysvg pv.01 |