From 84904c52066ee42f600234913e7427e3a384db2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 20 Mar 2023 19:33:00 +0800 Subject: [PATCH] Create working directory if not exists --- .goreleaser.yaml | 1 - cmd/sing-box/main.go | 4 ++++ release/config/config.json | 1 + release/config/postinstall.sh | 3 --- release/local/install.sh | 1 - 5 files changed, 5 insertions(+), 5 deletions(-) delete mode 100755 release/config/postinstall.sh diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 4068cd05..e12d3030 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -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 diff --git a/cmd/sing-box/main.go b/cmd/sing-box/main.go index 1c4c2df3..f7974d2c 100644 --- a/cmd/sing-box/main.go +++ b/cmd/sing-box/main.go @@ -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) } diff --git a/release/config/config.json b/release/config/config.json index ce359de6..c518d18b 100644 --- a/release/config/config.json +++ b/release/config/config.json @@ -15,6 +15,7 @@ "listen": "::", "listen_port": 8080, "sniff": true, + "network": "tcp", "method": "2022-blake3-aes-128-gcm", "password": "8JCsPssfgS8tiRwiMlhARg==" } diff --git a/release/config/postinstall.sh b/release/config/postinstall.sh deleted file mode 100755 index 0fb0f05f..00000000 --- a/release/config/postinstall.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -mkdir -p /var/lib/sing-box \ No newline at end of file diff --git a/release/local/install.sh b/release/local/install.sh index 4d5b9e1b..24e9d006 100755 --- a/release/local/install.sh +++ b/release/local/install.sh @@ -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