summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Neves2012-01-27 15:03:56 +0100
committerMichael Neves2012-01-27 15:03:56 +0100
commit8e8af091fd55501dcbab42836726cd25a494c077 (patch)
tree1af1be3fa81ca5196f5a7dba0e0df8218bde2cc5
parentadded boot media type in kcl of preboot environment (diff)
downloadusb-boot-stick-8e8af091fd55501dcbab42836726cd25a494c077.tar.gz
usb-boot-stick-8e8af091fd55501dcbab42836726cd25a494c077.tar.xz
usb-boot-stick-8e8af091fd55501dcbab42836726cd25a494c077.zip
pbs-serials added
-rw-r--r--config/setup.conf8
-rwxr-xr-xcreate-installer.sh60
-rw-r--r--inc/functions.pbs-serials.sh64
-rw-r--r--inc/functions.pbs.sh74
-rwxr-xr-xinstall-usb.sh129
-rwxr-xr-xmake-boot-iso.sh62
-rwxr-xr-xpbmtk.sh79
7 files changed, 476 insertions, 0 deletions
diff --git a/config/setup.conf b/config/setup.conf
index 41503c0..ece1f21 100644
--- a/config/setup.conf
+++ b/config/setup.conf
@@ -10,3 +10,11 @@ syslinux_testing_version=syslinux-4.04-pre22
syslinux_testing_url=http://www.kernel.org/pub/linux/utils/boot/syslinux/Testing/${syslinux_testing_version}.tar.bz2
make_num_jobs=6
base_dir=~/work/preboot
+
+#PBS CONFIG
+pbs_url=http://pbs2.mp.openslx.org
+default_serial=11-22-33-44-55
+
+#Apikeys
+openslx=apikey1
+dfn=apikey2
diff --git a/create-installer.sh b/create-installer.sh
new file mode 100755
index 0000000..0bd5038
--- /dev/null
+++ b/create-installer.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Copyright (c) 2011 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# PreBoot USB stick preparation utility
+# -----------------------------------------------------------------------------
+
+ROOT_DIR=$(dirname $(readlink -f $0))
+
+if [ $(whoami) != "root" ]; then
+ echo "you should be root"
+ exit 1;
+fi
+
+OUT_DEV=$1
+SYSLINUX=$ROOT_DIR/contrib/syslinux/latest
+
+PBSI=$ROOT_DIR/installer/pbstick-installer
+
+PATH="$PATH:$ROOT_DIR/bin/"
+
+[ ! -f $SYSLINUX/Makefile ] && env.setup-syslinux.sh
+
+rm -rf $ROOT_DIR/installer/tmp
+rm -f $ROOT_DIR/installer/stick-payload.tar.bz2
+
+mkdir -p $ROOT_DIR/installer/tmp/share \
+ $ROOT_DIR/installer/tmp/bin \
+ $ROOT_DIR/installer/tmp/boot
+
+cp -f $SYSLINUX/mbr/mbr.bin $ROOT_DIR/installer/tmp/share
+cp -f $SYSLINUX/linux/syslinux $ROOT_DIR/installer/tmp/bin
+
+[ ! -f $ROOT_DIR/build/kernel-preboot-latest ] && build.kernel.sh
+cp -f $ROOT_DIR/build/kernel-preboot-latest $ROOT_DIR/installer/tmp/boot/kernel
+
+build.initramfs.sh
+cp -f $ROOT_DIR/build/initramfs-default $ROOT_DIR/installer/tmp/boot/initramfs
+
+cp -f $SYSLINUX/com32/menu/menu.c32 $ROOT_DIR/installer/tmp/boot/
+cp -f $SYSLINUX/com32/menu/vesamenu.c32 $ROOT_DIR/installer/tmp/boot/
+cp -f $ROOT_DIR/config/extlinux/* $ROOT_DIR/installer/tmp/boot/
+mv $ROOT_DIR/installer/tmp/boot/extlinux.conf $ROOT_DIR/installer/tmp/boot/syslinux.cfg
+
+cd $ROOT_DIR/installer/tmp/
+tar cjf ../stick-payload.tar.bz2 *
+cd $ROOT_DIR
+
+cat $ROOT_DIR/installer/tpl/installer.tpl.sh > $PBSI
+echo "PAYLOAD:" >> $PBSI
+cat $ROOT_DIR/installer/stick-payload.tar.bz2 | uuencode - >> $PBSI
+chmod +rx $PBSI
diff --git a/inc/functions.pbs-serials.sh b/inc/functions.pbs-serials.sh
new file mode 100644
index 0000000..844b239
--- /dev/null
+++ b/inc/functions.pbs-serials.sh
@@ -0,0 +1,64 @@
+SHORT_OPTS=":vh"
+LONG_OPTS="version,help"
+
+LOG_DIR="/tmp/pbmtk"
+
+run_module_checks () {
+
+ if [ ! -z $1 ]; then
+ perror "Too many parameters. \n"
+ print_usage
+ exit 1
+ fi
+
+}
+
+init_params () {
+
+}
+
+print_usage() {
+ echo "Usage: $(basename $SELF) pbs-serials [OPTIONS]"
+ echo -e " -h --help \t print help"
+ echo -e " -v --version \t print version information"
+}
+
+read_params() {
+ getopt_start $@
+
+ eval set -- "$GETOPT_TEMP"
+
+ while true ; do
+ case "$1" in
+ -v|--version)
+ echo "OpenSLX PreBoot .. ($VERSION - $VDATE)."
+ exit 0
+ ;;
+ -h|--help)
+ print_usage
+ exit 0
+ ;;
+ --) shift ; break ;;
+ *) perror "Internal error!" ; exit 1 ;;
+ esac
+ done
+}
+
+get_preboot_serials() {
+
+ pinfo "Retrieving Serials..."
+
+ unset_quiet
+ wget -qO- pbs2.mp.openslx.org/resource/getprebootserials/apikey/apikey_uni-freiburg | cat
+ set_quiet
+
+
+}
+
+run () {
+
+ set_quiet
+ get_preboot_serials
+ unset_quiet
+
+} \ No newline at end of file
diff --git a/inc/functions.pbs.sh b/inc/functions.pbs.sh
new file mode 100644
index 0000000..563a39e
--- /dev/null
+++ b/inc/functions.pbs.sh
@@ -0,0 +1,74 @@
+SHORT_OPTS=":vfdh"
+LONG_OPTS="version,force,debug,help"
+
+LOG_DIR="/tmp/pbmtk"
+TMP_DIR=/tmp/openslx-iso
+
+run_module_checks () {
+
+ if [ ! -z $1 ]; then
+ perror "Too many parameters. \n"
+ print_usage
+ exit 1
+ fi
+
+ if [ -z $(which genisoimage) ]; then
+ perror "'genisoimage' is missing (if you are on a debian/ubuntu system: apt-get install genisoimage)"
+ exit 1
+ fi
+}
+
+init_params () {
+ FORCE=0
+ DEBUG=0
+}
+
+print_usage() {
+ echo "Usage: $(basename $SELF) iso [OPTIONS]"
+ echo -e " -d --debug \t give more debug output"
+ echo -e " -f --force \t don't ask questions"
+ echo -e " -h --help \t print help"
+ echo -e " -v --version \t print version information"
+}
+
+read_params() {
+ getopt_start $@
+
+ eval set -- "$GETOPT_TEMP"
+
+ while true ; do
+ case "$1" in
+ -v|--version)
+ echo "OpenSLX PreBoot .. ($VERSION - $VDATE)."
+ exit 0
+ ;;
+ -h|--help)
+ print_usage
+ exit 0
+ ;;
+ -f|--force) pinfo "Disable user-interaction."; FORCE=1; shift ;;
+ -d|--debug) pinfo "Enabled debugmode."; DEBUG=1; unset_quiet; shift ;;
+ --) shift ; break ;;
+ *) perror "Internal error!" ; exit 1 ;;
+ esac
+ done
+}
+
+get_preboot_serials() {
+
+ pinfo "Retrieving Serials..."
+
+ unset_quiet
+ wget -qO- pbs2.mp.openslx.org/resource/getprebootserials/apikey/apikey_uni-freiburg | cat
+ set_quiet
+
+
+}
+
+run () {
+
+ set_quiet
+ get_preboot_serials
+ unset_quiet
+
+} \ No newline at end of file
diff --git a/install-usb.sh b/install-usb.sh
new file mode 100755
index 0000000..65838bc
--- /dev/null
+++ b/install-usb.sh
@@ -0,0 +1,129 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Copyright (c) 2011 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# PreBoot USB stick preparation utility
+# -----------------------------------------------------------------------------
+
+
+ROOT_DIR=$(dirname $(readlink -f $0))
+
+if [ $(whoami) != "root" ]; then
+ echo "you should be root"
+ exit 1;
+fi
+
+OUT_DEV=$1
+
+if [ -z $OUT_DEV ]; then
+ echo "[Error] No output device specified."
+ echo "Usage $0 [devicename of usb-stick] (e.g. \"sdc\" for /dev/sdc)."
+ exit 1
+fi
+
+echo "device ${OUT_DEV} will be repartitioned and formatted"
+echo -n "type 'cont' to proceed: "
+read cont
+[ "x${cont}" != "xcont" ] && exit 1
+
+for i in 1 2 3 4 5 6 7 8 9; do
+ umount /dev/${OUT_DEV}$i &> /dev/null
+done
+
+SYSLINUX=${ROOT_DIR}/contrib/syslinux/latest
+
+PATH="${ROOT_DIR}/bin/:$PATH"
+
+# create the required stuff (syslinux, kernel, initramfs)
+[ ! -f ${SYSLINUX}/Makefile ] && env.setup-syslinux.sh
+[ ! -f ${ROOT_DIR}/build/kernel-preboot-latest ] && build.kernel.sh
+#[ ! -f ${ROOT_DIR}/build/initramfs-default ] && build.initramfs.sh
+build.initramfs.sh
+
+# get the total size of the device
+DISKSIZE=$(sfdisk -s /dev/${OUT_DEV} 2>/dev/null || echo 0)
+DISKSIZE=$((${DISKSIZE}/1024))
+
+# get the size of boot stuff and calculate the left over free space on device
+KSIZE=$(ls -l ${ROOT_DIR}/build/kernel-preboot-latest|awk '{print $5}')
+ISIZE=$(ls -l ${ROOT_DIR}/build/initramfs-default|awk '{print $5}')
+IMAGESIZE=$(((${KSIZE}+${ISIZE}+6000000)/1048576))
+FREE=$((${DISKSIZE}-${IMAGESIZE}))
+
+# create bootable vfat at the end of the device if big enough, otherwise use
+# the entire device
+if [ ${FREE} -ge 50 ] ; then
+ sfdisk /dev/${OUT_DEV} -uM << EOF
+,${FREE},L,
+,,6,*
+EOF
+else
+ NO_USRHOME=true
+ sfdisk /dev/${OUT_DEV} << EOF
+,,6,*
+EOF
+fi
+
+# create bootable vfat partition with 96cylinders and a ext3 partition for the
+# rest of the stick
+#sfdisk /dev/${OUT_DEV} << EOF
+#,96,6,*
+#,,L
+#EOF
+
+sync
+
+# copy mbr to stick
+dd bs=440 count=1 conv=notrunc if=${SYSLINUX}/mbr/mbr.bin of=/dev/${OUT_DEV}
+
+# create filesystems on newly createt partitions
+if [ "x$NO_USRHOME" != "xtrue" ]; then
+ mkfs.vfat -F 16 -n openslx-stick /dev/${OUT_DEV}2
+ mkfs.ext2 -L openslx-usrhome /dev/${OUT_DEV}1
+else
+ mkfs.vfat -F 16 -n openslx-stick /dev/${OUT_DEV}1
+fi
+
+mkdir -p /media/openslx-stick /media/openslx-stick-usrhome
+
+
+if [ "x$NO_USRHOME" != "xtrue" ]; then
+ mount /dev/${OUT_DEV}2 /media/openslx-stick
+ mount /dev/${OUT_DEV}1 /media/openslx-stick-usrhome
+else
+ mount /dev/${OUT_DEV}1 /media/openslx-stick
+fi
+
+mkdir -p /media/openslx-stick/boot
+
+
+cp -v ${ROOT_DIR}/build/kernel-preboot-latest /media/openslx-stick/boot/kernel
+
+cp -v ${ROOT_DIR}/build/initramfs-default /media/openslx-stick/boot/initramfs
+
+cp -v ${SYSLINUX}/com32/menu/menu.c32 /media/openslx-stick/boot/
+cp -v ${SYSLINUX}/com32/menu/vesamenu.c32 /media/openslx-stick/boot/
+
+cp -v ${ROOT_DIR}/config/extlinux/* /media/openslx-stick/boot
+mv /media/openslx-stick/boot/extlinux.conf /media/openslx-stick/boot/syslinux.cfg
+
+sync
+umount /media/openslx-stick
+umount /media/openslx-stick-usrhome
+
+rm -rf /media/openslx-stick*
+
+if [ "x$NO_USRHOME" != "xtrue" ]; then
+ ${SYSLINUX}/linux/syslinux --install -d /boot -f /dev/${OUT_DEV}2
+else
+ ${SYSLINUX}/linux/syslinux --install -d /boot -f /dev/${OUT_DEV}1
+fi
+
diff --git a/make-boot-iso.sh b/make-boot-iso.sh
new file mode 100755
index 0000000..4ada7b4
--- /dev/null
+++ b/make-boot-iso.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Copyright (c) 2011 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# PreBoot ISO image creation utility
+# -----------------------------------------------------------------------------
+
+ROOT_DIR=$(dirname $(readlink -f $0))
+
+SYSLINUX=$ROOT_DIR/contrib/syslinux/latest
+
+PATH="$PATH:$ROOT_DIR/bin/"
+
+[ ! -f $SYSLINUX/Makefile ] && env.setup-syslinux.sh
+
+mkdir -p /tmp/openslx-iso/isolinux
+
+[ ! -f $ROOT_DIR/build/kernel-preboot-latest ] && build.kernel.sh
+cp -v $ROOT_DIR/build/kernel-preboot-latest /tmp/openslx-iso/isolinux/kernel
+
+#[ ! -f $ROOT_DIR/build/initramfs-default ] && build.initramfs.sh
+build.initramfs.sh
+cp -v $ROOT_DIR/build/initramfs-default /tmp/openslx-iso/isolinux/initramfs
+
+cp -v $SYSLINUX/com32/menu/menu.c32 /tmp/openslx-iso/isolinux/
+cp -v $SYSLINUX/com32/menu/vesamenu.c32 /tmp/openslx-iso/isolinux/
+
+# exchange this for another theme
+cp -v ${ROOT_DIR}/config/extlinux/pbs2.png /tmp/openslx-iso/isolinux/
+sed -e "s,USB,ISO," $ROOT_DIR/config/extlinux/extlinux.conf \
+ > /tmp/openslx-iso/isolinux/isolinux.cfg
+
+
+# add tools needed for menu setup and ramdisk environment
+cp ${SYSLINUX}/core/isolinux.bin ${SYSLINUX}/com32/menu/vesamenu.c32 \
+ ${SYSLINUX}/com32/menu/menu.c32 /tmp/openslx-iso/isolinux/
+
+# create an autorun.inf file
+echo -en "icon=\boot\openslx.ico,0\r\nlabel=OpenSLX PreBoot Linux\r\n" \
+ > /tmp/openslx-iso/autorun.inf
+cp COPYING /tmp/openslx-iso/copying.txt
+
+# generate the ISO image
+echo "[make-boot-iso]\t\tGenerating the ISO image"
+genisoimage -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 \
+ -r -J -l -boot-info-table -o ./openslx.iso -hide-list config/hide.conf \
+ -abstract /tmp/openslx-iso/isolinux/info.txt -relaxed-filenames \
+ -biblio /tmp/openslx-iso/isolinux/info.txt -publisher "OpenSLX GmbH" \
+ -p "OpenSLX Project, http://lab.openslx.org, info@openslx.org" \
+ -V "OpenSLX PreBoot Linux ISO Image" -input-charset iso8859-1 \
+ -volset "PreBoot Linux of the OpenSLX Project" -joliet-long \
+ -copyright /tmp/openslx-iso/copying.txt /tmp/openslx-iso/ 2>/dev/null
+echo "[make-boot-iso]\t\tOpenSLX PreBoot image created."
+
diff --git a/pbmtk.sh b/pbmtk.sh
new file mode 100755
index 0000000..0e6bc8c
--- /dev/null
+++ b/pbmtk.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Copyright (c) 2011 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# PreBoot Media ToolKit
+# -----------------------------------------------------------------------------
+
+ROOT_DIR=$(dirname $(readlink -f $0))
+SELF=$(readlink -f $0)
+
+SUBMODULE=$1
+shift
+
+. $ROOT_DIR/inc/functions.common.sh
+
+print_module_usage() {
+ echo "Toolkit for creating PreBoot Media for OpenSLX NG (pbmtk)"
+ echo "Usage: $(basename $SELF) MODULE [OPTIONS]"
+ echo "Modules:"
+ echo -e " env \t fetch, update, recreate kernel/initramfs"
+ echo -e " iso \t create preboot isos"
+ echo -e " usb \t create preboot usb sticks"
+ echo -e " installer \t create self-extracting installers"
+ echo -e " pbs-serials \t query all Serials available to Member"
+ echo -e " pbs-register\t register preboot with pbs"
+ echo -e " pbs-upload \t upload usb-installer/iso to usb"
+ echo "For more help run: $(basename $SELF) MODULE --help"
+}
+
+banner
+
+if [ "x$SUBMODULE" = "xenv" ]; then
+ echo -e "Module: ENV"
+ . $ROOT_DIR/inc/functions.env.sh
+elif [ "x$SUBMODULE" = "xiso" ]; then
+ echo -e "Module: PreBoot-ISO Creator"
+ . $ROOT_DIR/inc/functions.iso.sh
+elif [ "x$SUBMODULE" = "xusb" ]; then
+ echo -e "Module: PreBoot-USB-Stick Creator"
+ . $ROOT_DIR/inc/functions.usb.sh
+elif [ "x$SUBMODULE" = "xinstaller" ]; then
+ echo -e "Module: PreBoot-Media Installer Creator"
+ . $ROOT_DIR/inc/functions.create-installer.sh
+elif [ "x$SUBMODULE" = "xpbs-serials" ]; then
+ echo -e "Module: PBS Serial Query"
+ . $ROOT_DIR/inc/functions.pbs-serials.sh
+elif [ "x$SUBMODULE" = "xpbs-register" ]; then
+ echo -e "Module: PBS Serial Registrator"
+ . $ROOT_DIR/inc/functions.pbs-register.sh
+elif [ "x$SUBMODULE" = "xpbs-upload" ]; then
+ echo -e "Module: PBS Preboot Uploader"
+ . $ROOT_DIR/inc/functions.pbs-upload.sh
+elif [ "x$SUBMODULE" = "x--version" -o "x$SUBMODULE" = "x-v" ]; then
+ echo -e "Module: Version"
+ exit 1
+else
+ print_module_usage
+ exit 1
+fi
+
+init_params
+
+mkdir -p $LOG_DIR/
+
+run_global_checks
+
+read_params $@
+
+run_module_checks
+
+run