From 1cd35712539f4c4702846f21c7d10b4d18ef5108 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Sat, 27 Jan 2018 15:19:04 -0700 Subject: [PATCH] Using safer bash config for Build Linux script --- Build Linux | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Build Linux b/Build Linux index ff3119fe..bd0a0f1d 100755 --- a/Build Linux +++ b/Build Linux @@ -2,6 +2,11 @@ # ## Wizard Kit: Live Linux Build Tool +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail + # Prep DATE="$(date +%F)" DATETIME="$(date +%F_%H%M)" @@ -21,7 +26,7 @@ elif which vim >/dev/null 2>&1; then else EDITOR=vi fi -if which sudo >/dev/null 2>&1; then +if [ ! -z ${SUDO_USER+x} ]; then REAL_USER="$SUDO_USER" fi @@ -243,15 +248,15 @@ function update_repo() { # Archive current files if [[ -d "$REPO_DIR" ]]; then - mkdir "$BUILD_DIR/Archive" 2>/dev/null + mkdir -p "$BUILD_DIR/Archive" 2>/dev/null archive="$BUILD_DIR/Archive/$(date "+%F_%H%M%S")" mv -bv "$REPO_DIR" "$archive" fi sleep 1s # Build custom repo packages - mkdir "$REPO_DIR" 2>/dev/null - mkdir "$TEMP_DIR" 2>/dev/null + mkdir -p "$REPO_DIR" 2>/dev/null + mkdir -p "$TEMP_DIR" 2>/dev/null pushd "$TEMP_DIR" >/dev/null while read -r p; do echo "Building: $p" @@ -325,32 +330,38 @@ function build_full() { } # Check input -case $1 in +case ${1:-} in -b|--build-full) build_full + echo Done ;; -f|--fix-perms) fix_kit_permissions + echo Done ;; -i|--install-deps) install_deps + echo Done ;; -o|--build-iso) load_settings build_iso + echo Done ;; -p|--prep-live-env) load_settings copy_live_env update_live_env + echo Done ;; -u|--update-repo) update_repo + echo Done ;; *)