diff options
Diffstat (limited to 'community/arptables')
-rw-r--r-- | community/arptables/PKGBUILD | 36 | ||||
-rw-r--r-- | community/arptables/arptables.conf | 7 | ||||
-rw-r--r-- | community/arptables/arptables.install | 10 | ||||
-rw-r--r-- | community/arptables/arptables.rc | 62 | ||||
-rw-r--r-- | community/arptables/arptables.service | 11 | ||||
-rw-r--r-- | community/arptables/arptables.systemd | 22 |
6 files changed, 95 insertions, 53 deletions
diff --git a/community/arptables/PKGBUILD b/community/arptables/PKGBUILD index ac6942bcb..40eba2685 100644 --- a/community/arptables/PKGBUILD +++ b/community/arptables/PKGBUILD @@ -1,18 +1,27 @@ -# $Id: PKGBUILD 64145 2012-02-09 09:48:15Z seblu $ +# $Id: PKGBUILD 71317 2012-05-26 14:59:39Z seblu $ # Maintainer: Sébastien Luttringer <seblu@aur.archlinux.org> # Contributor: Daniel Micay <danielmicay@gmail.com> # Contributor: Michal Soltys <soltys@ziu.info> pkgname=arptables pkgver=0.0.3_4 -pkgrel=2 +pkgrel=3 pkgdesc='ARP filtering utility' arch=('i686' 'x86_64') url='http://ebtables.sourceforge.net/' license=('GPL') -source=("http://downloads.sourceforge.net/ebtables/$pkgname-v${pkgver//_/-}.tar.gz" 'arptables.rc') +backup=("etc/$pkgname.conf" "etc/conf.d/$pkgname") +install=$pkgname.install +source=("http://downloads.sourceforge.net/ebtables/$pkgname-v${pkgver//_/-}.tar.gz" + "$pkgname.conf" + "$pkgname.rc" + "$pkgname.systemd" + "$pkgname.service") md5sums=('1d4ab05761f063b0751645d8f2b8f8e5' - 'f8c0ecad9151a16347c133e043232d4a') + '00bfb5bd8a83a5b466c650ee5d8f86f3' + '60e0319b55b1ef9e13d9ac03dd98c8d4' + '65a9ed0b866f727184a87e4d480975bd' + 'b26771191e52905d8aea6333c26cb1c3') build() { cd $pkgname-v${pkgver//_/-} @@ -20,8 +29,7 @@ build() { } package() { - # setup arptables - cd $pkgname-v${pkgver//_/-} + pushd $pkgname-v${pkgver//_/-} make install \ DESTDIR="$pkgdir" \ PREFIX=/usr \ @@ -29,10 +37,18 @@ package() { BINDIR=/usr/sbin \ MANDIR=/usr/share/man \ INITDIR=/etc/rc.d \ - SYSCONFIGDIR=/etc/arptables - - # install rc script - install -D -m 0755 ../arptables.rc "$pkgdir/etc/rc.d/arptables" + SYSCONFIGDIR=/etc + popd + # 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/arptables/arptables.conf b/community/arptables/arptables.conf new file mode 100644 index 000000000..8b5456788 --- /dev/null +++ b/community/arptables/arptables.conf @@ -0,0 +1,7 @@ +# Configuration file used to load/save configuration. +CONFIG_FILE='/etc/arptables.conf' + +# Save configuration on stop/restart. +#SAVE_ON_STOP=yes + +# vim:set ts=2 sw=2 ft=sh et: diff --git a/community/arptables/arptables.install b/community/arptables/arptables.install new file mode 100644 index 000000000..5f03b6e24 --- /dev/null +++ b/community/arptables/arptables.install @@ -0,0 +1,10 @@ +## arg 1: the new package version +## arg 2: the old package version +post_upgrade() { + [ $(vercmp "$2" '0.0.3_4-2') -gt 0 ] || cat <<EOF +Config file have been moved from /etc/arptables/arptables to /etc/arptables.conf. +You can revert to the previous location by editing /etc/conf.d/arptables. +EOF +} + +# vim:set ts=2 sw=2 ft=sh et: diff --git a/community/arptables/arptables.rc b/community/arptables/arptables.rc index dae90ac2a..a188c65c1 100644 --- a/community/arptables/arptables.rc +++ b/community/arptables/arptables.rc @@ -2,57 +2,33 @@ . /etc/rc.conf . /etc/rc.d/functions - -[[ -x /usr/sbin/arptables ]] || exit 1 -[[ -x /usr/sbin/arptables-save ]] || exit 1 -[[ -x /usr/sbin/arptables-restore ]] || exit 1 - -do_start() { - stat_busy "Restore arptables rules" - if [[ -r /etc/arptables/arptables ]]; then - /usr/sbin/arptables-restore </etc/arptables/arptables - (( $? == 0 )) && stat_done && add_daemon arptables && return - fi - stat_fail -} - -do_stop() { - stat_busy "Flushing arptables rules" - /usr/sbin/arptables-restore </dev/null - if (( $? == 0 )); then - stat_done - rm_daemon arptables - else - stat_fail - fi -} - -do_save() { - stat_busy "Saving arptables rules" - /usr/sbin/arptables-save >/etc/arptables/arptables - (( $? == 0 )) && stat_done || stat_fail -} +. /etc/conf.d/${0##*/} case "$1" in start) - do_start - ;; + stat_busy 'Loading arptables rules' + arptables-restore < "$CONFIG_FILE" && + add_daemon ${0##*/} && stat_done || stat_die + ;; stop) - do_stop - ;; + [[ $SAVE_ON_STOP =~ [yY][eE][sS] ]] && $0 save + stat_busy 'Clearing arptables rules' + arptables-restore < /dev/null && + rm_daemon ${0##*/} && stat_done || stat_die + ;; restart) - do_stop - do_start - ;; + $0 start + $0 stop + ;; save) - do_save - ;; - status) - /usr/sbin/arptables-save - ;; + stat_busy 'Saving arptables rules' + arptables-save > "$CONFIG_FILE" && + stat_done || stat_die + ;; *) - echo "Usage $0 {start|stop|restart|save|status}" >&2 + echo "usage: ${0##*/} {start|stop|restart|save}" >&2 exit 1 + ;; esac # vim:set ts=2 sw=2 ft=sh et: diff --git a/community/arptables/arptables.service b/community/arptables/arptables.service new file mode 100644 index 000000000..4fc11f17d --- /dev/null +++ b/community/arptables/arptables.service @@ -0,0 +1,11 @@ +[Unit] +Description=ARP Tables + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/lib/systemd/scripts/arptables start +ExecStop=/usr/lib/systemd/scripts/arptables stop + +[Install] +WantedBy=multi-user.target diff --git a/community/arptables/arptables.systemd b/community/arptables/arptables.systemd new file mode 100644 index 000000000..bc5acdbcf --- /dev/null +++ b/community/arptables/arptables.systemd @@ -0,0 +1,22 @@ +#!/bin/bash + +. /etc/conf.d/arptables + +case $1 in + start) + arptables-restore < "$CONFIG_FILE" + ;; + stop) + [[ $SAVE_ON_STOP =~ [yY][eE][sS] ]] && $0 save + arptables-restore < /dev/null + ;; + save) + arptables-save > "$CONFIG_FILE" + ;; + *) + echo "usage: ${0##*/} {start|stop|save}" >&2 + exit 1 + ;; +esac + +# vim:set ts=2 sw=2 ft=sh et: |