Changeset 94c9e9e68a52a85cada2842d74d51b9407ccf5b2
- Timestamp:
- 04/23/09 10:19:24 (3 years ago)
- Author:
- Neutron Soutmun <neo.neutron@…>
- Children:
- aace70f808787e6416462b9148cc6777dd2b0ec3
- Parents:
- 32a2b8614528260422ecc05a560bd58085982248
- git-committer:
- Neutron Soutmun <neo.neutron@…> (04/23/09 10:19:24)
- Message:
-
Handle start-stop process, fix firewall script
2009-04-23 Neutron Soutmun <neo.neutron@…>
- example/rahunas.init.in:
- Adjust the code to handle the start and stop process.
- Waiting for the process really stop.
- tools/firewall.sh.in: Prevent the script to start the same rules again for
each virtual server.
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r32a2b86
|
r94c9e9e
|
|
| | 1 | 2009-04-23 Neutron Soutmun <neo.neutron@gmail.com> |
| | 2 | |
| | 3 | * example/rahunas.init.in: |
| | 4 | - Adjust the code to handle the start and stop process. |
| | 5 | - Waiting for the process really stop. |
| | 6 | * tools/firewall.sh.in: Prevent the script to start the same rules again for |
| | 7 | each virtual server. |
| | 8 | |
| 1 | 9 | 2009-04-21 Neutron Soutmun <neo.neutron@gmail.com> |
| 2 | 10 | |
-
|
rf94bd5c
|
r94c9e9e
|
|
| 22 | 22 | WEBLOGIN_CONFIG=@sysconfdir@/rahunas/weblogin-config-update.sh |
| 23 | 23 | NAME=rahunasd |
| 24 | | DESC="RahuNAS: Rahu Network Access Server" |
| | 24 | DESC="RahuNAS - Rahu Network Access Server" |
| 25 | 25 | |
| 26 | 26 | |
| … |
… |
|
| 36 | 36 | . $INIT |
| 37 | 37 | |
| 38 | | case "$1" in |
| 39 | | start) |
| 40 | | echo -n "Starting $DESC: " |
| | 38 | . /lib/lsb/init-functions |
| 41 | 39 | |
| | 40 | PID=@localstatedir@/run/$NAME.pid |
| | 41 | |
| | 42 | start () { |
| 42 | 43 | $FIREWALL start |
| 43 | 44 | $WEBLOGIN_CONFIG |
| 44 | 45 | |
| 45 | | if [ "$RUN_DAEMON" = "yes" ]; then |
| 46 | | start-stop-daemon --start --quiet --pidfile @localstatedir@/run/$NAME.pid \ |
| 47 | | --exec $DAEMON |
| 48 | | echo done |
| 49 | | else |
| 50 | | echo disabled |
| 51 | | fi |
| 52 | | ;; |
| | 46 | start-stop-daemon --start --quiet \ |
| | 47 | --pidfile $PID --exec $DAEMON < /dev/null |
| | 48 | return $? |
| | 49 | } |
| | 50 | |
| | 51 | stop () { |
| | 52 | start-stop-daemon --stop --quiet \ |
| | 53 | --pidfile $PID --name $NAME < /dev/null |
| | 54 | |
| | 55 | # Wait until the rahunasd has really stopped. |
| | 56 | sleep 2 |
| | 57 | if test -n "$PID" && kill -0 $PID 2>/dev/null |
| | 58 | then |
| | 59 | log_action_begin_msg " ... Waiting" |
| | 60 | cnt=0 |
| | 61 | while kill -0 $PID 2>/dev/null |
| | 62 | do |
| | 63 | cnt=`expr $cnt + 1` |
| | 64 | if [ $cnt -gt 24 ] |
| | 65 | then |
| | 66 | log_action_end_msg 1 |
| | 67 | return 1 |
| | 68 | fi |
| | 69 | sleep 5 |
| | 70 | log_action_cont_msg "" |
| | 71 | done |
| | 72 | |
| | 73 | log_action_end_msg 0 |
| | 74 | fi |
| | 75 | |
| | 76 | $FIREWALL stop |
| | 77 | return 0 |
| | 78 | } |
| | 79 | |
| | 80 | case "$1" in |
| | 81 | start) |
| | 82 | log_daemon_msg "Starting $DESC" "$NAME" |
| | 83 | |
| | 84 | if [ "$RUN_DAEMON" = "yes" ]; then |
| | 85 | if start ; then |
| | 86 | log_end_msg $? |
| | 87 | else |
| | 88 | log_end_msg $? |
| | 89 | fi |
| | 90 | else |
| | 91 | log_end_msg "disabled, to enable see $INIT" |
| | 92 | fi |
| | 93 | ;; |
| 53 | 94 | stop) |
| 54 | | echo -n "Stopping $DESC: " |
| | 95 | log_daemon_msg "Stopping $DESC" "$NAME" |
| | 96 | |
| | 97 | if stop ; then |
| | 98 | log_end_msg $? |
| | 99 | else |
| | 100 | log_end_msg $? |
| | 101 | fi |
| | 102 | ;; |
| | 103 | restart) |
| | 104 | log_daemon_msg "Restarting $DESC" "$NAME" |
| | 105 | stop |
| 55 | 106 | |
| 56 | | start-stop-daemon --stop --oknodo --quiet --pidfile @localstatedir@/run/$NAME.pid \ |
| 57 | | --exec $DAEMON |
| 58 | | echo done |
| 59 | | $FIREWALL stop |
| 60 | | ;; |
| 61 | | restart|force-reload) |
| 62 | | echo -n "Restarting $DESC: " |
| 63 | | |
| 64 | | start-stop-daemon --stop --oknodo --quiet --pidfile \ |
| 65 | | @localstatedir@/run/$NAME.pid --exec $DAEMON |
| 66 | | sleep 1 |
| 67 | | |
| 68 | | $FIREWALL restart |
| 69 | | |
| 70 | | start-stop-daemon --start --quiet --pidfile \ |
| 71 | | @localstatedir@/run/$NAME.pid --exec $DAEMON |
| 72 | | echo "$NAME." |
| 73 | | ;; |
| | 107 | if [ "$RUN_DAEMON" = "yes" ]; then |
| | 108 | if start ; then |
| | 109 | log_end_msg $? |
| | 110 | else |
| | 111 | log_end_msg $? |
| | 112 | fi |
| | 113 | else |
| | 114 | log_end_msg "disabled, to enable see $INIT" |
| | 115 | fi |
| | 116 | ;; |
| | 117 | status) |
| | 118 | status_of_proc -p "$PID" "$DAEMON" "$NAME" && exit 0 || exit $? |
| | 119 | ;; |
| 74 | 120 | *) |
| 75 | | N=@sysconfdir@/init.d/$NAME |
| 76 | | echo "Usage: $N {start|stop|restart|force-reload}" >&2 |
| 77 | | exit 1 |
| 78 | | ;; |
| | 121 | N=@sysconfdir@/init.d/$NAME |
| | 122 | echo "Usage: $N {start|stop|restart|status}" >&2 |
| | 123 | exit 1 |
| | 124 | ;; |
| 79 | 125 | esac |
| 80 | 126 | |
-
|
rebf1b31
|
r94c9e9e
|
|
| 14 | 14 | INIT=@sysconfdir@/default/rahunas |
| 15 | 15 | RUN=@localstatedir@/run/rahunas-firewall |
| | 16 | RUNDIR=@localstatedir@/run/rahunas-set |
| 16 | 17 | VSERVER_LIST=@localstatedir@/run/rahunas-vserver |
| 17 | 18 | |
| … |
… |
|
| 21 | 22 | . $INIT |
| 22 | 23 | |
| 23 | | test "$RUN_DAEMON" = "yes" || exit 0 |
| 24 | 24 | test -f $RAHUNAS_CONFIG || exit 1 |
| 25 | 25 | test -f $VSERVER_LIST || touch $VSERVER_LIST |
| | 26 | test -d $RUNDIR || mkdir -p $RUNDIR |
| 26 | 27 | |
| 27 | 28 | get_section_name () { |
| … |
… |
|
| 624 | 625 | |
| 625 | 626 | start () { |
| | 627 | test "$RUN_DAEMON" = "yes" || return 0 |
| 626 | 628 | test ! -f $RUN || return 0 |
| 627 | 629 | |
| … |
… |
|
| 651 | 653 | |
| 652 | 654 | start_config() { |
| | 655 | test ! -f $RUNDIR/$SETNAME || return 0 |
| 653 | 656 | add_set |
| 654 | 657 | new_chains |
| 655 | 658 | rules |
| | 659 | touch $RUNDIR/$SETNAME |
| | 660 | return 0 |
| 656 | 661 | } |
| 657 | 662 | |
| … |
… |
|
| 659 | 664 | do_get_config "" start |
| 660 | 665 | start_config |
| | 666 | return $? |
| 661 | 667 | } |
| 662 | 668 | |
| … |
… |
|
| 665 | 671 | do_get_config $file start |
| 666 | 672 | if [ $? -gt 0 ]; then |
| 667 | | return |
| | 673 | return 1 |
| 668 | 674 | fi |
| 669 | 675 | |
| 670 | 676 | start_config |
| | 677 | return $? |
| 671 | 678 | } |
| 672 | 679 | |
| 673 | 680 | stop_config() { |
| | 681 | test -f $RUNDIR/$SETNAME || return 0 |
| 674 | 682 | cleanup |
| 675 | 683 | cleanup_set |
| | 684 | rm -f $RUNDIR/$SETNAME |
| | 685 | return 0 |
| 676 | 686 | } |
| 677 | 687 | |
| … |
… |
|
| 679 | 689 | do_get_config "" stop |
| 680 | 690 | stop_config |
| | 691 | return $? |
| 681 | 692 | } |
| 682 | 693 | |
| … |
… |
|
| 685 | 696 | do_get_config $file stop |
| 686 | 697 | if [ $? -gt 0 ]; then |
| 687 | | return |
| | 698 | return 1 |
| 688 | 699 | fi |
| 689 | 700 | |
| 690 | 701 | stop_config |
| | 702 | return $? |
| 691 | 703 | } |
| 692 | 704 | |