Well, I’ve been tinkering with a way to “unify” the way we deploy new OpenSUSE/SLES ISOs onto our installation server, once they are released. So here, I’ll show you the script I came up with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
; html-script: false ]#!/bin/bash TFTP_DIR=/srv/tftpboot INSTSRC_DIR=/srv/instsrc if [ -z $@ ] ; then echo "Usage: register-suse <path to iso-file> labelname" exit 1 fi ISO_FILE=$1 mkdir /mnt/loop mount -o loop $ISO_FILE /mnt/loop # Determine ISO information OS_LABEL="$( grep '^LABEL' /mnt/loop/content | cut -d -f10- )" if [ -z "$OS_LABEL" ] ; then OS_LABEL="$( grep '^LABEL' /mnt/loop/content | cut -d -f2- | head -n1 )" fi OS_NAME="$( grep '^DISTRIBUTION' /mnt/loop/content | cut -d -f3- | tr '[:upper:]' '[:lower:]' )" if [ -z "$OS_NAME" ] ; then OS_NAME="$( grep '^PRODUCT' /mnt/loop/content | cut -d -f2- | cut -d_ -f1-2 | tr '[:upper:]' '[:lower:]' )" fi case "$OS_NAME" in suse_sle|suse_sles) OS_NAME=sles;; esac OS_RELEASE="$( grep ^VERSION /mnt/loop/content | awk '{ print $2 }' | cut -d- -f1 )" if [ "$( echo $OS_LABEL | grep -i vmware )" != "" ] ; then OS_RELEASE="$OS_RELEASE-vmware" fi OS_ARCH="$( grep ^BASEARCHS /mnt/loop/content | awk '{ print $2 }' )" if [ -z "$OS_ARCH" ] ; then OS_ARCH="$( grep ^DEFAULTBASE /mnt/loop/content | awk '{ print $2 }' )" fi OS_SHORTLABEL="$( grep ^SHORTLABEL /mnt/loop/content | awk '{ print $2 }' | cut -d( -f1 | sed -e "s,SLES-,SLES," -e "s,-, ,g" )" case "$OS_ARCH" in i*86) OS_ARCH=x86;; x86_64) OS_ARCH=x64;; esac # Create directories mkdir -p $TFTP_DIR/boot/$OS_NAME/$OS_RELEASE/$OS_ARCH mkdir -p $TFTP_DIR/pxelinux.cfg/$OS_NAME mkdir -p $INSTSRC_DIR/$OS_NAME/$OS_RELEASE/$OS_ARCH # Copy CD/DVD content rsync -av /mnt/loop/* $INSTSRC_DIR/$OS_NAME/$OS_RELEASE/$OS_ARCH/ # Create the info file cat > $INSTSRC_DIR/$OS_NAME/$OS_RELEASE/$OS_ARCH/info <<EOF Language: en_US Keytable: de-lat1-nd Install: http://install.home.barfoo.org/{INSTSRC_DIR//srv/}/$OS_NAME/$OS_RELEASE/$OS_ARCH/ Autoyast: http://install.home.barfoo.org/autoyast/ Textmode: 1 EOF # Copy the PXE boot file (initrd/kernel) cp $INSTSRC_DIR/$OS_NAME/$OS_RELEASE/$OS_ARCH/boot/*/loader/initrd $TFTP_DIR/boot/$OS_NAME/$OS_RELEASE/$OS_ARCH/initrd cp $INSTSRC_DIR/$OS_NAME/$OS_RELEASE/$OS_ARCH/boot/*/loader/linux $TFTP_DIR/boot/$OS_NAME/$OS_RELEASE/$OS_ARCH/linux # Create the PXE boot menu cat > $TFTP_DIR/pxelinux.cfg/$OS_NAME/$OS_NAME-$OS_RELEASE-$OS_ARCH.menu << EOF #LABEL $OS_SHORTLABEL #OSNAME $OS_NAME #OSARCH $OS_ARCH MENU TITLE Linux Installationservices MENU BACKGROUND addons/background-suse.png MENU COLOR screen 37;40 #80ffffff #00000000 MENU COLOR border 0 #ffffffff #ee000000 std MENU COLOR title 0 #ffffffff #ee000000 std MENU COLOR unsel 0 #ffffffff #ee000000 std MENU COLOR sel 0 #ffffffff #85000000 std MENU COLOR scrollbar 30;44 #40000000 #00000000 MENU COLOR tabmsg 0 #ee000000 #ffffffff std MENU COLOR cmdmark 0 #ff00ff00 #00000000 std MENU COLOR cmdline 0 #ee000000 #ffffffff std MENU COLOR timeout_msg 0 #ee000000 #ffffffff std MENU COLOR timeout 0 #ee000000 #ffffffff std MENU COLOR disabled 0 #ffffffff #ee000000 std MENU COLOR pwdheader 0 #ff000000 #99ffffff rev MENU COLOR pwdborder 0 #ff000000 #99ffffff rev MENU COLOR pwdentry 0 #ff000000 #99ffffff rev MENU COLOR hotkey 0 #ff00ff00 #ee000000 std MENU COLOR hotsel 0 #ffffffff #85000000 std LABEL DESC MENU LABEL $OS_LABEL ($OS_ARCH) MENU DISABLE MENU SEPARATOR LABEL autoyast MENU LABEL ^Automatisierte Installation KERNEL boot/$OS_NAME/$OS_RELEASE/$OS_ARCH/linux APPEND initrd=boot/$OS_NAME/$OS_RELEASE/$OS_ARCH/initrd info=http://install.home.barfoo.org/${INSTSRC_DIR//srv/}/$OS_NAME/$OS_RELEASE/$OS_ARCH/info splash=native ramdisk_size=65535 vga=791 barrier=off LABEL netinst MENU LABEL ^Netzwerkbasierte Installation KERNEL boot/$OS_NAME/$OS_RELEASE/$OS_ARCH/linux APPEND initrd=boot/$OS_NAME/$OS_RELEASE/$OS_ARCH/initrd install=http://install.home.barfoo.org/${INSTSRC_DIR//srv/}/$OS_NAME/$OS_RELEASE/$OS_ARCH/ splash=native ramdisk_size=65535 vga=791 barrier=off MENU SEPARATOR LABEL back MENU LABEL <-- ^Vorherige Ansicht KERNEL addons/vesamenu.c32 APPEND pxelinux.cfg/$OS_NAME.menu EOF umount /mnt/loop rmdir /mnt/loop |
This also needs a second script, as this will only create a menu entry, not the menu itself. You’ll find the script in the next post!