#!/bin/sh
#
# ruby_init This scripts configures cold-pluging for bruby, \
# loads additional input modules, manages the XFree \
# and display manager configuration files
#
# chkconfig: 2345 02 98
# description: Configures the Bruby input subsystem and manages \
# XFree and display manager configuration files.
# config: /etc/sysconfig/ruby.conf
#
# TODO
# * handle commented out "PciOsConfig"
# *? status/ ext-status
# - show config
# - check wether curr. configuration matches setup ?
# - make it work when hotplug files not installed ?
# ( currently it will just just inform that they are not installed
# and exit )
#
# $Id: XFree-Local-multi-user-HOWTO.xml,v 1.12 2003/11/11 14:52:42 gferg Exp $
# - don't exit silently if hackvideo or modules loading is deactivated,
# run the script to the end
# $Id: XFree-Local-multi-user-HOWTO.xml,v 1.12 2003/11/11 14:52:42 gferg Exp $
# - show keyboard status per VT ,use sed instead of head(head is in /usr)
# - *? status/ ext-status
# - (mice & evdev links)?
# $Id: XFree-Local-multi-user-HOWTO.xml,v 1.12 2003/11/11 14:52:42 gferg Exp $
# - include hackvideo handling (long time wondering what was missing)
# $Id: XFree-Local-multi-user-HOWTO.xml,v 1.12 2003/11/11 14:52:42 gferg Exp $
# - got it actually running
# - use >& /dev/null to load variables from the config file
# (what a mess)
# $Id: XFree-Local-multi-user-HOWTO.xml,v 1.12 2003/11/11 14:52:42 gferg Exp $
# - initial release
PATH=/sbin:/bin:/usr/sbin:/usr/bin
# source function library
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi
# source defaults
if [ -f /etc/sysconfig/ruby.conf ]; then
#WTF, how to get rid of the ".... >& /dev/null"
. /etc/sysconfig/ruby.conf >& /dev/null
RUBY_CONF="/etc/sysconfig/ruby.conf"
else
action "ruby_init: Configuration file missing" /bin/false
exit 1
fi
function get_status() {
run_hackvideo status
# prefbus_used ?
# print dumb_con=?
get_kbds #and curr. active VTs
}
function get_ext_status() {
run_input_rc status
run_hackvideo status
# prefbus_used ?
# print dumb_con=?
get_kbds #and curr. active VTs
get_links mouse
get_links event
}
function run_start_restart() {
load_modules
run_hackvideo start
run_input_rc start
run_auto_dm
run_auto_xfree
}
function run_input_rc () {
for RC in /etc/hotplug/input.rc
do
eval "doit=\"\$HOTPLUG_RC_input\""
if [ "$doit" != yes -a "$1" != status ]; then
continue
fi
$RC $1
if [ "$1" != status ]; then
action "bruby: configuring cold-pluged devices." $RC $1
fi
done
}
function run_hackvideo () {
eval "doit=\"\$HACK_VIDEO_ENABLE\""
if [ "$doit" != yes ]; then
if [ "$1" = status ]; then
echo "XFree hackvideo not configured."
fi
return ;
fi
if [ -f /proc/bus/pci/hackvideo ]; then
if [ -f /etc/X11/XF86Config-4 ]; then
xf_file="/etc/X11/XF86Config-4"
elif [ -f /etc/X11/XF86Config ]; then
xf_file="/etc/X11/XF86Config"
else
action "bruby: XFree configuration file not found" /bin/false
exit 1
fi
#fi
eval "xf_hackvideo=`sed -n '/^#/d;s/^.*"PciOsConfig"[ ]//p' $xf_file | sed -e 's/[ ]//g'`"
if [ "$xf_hackvideo" = "1" ]; then
case "$1" in
start)
action "bruby: Enabling XFree hackvideo workaound." /bin/true
/bin/echo "1" > /proc/bus/pci/hackvideo
;;
stop)
action "bruby: Disabling XFree hackvideo workaound."
/bin/echo "0" > /proc/bus/pci/hackvideo
;;
status)
eval "hack_enabled=`cat /proc/bus/pci/hackvideo`"
if [ $hack_enabled = 1 ]; then
echo "XFree hackvideo activated"
else
echo "XFree hackvideo not activated,"
echo "but enabled in configuration. "
fi
;;
*)
;;
esac
else
action "bruby: Hackvideo not configured in XFree," /bin/false
action "bruby: but enabled in $RUBY_CONF." /bin/false
fi
else
action "bruby: XFree hackvideo configured," /bin/false
action "bruby: but kernel hackvideo support missing." /bin/false
fi
}
function load_modules () {
eval "doit=\"\$LOAD_MODULES\""
if [ "$doit" != yes -a "$1" != status ]; then
return ;
fi
action "bruby: loading additional modules." /bin/true
cat $RUBY_CONF | sed -n "/input modules /,/config/p" | while read module args
do
case "$module" in
\#*|"") continue ;;
esac
initlog -s "Loading module: $module"
modprobe $module $args >/dev/null 2>&1
done
}
function run_auto_xfree () {
eval "doit=\"\$AUTO_XFree\""
if [ "$doit" != yes -a "$1" != status ]; then
return ;
fi
# (pixel) a kind of profile for XF86Config
# if no XFree=XXX given on kernel command-line, restore XF86Config.standard
for i in XF86Config XF86Config-4; do
if [ -L "/etc/X11/$i" ]; then
XFree=`sed -n 's/.*XFree=\(\w*\).*/\1/p' /proc/cmdline`
[ -n "$XFree" ] || XFree=standard
[ -r "/etc/X11/$i.$XFree" ] && ln -sf "$i.$XFree" "/etc/X11/$i"
fi
done
action "bruby: configuring XFree." /bin/true
}
function run_auto_dm () {
eval "doit=\"\$AUTO_DM\""
if [ "$doit" != yes -a "$1" != status ]; then
return ;
fi
#
#the same like XF86Config but for gdm.conf & Xservers
#
for i in xdm/Xservers gdm/gdm.conf; do
if [ -L "/etc/X11/$i" ]; then
DumbCon=`sed -n 's/.*dumbcon=\([0-9]*\).*/\1/p' /proc/cmdline`
[ -n "$DumbCon" ] || DumbCon=0
[ -r "/etc/X11/$i.$DumbCon" ] && ln -sf "/etc/X11/$i.$DumbCon" "/etc/X11/$i"
fi
done
action "bruby: configuring display manager." /bin/true
echo "Setting up display managers for `expr $DumbCon + 1` Xservers"
}
function get_kbds() {
j=0
for i in /proc/bus/console/*
do
echo
j=`expr $j + 1`
phys=`cat $i/keyboard`
if [ "$phys" = "" ];then
echo " VT-`basename $i` : keyboard not attached"
else
echo " VT-`basename $i` using :"
# grep -n2 "$phys" /proc/bus/input/devices | sed -e '{/^B: /s;^B:.*;;};{s;^.*: ;;};' -e "/EV=/d"
grep -B2 -A1 "$phys" /proc/bus/input/devices | sed 's;^.*: ;;'
fi
done
echo
echo "Total of $j VT's avialable."
}
function get_links() {
echo
for i in /dev/input/$1*br
do
real=`ls -l $i 2>/dev/null | sed "{s;^.*/dev/input/;;};{s; ->;;}" | cut -d " " -f 2`
if [ "$real" != "" ]; then
echo "$i"
sed -e '/Name/,/Handl/s/.*: //;{/^B: /s;^B:.*;;};' /proc/bus/input/devices | grep -B2 -A1 "$real"
else
exit 0
fi
done
}
if [ -f /proc/bus/console -o -n tmp=`uname -r | sed -n 's:ruby::p'` ]; then
if [ -x /etc/hotplug/input.rc -a -f /etc/hotplug/input.agent ]; then
case "$1" in
start|restart)
run_start_restart
;;
status)
get_status
touch /var/lock/subsys/ruby
;;
ext-status)
get_ext_status
touch /var/lock/subsys/ruby
;;
stop)
#run_hackvideo stop
run_input_rc stop
rm -f /var/lock/subsys/ruby
;;
force-reload)
run_input_rc stop
run_input_rc start
touch /var/lock/subsys/ruby
;;
*)
gprintf "Usage: %s {start|stop|restart|status|ext-status|force_reload}\n" "$0"
exit 3
;;
esac
else if [ -f /etc/hotplug/input.rc -a -f /etc/hotplug/input.agent ]; then
action "Input: input.rc and input.agent installed, but not executable." /bin/false
action "Input: Please check the file permissions." /bin/false
else
action "Input: Failed to configure cold plugged devices." /bin/false
action "Input: input.rc or input.agent missing." /bin/false
fi
fi
fi
|