Dateien nach „/“ hochladen
Script to connect to a free remote admin using freerdp
This commit is contained in:
commit
5d781baedc
1 changed files with 73 additions and 0 deletions
73
remote-admin.sh
Normal file
73
remote-admin.sh
Normal file
|
@ -0,0 +1,73 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script checks for the next free remote-admin pc and established a RDP session using xfreerdp to it.
|
||||
# To use this script you need to create two files in your home directory
|
||||
#
|
||||
# .smbcredentials
|
||||
# username=YOUR AD USERNAME
|
||||
# password=YOUR AD PASSWORD
|
||||
#
|
||||
# .remote-admin
|
||||
# USERNAME=administrator@zfd.forumzfd.de
|
||||
# PASSWORD=AD ADMIN PASSWORD FROM BITWARDEN
|
||||
#
|
||||
# Make sure to proper chmod them (e.g. chmod 600)
|
||||
#
|
||||
# Add the following line to your /etc/fstab and edit YOUR_USERNAME
|
||||
#
|
||||
# //remote-admin1/Ampel /tmp/remote-ampel cifs credentials=/home/YOUR_USERNAME/.smbcredentials,user,noauto,workgroup=ZFD,dir_mode=0777,file_mode=0777,_netdev 0 0
|
||||
#
|
||||
# setuid might be necessary on /usr/sbin/mount.cifs. Set it as root with
|
||||
#
|
||||
# chmod u+s /usr/sbin/mount.cifs
|
||||
|
||||
AMPEL_MOUNT=/tmp/remote-ampel
|
||||
AMPEL_SHARE=//remote-admin1/Ampel
|
||||
|
||||
if [ -f ~/.remote-admin ]; then
|
||||
source ~/.remote-admin
|
||||
else
|
||||
echo ".remote-admin not found! Please create it!"
|
||||
exit 4
|
||||
fi
|
||||
if [ ! -f ~/.smbcredentials ]; then
|
||||
echo ".smbcredentials not found! Please create it!"
|
||||
exit 5
|
||||
fi
|
||||
# Check for xfreerdp
|
||||
if [ ! -f /usr/bin/xfreerdp ]; then
|
||||
print "xfreerdp not found. Make sure it is installed"
|
||||
exit 1
|
||||
else # check for the mount point
|
||||
mkdir -p $AMPEL_MOUNT
|
||||
if grep -qs $AMPEL_MOUNT /proc/mounts; then
|
||||
echo "$AMPEL_MOUNT already mounted."
|
||||
else
|
||||
echo "Trying to mount $AMPEL_MOUNT"
|
||||
mount $AMPEL_MOUNT
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Mount successful."
|
||||
else
|
||||
echo "Mount failed. Check share"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
sleep 2
|
||||
# Take the first free remote-admin computer and connect to it.
|
||||
if [ -f $AMPEL_MOUNT/REMOTE-ADMIN1-FREE.txt ]; then
|
||||
echo 'REMOTE-ADMIN1 is FREE'
|
||||
xfreerdp /u:$USERNAME /p:$PASSWORD /v:remote-admin1.zfd.forumzfd.de /gfx:avc444 /dynamic-resolution
|
||||
elif [ -f $AMPEL_MOUNT/REMOTE-ADMIN2-FREE.txt ]; then
|
||||
echo 'REMOTE-ADMIN2 is FREE'
|
||||
xfreerdp /u:$USERNAME /p:$PASSWORD /v:remote-admin2.zfd.forumzfd.de /gfx:avc444 /dynamic-resolution
|
||||
elif [ -f $AMPEL_MOUNT/REMOTE-ADMIN3-FREE.txt ]; then
|
||||
echo 'REMOTE-ADMIN3 is FREE'
|
||||
xfreerdp /u:$USERNAME /p:$PASSWORD /v:remote-admin3.zfd.forumzfd.de /gfx:avc444 /dynamic-resolution
|
||||
else
|
||||
echo 'NO REMOTE-ADMIN FREE. Try again later'
|
||||
umount $AMPEL_MOUNT
|
||||
exit 3
|
||||
fi
|
||||
umount $AMPEL_MOUNT
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue