2012-03-20 16:46:24 +04:00
|
|
|
#!/bin/bash
|
2011-12-24 00:15:11 +04:00
|
|
|
|
2012-03-20 16:46:24 +04:00
|
|
|
PATH=/usr/local/sbin:/usr/local/bin:$PATH
|
2011-12-24 00:15:11 +04:00
|
|
|
|
2012-05-15 20:56:14 +04:00
|
|
|
TIMEOUT=8 # wait timeout for X server start
|
2011-12-24 00:15:11 +04:00
|
|
|
|
2012-03-20 16:46:24 +04:00
|
|
|
LOCK_FILE=/tmp/.snail.lock
|
|
|
|
FIFO_FILE=/tmp/.snail.fifo
|
2011-12-25 02:34:49 +04:00
|
|
|
|
2012-05-17 20:26:23 +04:00
|
|
|
[ ! -f $LOCK_FILE ] && echo "Snail daemon is not running. Please start it." && exit -1
|
2012-05-17 20:25:12 +04:00
|
|
|
|
2012-03-20 16:46:24 +04:00
|
|
|
{
|
2012-09-29 16:19:44 +04:00
|
|
|
flock -w 1 -s 9
|
2012-05-15 04:29:29 +04:00
|
|
|
if [ 0 -ne $? ]; then
|
|
|
|
(nohup echo -n > $FIFO_FILE &>/dev/null)&
|
|
|
|
flock -w $TIMEOUT -s 9
|
|
|
|
fi
|
2011-12-24 00:15:11 +04:00
|
|
|
|
2012-03-20 16:46:24 +04:00
|
|
|
if [ 0 -eq $? ]; then
|
2012-05-16 18:02:16 +04:00
|
|
|
echo "Trying to run $@ on nVidia"
|
2012-05-15 04:29:29 +04:00
|
|
|
export LD_LIBRARY_PATH=/usr/lib/snail
|
2012-05-15 17:10:04 +04:00
|
|
|
LD_PRELOAD="/usr/lib/snail/lib32/libGL.so.1 \
|
|
|
|
/usr/lib/snail/lib32/libnvidia-tls.so \
|
2012-05-15 17:02:25 +04:00
|
|
|
/usr/lib/snail/lib32/libnvidia-glcore.so" \
|
2012-05-16 18:02:16 +04:00
|
|
|
snail.vglrun -d :8293 "$@" 2>/dev/null \
|
2012-05-18 00:44:23 +04:00
|
|
|
&& echo "Application $@ was performed on nVidia ;-)" && exit 0
|
|
|
|
|
2012-05-18 00:56:48 +04:00
|
|
|
echo "nvrun $@ returns an error. Here is nVidia X-server error log:"
|
|
|
|
grep '] (EE) ' /var/log/Xorg.8293.log
|
2012-05-16 18:02:16 +04:00
|
|
|
|
|
|
|
else
|
|
|
|
echo "Timout received for 'power on' request to Snail-daemon ;-("
|
2012-03-20 16:46:24 +04:00
|
|
|
fi
|
2011-12-24 00:15:11 +04:00
|
|
|
|
2012-03-21 00:15:32 +04:00
|
|
|
flock -u 9
|
|
|
|
|
|
|
|
} 9>$LOCK_FILE
|