mirror of
https://github.com/Websoft9/websoft9.git
synced 2025-02-03 09:48:38 +08:00
proxy
This commit is contained in:
parent
3834051b2f
commit
2fba3a05e9
@ -2,10 +2,21 @@
|
|||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
echo "Start to change nginxproxymanage users" >> /tmp/userlog
|
|
||||||
username="help@websoft9.com"
|
username="help@websoft9.com"
|
||||||
password=$(openssl rand -base64 16 | tr -d '/+' | cut -c1-16)
|
password=$(openssl rand -base64 16 | tr -d '/+' | cut -c1-16)
|
||||||
token=""
|
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
|
while [ -z "$token" ]; do
|
||||||
sleep 5
|
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)
|
login_data=$(curl -X POST -H "Content-Type: application/json" -d '{"identity":"admin@example.com","scope":"user", "secret":"changeme"}' http://localhost:81/api/tokens)
|
||||||
@ -16,4 +27,8 @@ 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
|
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
|
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
|
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 New Issue
Block a user