-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathset-env-variable.sh
48 lines (38 loc) · 1.31 KB
/
set-env-variable.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
#!/bin/sh
# # if i need to add UI env variables in the future
# JSON_STRING='window.configs = { \
# "APP_VAR":"'"${APP_VAR}"'" \
# }'
# sed -i "s@// CONFIGURATIONS_PLACEHOLDER@${JSON_STRING}@" /usr/share/nginx/html/index.html
# exec "$@"
TMP=$(echo "$suwayomi" | sed "s@/\$@@")
echo $TMP
# get the resolver IPs from /etc/resolv.conf and make them nginx syntax
TMP2=$(awk '
#if ipv4 print it
$1=="nameserver" && $2~/^((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])\.?){4}$/{
print $2
}
# if the ip isnt ipv4 assume its ipv6 and surround it in []
$1=="nameserver" && $2!~/^((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])\.?){4}$/{
print "["$2"]"
}' /etc/resolv.conf)
echo $TMP2
cat /etc/nginx/conf.d/default.conf
echo ""
echo ""
sed -i "s@resolverPLACEHOLDER@$TMP2@" /etc/nginx/conf.d/default.conf
cat /etc/nginx/conf.d/default.conf
echo ""
echo ""
sed -i "s@urlPLACEHOLDER@$TMP@" /etc/nginx/conf.d/default.conf
cat /etc/nginx/conf.d/default.conf
echo ""
cd /usr/share/nginx/html
# test
THEME="${theme:-skeleton}"
find . -name '*.html' -exec sed -i -e "s/data-theme=\"skeleton\"/data-theme=\"$THEME\"/g" {} \;
if [[ "${light}" = "true" || "${light}" = "True" || "${light}" = "TRUE" ]]; then
find . -name '*.html' -exec sed -i -e 's/<html lang="en" class="dark">/<html lang="en" class>/g' {} \;
fi
echo "completed set-env-variable.sh"