Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

52 строки
1.5 KiB

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