Create working directory if not exists

This commit is contained in:
世界 2023-03-20 19:33:00 +08:00
parent fe4b429fc2
commit 84904c5206
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
5 changed files with 5 additions and 5 deletions

View file

@ -118,7 +118,6 @@ nfpms:
- src: LICENSE
dst: /usr/share/licenses/sing-box/LICENSE
scripts:
postinstall: release/config/postinstall.sh
postremove: release/config/postremove.sh
source:
enabled: false

View file

@ -40,6 +40,10 @@ func preRun(cmd *cobra.Command, args []string) {
log.SetStdLogger(log.NewFactory(log.Formatter{BaseTime: time.Now(), DisableColors: true}, os.Stderr, nil).Logger())
}
if workingDir != "" {
_, err := os.Stat(workingDir)
if err != nil {
os.MkdirAll(workingDir, 0o777)
}
if err := os.Chdir(workingDir); err != nil {
log.Fatal(err)
}

View file

@ -15,6 +15,7 @@
"listen": "::",
"listen_port": 8080,
"sniff": true,
"network": "tcp",
"method": "2022-blake3-aes-128-gcm",
"password": "8JCsPssfgS8tiRwiMlhARg=="
}

View file

@ -1,3 +0,0 @@
#!/bin/sh
mkdir -p /var/lib/sing-box

View file

@ -14,7 +14,6 @@ go install -v -trimpath -ldflags "-s -w -buildid=" -tags with_quic,with_wireguar
popd
sudo cp $(go env GOPATH)/bin/sing-box /usr/local/bin/
sudo mkdir -p /var/lib/sing-box
sudo mkdir -p /usr/local/etc/sing-box
sudo cp $PROJECT/release/config/config.json /usr/local/etc/sing-box/config.json
sudo cp $DIR/sing-box.service /etc/systemd/system