From 6f560bda3893a0f767975850133de61ebe61dcb3 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Fri, 6 Nov 2015 14:01:02 -0800 Subject: [PATCH] More OpenWRT tweaks from Matt Darfeuille Signed-off-by: Tom Eastep --- Shorewall-core/install.sh | 6 +++--- Shorewall-core/shorewallrc.openwrt | 6 +++--- Shorewall-lite/install.sh | 13 ++++++++++--- Shorewall-lite/uninstall.sh | 8 ++++++-- Shorewall6-lite/uninstall.sh | 10 +++++++++- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Shorewall-core/install.sh b/Shorewall-core/install.sh index 445136f08..c53392be1 100755 --- a/Shorewall-core/install.sh +++ b/Shorewall-core/install.sh @@ -226,7 +226,7 @@ if [ -z "$BUILD" ]; then BUILD=suse elif [ -f /etc/arch-release ] ; then BUILD=archlinux - elif [ -f ${CONFDIR}/openwrt-release ] ; then + elif [ -f ${CONFDIR}/openwrt_release ] ; then BUILD=openwrt else BUILD=linux @@ -256,7 +256,7 @@ case $BUILD in [ -z "$GROUP" ] && GROUP=wheel ;; *) - if [ $(id -n) -eq 0 ]; then + if [ $(id -u) -eq 0 ]; then [ -z "$OWNER" ] && OWNER=root [ -z "$GROUP" ] && GROUP=root fi @@ -276,7 +276,7 @@ case "$HOST" in apple) echo "Installing Mac-specific configuration..."; ;; - debian|gentoo|redhat|slackware|archlinux|linux|suse) + debian|gentoo|redhat|slackware|archlinux|linux|suse|openwrt) ;; *) echo "ERROR: Unknown HOST \"$HOST\"" >&2 diff --git a/Shorewall-core/shorewallrc.openwrt b/Shorewall-core/shorewallrc.openwrt index 249862076..1f227eb62 100644 --- a/Shorewall-core/shorewallrc.openwrt +++ b/Shorewall-core/shorewallrc.openwrt @@ -1,9 +1,9 @@ # -# Created by Shorewall Core version 5.0.2-Beta2 configure - Mon, Nov 02, 2015 8:13:14 AM +# Created by Shorewall Core version 5.0.2-RC1 configure - Fri, Nov 06, 2015 10:02:03 AM # -# Input: host=default initsource=init.openwrt.sh sysconfdir=${CONFDIR}/sysconfig sysconffile=default.openwrt varlib=/lib +# Input: host=openwrt # -HOST=linux +HOST=openwrt PREFIX=/usr SHAREDIR=${PREFIX}/share LIBEXECDIR=${PREFIX}/share diff --git a/Shorewall-lite/install.sh b/Shorewall-lite/install.sh index 291aa79bf..f3086ea7d 100755 --- a/Shorewall-lite/install.sh +++ b/Shorewall-lite/install.sh @@ -255,7 +255,7 @@ if [ -z "$BUILD" ]; then BUILD=slackware elif [ -f ${CONFDIR}/arch-release ] ; then BUILD=archlinux - elif [ -f ${CONFDIR}/openwrt-release ] ; then + elif [ -f ${CONFDIR}/openwrt_release ]; then BUILD=openwrt else BUILD=linux @@ -274,7 +274,7 @@ case $BUILD in [ -z "$GROUP" ] && GROUP=wheel ;; *) - if [ $(id -n) -eq 0 ]; then + if [ $(id -u) -eq 0 ]; then [ -z "$OWNER" ] && OWNER=root [ -z "$GROUP" ] && GROUP=root fi @@ -549,7 +549,7 @@ if [ -n "$SYSCONFFILE" -a -f "$SYSCONFFILE" -a ! -f ${DESTDIR}${SYSCONFDIR}/${PR chmod 755 ${DESTDIR}${SYSCONFDIR} fi - install_file ${SYSCONFFILE} ${DESTDIR}${SYSCONFDIR}/${PRODUCT} + install_file ${SYSCONFFILE} ${DESTDIR}${SYSCONFDIR}/${PRODUCT} 0640 echo "$SYSCONFFILE installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}" fi @@ -603,6 +603,13 @@ if [ $configure -eq 1 -a -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${ else cant_autostart fi + elif [ $HOST = openwrt -a -f ${CONFDIR}/rc.common ]; then + /etc/init.d/$PRODUCT enable + if /etc/init.d/$PRODUCT enabled; then + echo "$PRODUCT will start automatically at boot" + else + cant_autostart + fi elif [ "$INITFILE" != rc.${PRODUCT} ]; then #Slackware starts this automatically cant_autostart fi diff --git a/Shorewall-lite/uninstall.sh b/Shorewall-lite/uninstall.sh index dca03e770..f2c3d8472 100755 --- a/Shorewall-lite/uninstall.sh +++ b/Shorewall-lite/uninstall.sh @@ -153,7 +153,7 @@ if [ -f ${SHAREDIR}/shorewall-lite/version ]; then VERSION="$INSTALLED_VERSION" fi else - echo "WARNING: Shorewall Lite Version $VERSION is not installed" + echo "WARNING: Shorewal Lite Version $VERSION is not installed" VERSION="" fi @@ -168,7 +168,11 @@ if [ $configure -eq 1 ]; then fi if [ -L ${SHAREDIR}/shorewall-lite/init ]; then - if [ $HOST = "linux" ] && [ -f /etc/openwrt_release -o -f /etc/openwrt_version ]; then + if [ $HOST = openwrt ]; then + if [ $configure -eq 1 ] && /etc/init.d/shorewall-lite enabled; then + /etc/init.d/shorewall-lite disable + fi + FIREWALL=$(readlink ${SHAREDIR}/shorewall-lite/init) else FIREWALL=$(readlink -m -q ${SHAREDIR}/shorewall-lite/init) diff --git a/Shorewall6-lite/uninstall.sh b/Shorewall6-lite/uninstall.sh index b245811cf..8674394f3 100755 --- a/Shorewall6-lite/uninstall.sh +++ b/Shorewall6-lite/uninstall.sh @@ -164,7 +164,15 @@ if [ $configure -eq 1 ]; then fi if [ -f ${SHAREDIR}/shorewall6-lite/init ]; then - FIREWALL=$(readlink -m -q ${SHAREDIR}/shorewall6-lite/init) + if [ $HOST = openwrt ]; then + if [ $configure -eq 1 ] && /etc/init.d/shorewall6-lite enabled; then + /etc/init.d/shorewall6-lite disable + fi + + FIREWALL$(readlink ${SHAREDIR}/shorewall6-lite/init) + else + FIREWALL=$(readlink -m -q ${SHAREDIR}/shorewall6-lite/init) + fi elif [ -n "$INITFILE" ]; then FIREWALL=${INITDIR}/${INITFILE} fi