summaryrefslogtreecommitdiff
path: root/community/ebtables
diff options
context:
space:
mode:
authorroot <root@rshg054.dnsready.net>2012-05-28 00:02:35 +0000
committerroot <root@rshg054.dnsready.net>2012-05-28 00:02:35 +0000
commit89dd7b5f30d48c708092a71b1c8285090fe91505 (patch)
treefb3a22f789121b955ff0fce7ec8d2f8c8886579b /community/ebtables
parent1f45ad8e3f17397e2f44e68ef9a0d860091eea9e (diff)
Mon May 28 00:02:35 UTC 2012
Diffstat (limited to 'community/ebtables')
-rw-r--r--community/ebtables/PKGBUILD52
-rw-r--r--community/ebtables/ebtables.conf40
-rw-r--r--community/ebtables/ebtables.install9
-rw-r--r--community/ebtables/ebtables.rc135
-rw-r--r--community/ebtables/ebtables.service11
-rw-r--r--community/ebtables/ebtables.systemd22
6 files changed, 96 insertions, 173 deletions
diff --git a/community/ebtables/PKGBUILD b/community/ebtables/PKGBUILD
index f3400453c..ffc3b451b 100644
--- a/community/ebtables/PKGBUILD
+++ b/community/ebtables/PKGBUILD
@@ -1,48 +1,56 @@
-# $Id: PKGBUILD 60674 2011-12-16 19:18:54Z seblu $
-# Maintainer: Sebastien Luttringer <seblu+arch@seblu.net>
+# $Id: PKGBUILD 71322 2012-05-26 15:04:32Z seblu $
+# Maintainer: Sébastien Luttringer <seblu@aur.archlinux.org>
# Contributor: Michal Soltys <soltys@ziu.info>
pkgname=ebtables
pkgver=2.0.10_4
-pkgrel=1
+pkgrel=2
pkgdesc='Ethernet bridge filtering utilities'
arch=('i686' 'x86_64')
-backup=('etc/conf.d/ebtables')
url='http://ebtables.sourceforge.net/'
license=('GPL2')
+backup=("etc/$pkgname.conf" "etc/conf.d/$pkgname")
# ebtables segfault with --as-needed
options=('!buildflags')
-source=(
- "http://downloads.sourceforge.net/${pkgname}/${pkgname}-v${pkgver/_/-}.tar.gz"
- 'ebtables.rc'
- 'ebtables.conf'
- )
+install=$pkgname.install
+source=("http://downloads.sourceforge.net/${pkgname}/${pkgname}-v${pkgver/_/-}.tar.gz"
+ "$pkgname.conf"
+ "$pkgname.rc"
+ "$pkgname.systemd"
+ "$pkgname.service")
md5sums=('506742a3d44b9925955425a659c1a8d0'
- '368825c83a2b1180d2223e61b9f3bd07'
- '86fc3622e6fc0a7a7920c90ff576cc38')
+ 'c6f0838de4429af68d21b4d61f00db59'
+ 'd0e340f2cefe91b1569c0e87c2a1288f'
+ '5a49ea09af202cb438c8a1b15abf9147'
+ 'baf923443c3b16277e50d60d2e68f534')
build() {
- cd ${pkgname}-v${pkgver/_/-}
+ cd $pkgname-v${pkgver/_/-}
make CFLAGS='-Wunused -Wall -Werror -Wno-error=unused-but-set-variable'
}
package() {
- cd "${pkgname}-v${pkgver/_/-}"
+ pushd $pkgname-v${pkgver/_/-}
make install \
- DESTDIR="${pkgdir}" \
+ DESTDIR="$pkgdir" \
LIBDIR=/usr/lib \
MANDIR=/usr/share/man \
BINDIR=/usr/sbin \
INITDIR=/etc/rc.d \
- SYSCONFIGDIR=/etc/ebtables
-
+ SYSCONFIGDIR=/etc
+ popd
# rm package ebtables rc.d scripts
- rm "${pkgdir}/etc/rc.d/ebtables"
- rm "${pkgdir}/etc/ebtables/ebtables-config"
-
- # install custom ebtables rc.d scripts
- install -D -m 0755 "${srcdir}/$pkgname.rc" "${pkgdir}/etc/rc.d/$pkgname"
- install -D -m 0644 "${srcdir}/$pkgname.conf" "${pkgdir}/etc/conf.d/$pkgname"
+ rm "$pkgdir/etc/ebtables-config"
+ # install initscripts
+ install -Dm 755 $pkgname.rc "$pkgdir/etc/rc.d/$pkgname"
+ install -Dm 644 $pkgname.conf "$pkgdir/etc/conf.d/$pkgname"
+ # install systemd service
+ install -Dm 755 $pkgname.systemd \
+ "$pkgdir/usr/lib/systemd/scripts/$pkgname"
+ install -Dm 644 $pkgname.service \
+ "$pkgdir/usr/lib/systemd/system/$pkgname.service"
+ # default config file
+ install -Dm 644 /dev/null "$pkgdir/etc/$pkgname.conf"
}
# vim:set ts=2 sw=2 ft=sh et:
diff --git a/community/ebtables/ebtables.conf b/community/ebtables/ebtables.conf
index 0005444e7..386f94249 100644
--- a/community/ebtables/ebtables.conf
+++ b/community/ebtables/ebtables.conf
@@ -1,37 +1,7 @@
-# Save (and possibly restore) in text format.
-# Value: yes|no, default: yes
-# Save the firewall rules in text format to /etc/conf.d/ebtables
-# If EBTABLES_BINARY_FORMAT="no" then restoring the firewall rules
-# is done using this text format.
-EBTABLES_TEXT_FORMAT="yes"
+# Configuration file used to load/save configuration.
+CONFIG_FILE='/etc/ebtables.conf'
-# Save (and restore) in binary format.
-# Value: yes|no, default: yes
-# Save (and restore) the firewall rules in binary format to (and from)
-# /etc/ebtables/ebtables.<chain>. Enabling this option will make
-# firewall initialisation a lot faster.
-EBTABLES_BINARY_FORMAT="yes"
+# Save configuration on stop/restart.
+#SAVE_ON_STOP=yes
-# Unload modules on restart and stop
-# Value: yes|no, default: yes
-# This option has to be 'yes' to get to a sane state for a firewall
-# restart or stop. Only set to 'no' if there are problems unloading netfilter
-# modules.
-EBTABLES_MODULES_UNLOAD="yes"
-
-# Save current firewall rules on stop.
-# Value: yes|no, default: no
-# Saves all firewall rules if firewall gets stopped
-# (e.g. on system shutdown).
-EBTABLES_SAVE_ON_STOP="no"
-
-# Save current firewall rules on restart.
-# Value: yes|no, default: no
-# Saves all firewall rules if firewall gets restarted.
-EBTABLES_SAVE_ON_RESTART="no"
-
-# Save (and restore) rule counters.
-# Value: yes|no, default: no
-# Save rule counters when saving a kernel table to a file. If the
-# rule counters were saved, they will be restored when restoring the table.
-EBTABLES_SAVE_COUNTER="no"
+# vim:set ts=2 sw=2 ft=sh et:
diff --git a/community/ebtables/ebtables.install b/community/ebtables/ebtables.install
new file mode 100644
index 000000000..7dd6921ed
--- /dev/null
+++ b/community/ebtables/ebtables.install
@@ -0,0 +1,9 @@
+## arg 1: the new package version
+## arg 2: the old package version
+post_upgrade() {
+ [ $(vercmp "$2" '2.0.10_4-1') -gt 0 ] || cat <<EOF
+Config file have been moved to /etc/ebtables.conf and only support text format.
+EOF
+}
+
+# vim:set ts=2 sw=2 ft=sh et:
diff --git a/community/ebtables/ebtables.rc b/community/ebtables/ebtables.rc
index 3a889b914..a845449fe 100644
--- a/community/ebtables/ebtables.rc
+++ b/community/ebtables/ebtables.rc
@@ -1,128 +1,31 @@
#!/bin/bash
-# Credits to:
-# Sebastien Luttringer <seblu+arch@seblu.net>
-# Bart De Schuymer <bdschuym@pandora.be>
-# Rok Papez <rok.papez@arnes.si>
-# Dag Wieers <dag@wieers.com>
-
. /etc/rc.conf
. /etc/rc.d/functions
-
-#default configuration:
-EBTABLES_TEXT_FORMAT="yes"
-EBTABLES_BINARY_FORMAT="yes"
-EBTABLES_MODULES_UNLOAD="yes"
-EBTABLES_SAVE_ON_STOP="no"
-EBTABLES_SAVE_ON_RESTART="no"
-EBTABLES_SAVE_COUNTER="no"
-
-[[ -r "/etc/conf.d/ebtables" ]] && . "/etc/conf.d/ebtables"
-
-RETVAL=0
-
-start() {
- stat_busy "Starting ebtables"
- ! ck_daemon ebtables && stat_done && RETVAL=0 && return
- if [[ "$EBTABLES_BINARY_FORMAT" = yes ]]; then
- for table in $(ls /etc/ebtables/ebtables.* 2>/dev/null | sed -e 's/.*ebtables\.//' -e '/save/d' ); do
- /usr/sbin/ebtables -t ${table} --atomic-file /etc/ebtables/ebtables.${table} --atomic-commit || RETVAL=1
- done
- elif [[ "$EBTABLES_TEXT_FORMAT" = "yes" ]]; then
- [[ ! -r /etc/ebtables/ebtables ]] && :>/etc/ebtables/ebtables
- /usr/sbin/ebtables-restore </etc/ebtables/ebtables || RETVAL=1
- else
- RETVAL=1
- fi
-
- if (( RETVAL == 0 )); then
- stat_done
- add_daemon ebtables
- else
- stat_fail
- fi
-}
-
-stop() {
- stat_busy "Stopping ebtables"
- ck_daemon ebtables && stat_done && RETVAL=0 && return
- for table in $(grep '^ebtable_' /proc/modules | sed -e 's/ebtable_\([^ ]*\).*/\1/'); do
- /usr/sbin/ebtables -t $table --init-table || RETVAL=1
- done
-
- if [[ "$EBTABLES_MODULES_UNLOAD" = yes ]]; then
- for mod in $(grep -E '^(ebt|ebtable)_' /proc/modules | cut -f1 -d' ') ebtables; do
- /sbin/rmmod $mod 2> /dev/null
- done
- fi
-
- if (( RETVAL == 0 )); then
- rm_daemon ebtables
- stat_done
- else
- stat_fail
- fi
-}
-
-restart() {
- stop
- sleep 1
- start
-}
-
-save() {
- stat_busy "Saving ebtables"
- if [[ "$EBTABLES_TEXT_FORMAT" = yes ]]; then
- if [[ -r /etc/ebtables/ebtables ]]; then
- mv -f /etc/ebtables/ebtables /etc/ebtables/ebtables.save
- fi
- /usr/sbin/ebtables-save >/etc/ebtables/ebtables || RETVAL=1
- fi
- if [[ "$EBTABLES_BINARY_FORMAT" = yes ]]; then
- rm -f /etc/ebtables/ebtables.*.save
- for oldtable in $(ls /etc/ebtables/ebtables.* 2>/dev/null | grep -vF 'ebtables.save'); do
- mv -f $oldtable $oldtable.save
- done
- for table in $(grep '^ebtable_' /proc/modules | sed -e 's/ebtable_\([^ ]*\).*/\1/'); do
- :> /etc/ebtables/ebtables.$table
- /usr/sbin/ebtables -t $table --atomic-file /etc/ebtables/ebtables.$table --atomic-save || RETVAL=1
- if [[ "$EBTABLES_SAVE_COUNTER" = no ]]; then
- /usr/sbin/ebtables -t $table --atomic-file /etc/ebtables/ebtables.$table -Z || RETVAL=1
- fi
- done
- fi
-
- (( RETVAL == 0 )) && stat_done || stat_fail
-}
+. /etc/conf.d/${0##*/}
case "$1" in
start)
- start
- ;;
+ stat_busy 'Loading ebtables rules'
+ ebtables-restore < "$CONFIG_FILE" &&
+ add_daemon ${0##*/} && stat_done || stat_die
+ ;;
stop)
- [[ "$EBTABLES_SAVE_ON_STOP" = yes ]] && save
- stop
- ;;
- restart|reload)
- [[ "$EBTABLES_SAVE_ON_RESTART" = yes ]] && save
- restart
- ;;
- condrestart)
- ! ck_daemon ebtables && restart
- RETVAL=$?
- ;;
+ [[ $SAVE_ON_STOP =~ [yY][eE][sS] ]] && $0 save
+ status 'Clearing ebtables rules' ebtables -F && rm_daemon ${0##*/} || exit 1
+ ;;
+ restart)
+ $0 stop
+ $0 start
+ ;;
save)
- save
- ;;
- status)
- /usr/sbin/ebtables-save
- RETVAL=$?
- ;;
+ stat_busy 'Saving ebtables rules'
+ ebtables-save > "$CONFIG_FILE" && stat_done || stat_die
+ ;;
*)
- echo "Usage $0 {start|stop|restart|condrestart|save|status}"
- RETVAL=1
+ echo "usage: ${0##*/} {start|stop|restart|save}" >&2
+ exit 1
+ ;;
esac
-exit $RETVAL
-
-# vim:set ts=2 sw=2 ft=sh noet:
+# vim:set ts=2 sw=2 ft=sh et:
diff --git a/community/ebtables/ebtables.service b/community/ebtables/ebtables.service
new file mode 100644
index 000000000..25e6b76cc
--- /dev/null
+++ b/community/ebtables/ebtables.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Ethernet bridge table
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/lib/systemd/scripts/ebtables start
+ExecStop=/usr/lib/systemd/scripts/ebtables stop
+
+[Install]
+WantedBy=multi-user.target
diff --git a/community/ebtables/ebtables.systemd b/community/ebtables/ebtables.systemd
new file mode 100644
index 000000000..4c51e9b6f
--- /dev/null
+++ b/community/ebtables/ebtables.systemd
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+. /etc/conf.d/ebtables
+
+case $1 in
+ start)
+ ebtables-restore < "$CONFIG_FILE"
+ ;;
+ stop)
+ [[ $SAVE_ON_STOP =~ [yY][eE][sS] ]] && $0 save
+ ebtables -F
+ ;;
+ save)
+ ebtables-save > "$CONFIG_FILE"
+ ;;
+ *)
+ echo "usage: ${0##*/} {start|stop|save}" >&2
+ exit 1
+ ;;
+esac
+
+# vim:set ts=2 sw=2 ft=sh et: