Repository navigation
Expand file tree
/
Copy pathsetup
More file actions
executable file
·82 lines (76 loc) · 2.06 KB
/
Copy pathsetup
File metadata and controls
executable file
·82 lines (76 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
set -e
help() {
B="\033[1m"
S="\033[0m"
INDENT="\t\t\t\t"
echo "macsetup is a simple script to setup a mac. The script contain two parts: install and config"
echo -e "${B}install$S installs all developer tools, apps and everything else that is necessary"
echo -e "${B}config$S configures said tools and apps. Additionally it runs some custom dotfiles to have the mac to your liking"
echo
echo -e "This script can be run directly from github
${B}bash <(curl -s https://raw.githubusercontent.com/Cybertron1/macsetup/master/install) --help$S"
echo -e "Or it can be run locally ${B}./setup --help"$S
echo
echo "Default: setup -e=all -q=ask"
echo "Syntax: setup [-e=*|-q=*|-h]"
echo "options:"
echo -e "\t-e, --execute\t\tWhich part of the script to execute
$INDENT${B}Default$S: all
$INDENT${B}Allowed$S: all, install, config"
echo -e "\t-q, --questions\t\tIn some cases a user action is required. -q can provide a predefined answer
$INDENT${B}Default$S: ask
$INDENT${B}Allowed$S: ask, yes, no"
echo -e "\t-h, --help\t\tDisplays help"
echo
}
containsElement() {
local e match="$1"
shift
for e; do [[ "$e" == "$match" ]] && return 0; done
return 1
}
if [[ $# -eq 0 ]]; then
export MAC_SETUP_EXECUTE="all"
export MAC_SETUP_QUESTIONS="ask"
fi
shopt -s nocasematch
for var in "$@"; do
case $var in
--execute=* | -e=*)
execute=${var#*=}
check=("install" "config" "all")
if ! containsElement "${execute}" "${check[@]}"; then
echo "error"
exit 1
fi
if [ -n "$MAC_SETUP_EXECUTE" ]; then
echo "error 2"
fi
export MAC_SETUP_EXECUTE="$execute"
;;
--questions=* | -q=*)
questions=${var#*=}
check=("yes" "no" "ask")
if ! containsElement "${questions}" "${check[@]}"; then
echo "error"
exit 1
fi
if [ -n "$MAC_SETUP_QUESTIONS" ]; then
echo "error 2"
fi
export MAC_SETUP_QUESTIONS="$questions"
;;
--help | -h)
help
exit 0
;;
*)
echo "$var is not a valid argument"
help
exit 1
;;
esac
done
shopt -u nocasematch
bash ./runner