Make savecore return RC_CONFIGURED unconditionally.
[dragonfly.git] / etc / rc.d / savecore
1 #!/bin/sh
2 #
3 # $NetBSD: savecore,v 1.5 2002/03/22 04:34:00 thorpej Exp $
4 # $FreeBSD: src/etc/rc.d/savecore,v 1.3 2002/09/06 16:18:05 gordon Exp $
5 # $DragonFly: src/etc/rc.d/savecore,v 1.4 2003/12/14 19:13:15 dillon Exp $
6 #
7
8 # PROVIDE: savecore
9 # REQUIRE: syslogd
10 # BEFORE:  SERVERS
11 # KEYWORD: DragonFly FreeBSD NetBSD
12
13 . /etc/rc.subr
14
15 name="savecore"
16 start_cmd="savecore_start"
17 start_precmd="savecore_prestart"
18 stop_cmd=":"
19
20 case ${OSTYPE} in
21 NetBSD)
22         rcvar=$name
23         ;;
24 esac
25
26 savecore_prestart()
27 {
28         #       ${DUMPDIR} should be a directory or a symbolic link
29         #       to the crash directory if core dumps are to be saved.
30         #
31         DUMPDIR="${dumpdir:-/var/crash}"
32
33         case ${OSTYPE} in
34         DragonFly)
35                 # Quit if we have no dumb device
36                 case ${dumpdev} in
37                 [Nn][Oo] | '')
38                         debug 'No dump device. Quitting.'
39                         dumpdev=
40                         return 0
41                         ;;
42                 esac
43                 # If there is no crash directory set it now
44                 case ${dumpdir} in
45                 '')
46                         dumpdir='/var/crash'
47                         ;;
48                 [Nn][Oo])
49                         dumpdir='NO'
50                         ;;
51                 esac
52                 if [ ! -e "${dumpdev}" -o ! -d "${dumpdir}" ]; then
53                         warn "Wrong dump device or directory. Savecore not run."
54                         dumpdev=
55                         return 0
56                 fi
57                 ;;
58         FreeBSD)
59                 # Quit if we have no dump device
60                 case ${dumpdev} in
61                 [Nn][Oo] | '')
62                         debug 'No dump device. Quitting.'
63                         dumpdev=
64                         return 0
65                         ;;
66                 esac
67
68                 # If there is no crash directory set it now
69                 case ${dumpdir} in
70                 '')
71                         dumpdir='/var/crash'
72                         ;;
73                 [Nn][Oo])
74                         dumpdir='NO'
75                         ;;
76                 esac
77
78                 if [ ! -e "${dumpdev}" -o ! -d "${dumpdir}" ]; then
79                         warn "Wrong dump device or directory. Savecore not run."
80                         dumpdev=
81                         return 0
82                 fi
83                 ;;
84         NetBSD)
85                 if [ ! -d "${dumpdir}" ]; then
86                         warn "No /var/crash directory; savecore not run."
87                         dumpdev=
88                         return 0
89                 fi
90                 ;;
91         esac
92         return 0
93 }
94
95 savecore_start()
96 {
97         if [ X$dumpdev != X ]; then
98                 echo "Checking for core dump..."
99                 savecore ${savecore_flags} ${DUMPDIR}
100                 return ${RC_CONFIGURED}
101         fi
102 }
103
104 load_rc_config $name
105 run_rc_command "$1"