Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

38 righe
1.2 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. rdp() {
  12. # resolve REMOTE to IPv4 before connecting in order to avoid IPv6 usage
  13. REMOTE=$(dig ${REMOTE} A +short)
  14. # alternative to "dynamic-resolution" is "smart-sizing"
  15. xfreerdp /network:lan /gdi:hw +glyph-cache +fonts +aero \
  16. /bpp:32 /size:${DEF_RESOLUTION} /dynamic-resolution \
  17. /audio-mode:0 /sound:sys:pulse /microphone:sys:pulse \
  18. /kbd:German /drive:${DRIVE} \
  19. +auto-reconnect /auto-reconnect-max-retries:5 \
  20. /d:${DOMAIN} /u:${USER} /v:${REMOTE} /p:$(zenity --entry \
  21. --title="Password" --text="Enter your _password:" --hide-text)
  22. zenity --question --title="Disconnect?" \
  23. --text="RDP connection closed. Do you want to close the VPN connection too?" && \
  24. nmcli con down ${NMCONN}
  25. }
  26. if [ $(nmcli con show ${NMCONN} | awk '/GENERAL.STATE/ {print $2}') == "activated" ]; then
  27. rdp
  28. else
  29. nmcli --ask con up ${NMCONN} &
  30. rdp
  31. fi