Created rc.d init script

This commit is contained in:
ac3d912 2018-12-09 22:29:28 -06:00
parent 38bb24835e
commit 5ae90573f7
2 changed files with 56 additions and 3 deletions

View File

@ -106,10 +106,13 @@ If you only have two NICs, you can buy this cheap USB 100Mbps NIC [from Amazon](
**NOTE:** If you have the 5268AC, you'll also need to install `pfatt-5268.sh` due to [issue #5](https://github.com/aus/pfatt/issues/5). The script monitors your connection and disables or enables the EAP bridging as needed. It's a hacky workaround, but it enables you to keep your 5268AC connected, avoid EAP-Logoffs and survive reboots. Consider changing the `PING_HOST` in `pfatt-5268AC.sh` to a reliable host. Then perform these additional steps to install:
Copy `bin/pfatt-5268AC.sh` to `/usr/local/etc/rc.d/`:
Copy `bin/pfatt-5268AC` to `/usr/local/etc/rc.d/`
Copy `bin/pfatt-5268AC.sh` to `/root/bin/`:
```
scp bin/pfatt-5268AC.sh root@pfsense:/usr/local/etc/rc.d/
ssh root@pfsense chmod +x /usr/local/etc/rc.d/pfatt-5268AC.sh
scp bin/pfatt-5268AC root@pfsense:/usr/local/etc/rc.d/
scp bin/pfatt-5268AC.sh root@pfsense:/root/bin/
ssh root@pfsense chmod +x /usr/local/etc/rc.d/pfatt-5268AC.sh /root/bin/pfatt-5268AC
```
4. Connect cables:

50
bin/pfatt-5268AC Normal file
View File

@ -0,0 +1,50 @@
#!/bin/sh
script_path="/root/bin/pfatt-5268AC.sh"
name=`/usr/bin/basename "${script_path}"`
rc_start() {
### Lock out other start signals until we are done
/usr/bin/touch /var/run/${name}.lck
${script_path} &
pid=$!
if [ $pid ]; then
echo $pid > /var/run/${name}.pid
/usr/bin/logger -p daemon.info -i -t pfattStartup "Successfully started ${name}"
else
/usr/bin/logger -p daemon.error -i -t pfattStartup "Error starting ${name}"
fi
### Remove the lock
if [ -f /var/run/${name}.lck ]; then
/bin/sleep 2
/bin/rm /var/run/${name}.lck
fi
}
rc_stop() {
if [ -f /var/run/${name}.pid ]; then
kill -9 `cat /var/run/${name}.pid`
/bin/rm /var/run/${name}.pid
fi
}
case $1 in
start)
if [ ! -f /var/run/${name}.lck ]; then
rc_start
fi
;;
stop)
rc_stop
;;
restart)
if [ ! -f /var/run/${name}.lck ]; then
rc_stop
rc_start
fi
;;
esac