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`
|
|
|
|
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
|
|
|
|
update-rc.d snail-watcher defaults
|
|
|
|
/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
|
|
|
|
rm -f /usr/lib64/xorg/modules/extensions/libglx.so
|
|
|
|
ln -sf /usr/lib64/xorg/modules/extensions/libglx.so.* /usr/lib64/snail/modules/extensions/libglx.so
|
|
|
|
apt-get install --reinstall xserver-xorg-core
|
|
|
|
if [ -f /usr/lib64/nvidia/diversions/libGL.so.1 ]; then
|
|
|
|
rm -f /etc/alternatives/libGL.so.1
|
|
|
|
ln -s /usr/lib64/nvidia/diversions/libGL.so.1 /etc/alternatives
|
|
|
|
else
|
|
|
|
rm -f /usr/lib64/libGL.so /usr/lib64/libGL.so.1
|
|
|
|
ln -sf libGL.so.1 /usr/lib64/snail/libGL.so
|
|
|
|
ln -sf /usr/lib64/libGL.so.* /usr/lib64/snail/libGL.so.1
|
|
|
|
mv -f /usr/lib64/libGL.so.* /tmp
|
|
|
|
apt-get install --reinstall libgl1-mesa-glx
|
|
|
|
mv -f /tmp/libGL.so.* /usr/lib64
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
"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! ;-)"
|