Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
saifsas committed Jun 12, 2020
0 parents commit ffc0316
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
Empty file added README.md
Empty file.
68 changes: 68 additions & 0 deletions install.sh
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
30 changes: 30 additions & 0 deletions sign.sh
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

0 comments on commit ffc0316

Please sign in to comment.