forked from giggio/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall
More file actions
executable file
·111 lines (98 loc) · 2.19 KB
/
Copy pathinstall
File metadata and controls
executable file
·111 lines (98 loc) · 2.19 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env bash
set -euo pipefail
if [ "$EUID" == "0" ]; then
echo "Please do not run as root"
exit 2
fi
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ALL_ARGS=$@
CLEAN=false
UPDATE=false
NAME=''
EMAIL=''
SHOW_HELP=false
VERBOSE=false
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--clean|-c)
CLEAN=true
shift
;;
--update|-u)
UPDATE=true
shift
;;
-n|--name)
NAME="$2"
shift
shift
;;
-e|--email)
EMAIL="$2"
shift
shift
;;
--help|-h)
SHOW_HELP=true
break
;;
--verbose)
VERBOSE=true
shift
;;
*)
shift
;;
esac
done
if $SHOW_HELP; then
cat <<EOF
Post installer.
Usage:
`readlink -f $0` [flags]
Flags:
--vim Will configure to use Vim as default editor.
--no-vim Will remove Vim configuration as default editor.
-n, --name Name to use when configuring Git.
-e, --email Email to use when configuring Git.
-c, --clean Will clean installed packages.
-u, --update Will download and install/reinstall even if the tools are already installed
--verbose Show verbose output
-h, --help This help
EOF
exit 0
fi
if $VERBOSE; then
echo -e "\e[32mRunning `basename "$0"` $ALL_ARGS\e[0m"
echo Update is $UPDATE
fi
if [ "$NAME" == "" ]; then
if ! hash git 2>/dev/null || [[ `git config --global user.name` == "" ]] || [[ `git config --global user.name` == "placeholder" ]]; then
>&2 echo Name is required.
exit 2
fi
fi
if [ "$EMAIL" == "" ]; then
if ! hash git 2>/dev/null || [[ `git config --global user.email` == "" ]] || [[ `git config --global user.email` == "placeholder@lambda3.com.br" ]]; then
>&2 echo Email is required.
exit 2
fi
fi
pushd "${BASEDIR}" > /dev/null
export DEBIAN_FRONTEND=noninteractive
if grep [Mm]icrosoft /proc/version > /dev/null; then
export WSL=true
else
export WSL=false
fi
if grep docker /proc/1/cgroup -qa; then
export RUNNING_IN_CONTAINER=true
else
export RUNNING_IN_CONTAINER=false
fi
$BASEDIR/pre-install.sh $ALL_ARGS
$BASEDIR/install.sh
$BASEDIR/post-install.sh $ALL_ARGS
popd > /dev/null
echo Done.