120 lines
2.9 KiB
Bash
Executable File
120 lines
2.9 KiB
Bash
Executable File
#!/bin/bash -x
|
|
|
|
PASS="sudo docker-compose pull hass"
|
|
HOST=des-ddp.du.deakin.edu.au
|
|
IP=10.68.0.113
|
|
USERNAME=ddp
|
|
MAX_ATTEMPTS=20
|
|
xrandr | grep -q "VGA1 conn"
|
|
res=$?
|
|
|
|
export PATH=$PATH:/sbin:/usr/sbin:/opt/freerdp-nightly/bin/
|
|
|
|
if [ $# -ge 1 ]; then
|
|
if [ $# == 1 ]; then
|
|
if [ "x$1" = "x-f" ]; then
|
|
fs="/f";
|
|
else
|
|
IP=$1;
|
|
USERNAME=ddp_adm
|
|
fi
|
|
fi
|
|
if [ $# == 2 ]; then
|
|
if [ "x$1" = "x-f" ]; then
|
|
fs="/f";
|
|
IP=$2
|
|
USERNAME=ddp_adm
|
|
else
|
|
echo "Usage: $0 [-f] [host]"
|
|
fi
|
|
else
|
|
echo "Usage: $0 [-f] [host]"
|
|
fi
|
|
fi
|
|
|
|
|
|
echo $fs
|
|
|
|
vpn_running=0
|
|
|
|
cnt=1
|
|
while [ 1 == 5 ]; do
|
|
pgrep vpnui > /dev/null
|
|
if [ $? == 0 ]; then
|
|
host www.deakin.edu.au | grep -q global
|
|
if [ $? == 0 ]; then
|
|
vpn_str="the Cisco VPN process is running, and is working, just need priv access to kick in via NSX"
|
|
else
|
|
vpn_str="the Cisco VPN process is running, but does not seem to be working???"
|
|
fi
|
|
vpn_running=1
|
|
else
|
|
vpn_str="the Cisco VPN software is not even running, you sure you know
|
|
what you are doing :) ?"
|
|
fi
|
|
nmap -p 3389 $IP | grep open > /dev/null
|
|
|
|
if [ $? == 1 ]; then
|
|
if [ $vpn_running ]; then
|
|
echo "VPN is up, but port is not open yet, lets kick dcm timer now rather than wait for it"
|
|
sudo systemctl restart dcm-ip-association
|
|
else
|
|
echo "no VPN running, so not much chance of the port being open"
|
|
fi
|
|
else
|
|
# port is open, get on with running xfreerdp
|
|
break
|
|
fi
|
|
zenity --notification --timeout=4 --text="Port is not open.\n($vpn_str)\nis it too soon? (attempt $cnt)"
|
|
sleep 20
|
|
cnt=`expr $cnt + 1`
|
|
if [ $cnt -gt $MAX_ATTEMPTS ]; then
|
|
zenity --question --text="Tried $MAX_ATTEMPTS times.\nNoting that: $vpn_str\nDo you want to continue trying?"
|
|
if [ "$?" = "0" ]; then
|
|
cnt=1
|
|
else
|
|
exit 1
|
|
fi
|
|
fi
|
|
done
|
|
|
|
#hack
|
|
#xfreerdp -0 -x 0x180 --plugin cliprdr --plugin rdpsnd -d DU -u ddp -p $PASS -g 1880x1100 $IP
|
|
#exit 0
|
|
# hack
|
|
|
|
RES=`nvidia-settings -q currentmetamode 2>/dev/null | grep '@' | cut -f2 -d'@' | cut -f1 -d' '`
|
|
RES=`xwininfo -root | grep geom | cut -f4 -d' ' | sed -e 's/+0//g'`
|
|
|
|
echo "RES='${RES}'"
|
|
|
|
SIZE="/size:1024x768"
|
|
SCALE=""
|
|
if [ "x$RES" = "x5120x1440" ] || [ "x$RES" = "x2560x1440" ]; then
|
|
SIZE="/size:2480x1380"
|
|
SCALE="/scale:140"
|
|
elif [ "x$RES" = "x1920x1080" ]; then
|
|
SIZE="/size:1880x980"
|
|
elif [ "x$RES" = "x1920x1200" ]; then
|
|
SIZE="/size:1880x1100"
|
|
elif [ "x$RES" = "x2880x1800" ]; then
|
|
SIZE="/size:2600x1600"
|
|
elif [ "x$RES" = "x3440x1440" ]; then
|
|
SIZE="/size:2800x1400"
|
|
SCALE="/scale:140"
|
|
elif [ "x$RES" = "x3840x2160" ]; then
|
|
SIZE="/size:3072x1728"
|
|
SCALE="/scale:150"
|
|
else
|
|
zenity --error --text="outlook failed to work out your screen resolution. I think the macbook is '$RES_mb' and the monitor is '$RES_mon'"
|
|
SIZE="/size:1880x980"
|
|
fi
|
|
|
|
# hack for now, seems scale no longer works
|
|
SCALE=""
|
|
|
|
|
|
xfreerdp +clipboard /gdi:hw /sound:sys:pulse /aero /fonts /clipboard /sound /d:DU /u:$USERNAME "/p:$PASS" $SIZE /v:$IP $SCALE /microphone:sys:pulse +toggle-fullscreen $fs
|
|
|
|
#####
|