-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
152 lines (134 loc) · 3.2 KB
/
setup.sh
File metadata and controls
152 lines (134 loc) · 3.2 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
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
#!/bin/bash
CDIR=$PWD
PACKAGE_SET=""
PACKAGE_SET_INFO="@ These tools would be installed:"
PACKAGE_SET_QEMU=0
PACKAGE_SET_TOOL=0
PACKAGE_SET_NODE=0
NO_PACKAGES=0
NO_DESICION=1
VERBOSE=0
print_help() {
echo "? Usage: setup.sh -qbvhnr"
echo "? Options:"
echo " -q => Install QEMU."
echo " -b => Install Build Toolchain."
echo " -n => Compile Node JS for Makefile codegen."
echo " -h => Show help."
echo " -v => Show version."
echo " -r => Verbose output."
}
while getopts 'qbvhnr' SHELLARGUMENT; do
case "$SHELLARGUMENT" in
q)
PACKAGE_SET="qemu-system-x86 ${PACKAGE_SET}"
PACKAGE_SET_INFO=$"${PACKAGE_SET_INFO}\n - QEMU (x86)"
PACKAGE_SET_QEMU=1
NO_DESICION=0
;;
b)
PACKAGE_SET="${PACKAGE_SET} iat make xorriso build-essential gcc-i686-linux-gnu binutils-i686-linux-gnu zip"
PACKAGE_SET_INFO=$"${PACKAGE_SET_INFO}\n - Build Toolchain (x86)"
PACKAGE_SET_TOOL=1
NO_DESICION=0
;;
n)
PACKAGE_SET="${PACKAGE_SET} python3-pip python3 gcc automake autoconf build-essential"
PACKAGE_SET_INFO=$"${PACKAGE_SET_INFO}\n - Node JS\n - Build Toolchain (x86_64)"
PACKAGE_SET_NODE=1
NO_DESICION=0
;;
h)
print_help
exit 0
;;
v)
echo "+ Tunnel OS Setup Script"
echo "$ Version: 1.4"
exit 0
;;
r)
VERBOSE=1
;;
?)
print_help
exit 1
;;
esac
done
shift "$(($OPTIND -1))"
if [ "$NO_DESICION" -eq 1 ]
then
print_help
exit 1
fi
if [ $PACKAGE_SET_TOOL -eq 1 ] || [ $PACKAGE_SET_QEMU -eq 1 ] || [ $PACKAGE_SET_NODE -eq 1 ]
then
printf "$PACKAGE_SET_INFO"
NO_PACKAGES=0
echo
fi
read -r -p "? Do you want to continue? [y/N] " response
response=${response,,}
if [[ "$response" =~ ^(no|n)$ ]]
then
exit 0
fi
if [ "$EUID" -ne 0 ]
then
echo "! Setup command should be runned as root user."
exit 1
fi
if [ $VERBOSE -eq 1 ]
then
rm -vf /usr/include/stdarg.h /usr/include/cpuid.h
else
rm -f /usr/include/stdarg.h /usr/include/cpuid.h
fi
if [ $NO_PACKAGES -eq 0 ]
then
if [ $VERBOSE -eq 1 ]
then
apt-get install $PACKAGE_SET -y;
else
apt-get -qq install -o=Dpkg::Use-Pty=0 $PACKAGE_SET -y 1> /dev/null;
fi
fi
cd /usr/include
echo "* Downloading stdarg.h"
if [ $VERBOSE -eq 1 ]
then
wget https://sites.uclouvain.be/SystInfo/usr/include/stdarg.h
else
wget https://sites.uclouvain.be/SystInfo/usr/include/stdarg.h -q
fi
echo "* Downloading cpuid.h"
if [ $VERBOSE -eq 1 ]
then
wget https://sites.uclouvain.be/SystInfo/usr/include/cpuid.h
else
wget https://sites.uclouvain.be/SystInfo/usr/include/cpuid.h -q
fi
if [ $PACKAGE_SET_NODE -eq 1 ]
then
echo "* Downloading Node JS."
cd /root
if [ ! -d "node" ]
then
if [ $VERBOSE -eq 1 ]
then
git clone --depth 1 --recursive https://github.com/nodejs/node.git
else
git clone --depth 1 --recursive https://github.com/nodejs/node.git &> /dev/null
fi
fi
cd node
echo "* Configuring Node JS."
bash ./configure
echo "* Compiling Node JS with $(nproc) jobs."
make VERBOSE=$VERBOSE -j$(nproc)
echo "* Installing Node JS."
make install
fi
cd $CDIR
echo "** Everything is set up to compile this code and execute system on supported targets!"