diff --git a/colors.sh b/colors.sh new file mode 100644 index 0000000..2c156a6 --- /dev/null +++ b/colors.sh @@ -0,0 +1,17 @@ +C_BLACK='\033[0;30m' +C_DGRAY='\033[1;30m' +C_RED='\033[0;31m' +C_LRED='\033[1;31m' +C_GREEN='\033[0;32m' +C_LGREEN='\033[1;32m' +C_ORANGE='\033[0;33m' +C_YELLOW='\033[1;33m' +C_BLUE='\033[0;34m' +C_LBLUE='\033[1;34m' +C_PURPLE='\033[0;35m' +C_LPURPLE='\033[1;35m' +C_CYAN='\033[0;36m' +C_LCYAN='\033[1;36m' +C_LGRAY='\033[0;37m' +C_WHITE='\033[1;37m' +C_NC='\033[0m' diff --git a/setup.sh b/setup.sh old mode 100644 new mode 100755 index ff6df88..1b695b1 --- a/setup.sh +++ b/setup.sh @@ -1,13 +1,32 @@ #!/bin/bash -CYAN='\033[0;36m' -NC='\033[0m' -echo "${CYAN}andrejusk/dotfiles${NC}" +dir=`dirname "$0"` +source "$dir/colors.sh" +printf "${C_CYAN}andrejusk/dotfiles${C_NC}\n" +# Check if running +lock_file="$dir/setup.lock" +if [ -f "$dir/.lock" ]; then + printf "${C_RED}Script already running${C_NC}\n" + exit 1 +elif + touch +fi + +# Check for root if [[ $EUID -ne 0 ]]; then - echo "sudo !!" + printf "${C_RED}Called without sudo, please run:${C_NC}\n" + printf "sudo !!\n\n" exit 1 fi -install_dir="$0/install" -state_dir="$install_dir/.state" -for script in $install_dir/*.sh; do sh $script; done +# Run all install scripts +install_dir="$dir/install" +for script in $install_dir/*.sh; +do + if [ -f "$script.lock" ]; then + printf "$script\n" + fi + printf $script + # sh $script; + +done