change username and password

This commit is contained in:
qiaofeng1227 2023-09-21 10:45:37 +08:00
parent 3498a47eff
commit cb2c0139af
2 changed files with 17 additions and 3 deletions

View file

@ -3,10 +3,10 @@ FROM jc21/nginx-proxy-manager:2.10.4
LABEL maintainer="Websoft9<help@websoft9.com>"
LABEL version="2.10.4"
RUN apt-get update && apt-get install -y curl supervisor
RUN apt-get update && apt-get install -y curl supervisor jq
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY config/user.sh /user.sh
COPY config/entrypoint.sh /entrypoint.sh
COPY ./config/initproxy.conf /data/nginx/proxy_host
COPY ./config/initproxy.conf /data/nginx/proxy_host/
RUN chmod +x /user.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View file

@ -2,4 +2,18 @@
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
echo "Start to change nginxproxymanage users"
echo "Start to change nginxproxymanage users"
username="help@websoft9.com"
password=$(openssl rand -base64 16 | tr -d '/+' | cut -c1-16)
token=""
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://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)"
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"
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