-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·56 lines (43 loc) · 1.43 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Spectre 安装文件
# @author leozhang2018 <[email protected]>
# @license http://www.opensource.org/licenses/MIT
## root 环境检查函数
function checkRoot(){
if [ $UID -ne 0 ]; then
echo "非 root 用户请切换至 root 用户执行"
exit 1
fi
}
## ipv4_CN iptable 的定时自动更新函数
IptableIntoCrontab(){
cron="/etc/cron.d/Update-iptables" #检测 crontab 是否存在 Update-iptables.sh
if test -s $cron ;then
echo "更新 iptable 的 Cron 任务已经存在"
else
echo "是否进行 ipv4_CN iptable 的定时自动更新?(yes or no)"
read input
file_location=/Spectre/crontasks/Update-iptables.sh
if [ "$input" == "yes" -o "$input" == "Yes" ]; then
#每个月总有那么一次
echo '* * 1 * * sh root bash' $file_location '/dev/null 2>&1' >> /etc/cron.d/Update-iptables
echo -e "写入 Crontab 完毕 时间设置每月定时更新"
else
exit 0
fi
fi
}
# 检查 root 环境
checkRoot
##复制程序目录
sudo cp -R Spectre /Spectre
##更改权限
sudo chmod -R 775 /Spectre
##开启 IP 数据包转发
sysctl -w net.ipv4.ip_forward=1 >> /dev/null
##将 Spectre.sh 脚本添加至开机启动项
echo "/Spectre/Spectre.sh \nexit 0" >> /etc/rc.local
## 是否进行 ipv4_CN iptable 的定时自动更新
IptableIntoCrontab
##提示用户修改配置文件
echo "安装完毕,请修改位于 /Spectre 目录下的配置文件 config.conf"