websoft9/docker/proxy/s6/user/setup

19 lines
1004 B
Plaintext
Raw Normal View History

2023-09-19 17:47:59 +08:00
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
2023-09-21 11:57:10 +08:00
echo "Start to change nginxproxymanage users" >> /tmp/userlog
2023-09-21 10:45:37 +08:00
username="help@websoft9.com"
password=$(openssl rand -base64 16 | tr -d '/+' | cut -c1-16)
token=""
while [ -z "$token" ]; do
sleep 5
2023-09-21 11:57:10 +08:00
login_data=$(curl -X POST -H "Content-Type: application/json" -d '{"identity":"admin@example.com","scope":"user", "secret":"changeme"}' http://localhost:81/api/tokens)
2023-09-21 10:45:37 +08:00
token=$(echo $login_data | jq -r '.token')
done
2023-09-21 11:57:10 +08:00
echo "Change username(email)" >> /tmp/userlog
2023-09-21 10:45:37 +08:00
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
2023-09-21 11:57:10 +08:00
echo "Update password" >> /tmp/userlog
2023-09-21 10:45:37 +08:00
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