1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-28 05:29:48 +00:00
freebsd-ports/sysutils/hal/files/hald.in
Koop Mast 0175115cb7 Make sure /var is populated correctly before hal is started, like dbus does
already in its rc.d script. [1]
Don't list entries twice, set some more details about storage devices like
the linux backend does. [2]

PR:		ports/171568 [1]
PR:		ports/171727 [2]
Submitted by:	Norbert Koch <nkoch@demig.de> [1], avilla@ [2]
Reviewed by:	marcus@
2012-09-29 18:17:59 +00:00

122 lines
2.5 KiB
Bash

#!/bin/sh
#
# $FreeBSD$
# $MCom: ports/sysutils/hal/files/hald.in,v 1.22 2010/04/17 19:05:10 marcus Exp $
#
# PROVIDE: hald
# REQUIRE: DAEMON usbd devd dbus moused webcamd
#
# Add the following line to /etc/rc.conf to enable the HAL daemon:
#
# hald_enable="YES"
#
. /etc/rc.subr
. %%GNOME_SUBR%%
hald_enable=${hald_enable-${gnome_enable}}
hald_flags=${hald_flags-""}
name=hald
rcvar=hald_enable
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
}
init_var_policykit()
{
local USER=polkit
local GROUP=${USER}
local PREFIX=/usr/local
/usr/bin/install -d -o root -m 0770 -g ${GROUP} /var/run/PolicyKit
/usr/bin/install -d -o root -m 0770 -g ${GROUP} /var/lib/PolicyKit
/usr/bin/install -d -o ${USER} -m 0755 -g wheel /var/lib/PolicyKit-public
/bin/mkdir -p /var/lib/misc
/usr/bin/touch -f /var/lib/misc/PolicyKit.reload
/usr/sbin/chown ${USER}:${GROUP} /var/lib/misc/PolicyKit.reload
/bin/chmod 0664 /var/lib/misc/PolicyKit.reload
}
init_var_polkit()
{
mkdir -p /var/lib/polkit-1/localauthority
for i in 10-vendor.d 20-org.d 30-site.d 50-local.d 90-mandatory.d
do
mkdir -p /var/lib/polkit-1/localauthority/${i}
done
chmod 0700 /var/lib/polkit-1
}
init_var_hal()
{
local USER=haldaemon
local GROUP=${USER}
/usr/bin/install -d -o ${USER} -g ${GROUP} /var/run/hald
/usr/bin/install -d -o ${USER} -g ${GROUP} /var/cache/hald
/usr/bin/install -d -o ${USER} -g ${GROUP} /var/lib/hal
/usr/local/bin/polkit-auth --user ${USER} --grant \
org.freedesktop.policykit.read 1> /dev/null 2>&1
}
hald_precmd()
{
if ! checkyesno dbus_enable
then
local_force_depend dbus || return 1
fi
init_var_policykit
init_var_polkit
init_var_hal
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"