You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

45 lines
1.4 KiB

  1. #!/bin/sh
  2. set -x
  3. # VPN
  4. NMCONN="49088a1e-18c2-48aa-a664-f212eb83a727"
  5. # RDP
  6. DEF_RESOLUTION="1920x1080"
  7. DRIVE="work,${HOME}/Documents/Work"
  8. DOMAIN="$(pass show Work/AD-LOGIN | awk '/domain:/ {print $2}')"
  9. USER="$(pass show Work/AD-LOGIN | awk '/user:/ {print $2}')"
  10. REMOTE="$(pass show Work/AD-LOGIN | awk '/remote:/ {print $2}')"
  11. PASSWORD="$(pass show Work/AD-LOGIN | head -1)"
  12. rdp() {
  13. # resolve REMOTE to IPv4 before connecting in order to avoid IPv6 usage
  14. REMOTE=$(dig ${REMOTE} A +short)
  15. # alternative to "dynamic-resolution" is "smart-sizing"
  16. if [ -z ${PASSWORD} ]; then
  17. PASWORD=$(zenity --entry --title="Password" \
  18. --text="Enter your _password:" --hide-text)
  19. fi
  20. xfreerdp /network:lan /gdi:hw +glyph-cache +fonts +aero \
  21. /bpp:32 /size:${DEF_RESOLUTION} /dynamic-resolution \
  22. /audio-mode:0 /sound:sys:pulse /microphone:sys:pulse \
  23. /kbd:German /drive:${DRIVE} \
  24. +auto-reconnect /auto-reconnect-max-retries:5 \
  25. /d:${DOMAIN} /u:${USER} /v:${REMOTE} /p:${PASSWORD}
  26. zenity --question --title="Disconnect?" \
  27. --text="RDP connection closed. Do you want to close the VPN connection too?" && \
  28. nmcli con down ${NMCONN}
  29. }
  30. if [ $(nmcli con show ${NMCONN} | awk '/GENERAL.STATE/ {print $2}') == "activated" ]; then
  31. rdp
  32. else
  33. nmcli --ask con up ${NMCONN}
  34. while [ $(nmcli con show ${NMCONN} | awk '/GENERAL.STATE/ {print $2}') != "activated" ]; do
  35. sleep 1
  36. done
  37. rdp
  38. fi