-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
32 lines (30 loc) · 1.83 KB
/
Makefile
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
all:
install:
@echo "Copying files to /usr/local/openresty/nginx/auth and restarting"; \
echo "nginx web server..."; \
sudo sh -ec 'mkdir -p /usr/local/openresty/nginx/auth && \
cp -a * /usr/local/openresty/nginx/auth/ && \
/etc/init.d/nginx restart'
password:
@echo "Enter account information to compute password hash"; \
read -p "User id: " user; \
while :; do \
stty="`stty -g`"; trap 'stty $${stty}' INT HUP TERM QUIT EXIT; \
stty -echo; \
read -p "Password: " password; echo; \
read -p "Re-enter password: " verify; echo; \
trap - INT HUP TERM QUIT EXIT; stty $${stty}; \
[ -n "$${password}" ] && \
[ "$${password}" = "$${verify}" ] && break; \
echo "Password error; please retry"; \
done; \
read -p "Realm(s): " realms; \
salt="`dd if=/dev/urandom count=1 2>&1 | \
openssl dgst -sha1 -binary | \
base64 | \
sed 's/\(........\).*/\1/'`"; \
hash="`echo -n "$${password}" | \
openssl dgst -sha1 -hmac "$${salt}" -binary | \
openssl dgst -sha1 -binary | \
base64`"; \
printf '%s\t%s\t%s\n' "$${user}" "$${salt}:$${hash}" "$${realms}"