-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathautordp.sh
67 lines (51 loc) · 1.47 KB
/
autordp.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# This script will login to a users "normal" Windows
# PC if they are logged in elsewhere on the network
# gather credentials
clear
echo
echo "Sitewide hotdesk login"
echo ----------------------
unset ADUSERNAME
echo -n "Username: "
read ADUSERNAME
unset ADPASSWORD
prompt="Password: "
while IFS= read -p "$prompt" -r -s -n 1 char
do
if [[ $char == $'\0' ]]
then
break
fi
prompt='*'
ADPASSWORD+="$char"
done
# find IP for this users PC
cd /tmp
rm logincheck.txt 2> /dev/null
wget https://ServerWithDumpOfLogins/logincheck/logincheck.txt --http-user=logincheck --password=SecretPassword -q --ca-certificate=/location/of/your/enterprise/root/public/certificate.crt
USERSIP=$(grep $ADUSERNAME logincheck.txt | egrep -o -m 1 "\;[0-9].*$" | cut -c2-)
# if we can't find their PC throw an error
if [ -z "$USERSIP" ]
then
echo
echo No active workstation found!
echo You must be logged in to a Windows PC elsewhere.
echo "(press any key to retry)"
read -r -s -n 1 char
/home/hotdesk/autordp.sh
fi
# attempt to login to PC
echo
echo
sudo nice -n -15 xfreerdp /size:1920x1080 /network:broadband /u:$ADUSERNAME /p:$ADPASSWORD /d:PI /f /cert-ignore /v:$USERSIP
RDPERROR=$?
# Good connection, so start again
if [ 11 == $RDPERROR ] || [ 0 == $RDPERROR ]
then
/home/hotdesk/autordp.sh
fi
# Something went wrong, so stop and let people see the error
echo "(press any key to retry)"
read -r -s -n 1 char
/home/hotdesk/autordp.sh