aboutsummaryrefslogtreecommitdiffstats
path: root/x11/slim/files/slim.in
blob: d54bd26d2c316e6e1ce750e3ed6a2210ce01401a (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
#!/bin/sh

# $FreeBSD$
#
# PROVIDE: slim
# REQUIRE: LOGIN dbus hald
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable slim:
# slim_enable (bool):      Set to "NO" by default.
#                          Set it to "YES" to enable slim
#
# Alternatively, edit /etc/ttys and change the line below
#   ttyv8   "/usr/X11R6/bin/xdm -nodaemon"  xterm   off secure
# to this:
#   ttyv8   "%%PREFIX%%/bin/slim"   xterm   on secure

. /etc/rc.subr

name="slim"
rcvar=slim_enable

start_precmd=${name}_rmfile
stop_precmd=${name}_prestop
stop_postcmd=${name}_rmfile

load_rc_config $name

: ${slim_enable="NO"}

command=%%PREFIX%%/bin/slim
command_args="-d"

find_pidfile()
{
    if type get_pidfile_from_conf >/dev/null 2>&1 &&
        get_pidfile_from_conf lockfile %%PREFIX%%/etc/${name}.conf; then
        pidfile="$_pidfile_from_conf"
    else
        pidfile="/var/run/${name}.pid"
    fi
}

slim_rmfile ()
{
    local file

    [ -z "$pidfile" ] && find_pidfile

    for file in $pidfile /var/run/slim.auth; do
        [ -e "$file" ] && unlink $file
    done
    
    # Needed if neither file exists
    return 0
}

slim_prestop ()
{
    local xpid

    find_pidfile

    xpid=`ps -axww | grep '/bin/[X] .* -auth /var/run/slim.auth' | grep -v grep | awk '{print $1};'`
    [ -n "$xpid" ] && kill $xpid
}

run_rc_command "$1"