|
1 #!/bin/sh |
|
2 # |
|
3 # Copyright 2008, 2016, Oracle and/or its affiliates. All rights reserved. |
|
4 # |
|
5 # For modifying parameters passed to gdm, do not edit this script. |
|
6 # Instead use svccfg(1m) to modify the SMF repository. For example: |
|
7 # |
|
8 # # svccfg |
|
9 # svc:> select application/graphical-login/gdm |
|
10 # svc:/application/graphical-login/gdm> setprop gdm/args = "--fatal-warnings" |
|
11 # svc:/application/graphical-login/gdm> exit |
|
12 |
|
13 . /lib/svc/share/smf_include.sh |
|
14 |
|
15 CK_FMRI='svc:/system/consolekit' |
|
16 sessions="$(eval "echo $(svcprop -p consolekit/sessions $CK_FMRI)")" |
|
17 |
|
18 case "$1" in |
|
19 'start') |
|
20 FMRI=svc:/application/graphical-login/gdm |
|
21 |
|
22 arg="$(eval "echo $(svcprop -p gdm/args $FMRI)")" |
|
23 |
|
24 /usr/sbin/gdm $arg & |
|
25 |
|
26 rc=$? |
|
27 if [[ $rc != 0 ]]; then |
|
28 echo "$0: gdm failed with $rc" |
|
29 exit $SMF_EXIT_ERR_FATAL |
|
30 fi |
|
31 |
|
32 # If no static sessions started, start dynamic ones |
|
33 if [[ -z "$sessions" && -x /usr/lib/ConsoleKit/dsession ]]; then |
|
34 sleep 2 |
|
35 /usr/lib/ConsoleKit/dsession --init |
|
36 fi |
|
37 ;; |
|
38 |
|
39 'stop') |
|
40 if [[ -z "$sessions" && -x /usr/lib/ConsoleKit/dsession ]]; then |
|
41 /usr/lib/ConsoleKit/dsession --fini |
|
42 fi |
|
43 |
|
44 PIDFILE='/var/run/gdm/gdm.pid' |
|
45 if [[ ! -f $PIDFILE ]] ; then |
|
46 echo "$PIDFILE doesn't exist, perhaps GDM isn't running" |
|
47 else |
|
48 kill -TERM $(cat $PIDFILE) && sleep 5 |
|
49 fi |
|
50 # kill any stragglers that gdm itself didn't kill off |
|
51 smf_kill_contract $2 TERM 1 30 |
|
52 [[ $? -ne 0 ]] && exit 1 |
|
53 ;; |
|
54 |
|
55 *) |
|
56 echo "Usage: $0 { start | stop }" |
|
57 exit $SMF_EXIT_ERR_FATAL |
|
58 ;; |
|
59 esac |
|
60 |
|
61 exit $SMF_EXIT_OK |