root/honeywall/trunk/rpm-devel/roo-base/src/etc/rc.d/init.d/hwdaemons @ 45

Revision 45, 4.8 KB (checked in by rmcmillen, 11 years ago)

Added sighup of syslog when the iptables log is cleaned out in order to start writting to it.

Line 
1#!/bin/bash
2#
3# $Id: hwdaemons 5184 2007-03-13 17:52:38Z esammons $
4#
5#############################################
6#
7# Copyright (C) <2005> <The Honeynet Project>
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2 of the License, or (at
12# your option) any later version.
13#
14# This program is distributed in the hope that it will be useful, but
15# WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17# General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, write to the Free Software
21# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22# USA
23#
24#############################################
25
26#
27#
28# PURPOSE: Manage all of the honeywall related daemons that are
29#          dependant on the bridge interfaces, such that the
30#          daemons do not die when the bridge gets reset.  This
31#          script is not run as part of the normal SVR4-style
32#          startup mechanism, as are other scripts.  They are
33#          started/stopped as necessary, based on their dependancy
34#          order, for normal system reboot/shutdown behavior.
35#          The purpose of this script is solely to manage
36#          graceful restarts and wholesale start/stop of these
37#          daemons when necessary.  Its main use is by hwctl.
38
39. /etc/rc.d/init.d/hwfuncs.sub
40. /etc/rc.d/init.d/functions
41
42if [ $(hw_isconfigured) -eq 0 ]; then
43    exit 1
44fi
45
46
47# Functions
48
49
50
51start () {
52   if [ "$(hw_get HwHONEYWALL_RUN)" = "yes" ]; then
53      logger -p local0.info "hwdaemons: activating honeywall"
54        /etc/init.d/bridge.sh start
55        /etc/init.d/hwnetwork start
56        /etc/init.d/rc.firewall start
57        /etc/init.d/hw-mysqld start
58        /etc/init.d/hw-pcap  start
59        /etc/init.d/hw-snort_inline start
60        /etc/init.d/walleye-httpd start
61        /etc/init.d/hflow      start
62        /etc/init.d/swatch.sh  start
63        # Catch all for anything else that may need starting.
64        /usr/local/bin/hwctl -s
65      logger -p local0.info "hwdaemons: honeywall activated"
66   fi
67}
68
69stop () {
70        logger -p local0.info "hwdaemons: deactivating honeywall"
71        /etc/init.d/swatch.sh stop
72        /etc/init.d/hflow      stop
73        /etc/init.d/hw-mysqld stop
74        /etc/init.d/walleye-httpd stop
75        /etc/init.d/hw-pcap  stop
76        /etc/init.d/hw-snort_inline stop
77        /etc/init.d/bridge.sh stop
78        /etc/init.d/hwnetwork stop
79        logger -p local0.info "hwdaemons: honeywall deactivated"
80}
81
82log_cleanout_start () {
83   if [ "$(hw_get HwHONEYWALL_RUN)" = "yes" ]; then
84      logger -p local0.info "hwdaemons: activating honeywall post log cleanout"
85        /etc/init.d/hw-pcap  start
86        /etc/init.d/hw-snort_inline start
87        /etc/init.d/hflow      start
88        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null
89      logger -p local0.info "hwdaemons: honeywall activated"
90   fi
91}
92
93log_cleanout_stop () {
94        logger -p local0.info "hwdaemons: deactivating honeywall for log cleanout"
95        /etc/init.d/hflow      stop
96        /etc/init.d/hw-pcap  stop
97        /etc/init.d/hw-snort_inline stop
98        logger -p local0.info "hwdaemons: honeywall deactivated fro log cleanout"
99}
100
101lockdown () {
102        logger -p local0.info "hwdaemons: Emergency Lockdown started"
103        /etc/init.d/rc.firewall  lockdown
104# EWS- Commenting thes out to be consistent with rc.firewall lockdown()
105#       /etc/init.d/bridge.sh    stop
106#       /etc/init.d/hflowd       stop
107#       /etc/init.d/hflow-snort_inline stop
108#       /etc/init.d/hflow-snort  stop
109#       /etc/init.d/hflow-pcap   stop
110#       /etc/init.d/hflow-p0f    stop
111#       /etc/init.d/hflow-argus  stop
112#       /etc/init.d/sebekd       stop
113#       /etc/init.d/rc.firewall  stop
114# EWS - End commenting
115        logger -p local0.info "hwdaemons: Emergency lockdown complete"
116}
117
118# Main body
119
120case "$1" in
121    start)
122        start
123        ;;
124    stop)
125        stop
126        ;;
127    log_cleanout_start)
128        log_cleanout_start
129        ;;
130    log_cleanout_stop)
131        log_cleanout_stop
132        ;;
133    log_cleanout_restart)
134        log_cleanout_stop
135        log_cleanout_start
136        ;;
137    lockdown)
138        lockdown
139        ;;
140    restart)
141        stop
142        start
143        ;;
144    status)
145        # Note that we give status of more things that this script
146        # normally stops/starts, just to give a more complete picture
147        # of the honeywall.
148        echo "Honeywall health as of " `date`
149        /etc/init.d/hwnetwork status
150        /etc/init.d/bridge.sh status
151        /etc/init.d/rc.firewall status
152        /etc/init.d/hflow      status
153        /etc/init.d/hw-snort_inline status
154        /etc/init.d/hw-pcap  status
155        /etc/init.d/hw-mysqld status
156        echo "Related services:"
157        /etc/init.d/monit.sh    status
158        /etc/init.d/swatch.sh   status
159        ;;
160    *)
161        echo $"Usage: $0 {start|stop|restart|log_cleanout_start|log_cleanout_stop"
162        echo $"            |log_cleanout_restart|lockdown|status)"
163esac
164
165exit 0
Note: See TracBrowser for help on using the browser.