2012-03-23 19:56:14 +04:00
|
|
|
#!/bin/bash
|
2011-12-24 00:15:11 +04:00
|
|
|
|
2012-03-24 11:16:52 +04:00
|
|
|
echo "Test for nVidia driver"
|
|
|
|
lsmod | grep '^nvidia ' &>/dev/null
|
|
|
|
[ 0 -ne $? ] && snail.nv_pwr_on && modprobe nvidia ; snail.nv_pwr_off
|
|
|
|
if [ 0 -eq $? ]; then
|
|
|
|
echo "nVidia driver is OK! ;-)"
|
|
|
|
modprobe -r nvidia
|
|
|
|
else
|
|
|
|
echo "You must install standart nVidia driver first!"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2012-03-24 00:51:23 +04:00
|
|
|
echo "Test for acpi_call module..."
|
|
|
|
lsmod | grep '^acpi_call ' &>/dev/null
|
|
|
|
if [ 0 -eq $? ]; then
|
|
|
|
echo "acpi_call is OK! ;-)"
|
|
|
|
else
|
|
|
|
modprobe acpi_call && lsmod | grep '^acpi_call ' &>/dev/null
|
|
|
|
if [ 0 -eq $? ]; then
|
|
|
|
modprobe -rf acpi_call
|
|
|
|
echo "Please configure acpi_call module for autoloading on system start and try again!"
|
|
|
|
exit -1
|
|
|
|
else
|
|
|
|
echo "acpi_call kernel module not found, please install it!"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
fi
|
2011-12-24 00:15:11 +04:00
|
|
|
|
2012-03-24 00:51:23 +04:00
|
|
|
echo "Test for dmidecode utility..."
|
|
|
|
dmidecode &>/dev/null
|
|
|
|
if [ 0 -eq $? ]; then
|
|
|
|
echo "dmidecode utility is OK! ;-)"
|
|
|
|
else
|
|
|
|
echo "Please install dmidecode and run the script as root again."
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Detecting your distribution..."
|
|
|
|
DISTRIB_ID=
|
|
|
|
DISTRIB_DESCRIPTION=
|
|
|
|
DISTRIB_RELEASE=
|
|
|
|
DISTRIB_CODENAME=
|
|
|
|
if [ -f /etc/gentoo-release ]; then
|
|
|
|
DISTRIB_ID=gentoo
|
|
|
|
DISTRIB_DESCRIPTION=`cat /etc/gentoo-release`
|
|
|
|
DISTRIB_RELEASE=${DISTRIB_DESCRIPTION##* }
|
|
|
|
DISTRIB_CODENAME=gentoo
|
2012-04-01 21:22:09 +04:00
|
|
|
elif [ -f /etc/debian_version ]; then
|
2012-03-24 00:51:23 +04:00
|
|
|
DISTRIB_ID=debian
|
2012-04-01 21:22:09 +04:00
|
|
|
DISTRIB_RELEASE=`cat /etc/debian_version`
|
|
|
|
DISTRIB_DESCRIPTION=`cat /etc/issue.net`
|
2012-04-02 01:10:10 +04:00
|
|
|
DISTRIB_CODENAME=${DISTRIB_RELEASE%%/*}
|
2012-04-01 21:22:09 +04:00
|
|
|
elif [ -f /etc/slax_version ]; then
|
2012-03-24 00:51:23 +04:00
|
|
|
DISTRIB_ID=slax
|
2012-04-01 21:22:09 +04:00
|
|
|
DISTRIB_DESCRIPTION=`cat /etc/slax_version`
|
2012-03-24 00:51:23 +04:00
|
|
|
elif [ -f /etc/arch-release ]; then
|
|
|
|
DISTRIB_ID=arch
|
|
|
|
DISTRIB_DESCRIPTION=`cat /etc/arch-release`
|
2012-04-01 21:22:09 +04:00
|
|
|
elif [ -f /etc/slackware_version ]; then
|
2012-03-24 00:51:23 +04:00
|
|
|
DISTRIB_ID=slackware
|
2012-04-01 21:22:09 +04:00
|
|
|
DISTRIB_DESCRIPTION=`cat /etc/slackware_version`
|
2012-03-24 00:51:23 +04:00
|
|
|
elif [ `which lsb_release` ]; then
|
|
|
|
DISTRIB_ID=`lsb_release | grep '^Distributor' | sed 's~[^:]*:~~' | tr 'A-Z' 'a-z'`
|
|
|
|
DISTRIB_DESCRIPTION=`lsb_release | grep '^Description' | sed 's~[^:]*:~~'`
|
|
|
|
DISTRIB_RELEASE=`lsb_release | grep '^Release' | sed 's~[^:]*:~~'`
|
|
|
|
DISTRIB_CODENAME=`lsb_release | grep '^Codename' | sed 's~[^:]*:~~'`
|
|
|
|
elif [ -f /etc/os-release ]; then
|
|
|
|
DISTRIB_ID=`grep '^ID=' /etc/os-release | cut -d'=' -f2`
|
|
|
|
DISTRIB_DESCRIPTION=`grep '^PRETTY_NAME=' /etc/os-release | cut -d'=' -f2`
|
|
|
|
DISTRIB_RELEASE=`grep '^VERSION_ID=' /etc/os-release | cut -d'=' -f2`
|
|
|
|
DISTRIB_CODENAME=`grep '^NAME=' /etc/os-release | cut -d'=' -f2`
|
|
|
|
else
|
|
|
|
DISTRIB_DESCRIPTION=`cat /etc/*release* | head -n1`
|
|
|
|
DISTRIB_ID=`echo ${DISTRIB_DESCRIPTION%% *} | tr 'A-Z' 'a-z'`
|
|
|
|
DISTRIB_RELEASE=`echo ${DISTRIB_DESCRIPTION%% *} | sed 's~[^0-9]\+\([0-9\.]\+\).*~\1~'`
|
|
|
|
DISTRIB_CODENAME=$DISTRIB_ID
|
|
|
|
fi
|
|
|
|
[ "" == "$DISTRIB_ID" ] && echo 'GNU/Linux distribution not recognized, sorry! Please post a bug!' && exit -1
|
|
|
|
echo 'Detected distribution:'
|
|
|
|
echo "DISTRIB_ID=$DISTRIB_ID"
|
|
|
|
echo "DISTRIB_DESCRIPTION=$DISTRIB_DESCRIPTION"
|
|
|
|
echo "DISTRIB_RELEASE=$DISTRIB_RELEASE"
|
|
|
|
echo "DISTRIB_CODENAME=$DISTRIB_CODENAME"
|
|
|
|
|
2012-04-01 22:21:13 +04:00
|
|
|
echo "Copying system init scripts to /etc/init.d and start snail-watcher"
|
|
|
|
SNAIL_INIT_D_PATH=/usr/share/snail/init.d
|
|
|
|
case "$DISTRIB_ID" in
|
|
|
|
"gentoo")
|
|
|
|
cp -f $SNAIL_INIT_D_PATH/snail-watcher.openrc /etc/init.d/snail-watcher
|
|
|
|
cp -f $SNAIL_INIT_D_PATH/snail-xserver.openrc /etc/init.d/snail-xserver
|
|
|
|
eselect rc delete snail-xserver boot default
|
|
|
|
eselect rc delete snail-watcher boot
|
|
|
|
eselect rc add snail-watcher default
|
|
|
|
eselect rc stop snail-xserver
|
|
|
|
eselect rc restart snail-watcher
|
|
|
|
;;
|
|
|
|
|
|
|
|
"debian")
|
|
|
|
cp -f $SNAIL_INIT_D_PATH/snail-watcher.sysv /etc/init.d/snail-watcher
|
|
|
|
cp -f $SNAIL_INIT_D_PATH/snail-xserver.sysv /etc/init.d/snail-xserver
|
2012-04-02 01:10:10 +04:00
|
|
|
update-rc.d snail-xserver remove
|
2012-04-01 22:21:13 +04:00
|
|
|
update-rc.d snail-watcher defaults
|
2012-04-02 01:10:10 +04:00
|
|
|
/etc/init.d/snail-xserver stop
|
2012-04-01 22:21:13 +04:00
|
|
|
/etc/init.d/snail-watcher start
|
|
|
|
;;
|
|
|
|
|
|
|
|
"fedora")
|
|
|
|
echo ""
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "No rules for Your distribution. Please make a bug report."
|
|
|
|
exit -1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
echo "Configuring kernel modules and OpenGL libraries"
|
|
|
|
case "$DISTRIB_ID" in
|
|
|
|
"gentoo")
|
|
|
|
eselect opengl set xorg-x11
|
|
|
|
for arch in 32bit 64bit; do
|
|
|
|
for chip in i915 i965 r300 r600 sw; do
|
|
|
|
eselect mesa set $arch $chip classic &>/dev/null;
|
|
|
|
done;
|
|
|
|
done
|
2012-04-01 19:34:26 +04:00
|
|
|
ln -sf /usr/lib/opengl/nvidia/extensions /usr/lib/snail/extensions
|
|
|
|
ln -sf /usr/lib/opengl/nvidia/lib /usr/lib/snail/lib
|
|
|
|
ln -sf /usr/lib/xorg/modules /usr/lib/snail/modules
|
2012-04-01 22:21:13 +04:00
|
|
|
grep acpi_call /etc/conf.d/modules || echo 'modules="${modules} acpi_call' >> /etc/conf.d/modules
|
|
|
|
;;
|
|
|
|
|
|
|
|
"debian")
|
|
|
|
grep '^acpi_call$' /etc/modules || echo acpi_call >> /etc/modules
|
2012-04-02 01:10:10 +04:00
|
|
|
case "$DISTRIB_RELEASE" in
|
2012-04-02 23:30:15 +04:00
|
|
|
"6.0.4")
|
|
|
|
# nVidia driver installed from Debian repositories
|
|
|
|
if [ -f /usr/lib/nvidia/diversions/libGL.so.1 ]; then
|
|
|
|
ln -sf /usr/lib/xorg/modules/libfb.so /usr/lib/snail/libfb.so
|
|
|
|
ln -sf /usr/lib/xorg/modules/libwfb.so /usr/lib/snail/libwfb.so
|
|
|
|
ln -sf /usr/lib/xorg/modules/drivers/nvidia_drv.so /usr/lib/snail/nvidia_drv.so
|
|
|
|
|
|
|
|
# rm -f /usr/lib/xorg/modules/extensions/libglx.so
|
|
|
|
|
|
|
|
ln -sf /usr/lib/xorg/modules/extensions/libglx.so.[0-9][0-9]* /usr/lib/snail/libglx.so
|
|
|
|
ln -sf /usr/lib/libGL.so.[0-9][0-9]* /usr/lib/snail/libGL.so.1
|
|
|
|
|
|
|
|
# apt-get install --reinstall xserver-xorg-core
|
|
|
|
# rm -f /etc/alternatives/libGL.so.1
|
|
|
|
# ln -s /usr/lib/nvidia/diversions/libGL.so.1 /etc/alternatives
|
|
|
|
|
|
|
|
# nVidia driver was installed by NVIDIA-installer...run
|
|
|
|
else
|
|
|
|
ln -sf /usr/lib/xorg/modules/libfb.so /usr/lib/snail/libfb.so
|
|
|
|
ln -sf /usr/lib/xorg/modules/libwfb.so /usr/lib/snail/libwfb.so
|
|
|
|
ln -sf /usr/lib/xorg/modules/drivers/nvidia_drv.so /usr/lib/snail/nvidia_drv.so
|
|
|
|
ln -sf /usr/lib/xorg/modules/extensions/libglx.so.[0-9][0-9]* /usr/lib/snail/libglx.so
|
|
|
|
ln -sf /usr/lib/libGL.so.[0-9][0-9]* /usr/lib/snail/libGL.so.1
|
|
|
|
|
|
|
|
rm -f /usr/lib/libGL.so /usr/lib/libGL.so.1
|
|
|
|
mv -f /usr/lib/libGL.so.* /tmp
|
|
|
|
apt-get install --reinstall libgl1-mesa-glx
|
|
|
|
mv -f /tmp/libGL.so.* /usr/lib
|
|
|
|
fi
|
2012-04-02 01:10:10 +04:00
|
|
|
;;
|
|
|
|
|
|
|
|
"wheezy")
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "No rules for Your distribution. Please make a bug report."
|
|
|
|
exit -1
|
|
|
|
;;
|
2012-04-02 23:30:15 +04:00
|
|
|
esac
|
2012-04-01 22:21:13 +04:00
|
|
|
;;
|
|
|
|
|
|
|
|
"fedora")
|
|
|
|
echo ""
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "No rules for Your distribution. Please make a bug report."
|
|
|
|
exit -1
|
|
|
|
;;
|
|
|
|
esac
|
2012-03-24 00:51:23 +04:00
|
|
|
|
|
|
|
echo "Creating backups of original xorg.conf.* files and replacing with snail's versions..."
|
2011-12-24 00:15:11 +04:00
|
|
|
[[ -f /etc/X11/xorg.conf && ! -f /etc/X11/xorg.conf.snail-bkp ]] && mv /etc/X11/xorg.conf /etc/X11/xorg.conf.snail-bkp
|
|
|
|
[[ -f /etc/X11/xorg.conf.intel && ! -f /etc/X11/xorg.conf.intel.snail-bkp ]] && mv /etc/X11/xorg.conf.intel /etc/X11/xorg.conf.intel.snail-bkp
|
|
|
|
[[ -f /etc/X11/xorg.conf.nvidia && ! -f /etc/X11/xorg.conf.nvidia.snail-bkp ]] && mv /etc/X11/xorg.conf.nvidia /etc/X11/xorg.conf.nvidia.snail-bkp
|
|
|
|
cp -f /etc/X11/xorg.conf.intel.snail /etc/X11/xorg.conf.intel
|
|
|
|
cp -f /etc/X11/xorg.conf.nvidia.snail /etc/X11/xorg.conf.nvidia
|
|
|
|
ln -sf xorg.conf.intel /etc/X11/xorg.conf
|
|
|
|
|
2012-03-24 00:51:23 +04:00
|
|
|
echo "Recognizing BusID of both chips and set it in xorg.conf.* files..."
|
2011-12-24 00:15:11 +04:00
|
|
|
BusIDIntel="PCI:`lspci | grep VGA | grep Intel | cut -d" " -f1 | sed 's~\.~\:~g ; s~0\([0-9]\)~\1~g'`"
|
|
|
|
BusIDNvidia="PCI:`lspci | grep VGA | grep nVidia | cut -d" " -f1 | sed 's~\.~\:~g ; s~0\([0-9]\)~\1~g'`"
|
|
|
|
sed -i "s~BusIDIntel~$BusIDIntel~" /etc/X11/xorg.conf.intel
|
|
|
|
sed -i "s~BusIDNvidia~$BusIDNvidia~" /etc/X11/xorg.conf.nvidia
|
2012-03-24 00:51:23 +04:00
|
|
|
|
|
|
|
echo "`basename -- $0` is complete! ;-)"
|