-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.sh
executable file
·210 lines (196 loc) · 5.55 KB
/
main.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/bin/bash
. src/hardcoded_variables.txt
. src/ask_user_choice.sh
. src/install_user_choice.sh
. src/helper.sh
autokey_flag='false'
brave_flag='false'
github_flag='false'
keepass2_flag='false'
nordvpn_flag='false'
openvpn3_flag='false'
privoxy_flag='false'
searchmonkey_flag='false'
signal_flag='false'
texlive_flag='false'
texmaker_flag='false'
wine_flag='false'
zotero_flag='false'
anki_flag='false'
notepadpp_flag='false'
anaconda_flag='false'
energized_pro_flag='false'
energized_pro_social_flag='false'
energized_pro_porn_flag='false'
energized_pro_additional_flag='false'
language_tool_flag='false'
file_extensions_default_progs='false'
print_usage() {
printf "\nUsage: write:"
printf "\n\n ./main.sh \nTo decide with a y/n whether you want to install a package for each supported software package."
printf "\n\n ./main.sh --install <list of packages separated by spaces (example on nextline)>"
#printf "\n./install_gitlab -w\n to do an installation of the GitLab runner that waits untill the GitLab server is running."
printf "\n ./main.sh --install autokey zotero"
printf "\nTo install the autokey software and zotero."
printf "\n\n ./main.sh -h\n ./main.sh --help\nTo see this menu.\n\n"
printf "The supported package argument list is:\n"
printf "anaconda\n"
printf "anki\n"
printf "autokey-gtk\n"
printf "brave\n"
printf "energizedprotection_social\n"
printf "energizedprotection_porn\n"
printf "energizedprotection_additional\n"
printf "github\n"
printf "keepass2\n"
printf "language_tool\n"
printf "nordvpn\n"
printf "notepad++\n"
printf "openvpn3\n"
printf "privoxy\n"
printf "searchmonkey\n"
printf "signal\n"
printf "texlive-xetex\n"
printf "texmaker\n"
printf "wine\n"
printf "zotero\n"
printf "\n\n"
}
eat_argument_list() {
# create array
local -n arr=$1 # use nameref for indirection
shift # eat the reference variable to get the original remaining argument list
arr=() # innitialise array with branches
# Loop through the remaining arguments
while [ "${1:-}" != "" ]; do
case "$1" in
"autokey")
shift # eat the remaining argument list element
arr+=("autokey") # add autokey to array
;;
"brave")
shift # eat the remaining argument list element
arr+=("") # add to array
;;
"github")
shift # eat the remaining argument list element
arr+=("github") # add to array
;;
"keepass2")
shift # eat the remaining argument list element
arr+=("keepass2") # add to array
;;
"nordvpn")
shift # eat the remaining argument list element
arr+=("nordvpn") # add to array
;;
"openvpn3")
shift # eat the remaining argument list element
arr+=("openvpn3") # add to array
;;
"privoxy")
shift # eat the remaining argument list element
arr+=("privoxy") # add to array
;;
"searchmonkey")
shift # eat the remaining argument list element
arr+=("searchmonkey") # add to array
;;
"signal")
shift # eat the remaining argument list element
arr+=("signal") # add to array
;;
"texlive")
shift # eat the remaining argument list element
arr+=("texlive") # add to array
;;
"texmaker")
shift # eat the remaining argument list element
arr+=("texmaker") # add to array
;;
"wine")
shift # eat the remaining argument list element
arr+=("wine") # add to array
;;
"zotero")
shift # eat the remaining argument list element
arr+=("zotero") # add zotero to array
;;
"anki")
shift # eat the remaining argument list element
arr+=("anki") # add to array
;;
"notepad")
shift # eat the remaining argument list element
arr+=("notepad") # add to array
;;
"anaconda")
shift # eat the remaining argument list element
arr+=("anaconda") # add to array
;;
"ep_soc")
shift # eat the remaining argument list element
arr+=("ep_soc") # add to array
;;
"ep_pn")
shift # eat the remaining argument list element
arr+=("ep_pn") # add to array
;;
"ep_extra")
shift # eat the remaining argument list element
arr+=("ep_extra") # add to array
;;
"language_tool")
shift # eat the remaining argument list element
arr+=("language_tool") # add to array
;;
"file_extensions_default_progs")
shift # eat the remaining argument list element
arr+=("file_extensions_default_progs") # add to array
;;
esac
done
}
_setArgs(){
while [ "${1:-}" != "" ]; do
case "$1" in
"--install")
shift
eat_argument_list package_list "$@"
declare -p package_list
;;
"-h" | "--help")
help_flag=true
;;
esac
shift
done
}
_setArgs "$@"
if [ "$help_flag" == "true" ]; then
print_usage
fi
if [[ "${package_list[@]}" != "" ]]; then
echo "package_list=${package_list[@]}"
fi
# get list of all possible installation types and pass it to the prompt.
function run_prompt_user_choice() {
supported_installation_categories=$(read_categories "supported")
if [ "${package_list[0]}" != "" ]; then
# Export the user choices.
selected_software_packages=$(cli_args_to_package_list "${package_list[@]}")
else
echo "ask user"
# Assumption: this writes the selected packages to a selected_packages_list.txt
selected_software_packages=$(prompt_user_choice "install" $supported_installation_categories)
fi
echo "The selected_software_packages for installation are:"
echo $selected_software_packages
# install selected packages.
# shellcheck disable=SC2091
install_user_choices
# test selected packages.
test_user_choice_installation
}
sudo chmod +x src/*.sh
run_prompt_user_choice "$@"