forked from uGeek/docker-webdav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
36 lines (30 loc) · 946 Bytes
/
entrypoint.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
#!/bin/bash
touch /etc/nginx/htpasswd
if [ -n "$USERNAME" ] && [ -n "$PASSWORD" ]
then
htpasswd -b /etc/nginx/htpasswd "$USERNAME" "$PASSWORD"
echo "Done for User: $USERNAME"
fi
max_users=50
for ((i=1; i<=$max_users; i++))
do
username_var="USERNAME$i"
password_var="PASSWORD$i"
if [ -n "${!username_var}" ] && [ -n "${!password_var}" ]
then
htpasswd -b /etc/nginx/htpasswd "${!username_var}" "${!password_var}"
echo "Done for User $i: ${!username_var}"
fi
done
if [ -z "$(env | grep '^USERNAME')" ] || [ -z "$(env | grep '^PASSWORD')" ]
then
echo Using no auth.
sed -i 's%auth_basic "Restricted";% %g' /etc/nginx/conf.d/default.conf
sed -i 's%auth_basic_user_file htpasswd;% %g' /etc/nginx/conf.d/default.conf
fi
mediaowner=$(ls -ld /media | awk '{print $3}')
echo "Current /media owner is $mediaowner"
if [ "$mediaowner" != "www-data" ]
then
chown -R www-data:www-data /media
fi