PageRenderTime 108ms CodeModel.GetById 100ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/init.d/x11-common

http://github.com/brinkman83/bashrc
Shell | 90 lines | 66 code | 13 blank | 11 comment | 18 complexity | 9a2901c839ade46a2a0f795ad1400fdf MD5 | raw file
 1#!/bin/sh
 2# /etc/init.d/x11-common: set up the X server and ICE socket directories
 3### BEGIN INIT INFO
 4# Provides:          x11-common
 5# Required-Start:    $local_fs
 6# Required-Stop:     $local_fs
 7# Default-Start:     S
 8# Default-Stop:
 9### END INIT INFO
10
11set -e
12
13PATH=/bin:/usr/bin:/sbin:/usr/sbin
14SOCKET_DIR=/tmp/.X11-unix
15ICE_DIR=/tmp/.ICE-unix
16
17. /lib/lsb/init-functions
18if [ -f /etc/default/rcS ]; then
19  . /etc/default/rcS
20fi
21
22do_restorecon () {
23  # Restore file security context (SELinux).
24  if which restorecon >/dev/null 2>&1; then
25    restorecon "$1"
26  fi
27}
28
29set_up_socket_dir () {
30  if [ "$VERBOSE" != no ]; then
31    log_begin_msg "Setting up X server socket directory $SOCKET_DIR..."
32  fi
33  if [ -e $SOCKET_DIR ] && [ ! -d $SOCKET_DIR ]; then
34    mv $SOCKET_DIR $SOCKET_DIR.$$
35  fi
36  mkdir -p $SOCKET_DIR
37  chown root:root $SOCKET_DIR
38  chmod 1777 $SOCKET_DIR
39  do_restorecon $SOCKET_DIR
40  [ "$VERBOSE" != no ] && log_end_msg 0 || return 0
41}
42
43set_up_ice_dir () {
44  if [ "$VERBOSE" != no ]; then
45    log_begin_msg "Setting up ICE socket directory $ICE_DIR..."
46  fi
47  if [ -e $ICE_DIR ] && [ ! -d $ICE_DIR ]; then
48    mv $ICE_DIR $ICE_DIR.$$
49  fi
50  mkdir -p $ICE_DIR
51  chown root:root $ICE_DIR
52  chmod 1777 $ICE_DIR
53  do_restorecon $ICE_DIR
54  [ "$VERBOSE" != no ] && log_end_msg 0 || return 0
55}
56
57do_status () {
58    if [ -d $ICE_DIR ] && [ -d $SOCKET_DIR ]; then
59      return 0
60    else
61      return 4
62    fi
63}
64
65case "$1" in
66  start)
67    set_up_socket_dir
68    set_up_ice_dir
69  ;;
70
71  restart|reload|force-reload)
72    /etc/init.d/x11-common start
73  ;;
74
75  stop)
76   :
77  ;;
78
79  status)
80    do_status
81  ;;
82  *)
83    log_success_msg "Usage: /etc/init.d/x11-common {start|stop|status|restart|reload|force-reload}"
84    exit 1
85    ;;
86esac
87
88exit 0
89
90# vim:set ai et sts=2 sw=2 tw=0: