-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ffc0316
Showing
3 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/sh | ||
echo '正在安装依赖' | ||
if cat /etc/os-release | grep "centos" > /dev/null | ||
then | ||
yum update | ||
yum install unzip wget curl -y > /dev/null | ||
yum update curl -y | ||
else | ||
apt update | ||
apt-get install unzip wget curl -y > /dev/null | ||
apt-get update curl -y | ||
fi | ||
|
||
api=$1 | ||
key=$2 | ||
nodeId=$3 | ||
localPort=$4 | ||
license=$5 | ||
folder=$key-trojan | ||
if [[ "$6" -ne "" ]] | ||
then | ||
syncInterval=$6 | ||
else | ||
syncInterval=60 | ||
fi | ||
#kill process and delete dir | ||
kill -9 $(ps -ef | grep ${folder} | grep -v grep | grep -v bash | awk '{print $2}') 1 > /dev/null | ||
kill -9 $(ps -ef | grep defunct | grep -v grep | awk '{print $2}') 1 > /dev/null | ||
echo '结束进程' | ||
rm -rf $folder | ||
|
||
#create dir, init files | ||
mkdir $folder | ||
cd $folder | ||
wget https://github.com/tokumeikoi/tidalab-trojan/releases/latest/download/tidalab-trojan | ||
wget https://github.com/p4gefau1t/trojan-go/releases/download/v0.7.0/trojan-go-linux-amd64.zip | ||
curl "${api}/api/v1/server/TrojanTidalab/config?token=${key}&node_id=${nodeId}&local_port=${localPort}" > ./config.json | ||
|
||
if cat config.json | grep "run_type" > /dev/null | ||
then | ||
echo '配置获取成功' | ||
else | ||
echo '配置获取失败' | ||
exit | ||
fi | ||
|
||
unzip trojan-go-linux-amd64.zip | ||
chmod 755 * | ||
|
||
if ls /root/.cert | grep "key" > /dev/null | ||
then | ||
echo '证书存在' | ||
else | ||
echo '请签发证书后在执行' | ||
exit | ||
fi | ||
|
||
#run server | ||
nohup `pwd`/tidalab-trojan -api=$api -token=$key -node=$nodeId -localport=$localPort -license=$license -syncInterval=$syncInterval > tidalab.log 2>&1 & | ||
echo '部署完成' | ||
sleep 3 | ||
cat tidalab.log | ||
if ls | grep "service.log" | ||
then | ||
cat service.log | ||
else | ||
echo '启动失败' | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
|
||
echo '正在安装依赖' | ||
|
||
if cat /etc/os-release | grep "centos" > /dev/null | ||
then | ||
yum update | ||
yum install tar wget -y > /dev/null | ||
else | ||
apt update | ||
apt-get install tar wget -y > /dev/null | ||
fi | ||
|
||
domain=$1 | ||
|
||
wget https://github.com/go-acme/lego/releases/download/v3.7.0/lego_v3.7.0_linux_amd64.tar.gz | ||
|
||
tar zxvf lego_v3.7.0_linux_amd64.tar.gz | ||
chmod 755 * | ||
./lego --email="admin@$domain" --domains="$domain" --http -a run | ||
|
||
if ls ./.lego/certificates | grep "$domain" | ||
then | ||
echo '证书签发成功' | ||
mkdir /root/.cert | ||
cp ./.lego/certificates/$domain.crt /root/.cert | ||
cp ./.lego/certificates/$domain.key /root/.key | ||
else | ||
echo '证书签发失败' | ||
fi |