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.
|
- #!/bin/sh
-
- set -x
-
- # VPN
- NMCONN="49088a1e-18c2-48aa-a664-f212eb83a727"
- # RDP
- DEF_RESOLUTION="1920x1080"
- DRIVE="`xdg-user-dir DOCUMENTS`/Work"
- DOMAIN="$(pass show Work/AD-LOGIN | awk '/domain:/ {print $2}')"
- USER="$(pass show Work/AD-LOGIN | awk '/user:/ {print $2}')"
- REMOTE="$(pass show Work/AD-LOGIN | awk '/remote:/ {print $2}')"
- PASSWORD="$(pass show Work/AD-LOGIN | head -1)"
-
- [[ ! -d "${DRIVE}" ]] && mkdir -p ${DRIVE}
-
- rdp() {
- # resolve REMOTE to IPv4 before connecting in order to avoid IPv6 usage
- REMOTE=$(dig ${REMOTE} A +short)
- if [ -z ${PASSWORD} ]; then
- PASWORD=$(zenity --entry --title="Password" \
- --text="Enter your _password:" --hide-text)
- fi
- # alternative to "dynamic-resolution" is "smart-sizing"
- xfreerdp /network:lan /gdi:hw /rfx +glyph-cache +fonts +aero \
- /bpp:32 /size:${DEF_RESOLUTION} /dynamic-resolution \
- /audio-mode:2 /sound:sys:pulse /microphone:sys:pulse \
- /kbd:German /drive:"`basename ${DRIVE}`,${DRIVE}" \
- +auto-reconnect /auto-reconnect-max-retries:5 \
- /d:${DOMAIN} /u:${USER} /v:${REMOTE} /p:${PASSWORD}
- zenity --question --title="Disconnect?" \
- --text="RDP connection closed. Do you want to close the VPN connection too?" && \
- nmcli con down ${NMCONN}
- }
-
-
- if [ $(nmcli con show ${NMCONN} | awk '/GENERAL.STATE/ {print $2}') == "activated" ]; then
- rdp
- else
- nmcli --ask con up ${NMCONN}
- while [ $(nmcli con show ${NMCONN} | awk '/GENERAL.STATE/ {print $2}') != "activated" ]; do
- sleep 1
- done
- sleep 3
- rdp
- fi
|