#!/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/ # ----------------------------------------------------------------------------- # # Mini-Linux Toolkit # # ----------------------------------------------------------------------------- SELF=$(readlink -f $0) ROOT_DIR=$(dirname ${SELF}) MLTK_PID="$$" qnd_exit() { unset_quiet kill "$MLTK_PID" [ $# -ge 1 ] && kill "$1" } . "${ROOT_DIR}/helper/logging.inc" . "${ROOT_DIR}/helper/useradd.inc" . "${ROOT_DIR}/helper/downloader.inc" . "${ROOT_DIR}/helper/fileutil.inc" . "${ROOT_DIR}/helper/binutil.inc" banner () { echo -e "\033[38;5;202m\t __ __ __ " echo -e "\033[38;5;202m\t.--------.| | | |_| |--." echo -e "\033[38;5;208m\t| || |_| _| < " echo -e "\033[38;5;214m\t|__|__|__||____|____|__|__|" echo -e "\033[38;5;214m\t " echo -e "\033[38;5;220m\t ** OpenSLX Project // 2013 **" echo -e "\033[38;5;226m\t http://lab.openslx.org/" echo -e "\033[0m" } print_usage() { echo "Toolkit for creating preboot mini-linux for OpenSLX NG (mltk)" 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 " 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 options:" echo -e " tools [OPTION] [TOOL]" echo -e " TOOL can be: \t $(echo $(ls ${ROOT_DIR}/remote/tools))" } initial_checks() { if [ "x$(whoami)" != "xroot" ]; then perror "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 [ ! -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 } 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 while true ; do case "$1" in -c|clean) CLEAN=1 shift ;; -b|build) BUILD=1 shift ;; -d|debug) DEBUG=1 shift ;; *) break ;; esac done # exit if no command [ "x$BUILD" = "x" -a "x$CLEAN" = "x" ] && print_usage && exit 1 TOOLS="$@" } run() { [ "x$DEBUG" != "x1" ] && set_quiet if [ $TARGET_TOOLS ]; then . ${SETUP_TOOLS} [ $CLEAN ] && clean_tools $TOOLS [ $BUILD ] && generate_stage32 $TOOLS fi if [ $TARGET_CORE ]; then local TOOL_STR="[CORE]" . ${BUILD_CORE} [ $CLEAN ] && clean_core [ $BUILD ] && generate_stage31 fi } initial_checks read_params $@ run