summaryrefslogtreecommitdiff
path: root/pcr/openrc-desktop
diff options
context:
space:
mode:
Diffstat (limited to 'pcr/openrc-desktop')
-rw-r--r--pcr/openrc-desktop/acpid-2.0.16-conf.d6
-rw-r--r--pcr/openrc-desktop/acpid-2.0.16-init.d21
-rw-r--r--pcr/openrc-desktop/alsasound.confd-r415
-rw-r--r--pcr/openrc-desktop/alsasound.initd-r688
-rw-r--r--pcr/openrc-desktop/bluetooth-init.d-r321
-rw-r--r--pcr/openrc-desktop/consolekit-0.2.rc26
-rw-r--r--pcr/openrc-desktop/gpm.conf.d23
-rw-r--r--pcr/openrc-desktop/gpm.rc6-229
-rw-r--r--pcr/openrc-desktop/rfcomm-conf.d5
-rw-r--r--pcr/openrc-desktop/rfcomm-init.d-r235
-rw-r--r--pcr/openrc-desktop/startDM.sh31
-rw-r--r--pcr/openrc-desktop/wpa_cli.sh47
-rw-r--r--pcr/openrc-desktop/wpa_supplicant-conf.d6
-rw-r--r--pcr/openrc-desktop/wpa_supplicant-init.d70
-rw-r--r--pcr/openrc-desktop/xdm-setup.initd-114
-rw-r--r--pcr/openrc-desktop/xdm.confd-410
-rw-r--r--pcr/openrc-desktop/xdm.initd-11231
17 files changed, 678 insertions, 0 deletions
diff --git a/pcr/openrc-desktop/acpid-2.0.16-conf.d b/pcr/openrc-desktop/acpid-2.0.16-conf.d
new file mode 100644
index 000000000..9aadb4cd8
--- /dev/null
+++ b/pcr/openrc-desktop/acpid-2.0.16-conf.d
@@ -0,0 +1,6 @@
+# /etc/conf.d/acpid: config file for /etc/init.d/acpid
+
+# Options to pass to the acpid daemon.
+# See the acpid(8) man page for more info.
+
+ACPID_ARGS=""
diff --git a/pcr/openrc-desktop/acpid-2.0.16-init.d b/pcr/openrc-desktop/acpid-2.0.16-init.d
new file mode 100644
index 000000000..412a265fc
--- /dev/null
+++ b/pcr/openrc-desktop/acpid-2.0.16-init.d
@@ -0,0 +1,21 @@
+#!/sbin/runscript
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-power/acpid/files/acpid-2.0.16-init.d,v 1.1 2012/05/19 09:53:59 ssuominen Exp $
+
+extra_started_commands="reload"
+command="/usr/sbin/acpid"
+command_args="${ACPID_ARGS}"
+start_stop_daemon_args="--quiet"
+description="Daemon for Advanced Configuration and Power Interface"
+
+depend() {
+ need localmount
+ use logger
+}
+
+reload() {
+ ebegin "Reloading acpid configuration"
+ start-stop-daemon --exec $command --signal HUP
+ eend $?
+}
diff --git a/pcr/openrc-desktop/alsasound.confd-r4 b/pcr/openrc-desktop/alsasound.confd-r4
new file mode 100644
index 000000000..6fec8f593
--- /dev/null
+++ b/pcr/openrc-desktop/alsasound.confd-r4
@@ -0,0 +1,15 @@
+# RESTORE_ON_START:
+# Do you want to restore your mixer settings? If not, your cards will be
+# muted.
+# no - Do not restore state
+# yes - Restore state
+
+RESTORE_ON_START="yes"
+
+# SAVE_ON_STOP:
+# Do you want to save changes made to your mixer volumes when alsasound
+# stops?
+# no - Do not save state
+# yes - Save state
+
+SAVE_ON_STOP="yes"
diff --git a/pcr/openrc-desktop/alsasound.initd-r6 b/pcr/openrc-desktop/alsasound.initd-r6
new file mode 100644
index 000000000..2eddfd308
--- /dev/null
+++ b/pcr/openrc-desktop/alsasound.initd-r6
@@ -0,0 +1,88 @@
+#!/sbin/runscript
+# $Header: /var/cvsroot/gentoo-x86/media-sound/alsa-utils/files/alsasound.initd-r6,v 1.1 2014/06/23 21:34:42 ssuominen Exp $
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+alsastatedir=/var/lib/alsa
+alsascrdir=/etc/alsa.d
+alsahomedir=/var/run/alsasound
+
+extra_commands="save restore"
+
+depend() {
+ need localmount
+ after bootmisc modules isapnp coldplug hotplug
+}
+
+restore() {
+ ebegin "Restoring Mixer Levels"
+
+ checkpath -q -d -m 0700 -o root:root ${alsahomedir} || return 1
+
+ if [ ! -r "${alsastatedir}/asound.state" ] ; then
+ ewarn "No mixer config in ${alsastatedir}/asound.state, you have to unmute your card!"
+ eend 0
+ return 0
+ fi
+
+ local cards="$(sed -n -e 's/ *\([[:digit:]]*\) .*/\1/p' /proc/asound/cards)"
+ local CARDNUM
+ for cardnum in ${cards}; do
+ [ -e /dev/snd/controlC${cardnum} ] || sleep 2
+ [ -e /dev/snd/controlC${cardnum} ] || sleep 2
+ [ -e /dev/snd/controlC${cardnum} ] || sleep 2
+ [ -e /dev/snd/controlC${cardnum} ] || sleep 2
+ alsactl -E HOME="${alsahomedir}" -I -f "${alsastatedir}/asound.state" restore ${cardnum} \
+ || ewarn "Errors while restoring defaults, ignoring"
+ done
+
+ for ossfile in "${alsastatedir}"/oss/card*_pcm* ; do
+ [ -e "${ossfile}" ] || continue
+ # We use cat because I'm not sure if cp works properly on /proc
+ local procfile=${ossfile##${alsastatedir}/oss}
+ procfile="$(echo "${procfile}" | sed -e 's,_,/,g')"
+ if [ -e /proc/asound/"${procfile}"/oss ] ; then
+ cat "${ossfile}" > /proc/asound/"${procfile}"/oss
+ fi
+ done
+
+ eend 0
+}
+
+save() {
+ ebegin "Storing ALSA Mixer Levels"
+
+ checkpath -q -d -m 0700 -o root:root ${alsahomedir} || return 1
+
+ mkdir -p "${alsastatedir}"
+ if ! alsactl -E HOME="${alsahomedir}" -f "${alsastatedir}/asound.state" store; then
+ eerror "Error saving levels."
+ eend 1
+ return 1
+ fi
+
+ for ossfile in /proc/asound/card*/pcm*/oss; do
+ [ -e "${ossfile}" ] || continue
+ local device=${ossfile##/proc/asound/} ; device=${device%%/oss}
+ device="$(echo "${device}" | sed -e 's,/,_,g')"
+ mkdir -p "${alsastatedir}/oss/"
+ cp "${ossfile}" "${alsastatedir}/oss/${device}"
+ done
+
+ eend 0
+}
+
+start() {
+ if [ "${RESTORE_ON_START}" = "yes" ]; then
+ restore
+ fi
+
+ return 0
+}
+
+stop() {
+ if [ "${SAVE_ON_STOP}" = "yes" ]; then
+ save
+ fi
+ return 0
+}
diff --git a/pcr/openrc-desktop/bluetooth-init.d-r3 b/pcr/openrc-desktop/bluetooth-init.d-r3
new file mode 100644
index 000000000..f97fdb2c7
--- /dev/null
+++ b/pcr/openrc-desktop/bluetooth-init.d-r3
@@ -0,0 +1,21 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-wireless/bluez/files/bluetooth-init.d-r3,v 1.2 2014/01/09 13:24:42 joker Exp $
+
+depend() {
+ after coldplug
+ need dbus localmount hostname
+}
+
+start() {
+ ebegin "Starting ${SVCNAME}"
+ start-stop-daemon --start --background --exec /usr/libexec/bluetooth/bluetoothd
+ eend $?
+}
+
+stop() {
+ ebegin "Shutting down ${SVCNAME}"
+ start-stop-daemon --stop --quiet --exec /usr/libexec/bluetooth/bluetoothd
+ eend $?
+}
diff --git a/pcr/openrc-desktop/consolekit-0.2.rc b/pcr/openrc-desktop/consolekit-0.2.rc
new file mode 100644
index 000000000..b20226767
--- /dev/null
+++ b/pcr/openrc-desktop/consolekit-0.2.rc
@@ -0,0 +1,26 @@
+#!/sbin/runscript
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: /var/cvsroot/gentoo-x86/sys-auth/consolekit/files/consolekit-0.2.rc,v 1.1 2011/10/20 19:14:47 axs Exp $
+
+depend() {
+ need dbus
+ use logger
+}
+
+start() {
+ ebegin "Starting ConsoleKit daemon"
+
+ checkpath -q -d -m 0755 /var/run/ConsoleKit
+
+ start-stop-daemon --start -q \
+ --pidfile /var/run/ConsoleKit/pid \
+ --exec /usr/sbin/console-kit-daemon --
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ConsoleKit daemon"
+ start-stop-daemon --stop -q --pidfile /var/run/ConsoleKit/pid
+ eend $?
+}
diff --git a/pcr/openrc-desktop/gpm.conf.d b/pcr/openrc-desktop/gpm.conf.d
new file mode 100644
index 000000000..f21c25755
--- /dev/null
+++ b/pcr/openrc-desktop/gpm.conf.d
@@ -0,0 +1,23 @@
+# /etc/init.d/gpm
+
+# Please uncomment the type of mouse you have and the appropriate MOUSEDEV entry
+
+MOUSE=ps2
+#MOUSE=imps2
+#MOUSEDEV=/dev/psaux
+MOUSEDEV=/dev/input/mice
+
+# Extra settings
+
+#RESPONSIVENESS=
+#REPEAT_TYPE=raw
+
+# Please uncomment this line if you want gpm to understand charsets used
+# in URLs and names with ~ or : in them, etc. This is a good idea to turn on!
+
+#APPEND="-l \"a-zA-Z0-9_.:~/\300-\326\330-\366\370-\377\""
+
+# Various other options, see gpm(8) manpage for more.
+
+#APPEND="-g 1 -A60"
+#APPEND="-l \"a-zA-Z0-9_.:~/\300-\326\330-\366\370-\377\" -g 1 -A60"
diff --git a/pcr/openrc-desktop/gpm.rc6-2 b/pcr/openrc-desktop/gpm.rc6-2
new file mode 100644
index 000000000..1e0aaf3e1
--- /dev/null
+++ b/pcr/openrc-desktop/gpm.rc6-2
@@ -0,0 +1,29 @@
+#!/sbin/runscript
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/gpm/files/gpm.rc6-2,v 1.2 2012/10/28 11:35:56 vapier Exp $
+
+#NB: Config is in /etc/conf.d/gpm
+
+command=/usr/sbin/gpm
+command_args="
+ -m ${MOUSEDEV}
+ -t ${MOUSE}
+ ${RESPONSIVENESS:+ -r ${RESPONSIVENESS}}
+ ${REPEAT_TYPE:+ -R${REPEAT_TYPE}}
+ ${APPEND}
+"
+
+pidfile=/var/run/gpm.pid
+
+depend() {
+ need localmount
+ use hotplug logger
+}
+
+start_pre() {
+ if [ -z "${MOUSEDEV}" ] || [ -z "${MOUSE}" ] ; then
+ eerror "You need to setup MOUSEDEV and MOUSE in /etc/conf.d/gpm first"
+ return 1
+ fi
+}
diff --git a/pcr/openrc-desktop/rfcomm-conf.d b/pcr/openrc-desktop/rfcomm-conf.d
new file mode 100644
index 000000000..d87acdb28
--- /dev/null
+++ b/pcr/openrc-desktop/rfcomm-conf.d
@@ -0,0 +1,5 @@
+# Bind rfcomm devices (allowed values are "true" and "false")
+RFCOMM_ENABLE=true
+
+# Config file for rfcomm
+RFCOMM_CONFIG="/etc/bluetooth/rfcomm.conf"
diff --git a/pcr/openrc-desktop/rfcomm-init.d-r2 b/pcr/openrc-desktop/rfcomm-init.d-r2
new file mode 100644
index 000000000..c56405559
--- /dev/null
+++ b/pcr/openrc-desktop/rfcomm-init.d-r2
@@ -0,0 +1,35 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-wireless/bluez/files/rfcomm-init.d-r2,v 1.1 2014/06/26 17:18:43 alonbl Exp $
+
+depend() {
+ need bluetooth
+}
+
+checkconfig() {
+ if [ -z "${ADDRESS}" ]; then
+ eerror "ADDRESS must be set"
+ return 1
+ fi
+
+ return 0
+}
+
+start() {
+ local DEVICE=${RC_SVCNAME#*.}
+
+ checkconfig || return 1
+
+ ebegin "Starting ${RC_SVCNAME}"
+ rfcomm bind "${DEVICE}" "${ADDRESS}" ${CHANNEL}
+ eend $?
+}
+
+stop() {
+ local DEVICE=${RC_SVCNAME#*.}
+
+ ebegin "Shutting down ${RC_SVCNAME}"
+ rfcomm release "${DEVICE}"
+ eend $?
+}
diff --git a/pcr/openrc-desktop/startDM.sh b/pcr/openrc-desktop/startDM.sh
new file mode 100644
index 000000000..ebb797040
--- /dev/null
+++ b/pcr/openrc-desktop/startDM.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2
+# $Header: /var/cvsroot/gentoo-x86/x11-apps/xinit/files/startDM.sh,v 1.5 2011/01/22 15:35:49 lxnay Exp $
+
+# We need to source /etc/profile for stuff like $LANG to work
+# bug #10190.
+. /etc/profile
+
+. /etc/init.d/functions.sh
+
+# baselayout-1 compat
+if ! type get_options >/dev/null 2>/dev/null ; then
+ [ -r "${svclib}"/sh/rc-services.sh ] && . "${svclib}"/sh/rc-services.sh
+fi
+
+# Great new Gnome2 feature, AA
+# We enable this by default
+export GDK_USE_XFT=1
+
+export SVCNAME=xdm
+EXEC="$(get_options service)"
+NAME="$(get_options name)"
+PIDFILE="$(get_options pidfile)"
+START_STOP_ARGS="$(get_options start_stop_args)"
+
+start-stop-daemon --start --exec ${EXEC} \
+${NAME:+--name} ${NAME} ${PIDFILE:+--pidfile} ${PIDFILE} ${START_STOP_ARGS} || \
+eerror "ERROR: could not start the Display Manager"
+
+# vim:ts=4
diff --git a/pcr/openrc-desktop/wpa_cli.sh b/pcr/openrc-desktop/wpa_cli.sh
new file mode 100644
index 000000000..4fd0d2cda
--- /dev/null
+++ b/pcr/openrc-desktop/wpa_cli.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+# Copyright 1999-2011 Gentoo Foundation
+# Written by Roy Marples <uberlord@gentoo.org>
+# Distributed under the terms of the GNU General Public License v2
+# Alternatively, this file may be distributed under the terms of the BSD License
+# $Header: /var/cvsroot/gentoo-x86/net-wireless/wpa_supplicant/files/wpa_cli.sh,v 1.3 2011/07/08 07:06:21 gurligebis Exp $
+
+if [ -z "$1" -o -z "$2" ]; then
+ logger -t wpa_cli "Insufficient parameters"
+ exit 1
+fi
+
+INTERFACE="$1"
+ACTION="$2"
+
+# Note, the below action must NOT mark the interface down via ifconfig, ip or
+# similar. Addresses can be removed, changed and daemons can be stopped, but
+# the interface must remain up for wpa_supplicant to work.
+
+if [ -f /etc/gentoo-release ]; then
+ EXEC="/etc/init.d/net.${INTERFACE} --quiet"
+else
+ logger -t wpa_cli "I don't know what to do with this distro!"
+ exit 1
+fi
+
+case ${ACTION} in
+ CONNECTED)
+ EXEC="${EXEC} start"
+ ;;
+ DISCONNECTED)
+ # Deactivated, since stopping /etc/init.d/net.wlanX
+ # stops the network completly.
+ EXEC="false ${EXEC} stop"
+ ;;
+ *)
+ logger -t wpa_cli "Unknown action ${ACTION}"
+ exit 1
+ ;;
+esac
+
+# ${EXEC} can use ${IN_BACKGROUND} so that it knows that the user isn't
+# stopping the interface and a background process - like wpa_cli - is.
+export IN_BACKGROUND=true
+
+logger -t wpa_cli "interface ${INTERFACE} ${ACTION}"
+${EXEC} || logger -t wpa_cli "executing '${EXEC}' failed"
diff --git a/pcr/openrc-desktop/wpa_supplicant-conf.d b/pcr/openrc-desktop/wpa_supplicant-conf.d
new file mode 100644
index 000000000..104b9dc5d
--- /dev/null
+++ b/pcr/openrc-desktop/wpa_supplicant-conf.d
@@ -0,0 +1,6 @@
+# conf.d file for wpa_supplicant
+#
+# Please check man 8 wpa_supplicant for more information about the options
+# wpa_supplicant accepts.
+#
+wpa_supplicant_args=""
diff --git a/pcr/openrc-desktop/wpa_supplicant-init.d b/pcr/openrc-desktop/wpa_supplicant-init.d
new file mode 100644
index 000000000..8429a3733
--- /dev/null
+++ b/pcr/openrc-desktop/wpa_supplicant-init.d
@@ -0,0 +1,70 @@
+#!/sbin/runscript
+# Copyright (c) 2009 Roy Marples <roy@marples.name>
+# All rights reserved. Released under the 2-clause BSD license.
+
+command=/usr/sbin/wpa_supplicant
+: ${wpa_supplicant_conf:=/etc/wpa_supplicant/wpa_supplicant.conf}
+wpa_supplicant_if=${wpa_supplicant_if:+-i}$wpa_supplicant_if
+command_args="$wpa_supplicant_args -B -c$wpa_supplicant_conf $wpa_supplicant_if"
+name="WPA Supplicant Daemon"
+
+depend()
+{
+ need localmount
+ use logger
+ after bootmisc modules
+ before dns dhcpcd net
+ keyword -shutdown
+}
+
+find_wireless()
+{
+ local iface=
+
+ case "$RC_UNAME" in
+ Linux)
+ for iface in /sys/class/net/*; do
+ if [ -e "$iface"/wireless -o \
+ -e "$iface"/phy80211 ]
+ then
+ echo "${iface##*/}"
+ return 0
+ fi
+ done
+ ;;
+ *)
+ for iface in /dev/net/* $(ifconfig -l 2>/dev/null); do
+ if ifconfig "${iface##*/}" 2>/dev/null | \
+ grep -q "[ ]*ssid "
+ then
+ echo "${iface##*/}"
+ return 0
+ fi
+ done
+ ;;
+ esac
+
+ return 1
+}
+
+append_wireless()
+{
+ local iface= i=
+
+ iface=$(find_wireless)
+ if [ -n "$iface" ]; then
+ for i in $iface; do
+ command_args="$command_args -i$i"
+ done
+ else
+ eerror "Could not find a wireless interface"
+ fi
+}
+
+start_pre()
+{
+ case " $command_args" in
+ *" -i"*) ;;
+ *) append_wireless;;
+ esac
+}
diff --git a/pcr/openrc-desktop/xdm-setup.initd-1 b/pcr/openrc-desktop/xdm-setup.initd-1
new file mode 100644
index 000000000..365664e66
--- /dev/null
+++ b/pcr/openrc-desktop/xdm-setup.initd-1
@@ -0,0 +1,14 @@
+#!/sbin/runscript
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/x11-base/xorg-server/files/xdm-setup.initd-1,v 1.1 2010/04/13 10:07:39 scarabeus Exp $
+
+depend() {
+ need localmount
+}
+
+start() {
+ if get_bootparam "nox" ; then
+ touch /etc/.noxdm
+ fi
+}
diff --git a/pcr/openrc-desktop/xdm.confd-4 b/pcr/openrc-desktop/xdm.confd-4
new file mode 100644
index 000000000..c82fece01
--- /dev/null
+++ b/pcr/openrc-desktop/xdm.confd-4
@@ -0,0 +1,10 @@
+# We always try and start X on a static VT. The various DMs normally default
+# to using VT7. If you wish to use the xdm init script, then you should ensure
+# that the VT checked is the same VT your DM wants to use. We do this check to
+# ensure that you haven't accidentally configured something to run on the VT
+# in your /etc/inittab file so that you don't get a dead keyboard.
+CHECKVT=7
+
+# What display manager do you use ? [ xdm | gdm | kdm | gpe | entrance ]
+# NOTE: If this is set in /etc/rc.conf, that setting will override this one.
+DISPLAYMANAGER="xdm"
diff --git a/pcr/openrc-desktop/xdm.initd-11 b/pcr/openrc-desktop/xdm.initd-11
new file mode 100644
index 000000000..2f7b47cb2
--- /dev/null
+++ b/pcr/openrc-desktop/xdm.initd-11
@@ -0,0 +1,231 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License, v2
+# $Header: /var/cvsroot/gentoo-x86/x11-base/xorg-server/files/xdm.initd-11,v 1.1 2014/04/14 16:19:25 chithanh Exp $
+
+# This is here to serve as a note to myself, and future developers.
+#
+# Any Display manager (gdm,kdm,xdm) has the following problem: if
+# it is started before any getty, and no vt is specified, it will
+# usually run on vt2. When the getty on vt2 then starts, and the
+# DM is already started, the getty will take control of the keyboard,
+# leaving us with a "dead" keyboard.
+#
+# Resolution: add the following line to /etc/inittab
+#
+# x:a:once:/etc/X11/startDM.sh
+#
+# and have /etc/X11/startDM.sh start the DM in daemon mode if
+# a lock is present (with the info of what DM should be started),
+# else just fall through.
+#
+# How this basically works, is the "a" runlevel is a additional
+# runlevel that you can use to fork processes with init, but the
+# runlevel never gets changed to this runlevel. Along with the "a"
+# runlevel, the "once" key word means that startDM.sh will only be
+# run when we specify it to run, thus eliminating respawning
+# startDM.sh when "xdm" is not added to the default runlevel, as was
+# done previously.
+#
+# This script then just calls "telinit a", and init will run
+# /etc/X11/startDM.sh after the current runlevel completes (this
+# script should only be added to the actual runlevel the user is
+# using).
+#
+# Martin Schlemmer
+# aka Azarah
+# 04 March 2002
+
+depend() {
+ need localmount xdm-setup
+
+ # this should start as early as possible
+ # we can't do 'before *' as that breaks it
+ # (#139824) Start after ypbind and autofs for network authentication
+ # (#145219 #180163) Could use lirc mouse as input device
+ # (#70689 comment #92) Start after consolefont to avoid display corruption
+ # (#291269) Start after quota, since some dm need readable home
+ # (#390609) gdm-3 will fail when dbus is not running
+ # (#366753) starting keymaps after X causes problems
+ after bootmisc consolefont modules netmount
+ after readahead-list ypbind autofs openvpn gpm lircmd
+ after quota keymaps
+ before alsasound
+
+ # Start before X
+ use consolekit dbus xfs
+}
+
+setup_dm() {
+ local MY_XDM
+
+ MY_XDM=$(echo "${DISPLAYMANAGER}" | tr '[:upper:]' '[:lower:]')
+
+ # Load our root path from profile.env
+ # Needed for kdm
+ PATH=${PATH}:$(. /etc/profile.env; echo "${ROOTPATH}")
+
+ NAME=
+ case "${MY_XDM}" in
+ kdm|kde)
+ EXE=/usr/bin/kdm
+ PIDFILE=/run/kdm.pid
+ ;;
+ entrance*)
+ EXE=/usr/sbin/entrance
+ PIDFILE=/run/entrance.pid
+ ;;
+ gdm|gnome)
+ # gdm-3 and above has different paths
+ if [ -f /usr/sbin/gdm ]; then
+ EXE=/usr/sbin/gdm
+ PIDFILE=/run/gdm/gdm.pid
+ START_STOP_ARGS="--background"
+ AUTOCLEAN_CGROUP="yes"
+ else
+ EXE=/usr/bin/gdm
+ PIDFILE=/run/gdm.pid
+ fi
+ [ "${RC_UNAME}" != "Linux" ] && NAME=gdm-binary
+ ;;
+ wdm)
+ EXE=/usr/bin/wdm
+ PIDFILE=
+ ;;
+ gpe)
+ EXE=/usr/bin/gpe-dm
+ PIDFILE=/run/gpe-dm.pid
+ ;;
+ lxdm)
+ EXE=/usr/sbin/lxdm-binary
+ PIDFILE=/run/lxdm.pid
+ START_STOP_ARGS="--background"
+ ;;
+ lightdm)
+ EXE=/usr/sbin/lightdm
+ PIDFILE=/run/lightdm.pid
+ START_STOP_ARGS="--background"
+ ;;
+ sddm)
+ EXE="/usr/bin/sddm"
+ START_STOP_ARGS="-m --background"
+ PIDFILE=/run/sddm.pid
+ ;;
+ *)
+ # first find out if there is such executable
+ EXE="$(command -v ${MY_XDM} 2>/dev/null)"
+ PIDFILE="/run/${MY_XDM}.pid"
+
+ # warn user that he is doing sick things if the exe was not found
+ if [ -z "${EXE}" ]; then
+ echo "ERROR: Your XDM value is invalid."
+ echo " No ${MY_XDM} executable could be found on your system."
+ fi
+ ;;
+ esac
+
+ if ! [ -x "${EXE}" ]; then
+ EXE=/usr/bin/xdm
+ PIDFILE=/run/xdm.pid
+ if ! [ -x "/usr/bin/xdm" ]; then
+ echo "ERROR: Please set your DISPLAYMANAGER variable in /etc/conf.d/xdm,"
+ echo " or install x11-apps/xdm package"
+ eend 255
+ fi
+ fi
+}
+
+# Check to see if something is defined on our VT
+vtstatic() {
+ if [ -e /etc/inittab ] ; then
+ grep -Eq "^[^#]+.*\<tty$1\>" /etc/inittab
+ elif [ -e /etc/ttys ] ; then
+ grep -q "^ttyv$(($1 - 1))" /etc/ttys
+ else
+ return 1
+ fi
+}
+
+start() {
+ local EXE NAME PIDFILE AUTOCLEAN_CGROUP
+ setup_dm
+
+ if [ -f /etc/.noxdm ]; then
+ einfo "Skipping ${EXE##*/}, /etc/.noxdm found or \"nox\" bootparam passed."
+ rm /etc/.noxdm
+ return 0
+ fi
+
+ ebegin "Setting up ${EXE##*/}"
+
+ # save the prefered DM
+ save_options "service" "${EXE}"
+ save_options "name" "${NAME}"
+ save_options "pidfile" "${PIDFILE}"
+ save_options "start_stop_args" "${START_STOP_ARGS}"
+ save_options "autoclean_cgroup" "${AUTOCLEAN_CGROUP:-no}"
+
+ if [ -n "${CHECKVT-y}" ] ; then
+ if vtstatic "${CHECKVT:-7}" ; then
+ if [ -x /sbin/telinit ] && [ "${SOFTLEVEL}" != "BOOT" ] && [ "${RC_SOFTLEVEL}" != "BOOT" ]; then
+ ewarn "Something is already defined on VT ${CHECKVT:-7}, will start X later"
+ telinit a >/dev/null 2>&1
+ return 0
+ else
+ eerror "Something is already defined on VT ${CHECKVT:-7}, not starting"
+ return 1
+ fi
+ fi
+ fi
+
+ /etc/X11/startDM.sh
+ eend 0
+}
+
+stop() {
+ local curvt retval
+
+ retval=0
+ if [ -t 0 ]; then
+ if type fgconsole >/dev/null 2>&1; then
+ curvt=$(fgconsole 2>/dev/null)
+ else
+ curvt=$(tty)
+ case "${curvt}" in
+ /dev/ttyv[0-9]*) curvt=${curvt#/dev/ttyv} ;;
+ *) curvt= ;;
+ esac
+ fi
+ fi
+ local myexe myname mypidfile myservice
+ myexe=$(get_options "service")
+ myname=$(get_options "name")
+ mypidfile=$(get_options "pidfile")
+ myservice=${myexe##*/}
+ yesno "${rc_cgroup_cleanup:-no}" || rc_cgroup_cleanup=$(get_options "autoclean_cgroup")
+
+ [ -z "${myexe}" ] && return 0
+
+ ebegin "Stopping ${myservice}"
+
+ if start-stop-daemon --quiet --test --stop --exec "${myexe}"; then
+ start-stop-daemon --stop --exec "${myexe}" --retry TERM/5/TERM/5 \
+ ${mypidfile:+--pidfile} ${mypidfile} \
+ ${myname:+--name} ${myname}
+ retval=${?}
+ fi
+
+ # switch back to original vt
+ if [ -n "${curvt}" ]; then
+ if type chvt >/dev/null 2>&1; then
+ chvt "${curvt}"
+ else
+ vidcontrol -s "$((curvt + 1))"
+ fi
+ fi
+
+ eend ${retval} "Error stopping ${myservice}"
+ return ${retval}
+}
+
+# vim: set ts=4 :