-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathvps_kvm_screenshot.sh
executable file
·37 lines (37 loc) · 1.17 KB
/
vps_kvm_screenshot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
export PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin";
export base="$(readlink -f "$(dirname "$0")")";
display=$1;
url="$2&vnc=$1";
if [ $# -lt 1 ]; then
echo "Take Screenshot Of VNC Session";
echo " Grabs screenshot, saves as shot.jpg";
echo "Syntax $0 [display] [url]";
echo " ie $0 2 url.com";
else
rm -f shot1_$1.jpg;
function timer() {
sleep 40 && kill $$
}
if [ -e /usr/bin/timeout ]; then
timeout 30s ${base}/vncsnapshot -dieblank -compresslevel 9 \
-quality 100 -vncQuality 9 -allowblank -count 1 -fps 5 \
-quiet 127.0.0.1:$display shot1_$1.jpg >/dev/null 2>&1;
else
timer & timerpid=$!
${base}/vncsnapshot -dieblank -compresslevel 9 \
-quality 100 -vncQuality 9 -allowblank -count 1 -fps 5 \
-quiet 127.0.0.1:$display shot1_$1.jpg >/dev/null 2>&1;
fi;
if [ -e shot1_$1.jpg ]; then
convert shot1_$1.jpg -quality 75 shot_$1.gif;
rm -f shot1_$1.jpg;
if [ ! "$url" = "" ] && [ -e "shot_$1.gif" ]; then
curl --connect-timeout 60 --max-time 600 -k -F screenshot=@shot_$1.gif "$url" 2>/dev/null;
fi;
rm -f shot_$1.gif;
fi;
if [ ! -z "$timerpid" ]; then
kill "$timerpid";
fi;
fi;