-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
better_anonymity
141 lines (119 loc) · 4.45 KB
/
better_anonymity
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env bash
################################################################################
# better-anonymity
# Script for setting up better anoymity configurations on MacOS.
# https://github.com/better-wealth/better-anonymity
# MIT License
# 2022 (C) John Patrick Roach
################################################################################
source lib/installers.sh
source lib/options.sh
source lib/reinstallers.sh
source lib/settings.sh
source lib/uninstallers.sh
source lib/utilities.sh
source lib/verifiers.sh
if [[ -e "$MAC_OS_CONFIG_PATH" ]]; then
source "$MAC_OS_CONFIG_PATH/lib/settings.sh"
else
printf "ERROR: Unable to load macOS configuration: $MAC_OS_CONFIG_PATH.\n\n"
printf "Please check the following before continuing:\n"
printf " • Download the default macOS configuration here: https://github.com/\n"
printf " • Customize as necessary for your setup or fork the project and make your own configuration.\n"
printf " • When finished, your folder structure should look like this:\n"
printf " • <root path>/env:\n"
printf " • <root path>/env-config:\n"
exit 1
fi
################################################################################
# logo
################################################################################
logo=" +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|b|e|t|t|e|r|-|a|n|o|n|y|m|i|t|y|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
################################################################################
# an associative array for storing color and a function for colorizing
################################################################################
declare -A _colors_;
_colors_[ 'red' ]='\x1b[0;31m';
_colors_[ 'green' ]='\x1b[0;32m';
_colors_[ 'yellow' ]='\x1b[0;33m';
_colors_[ 'cyan' ]='\x1b[0;36m';
_colors_[ 'white' ]='\x1b[0;37m';
_colors_[ 'reset' ]='\x1b[0m';
function colorize(){
if [[ ${_colors_[ $1 ]} ]]; then
echo -e "${_colors_[ $1 ]}$2${_colors_[ 'reset' ]}";
else
echo 'wrong color name!';
fi
}
function print_title(){
echo $(colorize cyan "$@");
}
if [ "$EUID" -ne 0 ]; then
script_path=$([[ "$0" = /* ]] && echo "$0" || echo "$PWD/${0#./}")
sudo "$script_path" || (
echo 'Administrator privileges are required.'
exit 1
)
exit 0
fi
################################################################################
# key-value array
################################################################################
# Options which set attributes:
# -a to make NAMEs indexed arrays (if supported)
# -A to make NAMEs associative arrays (if supported)
# -i to make NAMEs have the `integer' attribute
# -l to convert the value of each NAME to lower case on assignment
# -n make NAME a reference to the variable named by its value
# -r to make NAMEs readonly
# -t to make NAMEs have the `trace' attribute
# -u to convert the value of each NAME to upper case on assignment
# -x to make NAMEs export
declare -i _os_flag=0;
declare -a _os_args=();
declare -i _docker_flag=0;
declare -a _docker_args=();
declare -i _port_flag=0;
declare -a _port_args=1;
declare -r CLI_VERSION='0.1.0';
BASH_CLI_SCRIPT_NAME="hellowordWith2StringOptions.sh"
BASH_CLI_OPT_NAME[0]="-p"
BASH_CLI_OPT_NAME[1]="-t"
BASH_CLI_OPT_NAME[2]="-u"
BASH_CLI_OPT_NAME[3]="-l"
BASH_CLI_OPT_NAME[4]="hello"
BASH_CLI_OPT_ALT_NAME[0]="--text"
BASH_CLI_OPT_ALT_NAME[1]="--prefix"
BASH_CLI_OPT_ALT_NAME[2]="--uppercase"
BASH_CLI_OPT_ALT_NAME[3]="--lowercase"
BASH_CLI_OPT_ALT_NAME[4]="helloworld"
BASH_CLI_OPT_DATA_TYPE[0]="string"
BASH_CLI_OPT_DATA_TYPE[1]="string"
BASH_CLI_OPT_DATA_TYPE[2]="boolean"
BASH_CLI_OPT_DATA_TYPE[3]="boolean"
BASH_CLI_OPT_DATA_TYPE[4]="cmd"
BASH_CLI_MANDATORY_PARAM[4]="0,1"
BASH_CLI_NON_MANDATORY_PARAM[4]="2,3"
BASH_CLI_OPT_DESC[0]="text"
BASH_CLI_OPT_DESC[1]="prefix word to put infront of the given text"
BASH_CLI_OPT_DESC[2]="use uppercase"
BASH_CLI_OPT_DESC[3]="use lowercase"
BASH_CLI_OPT_DESC[4]="To print text from the value of -t"
hello() {
local prefix=${BASH_CLI_OPT_VALUE[0]}
local text=${BASH_CLI_OPT_VALUE[1]}
local enabled_uppercase=${BASH_CLI_OPT_VALUE[2]}
local enabled_lowercase=${BASH_CLI_OPT_VALUE[3]}
if [ ${enabled_uppercase} == true ]; then
echo "${prefix} ${text}" | tr '[:lower:]' '[:upper:]'
elif [ ${enabled_lowercase} == true ]; then
echo "${prefix} ${text}" | tr '[:upper:]' '[:lower:]'
else
echo "${prefix} ${text}"
fi
exit
}
source ../base.sh