|

楼主 |
发表于 2003-7-23 22:13:26
|
显示全部楼层
第二次更新:
#!/bin/sh
HOME=/root
# If we aren't root, bail:
if [ "$USER" = "root" ]; then
TMP=/var/log/setup/tmp
else
echo "Only root can configure X."
exit
fi
if ps -aA | grep "X" > /dev/null ; then
dialog --title "EXIT X SERVER?" --yesno \
"You are running the X server now,but this program can't run with it. \
I shall kill your X progress,after exit X server,please run 'xf4config' program to \
reconfigure once more. Do you want to continue ?
" 8 66
if [ ! $? = 0 ]; then
exit
fi
if ps -aA | grep "gdm-binary" > /dev/null ; then
killall gdm-binary
fi
if ps -aA | grep "kdm" > /dev/null ; then
killall kdm
fi
if ps -aA | grep "xdm" > /dev/null ; then
killall xdm
fi
if ps -aA | grep "gnome-session" > /dev/null ; then
killall gnome-session
fi
if ps -aA | grep "kdeinit" > /dev/null ; then
killall kdeinit
fi
if ps -aA | grep "wmaker" > /dev/null ; then
killall wmaker
fi
if ps -aA | grep "X" > /dev/null ; then
killall X
fi
fi
# Now, this wouldn't make much sense either:
if [ ! -r /usr/X11R6/bin/XFree86 ]; then
exit
fi
dialog --title "CONFIGURE X SERVER?" --yesno \
"If you like, XFree86 can attempt to probe for your video hardware and mouse, and \
write an initial configuration file to /etc/X11/XF86Config. Would you like to do this now ? \
You can reach http://www.linuxsir.cn explore even more help. \
Establish by hamigua <hamigua@8bb8.com>" 9 66
if [ ! $? = 0 ]; then
exit
fi
if [ ! -d $TMP ]; then
mkdir -p $TMP
chmod 700 $TMP
fi
# OK, we'll warn the user if there's already an existing XF86Config:
CONFIG_EXISTS=false
for xf86config in /etc/X11/XF86Config-4 /etc/XF86Config-4 /usr/X11R6/lib/X11/XF86Config-4 $HOME/XF86Config-4 ; do
if [ -r $xf86config ]; then
CONFIG_EXISTS=$xf86config
fi
done
if [ ! "$CONFIG_EXISTS" = "false" ]; then
dialog --title "FOUND EXISTING XF86Config in `dirname $CONFIG_EXISTS`" \
--msgbox "A previous X Window System configuration file has been found. \
You can now reconfigure X, replacing the file with a new version (and \
keeping a backup of the old file), or you can abort leaving the existing \
config file in place. Hit ENTER to rename the XF86Config file to \
XF86Config.backup and create a new one, or ESC to abort." 9 72
if [ ! $? = 0 ]; then
exit
fi
fi
# Have the X server create a default config file:
/usr/X11R6/bin/XFree86 -configure
if [ ! $? = 0 ]; then
# failure, bail.
exit
fi
# Move any existing config file(s) aside:
for xf86config in /etc/X11/XF86Config-4 /etc/XF86Config-4 /usr/X11R6/lib/X11/XF86Config-4 $HOME/XF86Config-4 ; do
if [ -r $xf86config ]; then
mv $xf86config ${xf86config}.backup
fi
done
mv $HOME/XF86Config.new /etc/X11/XF86Config
# Okay now we edit the little bugger to make it more usable
xf86cfg -textmode
# I know this completely hoses the indentation of the XF86Config file, but
# really don't know a good way around that. Shoulda used perl. ;)
cat /etc/X11/XF86Config | while read LINE ; do
echo "$LINE" >> /etc/X11/XF86Config-4
if echo $LINE | grep Load | grep type1 1> /dev/null ; then
# X -configure is pretty broken... it leaves out the type1 and freetype
# modules. We'll work around this. BTW, it matters not if these appear
# multiple times, but matters A LOT if they don't appear at all.
# echo "Load \"type1\"" >> /etc/X11/XF86Config-4
echo "Load \"xtt\"" >> /etc/X11/XF86Config-4
fi
# lets add wheel mouse support won't hurt if no wheel
if echo $LINE | grep Option | grep Device | grep /dev/mouse 1> /dev/null ; then
echo "Option \"ZAxisMapping\" \"4 5\"" >> /etc/X11/XF86Config-4
fi
#All right no we add a couple more font paths and we are there
if echo $LINE | grep "/usr/X11R6/lib/X11/fonts/100dpi/" 1> /dev/null ; then
echo "FontPath \"/usr/X11R6/lib/X11/fonts/TTF/\"" >> /etc/X11/XF86Config-4
echo "FontPath \"/usr/X11R6/lib/X11/fonts/local/\"" >> /etc/X11/XF86Config-4
echo "FontPath \"/usr/share/fonts/local/\"" >> /etc/X11/XF86Config-4
fi
#now lets add some monitor stuff
if echo $LINE | grep Section |grep Monitor 1> /dev/null ; then
ddcprobe |grep "horizontal =" |sed 's%Timing ranges: horizontal =%HorizSync %' |sed 's%, vertical =% VertRefresh %' >> /etc/X11/XF86Config-4
fi
done
rm -f $HOME/XF86Config.new
rm -f /etc/X11/XF86Config
# make it so normal users can use this config file
echo "Section \"DRI\"" >> /etc/X11/XF86Config-4
echo " Mode 0666" >> /etc/X11/XF86Config-4
echo "EndSection" >> /etc/X11/XF86Config-4
dialog --title "XFree86 CONFIGURED" \
--msgbox "Your new XFree86 configuration file has been saved to /etc/X11/XF86Config-4. \
You may still need to add or adjust some values in the file to achieve the desired \
results. For complete information about \
making these adjustments, please refer to. \"man XF86Config\" I'll go on X server now." \
11 66
gdm |
|