Adjust example/* to autogenerated on build time
authorNeutron Soutmun <neo.neutron@gmail.com>
Thu, 27 Nov 2008 08:56:06 +0000 (15:56 +0700)
committerNeutron Soutmun <neo.neutron@gmail.com>
Thu, 27 Nov 2008 08:56:06 +0000 (15:56 +0700)
2008-11-27  Neutron Soutmun <neo.neutron@gmail.com>

* -example/rahunas.{default,init,conf}, -example/{firewall,bandwidth}.sh
  +example/rahunas.{default,init,conf}.in,
  +example/{firewall,bandwidth}.sh.in:
  - Raname the wrapper script and example config files to .in which all of
    them will be autogenerated on build time with the respective prefix path.
* configure.ac: Add the files above to AC_CONFIG_FILES.

ChangeLog
configure.ac
example/bandwidth.sh.in [moved from example/bandwidth.sh with 88% similarity]
example/firewall.sh.in [moved from example/firewall.sh with 97% similarity]
example/rahunas.conf.in [moved from example/rahunas.conf with 98% similarity]
example/rahunas.default.in [moved from example/rahunas.default with 79% similarity]
example/rahunas.init.in [moved from example/rahunas.init with 65% similarity]

index a1d3ef0..bb22c7a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2008-11-27  Neutron Soutmun <neo.neutron@gmail.com>
 
+       * -example/rahunas.{default,init,conf}, -example/{firewall,bandwidth}.sh
+         +example/rahunas.{default,init,conf}.in, 
+         +example/{firewall,bandwidth}.sh.in:
+         - Raname the wrapper script and example config files to .in which all of
+           them will be autogenerated on build time with the respective prefix path.
+       * configure.ac: Add the files above to AC_CONFIG_FILES.
+
+2008-11-27  Neutron Soutmun <neo.neutron@gmail.com>
+
        [ Suriya Soutmun ]
        * +lcfg/lcfg_static.{h,c}, +lcfg/Makefile.am, +src/rh-config.c,
          src/rahunasd.{h,c}:
index 8e4e8cb..0c00dda 100644 (file)
@@ -59,6 +59,11 @@ AC_CONFIG_FILES([
        src/Makefile
        data/Makefile
   src/include/linux/netfilter_ipv4/Makefile
+  example/rahunas.default
+  example/rahunas.init
+  example/rahunas.conf
+  example/firewall.sh
+  example/bandwidth.sh
 ])
 
 AC_OUTPUT
similarity index 88%
rename from example/bandwidth.sh
rename to example/bandwidth.sh.in
index 524c381..43e9125 100755 (executable)
@@ -2,10 +2,15 @@
 # File: bandwidth.sh
 # Description: The bandwidth shaper wrapper script for RahuNAS
 
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:@prefix@/sbin:@prefix@/bin
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+
 TC=/sbin/tc
 IP=/sbin/ip
 
-RUN=/var/run/rahunas-bandwidth
+INIT=@sysconfdir@/default/rahunas
+RUN=@localstatedir@/run/rahunas-bandwidth
 
 # Unclassified clients' bandwidth (Kbit)
 DOWN_UNCLASS=256
@@ -14,14 +19,10 @@ UP_UNCLASS=256
 SHAPING_DOWN_INF=imq0
 SHAPING_UP_INF=imq1
 
-# Get configuration
-if [ -r /etc/default/rahunas ]; then
-  . /etc/default/rahunas
-fi
+test -f $INIT || exit 0
+. $INIT
 
-if [ "$RUN_DAEMON" = "no" ]; then
-  exit 0
-fi
+test "$RUN_DAEMON" = "yes" || exit 0
 
 start () {
   # Downlink
@@ -105,6 +106,8 @@ bw_del() {
   $TC class del dev $SHAPING_UP_INF parent 2: classid 2:${ID}
 }
 
+N=@sysconfdir@/rahunas/bandwidth.sh
+
 case "$1" in
   start)
     test -e $RUN || start
@@ -120,13 +123,13 @@ case "$1" in
     ;;
   add)
     if [ "$2" = "--help" ]; then
-      usage_add $0
+      usage_add $N
       exit 3
     fi
 
     if [ $# != 5 ]; then
       echo "Error: too few arguments"
-      usage_add $0
+      usage_add $N
       exit 1
     fi
 
@@ -134,20 +137,20 @@ case "$1" in
     ;;
   del)
     if [ "$2" = "--help" ]; then
-      usage_del $0
+      usage_del $N
       exit 3
     fi
 
     if [ $# != 2 ]; then
       echo "Error: too few arguments"
-      usage_del $0
+      usage_del $N
       exit 1
     fi
 
     bw_del $2
     ;;
   *)
-    usage $0
+    usage $N
     exit 3
     ;;
 esac 
similarity index 97%
rename from example/firewall.sh
rename to example/firewall.sh.in
index 0506617..3dba9d7 100755 (executable)
@@ -3,14 +3,16 @@
 # the clients and redirect them to the login page to get the authorization to 
 # access the network.
 
-set -e
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:@prefix@/sbin:@prefix@/bin
+prefix=@prefix@
+exec_prefix=@exec_prefix@
 
 IPTABLES=/sbin/iptables
 IPSET=/usr/sbin/ipset
 
 NAME="rahunas"
-INIT=/etc/default/rahunas
-RUN=/var/run/rahunas-firewall
+INIT=@sysconfdir@/default/rahunas
+RUN=@localstatedir@/run/rahunas-firewall
 
 RUN_DAEMON=no
 
@@ -20,6 +22,8 @@ test -f $INIT || exit 0
 test "$RUN_DAEMON" = "yes" || exit 0
 test -f $RAHUNAS_CONFIG || exit 1
 
+set -e
+
 get_config_value () {
   key=$1
   cat $RAHUNAS_CONFIG | grep -v ^/ | grep -w "$key" | cut -d= -f2 | sed 's: ::g' | sed 's:"::g'
@@ -391,7 +395,8 @@ case "$1" in
     reload     
     ;; 
   *)
-    echo "Usage: /etc/rahunas/firewall.sh {start|stop|restart|reload}"
+    N = @sysconfdir@/rahunas/firewall.sh
+    echo "Usage: $N {start|stop|restart|reload}"
     exit 3
     ;;
 esac 
similarity index 98%
rename from example/rahunas.conf
rename to example/rahunas.conf.in
index db8a31b..ae8be37 100644 (file)
@@ -29,7 +29,7 @@
 // idle_threshold = "600"
 
 //// Log file
-log_file = "/var/log/rahunas/rahunas.log"
+log_file = "@prefix@/var/log/rahunas/rahunas.log"
 
 /////////////////////////
 // Start-Up            //
similarity index 79%
rename from example/rahunas.default
rename to example/rahunas.default.in
index aed7022..f3a9ad1 100644 (file)
@@ -5,4 +5,4 @@
 RUN_DAEMON=no
 
 # RahuNAS config file
-RAHUNAS_CONFIG=/etc/rahunas/rahunas.conf
+RAHUNAS_CONFIG=@prefix@/etc/rahunas/rahunas.conf
similarity index 65%
rename from example/rahunas.init
rename to example/rahunas.init.in
index 0d93e1b..2da17e5 100755 (executable)
 # Description:       Starts, stops the rahunas daemon. 
 ### END INIT INFO
 
-PATH=/sbin:/bin:/usr/sbin:/usr/bin
-DAEMON=/usr/bin/rahunasd
-FIREWALL=/etc/rahunas/firewall.sh
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:@prefix@/sbin:@prefix@/bin
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+
+DAEMON=@bindir@/rahunasd
+INIT=@sysconfdir@/default/rahunas
+FIREWALL=@sysconfdir@/rahunas/firewall.sh
 NAME=rahunasd
-DESC="rahunasd: Rahu Network Access Server"
+DESC="RahuNAS: Rahu Network Access Server"
+
 
 # This value is overriden in /etc/default/rahunas if it exists
 RUN_DAEMON=no
@@ -26,10 +31,8 @@ test -f $FIREWALL || exit 0
 
 set -e
 
-# Get configuration
-if [ -r /etc/default/rahunas ]; then
-  . /etc/default/rahunas
-fi
+test -f $INIT || exit 0 
+. $INIT 
 
 case "$1" in
   start)
@@ -38,7 +41,7 @@ case "$1" in
   $FIREWALL start
 
        if [ "$RUN_DAEMON" = "yes" ]; then
-               start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
+               start-stop-daemon --start --quiet --pidfile @localstatedir@/run/$NAME.pid \
                --exec $DAEMON
                echo done
        else
@@ -48,7 +51,7 @@ case "$1" in
   stop)
        echo -n "Stopping $DESC: "
 
-       start-stop-daemon --stop --oknodo --quiet --pidfile /var/run/$NAME.pid \
+       start-stop-daemon --stop --oknodo --quiet --pidfile @localstatedir@/run/$NAME.pid \
                --exec $DAEMON
        echo done 
        $FIREWALL stop
@@ -57,17 +60,17 @@ case "$1" in
        echo -n "Restarting $DESC: "
 
        start-stop-daemon --stop --oknodo --quiet --pidfile \
-               /var/run/$NAME.pid --exec $DAEMON
+               @localstatedir@/run/$NAME.pid --exec $DAEMON
        sleep 1
 
        $FIREWALL restart
 
        start-stop-daemon --start --quiet --pidfile \
-               /var/run/$NAME.pid --exec $DAEMON
+               @localstatedir@/run/$NAME.pid --exec $DAEMON
        echo "$NAME."
        ;;
   *)
-       N=/etc/init.d/$NAME
+       N=@sysconfdir@/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;