#!/bin/bash set -e # exit on error set -o pipefail # exit on pipeline error set -u # treat unset variable as error SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" #. $SCRIPT_DIR/buildconfig || exit 1 . $SCRIPT_DIR/minioslib || exit 1 . $SCRIPT_DIR/config || exit 1 set +u if [ -z $OUTPUT ]; then . $SCRIPT_DIR/linux-live/buildconfig || exit 1 fi set -u CMD=(chroot_setup_host chroot_pkg_install chroot_configure chroot_finish_up) # ============= main ================ common_variables console_colours allow_root_only #check_is_in_chroot # check number of args if [[ $# == 0 || $# > 3 ]]; then help_ru; fi # loop through args dash_flag=false start_index=0 end_index=${#CMD[*]} for ii in "$@"; do if [[ $ii == "-" ]]; then dash_flag=true continue fi find_index $ii if [[ $dash_flag == false ]]; then start_index=$index else end_index=$(($index + 1)) fi done if [[ $dash_flag == false ]]; then end_index=$(($start_index + 1)) fi #loop through the commands for ((ii = $start_index; ii < $end_index; ii++)); do ${CMD[ii]} done echo -e "${BOLD}${LIGHTYELLOW}$0${ENDCOLOUR} - ${LIGHTGREEN}Command completed successfully!${ENDCOLOUR}"