All pastes #448451 Raw Edit

Someone

public text v1 · immutable
·published 2007-04-19 17:27 UTC
rendered paste body
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later

# This script is largely inspired from /etc/init.d/xdm
#
# Don't forget to set XUSER to the desired username in /etc/conf.d/xuser
#
# Yoann Aubineau
# yoann@yaubi.com
# 2004.03.10

# Start X Font Server before X
depend() {
        use xfs hotplug
}

start() {
        USER="$(echo ${XUSER} | awk '{ print tolower($1) }')"

        ebegin "Starting X session for ${USER}"
        save_options "user" "${USER}"

        /sbin/telinit b &>/dev/null
        eend 0
}

stop() {
        local retval=0
        local curvt="$(fgconsole)"

        ebegin "Stopping X session"

        rm -f ${svcdir}/options/xuser/user

        if [ "$(ps -A | grep -e "startx")" ]
        then
                start-stop-daemon --stop \
                        --name "startx"
                retval=$?
        fi

        #switch back to original vt
        chvt "${curvt}" &>/dev/null

        eend ${retval} "Error stopping ${myservice}."

        return ${retval}
}