Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

remoteoffice.sh 1.4 KiB

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