Przeglądaj źródła

Add linux server scripts

世界 3 lat temu
rodzic
commit
9b9b5ebb72

+ 14 - 0
release/local/config.json

@@ -0,0 +1,14 @@
+{
+  "log": {
+    "level": "info"
+  },
+  "inbounds": [
+    {
+      "type": "shadowsocks",
+      "listen": "::",
+      "listen_port": 8080,
+      "method": "2022-blake3-aes-128-gcm",
+      "password": "8JCsPssfgS8tiRwiMlhARg=="
+    }
+  ]
+}

+ 7 - 0
release/local/enable.sh

@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+set -e -o pipefail
+
+sudo systemctl enable sing-box
+sudo systemctl start sing-box
+sudo journalctl -u sing-box --output cat -f

+ 16 - 0
release/local/install.sh

@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+set -e -o pipefail
+
+DIR=$(dirname "$0")
+PROJECT=$DIR/../..
+
+pushd $PROJECT
+go install -v -trimpath -ldflags "-s -w -buildid=" -tags "no_gvisor" ./cmd/sing-box
+popd
+
+sudo cp $(go env GOPATH)/bin/sing-box /usr/local/bin/
+sudo mkdir -p /usr/local/etc/sing-box
+sudo cp $DIR/config.json /usr/local/etc/sing-box/config.json
+sudo cp $DIR/sing-box.service /etc/systemd/system
+sudo systemctl daemon-reload

+ 13 - 0
release/local/sing-box.service

@@ -0,0 +1,13 @@
+[Unit]
+Description=sing-box service
+Documentation=https://sing-box.sagernet.org
+After=network.target nss-lookup.target
+
+[Service]
+ExecStart=/usr/local/bin/sing-box run -c /usr/local/etc/sing-box/config.json
+Restart=on-failure
+RestartSec=10s
+LimitNOFILE=infinity
+
+[Install]
+WantedBy=multi-user.target

+ 7 - 0
release/local/uninstall.sh

@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+sudo systemctl stop sing-box
+sudo rm -rf /usr/local/bin/sing-box
+sudo rm -rf /usr/local/etc/sing-box
+sudo rm -rf /etc/systemd/system/sing-box.service
+sudo systemctl daemon-reload

+ 18 - 0
release/local/update.sh

@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+set -e -o pipefail
+
+DIR=$(dirname "$0")
+PROJECT=$DIR/../..
+
+pushd $PROJECT
+git fetch
+git reset FETCH_HEAD --hard
+git clean -fdx
+go install -v -trimpath -ldflags "-s -w -buildid=" -tags "no_gvisor" ./cmd/sing-box
+popd
+
+sudo systemctl stop sing-box
+sudo cp $(go env GOPATH)/bin/sing-box /usr/local/bin/
+sudo systemctl start sing-box
+sudo journalctl -u sing-box --output cat -f