updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / arptables / arptables.sh
blob71e386149e6f67a35d5253bd13bb66653ff14201
1 #!/bin/bash
3 # init script for arptables
5 # Original by Dag Wieers <dag@wieers.com>.
6 # Modified/changed to arptables by
7 # Rok Papez <rok.papez@arnes.si>.
9 # Adapted for Archlinux by Michal Soltys <soltys@ziu.info>
12 . /etc/rc.conf
13 . /etc/rc.d/functions
15 RETVAL=0
17 [ -x /usr/sbin/arptables ] || exit 1
18 [ -x /usr/sbin/arptables-save ] || exit 1
19 [ -x /usr/sbin/arptables-restore ] || exit 1
21 start() {
22 stat_busy "Starting arptables"
23 [[ ! -r /etc/arptables/arptables ]] && :>/etc/arptables/arptables
25 /usr/sbin/arptables-restore </etc/arptables/arptables || RETVAL=1
27 if (( $RETVAL == 0 )); then
28 stat_done
29 add_daemon arptables
30 else
31 stat_fail
35 stop() {
36 stat_busy "Stopping arptables"
37 /usr/sbin/arptables-restore </dev/null || RETVAL=1
39 if (( $RETVAL == 0 )); then
40 stat_done
41 rm_daemon arptables
42 else
43 stat_fail
47 restart() {
48 stop
49 sleep 2
50 start
53 save() {
54 stat_busy "Saving arptables"
55 /usr/sbin/arptables-save >/etc/arptables/arptables || RETVAL=1
57 (( $RETVAL == 0 )) && stat_done || stat_fail
60 case "$1" in
61 start)
62 if ! ck_daemon arptables; then
63 printhl "Arptables already started"
64 RETVAL=1
65 else
66 start
69 stop)
70 if ck_daemon arptables; then
71 printhl "Arptables not yet started"
72 RETVAL=1
73 else
74 stop
77 restart)
78 restart
80 save)
81 save
83 status)
84 /usr/sbin/arptables-save
85 RETVAL=$?
88 echo $"Usage $0 {start|stop|restart|save|status}"
89 RETVAL=1
90 esac
92 exit $RETVAL