-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.sh
executable file
·60 lines (54 loc) · 1.18 KB
/
init.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
#!/bin/sh
if [ $(id -u) -ne 0 ]; then
echo "E: Please run as root"
exit 1
fi
if [ -d $PROJECT_PATH ]; then
echo "E: Project dir at '$PROJECT_PATH' already exist"
exit 1
fi
if [ -r .env ]; then
set -a
. ./.env
set +a
else
echo "E: '.env' file not readible or missing"
exit 1
fi
if [ -d ext ]; then
for f in ext/*.sh; do
sh "$f" || break
done
else
echo "E: Project directory structure incorrect (missing ext/)"
exit 1
fi
if [ -d $PROJECT_PATH ]; then
cp .env $PROJECT_PATH/opt/.env
echo "#!/bin/sh
if [ -r .env ]; then
set -a
. ./.env
set +a
else
echo \"'.env' file not readible or missing\"
exit 1
fi
for f in /opt/nos-init/*.sh; do
sh \"\$f\" || break
done" > $PROJECT_PATH/opt/nos-init.sh
chmod +x $PROJECT_PATH/opt/nos-init.sh
if [ -d int ]; then
mkdir -p $PROJECT_PATH/opt/nos-init
rm -r $PROJECT_PATH/opt/nos-init/* 2>/dev/null
cp int/*.sh $PROJECT_PATH/opt/nos-init/
schroot -c mlnx -u root --directory /opt/ -- /opt/nos-init.sh
rm -r $PROJECT_PATH/opt/nos-init* $PROJECT_PATH/opt/.env
else
echo "E: Project directory structure incorrect (missing int/)"
exit 1
fi
else
echo "E: There is no $PROJECT_PATH"
exit 1
fi