Что ж, я хочу поделиться этим временным решением, я думаю, он не так элегантен, как я хотел, но он работает.
Сначала создайте файл и назовите его как хотите, т.е. fwsrv
#!/bin/bash
# Author: Francisco Tapia
#
# /etc/init.d/fwsrv
#
### BEGIN INIT INFO
# Provides: fwsrv
# Required-Start: network
# Should-Start: $null
# Required-Stop: $null
# Should-Stop: $null
# Default-Start: 5
# Default-Stop: 5
# Short-Description: Executes iptables rules.
# Description: this is not a service.
### END INIT INFO
. /etc/rc.status
rc_reset
case "$1" in
start)
# use colour for ease of spotting
echo -e "\E[36mRunning $0 (start)...\E[0m";
/etc/init.d/fwsrv.d/start
echo -e "\E[36mDone $0 \E[0m";
;;
stop)
echo -e "\E[36mRunning $0 (stop)...\E[0m";
/etc/init.d/fwsrv.d/stop
echo -e "\E[36mDone $0 \E[0m";
;;
restart)
$0 stop
$0 start
rc_status
;;
*)
echo "Usage $0 (start|stop|restart)"
exit 1;
;;
esac
rc_exit
Затем создайте 2 файла, один с именем start
, а другой stop
с этим содержимым в скрипте.
#!/bin/bash
# run scripts with names starting 0-9 in foreground. if you want to
# put a script in start.d and you care about when it gets run in relation
# to other scripts, give it a name starting 0-9
for i in $(dirname $0)/start.d/[0-9]*;do
test -x $i && echo -e "\E[36mRunning ${i} \E[0m" && $i
done
# run scripts with names starting a-z in the background
# as this reduces the over all time this script takes to run.
for i in $(dirname $0)/start.d/[a-z]*;do
test -x $i && echo -e "\E[36mRunning ${i} \E[0m" && $i &
done
# wait for children to exit
wait;
и, наконец, последний называется rules, и в нем будут все мои желаемые правила:
#!/bin/bash
rcSuSEfirewall2 start
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -F
#My Desired Rules
Затем выполните следующие команды в терминале.
cp fwsrv /etc/init.d/fwsrv
chmod u+x /etc/init.d/fwsrv
mkdir -p /etc/init.d/fwsrv.d/start.d
mkdir -p /etc/init.d/fwsrv.d/stop.d
cp start /etc/init.d/fwsrv.d/start
cp stop /etc/init.d/fwsrv.d/stop
chmod u+x /etc/init.d/fwsrv.d/start
chmod u+x /etc/init.d/fwsrv.d/stop
cp rules /etc/init.d/fwsrv.d/start.d/rules
chmod u+x /etc/init.d/fwsrv.d/start.d/rules
insserv /etc/init.d/fwsrv
Теперь Машина будет запускать брандмауэр при запуске и очищать все правила и применять все настраиваемые правила. если вы хотите добавить больше правил, просто отредактируйте файл правил в /etc/init.d/fwsrv.d/start.d/
Это связано с тем, что 2to3
не установлен по умолчанию и может быть установлен с помощью
yum install python-tools
Теперь запуск ./gnuhealth-setup install
должен позволить завершиться