aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils/hal/files/hald.in
blob: 4e8b7e7e66e111b0048ada122edb5786c3e16e58 (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
#!/bin/sh
#
# $FreeBSD$
#   $MCom: ports/sysutils/hal/files/hald.in,v 1.14 2008/08/21 16:04:48 mezz Exp $
#
# PROVIDE: hald
# REQUIRE: DAEMON usbd devd dbus moused
#
# Add the following line to /etc/rc.conf to enable the HAL daemon:
#
# hald_enable="YES"
#

. %%RC_SUBR%%
. %%GNOME_SUBR%%

hald_enable=${hald_enable-${gnome_enable}}
hald_flags=${hald_flags-""}

name=hald
rcvar=`set_rcvar`

command="%%PREFIX%%/sbin/hald"
pidfile="/var/run/${name}/${name}.pid"

stop_postcmd="hald_postcmd"
start_precmd="hald_precmd"
start_cmd="hald_start"

local_force_depend()
{
    _depend="$1"
    if [ -f %%LOCALBASE%%/etc/rc.d/${_depend}.sh ]; then
    _depend="${_depend}.sh"
    fi

    if ! %%LOCALBASE%%/etc/rc.d/${_depend} forcestatus 1>/dev/null 2>&1 &&
       ! %%LOCALBASE%%/etc/rc.d/${_depend} forcestart; then
       return 1
   fi
   return 0
}

hald_precmd()
{
    if ! checkyesno dbus_enable
    then
    local_force_depend dbus || return 1
    fi

    chmod 0755 /var/cache

    mkdir -p $(dirname $pidfile)
}

hald_postcmd()
{
    rm -f $pidfile
}

hald_start()
{
    if ! checkyesno hald_enable ; then
    return 0
    fi
    echo "Starting ${name}."

    ( iter=0
    while ! ps -axoargs | grep "^/usr/libexec/getty " | grep -qv grep >/dev/null 2>&1; do
    if [ ${iter} -eq 60 ]; then
        break
    fi
    sleep 1
    iter=$(expr ${iter} + 1)
    done
    ${command} ${hald_flags} ) &
}

load_rc_config ${name}
run_rc_command "$1"