diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 4068cd05..f48feabf 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -117,9 +117,6 @@ nfpms: dst: /etc/systemd/system/sing-box@.service - src: LICENSE dst: /usr/share/licenses/sing-box/LICENSE - scripts: - postinstall: release/config/postinstall.sh - postremove: release/config/postremove.sh source: enabled: false name_template: '{{ .ProjectName }}-{{ .Version }}.source' diff --git a/docs/examples/linux-server-installation.md b/docs/examples/linux-server-installation.md index a3bdefb9..a785b130 100644 --- a/docs/examples/linux-server-installation.md +++ b/docs/examples/linux-server-installation.md @@ -7,9 +7,9 @@ #### Install ```shell -git clone https://github.com/SagerNet/sing-box +git clone -b main https://github.com/SagerNet/sing-box cd sing-box -./release/local/install_go.sh # skip if you have go1.19 already installed +./release/local/install_go.sh # skip if you have golang already installed ./release/local/install.sh ``` diff --git a/docs/examples/linux-server-installation.zh.md b/docs/examples/linux-server-installation.zh.md index 02cf402f..91d908d6 100644 --- a/docs/examples/linux-server-installation.zh.md +++ b/docs/examples/linux-server-installation.zh.md @@ -7,9 +7,9 @@ #### 安装 ```shell -git clone https://github.com/SagerNet/sing-box +git clone -b main https://github.com/SagerNet/sing-box cd sing-box -./release/local/install_go.sh # 如果已安装 go1.19 则跳过 +./release/local/install_go.sh # 如果已安装 golang 则跳过 ./release/local/install.sh ``` 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/config/postremove.sh b/release/config/postremove.sh deleted file mode 100755 index 00fff784..00000000 --- a/release/config/postremove.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -rm -rf /var/lib/sing-box \ No newline at end of file diff --git a/release/config/sing-box.service b/release/config/sing-box.service index 756f5be4..76ab695f 100644 --- a/release/config/sing-box.service +++ b/release/config/sing-box.service @@ -4,10 +4,9 @@ Documentation=https://sing-box.sagernet.org After=network.target nss-lookup.target [Service] -WorkingDirectory=/var/lib/sing-box CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH -ExecStart=/usr/bin/sing-box run -c /etc/sing-box/config.json +ExecStart=/usr/bin/sing-box -D /var/lib/sing-box -C /etc/sing-box run ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure RestartSec=10s diff --git a/release/config/sing-box@.service b/release/config/sing-box@.service index c480c3fb..423ec458 100644 --- a/release/config/sing-box@.service +++ b/release/config/sing-box@.service @@ -4,10 +4,9 @@ Documentation=https://sing-box.sagernet.org After=network.target nss-lookup.target [Service] -WorkingDirectory=/var/lib/sing-box-%i CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH -ExecStart=/usr/bin/sing-box run -c /etc/sing-box/%i.json +ExecStart=/usr/bin/sing-box -D /var/lib/sing-box-%i -c /etc/sing-box/%i.json run ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure RestartSec=10s 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 diff --git a/release/local/install_go.sh b/release/local/install_go.sh index d8419768..ea64fec4 100755 --- a/release/local/install_go.sh +++ b/release/local/install_go.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash set -e -o pipefail -curl -Lo go.tar.gz https://go.dev/dl/go1.20.1.linux-amd64.tar.gz + +go_version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') +curl -Lo go.tar.gz "https://go.dev/dl/go$go_version.linux-amd64.tar.gz" sudo rm -rf /usr/local/go sudo tar -C /usr/local -xzf go.tar.gz rm go.tar.gz diff --git a/release/local/sing-box.service b/release/local/sing-box.service index 86e3b22f..7ff91253 100644 --- a/release/local/sing-box.service +++ b/release/local/sing-box.service @@ -4,10 +4,9 @@ Documentation=https://sing-box.sagernet.org After=network.target nss-lookup.target [Service] -WorkingDirectory=/var/lib/sing-box CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH -ExecStart=/usr/local/bin/sing-box run -c /usr/local/etc/sing-box/config.json +ExecStart=/usr/local/bin/sing-box -D /var/lib/sing-box -C /usr/local/etc/sing-box run ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure RestartSec=10s