mirror of
https://github.com/Websoft9/websoft9.git
synced 2025-01-24 01:50:19 +08:00
deployment
This commit is contained in:
parent
1428f2c14b
commit
635469f653
@ -9,5 +9,4 @@ RUN chmod +x /init_portainer
|
||||
FROM portainer/portainer-ce:2.19.0
|
||||
LABEL maintainer="websoft9<help@websoft9.com>"
|
||||
LABEL version="2.19.0"
|
||||
|
||||
COPY --from=builder /init_portainer /
|
@ -7,7 +7,6 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -42,7 +41,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
content, err := readPasswordFromFile(filePath)
|
||||
content, err := ioutil.ReadFile(filePath)
|
||||
if err != nil {
|
||||
fmt.Println("read file error:", err)
|
||||
return
|
||||
@ -75,26 +74,7 @@ func generatePassword(length int) string {
|
||||
return string(password)
|
||||
}
|
||||
|
||||
func readPasswordFromFile(filePath string) (string, error) {
|
||||
data, err := ioutil.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
var passwordMap map[string]string
|
||||
err = json.Unmarshal(data, &passwordMap)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
password := passwordMap["password"]
|
||||
return password, nil
|
||||
}
|
||||
func writeToFile(filePath , content string) error {
|
||||
|
||||
func writeToFile(filePath, password string) error {
|
||||
data := map[string]string{"username": "admin", "password": password}
|
||||
jsonData, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile(filePath, jsonData, 0755)
|
||||
return err
|
||||
return ioutil.WriteFile(filePath , []byte(content), 0755)
|
||||
}
|
Loading…
Reference in New Issue
Block a user