summaryrefslogtreecommitdiff
path: root/databases/cego/files/cego.in
blob: 138079bb9a3bb677daca65e002570ce9148ae458 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/sh 
#
# $FreeBSD$
#

# PROVIDE: cego
# REQUIRE: LOGIN cleanvar
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf to enable cego:
# cego_enable (bool):      Set to "NO" by default.
#                          Set it to "YES" to enable cego
# cego_profiles (str):     Set to "" by default.
#                          Define your profiles here.
# cego_tablespc (str):     Set it to the tablespace
# cego_flags (str):        Set to "" by default.
#                          Extra flags passed to start command.

. /etc/rc.subr

name="cego"
rcvar=cego_enable

command="%%PREFIX%%/bin/cego"

: ${cego_enable="NO"}
: ${cego_conf="%%PREFIX%%/cego"}
: ${cego_root="%%PREFIX%%/cego"}
: ${cego_user="%%USER%%"}

flags="--mode=daemon"

_pidprefix="/var/run/cego"
pidfile="${_pidprefix}.pid"

command_arg="--mode=daemon"
_pidprefix="/var/run/cego"

flags="--mode=daemon"

load_rc_config $name

if [ -n "$2" ]; then
        profile="$2"
        if [ "x${cego_profiles}" != "x" ]; then
                pidfile="${_pidprefix}.${profile}.pid"

                echo profile is $profile

		eval cego_tablespc="\${cego_${profile}_tablespc:-}"
                if [ "x${cego_tablespc}" = "x" ]; then
                        err 1 "You must define a tableset for db instance cego_${profile}_tablespc"
                fi

                eval cego_conf="\${cego_${profile}_conf:-${cego_conf}}"
                eval cego_root="\${cego_${profile}_root:-${cego_root}}"
                
                required_files="${cego_conf}/${profile}.xml"
                eval cego_enable="\${cego_${profile}_enable:-${cego_enable}}"
                command_args="--dbxml=${required_files} --tableset=${cego_tablespc} --lockfile=${cego_root}/${profile}.lck --logfile=${cego_root}/${profile}.log"
                echo "Setting command_args $command_args" 
        else
                warn "$0: extra argument ignored"
        fi
else
        if [ "x${cego_profiles}" != "x" -a "x$1" != "x" ]; then
                for profile in ${cego_profiles}; do
                        eval _enable="\${cego_${profile}_enable}"
                        case "x${_enable:-${cego_enable}}" in
                        x|x[Nn][Oo]|x[Nn][Oo][Nn][Ee])
                                continue
                                ;;
                        x[Yy][Ee][Ss])
                                ;;
                        *)
                                if test -z "$_enable"; then
                                        _var=cego_enable
                                else
                                        _var=cego_"${profile}"_enable
                                fi
                                warn "Bad value" \
                                    "'${_enable:-${cego_enable}}'" \
                                    "for ${_var}. " \
                                    "Profile ${profile} skipped."
                                continue
                                ;;
                        esac
                        echo "===> cego profile: ${profile}"
                        %%PREFIX%%/etc/rc.d/cego $1 ${profile}
                        retcode="$?"
                        if [ "0${retcode}" -ne 0 ]; then
                                failed="${profile} (${retcode}) ${failed:-}"
                        else
                                success="${profile} ${success:-}"
                        fi
                done
                exit 0
        fi
fi


cego_requirepidfile()
{
	if [ ! "0`check_pidfile ${pidfile} ${command}`" -gt 1 ]; then
		err 1 "${name} not running? (check $pidfile)."
	fi
}

run_rc_command "$1"