mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-25 00:50:30 +00:00
rc
This commit is contained in:
parent
325adc32ed
commit
aede9231b7
5 changed files with 30 additions and 11 deletions
|
@ -1,4 +1,4 @@
|
|||
# modify time: 202310191733, you can modify here to trigger Docker Build action
|
||||
# modify time: 2023102400933, you can modify here to trigger Docker Build action
|
||||
# step1: Build entrypoint execute program init_portainer by golang
|
||||
|
||||
FROM golang:latest AS builder
|
||||
|
|
|
@ -12,17 +12,25 @@ import (
|
|||
func main() {
|
||||
|
||||
filePath := "/data/credential"
|
||||
initPath := "/data/init"
|
||||
|
||||
_, err := os.Stat(filePath)
|
||||
if os.IsNotExist(err) {
|
||||
fmt.Println("credential is not exist, create it.")
|
||||
password := generatePassword(16)
|
||||
|
||||
err := writeToFile(filePath, password)
|
||||
if err != nil {
|
||||
fmt.Println("write file error:", err)
|
||||
return
|
||||
_, err := os.Stat(initPath)
|
||||
|
||||
if os.IsNotExist(err) {
|
||||
fmt.Println("credential is not exist, create it.")
|
||||
password := generatePassword(16)
|
||||
err := writeToFile(filePath, password)
|
||||
if err != nil {
|
||||
fmt.Println("write file error:", err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
fmt.Println("credential is exist, skip it.")
|
||||
}
|
||||
|
||||
// call portainer
|
||||
cmd := exec.Command("./portainer", "--admin-password-file", filePath)
|
||||
cmd.Stdout = os.Stdout
|
||||
|
@ -32,6 +40,8 @@ func main() {
|
|||
if err != nil {
|
||||
fmt.Println("error running compiled_program:", err)
|
||||
return
|
||||
}else{
|
||||
os.Create(initPath)
|
||||
}
|
||||
}else{
|
||||
fmt.Println("credential is exist, skip it.")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# modify time: 202310231624, you can modify here to trigger Docker Build action
|
||||
# modify time: 202310240910, you can modify here to trigger Docker Build action
|
||||
# Dockerfile refer to:https://github.com/NginxProxyManager/nginx-proxy-manager/blob/develop/docker/Dockerfile
|
||||
FROM jc21/nginx-proxy-manager:2.10.4
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ username="help@websoft9.com"
|
|||
password=$(openssl rand -base64 16 | tr -d '/+' | cut -c1-16)
|
||||
token=""
|
||||
cred_path="/data/credential"
|
||||
max_attempts=10
|
||||
|
||||
echo "Start to change nginxproxymanage users"
|
||||
if [ -e "$cred_path" ]; then
|
||||
|
@ -23,7 +24,7 @@ while [ -z "$token" ]; do
|
|||
done
|
||||
|
||||
echo "Change username(email)"
|
||||
while true; do
|
||||
for attempt in $(seq 1 $max_attempts); do
|
||||
response=$(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)
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Set username successful"
|
||||
|
@ -31,11 +32,15 @@ while true; do
|
|||
else
|
||||
echo "Set username failed, retrying..."
|
||||
sleep 5
|
||||
if [ $attempt -eq $max_attempts ]; then
|
||||
echo "Failed to set username after $max_attempts attempts. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Update password"
|
||||
while true; do
|
||||
for attempt in $(seq 1 $max_attempts); do
|
||||
response=$(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)
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Set password successful"
|
||||
|
@ -46,6 +51,10 @@ while true; do
|
|||
else
|
||||
echo "Set password failed, retrying..."
|
||||
sleep 5
|
||||
if [ $attempt -eq $max_attempts ]; then
|
||||
echo "Failed to set password after $max_attempts attempts. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "0.8.26-rc81",
|
||||
"version": "0.8.26-rc82",
|
||||
"plugins": {
|
||||
"portainer": "0.0.7",
|
||||
"nginx": "0.0.5",
|
||||
|
|
Loading…
Reference in a new issue