diff options
author | root | 2013-01-09 17:29:01 +0100 |
---|---|---|
committer | root | 2013-01-09 17:29:01 +0100 |
commit | ef9fc3ac8e7633625fb7680d0adc0325c11ea5a5 (patch) | |
tree | fd03ffb02616a7ea1bf0d17a20558106c19cdbb7 /mltk | |
parent | [systemd/udev] automatic networking on startup (diff) | |
download | tm-scripts-ef9fc3ac8e7633625fb7680d0adc0325c11ea5a5.tar.gz tm-scripts-ef9fc3ac8e7633625fb7680d0adc0325c11ea5a5.tar.xz tm-scripts-ef9fc3ac8e7633625fb7680d0adc0325c11ea5a5.zip |
rewrote params parsing of the main script
Diffstat (limited to 'mltk')
-rwxr-xr-x | mltk | 147 |
1 files changed, 90 insertions, 57 deletions
@@ -20,74 +20,107 @@ SELF=$(readlink -f $0) ROOT_DIR=$(dirname ${SELF}) banner () { - echo -e "\t __ __ __ " - echo -e "\t.--------.| | | |_| |--." - echo -e "\t| || |_| _| < " - echo -e "\t|__|__|__||____|____|__|__|" - echo -e "\t " - echo -e "\t ** OpenSLX Project // 2011 **" - echo -e "\t http://lab.openslx.org/" - echo -e "" + echo -e "\t __ __ __ " + echo -e "\t.--------.| | | |_| |--." + echo -e "\t| || |_| _| < " + echo -e "\t|__|__|__||____|____|__|__|" + echo -e "\t " + echo -e "\t ** OpenSLX Project // 2013 **" + echo -e "\t http://lab.openslx.org/" + echo -e "" } print_usage() { echo "Toolkit for creating preboot mini-linux for OpenSLX NG (mltk)" - echo "Usage: $(basename ${SELF}) MODULE [OPTION]" - echo " MODULE:" + echo "Usage: $(basename ${SELF}) MODULE [OPTIONS]" + echo -e "" + echo -e " MODULE:" echo -e " core \t minimal initramfs (stage 3.1) to mount the system-container (stage 3.2)." echo -e " tools \t minimal systemd-based rootfs including basic tools." - echo -e " OPTION:" - echo -e " build \t builds [MODULE]" - echo -e " clean \t clean build files for [MODULE]" + echo -e " all \t all of the above." + echo -e "" + echo -e " OPTIONS:" + echo -e " build, -b \t builds [MODULE]" + echo -e " clean, -c \t clean build files for [MODULE]" + echo -e " debug, -d \t activates debug output." echo -e "" - echo -e " Module specific option:" - echo -e " tools \t build [TOOL]" - echo -e " TOOL can be: \t base, busybox, dbus, udev, systemd, plymouth" + echo -e " Module specific options:" + echo -e " tools [OPTION] [TOOL]" + echo -e " TOOL can be: \t $(echo $(ls ${ROOT_DIR}/remote/tools))" } -banner - -if [ "x$1" = "x" ]; then - print_usage - exit 0 -elif [ "x$(whoami)" != "xroot" ]; then - echo "ERROR: You need to have root rights to install packages." - exit 1 -fi +initial_checks() { + if [ "x$(whoami)" != "xroot" ]; then + echo "ERROR: You need to have root rights to install packages." + exit 1 + else + banner + fi + + # setup_tools and build_core + BUILD_CORE=${ROOT_DIR}/server/build_core + SETUP_TOOLS=${ROOT_DIR}/remote/setup_tools -# read setup-tools and build_core -BUILD_CORE=${ROOT_DIR}/server/build_core -SETUP_TOOLS=${ROOT_DIR}/remote/setup_tools + [ ! -e ${BUILD_CORE} ] && echo "Missing script build_core, re-clone. Exiting." && exit 1 + [ ! -e ${SETUP_TOOLS} ] && echo "Missing script setup_tools, re-clone. Exiting." && exit 1 +} -if [ "x$1" = "xcore" ]; then - [ -e ${BUILD_CORE} ] && . ${BUILD_CORE} +read_params() { + MODULE=$1 + case "$1" in + core) + TARGET_CORE=1 + ;; + tools) + TARGET_TOOLS=1 + ;; + all) + TARGET_CORE=1 + TARGET_TOOLS=1 + ;; + *) + print_usage + exit 1 + ;; + esac shift - if [ "x$1" = "xbuild" ]; then - generate_stage31 - elif [ "x$1" = "xclean" ]; then - clean_core - else - print_usage - exit 1 + + while true ; do + case "$1" in + -c|clean) + CLEAN=1 + shift + ;; + -b|build) + BUILD=1 + shift + ;; + -d|debug) + DEBUG=1 + shift + ;; + *) + break + ;; + esac + done + + TOOLS="$@" +} + +run() { + if [ $TARGET_TOOLS ]; then + . ${SETUP_TOOLS} + [ $CLEAN ] && clean_tools $TOOLS + [ $BUILD ] && generate_stage32 $TOOLS fi -elif [ "x$1" = "xtools" ]; then - [ -e ${SETUP_TOOLS} ] && . $SETUP_TOOLS - shift - if [ "x$1" = "xbuild" ]; then - # shift away first 2 parameters - shift - echo "[tools] Building $@" - generate_stage32 $@ - elif [ "x$1" = "xclean" ]; then - shift - echo "[tools] Cleaning $@" - clean_tools $@ - else - print_usage - exit 1 + if [ $TARGET_CORE ]; then + . ${BUILD_CORE} + [ $CLEAN ] && clean_core + [ $BUILD ] && generate_stage31 fi -else - echo "Module $1 not known." - print_usage - exit 1 -fi +} + +initial_checks +read_params $@ +run |