#!/bin/sh # ------------------------------------------------------------------------- # parse command line 3.6.2 # # Creation: lanspezi 2004-10-25 # Last Update: $Id: parse_cmd.sh 23210 2012-08-05 07:09:33Z kristov $ # ------------------------------------------------------------------------- show_header () { echo -n "$1" if [ "${#1}" -lt 78 ] then len=`expr 78 - ${#1}` for i in `seq 1 $len` do echo -n '-' done fi echo } show_end () { case x$1 in x) ;; *) case x$verbose in x) echo ;; esac ;; esac echo "------------------------------------------------------------------------------" echo "" } log_error () { case $# in 0) while read line do echo " $line" echo " $line" >> /tmp/mkfli4l_error.log done ;; *) echo "$*" echo "$*" >> /tmp/mkfli4l_error.log ;; esac } append_error () { cat "$1" >> /tmp/mkfli4l_error.log } abort () { case "$1" in '') ;; -) log_error ;; *) log_error "$*" ;; esac if [ "$dir_build" != "" ]; then cat < "$dir_build/mkfli4l_error.log" An error occured while creating fli4l-files. ============================================ `cat /tmp/mkfli4l_error.log` EOF touch "$dir_build/mkfli4l_error.flg" cat "$dir_build/mkfli4l_error.log" echo "" echo "hit RETURN to continue ..." read dummy else cat < /dev/null 2>&1 then show_header "--- rebuilding mkfli4l, gen_init_cpio and gen_init_tar" if [ `echo $OSTYPE | grep -i "bsd"` ] then gmake -C unix cleanall > /dev/null gmake -C unix mkfli4l gen_init_cpio gen_init_tar else make -C unix cleanall > /dev/null make -C unix mkfli4l gen_init_cpio gen_init_tar fi show_end fi echo "using configuration from directory '$dir_config'..." echo "" # check for existence of base.txt in config-dir if [ ! -f "$dir_config/base.txt" ]; then log_error "- directory $dir_config does not exist" usage abort fi # check for exist of mkfli4l.conf in config-dir if [ -f "$dir_config/mkfli4l.conf" ]; then # check the conf-file . unix/scripts/parse_mkfli4l_conf.sh if ! parse_mkfli4l_conf; then abort fi fi dir_config= parse_options "$@" drive=`echo $drive | sed -e 's/://'` # check for build-dir different from root-dir if [ "$dir_build" = "/" ]; then abort "- build-directory must be different from filesystem root" fi # check existence of tftpboot_path if [ ! -d "$tftpboot_path" -a "$boot_type" = "netboot" ] || [ ! -d "$tftpboot_path" -a "$boot_type" = "pxeboot" ]; then abort "- directory $tftpboot_path does not exist" fi # check exist of build-dir if [ ! -e "$dir_build" ]; then mkdir -p "$dir_build" else if [ ! -d "$dir_build" -o ! -w "$dir_build" ]; then abort "- build dir $dir_build is either not a directory or not writable" fi fi boot_type= # check boot_type from base.txt if [ -f "$dir_config/_fli4l.txt" ]; then boot_type=`sed -n -e "s/^[[:space:]]*BOOT_TYPE=[\"']\(.*\)[\"'].*/\1/p" "$dir_config/_fli4l.txt"` fi if [ -z "$boot_type" ]; then boot_type=`sed -n -e "s/^[[:space:]]*BOOT_TYPE='\(.*\)'.*/\1/p" "$dir_config/base.txt"` fi # set opt_type base on boot_type case $boot_type in '') abort "- undefined variable BOOT_TYPE, please use config-file in correct format" ;; integrated|netboot|pxeboot) opt_type=integrated ;; attached) opt_type=attached ;; cd | cdemul) opt_type=tar ;; *) opt_type=bzip2 ;; esac _cmdline_parsed=true }