-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathload-libs.sh
executable file
·45 lines (36 loc) · 1.16 KB
/
load-libs.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
#!/bin/bash
# Load environment variables from const and config file
if [[ $(id -u) -eq 0 ]] || [[ $(id -g) -eq 0 ]] ; then
echo "[$0] You can't be root. root has too much power."
echo -e "\e[31mFATAL ERROR \e[0m"
exit 1
fi
if [[ ! -f "load-libs.sh" ]] ; then
echo "[load-libs] : The parent script is not running inside the directory that contains load-libs.sh"
echo -e "\e[31mFATAL ERROR \e[0m"
exit 1
fi
#call ./const.sh script: load constant environment variables
. ./const.sh
#call $WTL_CONFIG_FILE script: load environment variables defined by current configuration
if [[ ! -f "$WTL_CONFIG_FILE" ]] ; then
echo "Missing '"$WTL_CONFIG_FILE"' file in the current"
exit 1
else
. $WTL_CONFIG_FILE
fi
. ./scripts/wtl-event
# check the config file version
if [[ "$WTL_CONFIG_FILE_VERSION" != "1" ]] ; then
wtl-event CONFIG_VERSION_ERROR $WTL_CONFIG_FILE_VERSION
exit 1
fi
if [[ "$WTL_USER_UID" != $(id -u) ]] ; then
wtl-event CONFIG_UID_ERROR $WTL_USER_UID $(id -u)
exit 1
fi
if [[ "$WTL_USER_GID" != $(id -g) ]] ; then
wtl-event CONFIG_GID_ERROR $WTL_USER_GID $(id -g)
exit 1
fi
test -d $WTL_CACHE || mkdir $WTL_CACHE