-
Notifications
You must be signed in to change notification settings - Fork 88
/
TorBOX_Build
207 lines (150 loc) · 6.63 KB
/
TorBOX_Build
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
#!/bin/bash
# Save as /home/user/TorBOX_source/Build
# Version: TorBOX 0.2.1
# Copyright: proper
#
# License: GPL v3 or any later
#
# Any changes you pull changes into this source will be also licensed
# under GPL v3 or any later. Additionally you grant proper the right to
# re-license your work under a different license. If that is not acceptable,
# you can either fork this source under GPL v3 or any later or contact proper.
# Contact proper, if you require this source code under different license.
set -x
USERNAME="user"
script_help() {
echo \
"
# assumes a cloned source folder containing all the needed script:
# ~/TorBOX_source/Build
# ~/TorBOX_source/GetISO
# ~/TorBOX_source/ModifyISO
# ~/TorBOX_CreateVM
# ~/TorBOX_Image
# ~/TorBOX-Gateway
# ~/TorBOX-Workstation
# ~/torcheck
# creates separate build folder
# FLAGS:
# -all (NOT YET IMPLEMENTED)
# build both Virtual machines
#
# -tg
# build TorBOX-Gateway VBox machine
#
# -tw
# assumes TorBOX-Gateway is running because
# downloads go already through TorBOX-Gateway.
# build TorBOX-Workstation VBox machine
#
# -clean
# deletes the whole content of the TorBOX_binary folder
"
}
root_check() {
######################################################
# Checking script environment
######################################################
# Check if we are root
if [ "$(id -u)" != "0" ]; then
echo "ERROR: This must be run as root (sudo)!"
exit 1
else
echo "INFO: Script running as root."
fi
}
# If this file was created previously, delete it now.
rm /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED
################################################################
# tg #
################################################################
if [ "$1" = "-tg" ]; then
root_check
$HOME/TorBOX_source/TorBOX_GetISO -download
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
$HOME/TorBOX_source/TorBOX_ModifyISO -create
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
$HOME/TorBOX_source/TorBOX_CreateVM -tg-pre
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
$HOME/TorBOX_source/TorBOX_CreateVM -tg-install-os
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
$HOME/TorBOX_source/TorBOX_CreateVM -tg-post
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
$HOME/TorBOX_source/TorBOX_Image -tg-mount
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
$HOME/TorBOX_source/TorBOX_Image -tg-copyinto
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
$HOME/TorBOX_source/TorBOX_Image -tg-unmount
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
$HOME/TorBOX_source/TorBOX_CreateVM -tg-install-script
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
$HOME/TorBOX_source/TorBOX_CreateVM -tg-export
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
echo "INFO: No errors."
exit 0
fi
################################################################
# tw #
################################################################
if [[ "$1" = "-tw" ]]; then
root_check
# Assumes TorBOX-Gateway has already been created, i.e.
# operating system iso already downloaded.
$HOME/TorBOX_source/TorBOX_CreateVM -tw-pre
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
# Assumes TorBOX-Gateway is running, because downloads go already through TorBOX-Gateway.
$HOME/TorBOX_source/TorBOX_CreateVM -tw-install-os
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
$HOME/TorBOX_source/TorBOX_CreateVM -tw-post
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
$HOME/TorBOX_source/TorBOX_Image -tw-mount
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
$HOME/TorBOX_source/TorBOX_Image -tw-copyinto
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
$HOME/TorBOX_source/TorBOX_Image -tw-unmount
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
# Assumes TorBOX-Gateway is running, because downloads go already through TorBOX-Gateway.
$HOME/TorBOX_source/TorBOX_CreateVM -tw-install-script
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
$HOME/TorBOX_source/TorBOX_CreateVM -tw-export
if [ -f /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED ]; then echo "BUILD SCRIPT ERROR: Failed!"; exit 0; fi
exit 0
fi
################################################################
# -all #
################################################################
if [[ "$1" = "-all" ]]; then
root_check
exit 0
fi
################################################################
# -clean #
################################################################
if [[ "$1" = "-all" ]]; then
root_check
TorBOX_GetISO -delete
TorBOX_ModifyISO -delete
TorBOX_Image -tg-unmount
TorBOX_Image -tw-unmount
TorBOX_CreateVM -tg-delete
TorBOX_CreateVM -tw-delete
echo "TorBOX_Build: Done."
exit 0
fi
################################################################
# -help #
################################################################
if [[ "$1" = "-help" ]]; then
script_help
exit 0
fi
################################################################
# no option chosen #
################################################################
if [[ "$1" = "" ]]; then
echo "
INFO: No option chosen.
Please append -help to find out more.
"
exit 0
fi