So I think I fixed the problem, the script now executes on shutdowns and reboots!
I didn't think that all of those services had been setup at the exact time the script starts, but it gave me an idea. Instead of the script running just as a script, I made a script in /usr/local/bin/ called firewall that did the commands for starting up the service, but I made it wait 15 seconds to execute. The reason for 15 sec delay, is because it will apply the changes around the same time the login prompt is started. As well as when the dependencies have started to run. Along with this, I put the execution in the background, since I didn't know nor want to find out if the load/boot process would hang.
Here is what the init script looks like now:
Code:
#!/bin/sh
# Start up script to enable the firewall
case $1 in
'start')
#load custom configuration
/usr/local/bin/firewall &
;;
'stop')
#stop service
;;
*)
echo "Usage: $0 start|stop" >&2
exit 1
;;
esac
exit 0
Along with my firewall script in /usr/local/bin/ :
Code:
#!/bin/sh
#wait for system to bootup and services start
sleep 15
#Enable custom firewall rules for ipfilter...
svcadm enable ipfilter
svccfg -s ipfilter:default setprop \
firewall_config_default/policy = astring: "custom"
svccfg -s ipfilter:default setprop \
firewall_config_default/custom_policy_file = astring: \
"/etc/ipf/ipf.conf"
svcadm refresh ipfilter:default
Here is the svcs -xv on a cold boot:
Code:
root@openindiana:~# svcs -xv ipfilter
svc:/network/ipfilter:default (IP Filter)
State: online since June 4, 2017 04:27:16 PM PDT
See: man -M /usr/share/man -s 5 ipfilter
See: /var/svc/log/network-ipfilter:default.log
Impact: None.
Here is the ipfilter log:
Code:
[ Jun 4 16:26:38 Rereading configuration. ]
[ Jun 4 16:26:39 Executing start method ("/lib/svc/method/ipfilter start"). ]
Set 0 now inactive
filter sync'd
0 entries flushed from NAT table
4 entries flushed from NAT list
[ Jun 4 16:26:39 Method "start" exited with status 0. ]
[ Jun 4 16:26:39 Stopping because service disabled. ]
[ Jun 4 16:26:39 Executing stop method ("/lib/svc/method/ipfilter stop"). ]
[ Jun 4 16:26:39 Method "stop" exited with status 0. ]
[ Jun 4 16:26:49 Rereading configuration. ]
[ Jun 4 16:27:05 Rereading configuration. ]
[ Jun 4 16:27:06 Rereading configuration. ]
[ Jun 4 16:27:16 Enabled. ]
[ Jun 4 16:27:16 Rereading configuration. ]
[ Jun 4 16:27:16 Executing start method ("/lib/svc/method/ipfilter start"). ]
Set 0 now inactive
filter sync'd
0 entries flushed from NAT table
4 entries flushed from NAT list
[ Jun 4 16:27:16 Method "start" exited with status 0. ]
Along with /var/adm/messages
Code:
Jun 4 16:27:16 openindiana ipf: [ID 774698 kern.info] IP Filter: v4.1.9, running.