-
Notifications
You must be signed in to change notification settings - Fork 1
/
setupAccess.sh
executable file
·41 lines (38 loc) · 1.8 KB
/
setupAccess.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
#!/usr/bin/env bash
# Setup HAT access
echo "Setting up HAT access"
HAT_OWNER=${HAT_OWNER:-'bobtheplumber'}
HAT_OWNER_ID=${HAT_OWNER_ID:-`uuidgen`}
HAT_OWNER_NAME=${HAT_OWNER_NAME:-'Bob'}
# HAT_OWNER_PASSWORD env variable is set then use it as plain password
if [ -n "$HAT_OWNER_PASSWORD" ]; then
DEFAULT_HAT_OWNER_PASSWORD_HASH="crypt('$HAT_OWNER_PASSWORD', gen_salt('bf'))"
else
DEFAULT_HAT_OWNER_PASSWORD_HASH=''\''$2a$08$vXWZ7MvO0IJu/LvZoMGj3udxKFKTx7a9weDA11zz7wvfIB8qI9JrC'\''' # by default hash for pa55w0rd
fi
if [ -n "$HAT_OWNER_PASSWORD_HASH" ]; then
HAT_OWNER_PASSWORD_HASH="'$HAT_OWNER_PASSWORD_HASH'"
fi
HAT_OWNER_PASSWORD_HASH=${HAT_OWNER_PASSWORD_HASH:-$DEFAULT_HAT_OWNER_PASSWORD_HASH}
HAT_PLATFORM=${HAT_PLATFORM:-'hatdex.org'}
HAT_PLATFORM_ID=${HAT_PLATFORM_ID:-`uuidgen`}
HAT_PLATFORM_NAME=${HAT_PLATFORM_NAME:-'hatdex'}
# HAT_PLATFORM_PASSWORD env variable is set then use it as plain password
if [ -n "$HAT_PLATFORM_PASSWORD" ]; then
DEFAULT_HAT_PLATFORM_PASSWORD_HASH="crypt('$HAT_PLATFORM_PASSWORD', gen_salt('bf'))"
else
DEFAULT_HAT_PLATFORM_PASSWORD_HASH=''\''$2a$10$VTnzSsdslsrlj1gVOGZQ7O3ze4KML/qG1stH8yC/ksFPTx8NoF0Ri'\''' # by default hash for pa55w0rd
fi
if [ -n "$HAT_PLATFORM_PASSWORD_HASH" ]; then
HAT_PLATFORM_PASSWORD_HASH="'$HAT_PLATFORM_PASSWORD_HASH'"
fi
HAT_PLATFORM_PASSWORD_HASH=${HAT_PLATFORM_PASSWORD_HASH:-$DEFAULT_HAT_PLATFORM_PASSWORD_HASH}
sed -e "s;%HAT_OWNER%;$HAT_OWNER;g"\
-e "s;%HAT_OWNER_ID%;$HAT_OWNER_ID;g"\
-e "s;%HAT_OWNER_NAME%;$HAT_OWNER_NAME;g"\
-e "s;%HAT_OWNER_PASSWORD_HASH%;$HAT_OWNER_PASSWORD_HASH;g"\
-e "s;%HAT_PLATFORM%;$HAT_PLATFORM;g"\
-e "s;%HAT_PLATFORM_ID%;$HAT_PLATFORM_ID;g"\
-e "s;%HAT_PLATFORM_NAME%;$HAT_PLATFORM_NAME;g"\
-e "s;%HAT_PLATFORM_PASSWORD_HASH%;$HAT_PLATFORM_PASSWORD_HASH;g"\
41_authentication.sql.template > 41_authentication.sql