aboutsummaryrefslogtreecommitdiff
path: root/databases/frontbase/files/frontbase.sh.in
blob: 14b69a30711e2e477bca3f38b05080415864f3d5 (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
#!/bin/sh
# $FreeBSD$

# PROVIDE: frontbase
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown

# Define these frontbase_* variables in one of these files:
#       /etc/rc.conf
#       /etc/rc.conf.local
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#
name="frontbase"

frontbase_enable="${frontbase_enable-NO}"
frontbase_user="${frontbase_user-frontbase}"
frontbase_flags="${frontbase_flags--autostart}"
frontbase_pidfile="${frontbase_pidfile-/var/run/frontbase.pid}"
frontbase_logfile="${frontbase_logfile-/var/log/frontbase.log}"

. /etc/rc.subr

rcvar=`set_rcvar`

logfile=${frontbase_logfile}
runuser=${frontbase_user}

procname1="%%PREFIX%%/FrontBase/bin/FBExec"
procname2="%%PREFIX%%/FrontBase/bin/FrontBase"
logargs=">>${logfile} 2>&1"
command="%%PREFIX%%/FrontBase/bin/FBExec"
command_args="-daemon ${logargs}"

load_rc_config $name
start_precmd="start_precmd"
stop_cmd="stop_cmd"

start_precmd() {
  touch ${logfile} && chown ${runuser} ${logfile}
}

stop_cmd() {
  rc_pid="$(check_process ${procname1}) $(check_process ${procname2})"

  echo "Stopping ${name}."
  _doit="kill -${sig_stop:-TERM} $rc_pid"
  if [ -n "$_user" ]; then
    _doit="su -m $_user -c 'sh -c \"$_doit\"'"
  fi
  eval $_doit
  _return=$?
  [ $_return -ne 0 ] && [ -z "$rc_force" ] && return 1
  wait_for_pids $rc_pid
}

run_rc_command "$1"