服务配置调整
启动服务时加载已保存的规则文件
This commit is contained in:
parent
dacee0f550
commit
56f99332d8
@ -4,9 +4,13 @@ After=network.target
|
||||
|
||||
[Service]
|
||||
Environment="HOME=/root"
|
||||
ExecStartPre=iptables-restore /etc/iptables.rule
|
||||
WorkingDirectory=/opt/iptables-helper
|
||||
ExecStartPre=sh -c "[ -f /etc/iptables.rule ] && iptables-restore /etc/iptables.rule || exit 0;"
|
||||
ExecStart=/opt/iptables-helper/iptables-helper
|
||||
ExecStartPost=sh -c "iptables-save | tee /etc/iptables.rule > /dev/null"
|
||||
Restart=on-failure
|
||||
KillMode=process
|
||||
RestartSec=5s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -80,7 +80,7 @@ func DelRuleByCmd(cmd string) error {
|
||||
}
|
||||
|
||||
func SaveRule() {
|
||||
cmd := "sh -c \"iptables-save | tee /etc/iptables.rule\""
|
||||
cmd := "sh -c \"iptables-save | tee /etc/iptables.rule > /dev/null\""
|
||||
commander := command.Commander{}
|
||||
commander.Execute("sudo " + cmd)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user