generated from anishathalye/dotfiles_template
-
Notifications
You must be signed in to change notification settings - Fork 8
/
configure-root-env-android.sh
executable file
·61 lines (52 loc) · 1.2 KB
/
configure-root-env-android.sh
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
#!/usr/bin/env bash
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$BASEDIR"/_common-setup.sh
THIS_FILE="${BASH_SOURCE[0]}"
if (return 0 2>/dev/null); then
echo "Don't source this script ($THIS_FILE)."
exit 1
fi
SHOW_HELP=false
VERBOSE=false
while [[ $# -gt 0 ]]; do
case "$1" in
--help|-h)
SHOW_HELP=true
break
;;
--verbose)
VERBOSE=true
shift
;;
*)
shift
;;
esac
done
eval set -- "$PARSED_ARGS"
if $SHOW_HELP; then
cat <<EOF
Configures root environment (Android).
Usage:
`readlink -f "$0"` [flags]
Flags:
--verbose Show verbose output
-h, --help help
EOF
exit 0
fi
if $VERBOSE; then
writeGreen "Running `basename "$0"` $ALL_ARGS"
fi
if ! $ANDROID; then
die "This is not running in Android."
fi
# update localhost:
if ! grep -qE '127.0.0.1\s+localhost' /etc/hosts; then
writeBlue "Host localhost not found in /etc/hosts, adding 127.0.0.1 to it."
echo -e "127.0.0.1\tlocalhost" >> "/etc/hosts"
fi
if ! grep -qE '::1\s+ip6-localhost\s+ip6-loopback' /etc/hosts; then
writeBlue "Host ip6-localhost not found in /etc/hosts, adding ::1 to it."
echo -e "::1\tip6-localhost\tip6-loopback" >> "/etc/hosts"
fi