mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-22 15:40:22 +00:00
proxy
This commit is contained in:
parent
703360416f
commit
68bb02fce4
3 changed files with 35 additions and 33 deletions
|
@ -8,5 +8,4 @@ COPY ./config/initproxy.conf /data/nginx/proxy_host/
|
|||
COPY ./s6/init_user /etc/s6-overlay/s6-rc.d/init_user
|
||||
RUN ls /etc/s6-overlay/s6-rc.d/init_user
|
||||
RUN touch /etc/s6-overlay/s6-rc.d/user/contents.d/init_user
|
||||
|
||||
RUN chmod -R 755 /etc/s6-overlay/s6-rc.d/init_user
|
|
@ -1,34 +1,3 @@
|
|||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
username="help@websoft9.com"
|
||||
password=$(openssl rand -base64 16 | tr -d '/+' | cut -c1-16)
|
||||
token=""
|
||||
cred_path="/var/websoft9/credential"
|
||||
|
||||
if [ -e "$cred_path" ]; then
|
||||
echo "File $cred_path exists. Exiting script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "create diretory"
|
||||
mkdir -p "$(dirname "$cred_path")"
|
||||
|
||||
echo "Start to change nginxproxymanage users" >> /tmp/userlog
|
||||
|
||||
while [ -z "$token" ]; do
|
||||
sleep 5
|
||||
login_data=$(curl -X POST -H "Content-Type: application/json" -d '{"identity":"admin@example.com","scope":"user", "secret":"changeme"}' http://localhost:81/api/tokens)
|
||||
token=$(echo $login_data | jq -r '.token')
|
||||
done
|
||||
|
||||
echo "Change username(email)" >> /tmp/userlog
|
||||
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d '{"email": "'$username'", "nickname": "admin", "is_disabled": false, "roles": ["admin"]}' http://localhost:81/api/users/1
|
||||
|
||||
echo "Update password" >> /tmp/userlog
|
||||
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d '{"type":"password","current":"changeme","secret":"'$password'"}' http://localhost:81/api/users/1/auth
|
||||
|
||||
echo "Save to credential"
|
||||
json="{\"username\":\"$username\",\"password\":\"$password\"}"
|
||||
echo "$json" > "$cred_path"
|
||||
exec /etc/s6-overlay/s6-rc.d/init_user/up
|
34
docker/proxy/s6/init_user/up
Normal file
34
docker/proxy/s6/init_user/up
Normal file
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
username="help@websoft9.com"
|
||||
password=$(openssl rand -base64 16 | tr -d '/+' | cut -c1-16)
|
||||
token=""
|
||||
cred_path="/var/websoft9/credential"
|
||||
|
||||
if [ -e "$cred_path" ]; then
|
||||
echo "File $cred_path exists. Exiting script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "create diretory"
|
||||
mkdir -p "$(dirname "$cred_path")"
|
||||
|
||||
echo "Start to change nginxproxymanage users" >> /tmp/userlog
|
||||
|
||||
while [ -z "$token" ]; do
|
||||
sleep 5
|
||||
login_data=$(curl -X POST -H "Content-Type: application/json" -d '{"identity":"admin@example.com","scope":"user", "secret":"changeme"}' http://localhost:81/api/tokens)
|
||||
token=$(echo $login_data | jq -r '.token')
|
||||
done
|
||||
|
||||
echo "Change username(email)" >> /tmp/userlog
|
||||
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d '{"email": "'$username'", "nickname": "admin", "is_disabled": false, "roles": ["admin"]}' http://localhost:81/api/users/1
|
||||
|
||||
echo "Update password" >> /tmp/userlog
|
||||
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d '{"type":"password","current":"changeme","secret":"'$password'"}' http://localhost:81/api/users/1/auth
|
||||
|
||||
echo "Save to credential"
|
||||
json="{\"username\":\"$username\",\"password\":\"$password\"}"
|
||||
echo "$json" > "$cred_path"
|
Loading…
Reference in a new issue