forked from shaba/openuds
391 lines
11 KiB
Bash
Executable File
391 lines
11 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
function clearParams {
|
|
mclient set $REGKEY/address ""
|
|
mclient set $REGKEY/username ""
|
|
mclient set $REGKEY/password ""
|
|
mclient set $REGKEY/domain ""
|
|
|
|
mclient set $REGKEY/authorizations/user/execution 0
|
|
|
|
mclient commit
|
|
}
|
|
|
|
function getRegKey {
|
|
# Get Template_UDS
|
|
for key in `mclient get root/ConnectionType/freerdp/connections | sed "s/dir //g"`; do
|
|
val=`mclient get $key/label | sed "s/value //g"`
|
|
if [ "$val" == "Template_UDS" ]; then
|
|
REGKEY=$key
|
|
fi
|
|
done
|
|
}
|
|
|
|
function createUDSConnectionTemplate {
|
|
TMPFILE=$(mktemp /tmp/udsexport.XXXXXX)
|
|
cat > $TMPFILE << EOF
|
|
<Profile>
|
|
<ProfileSettings>
|
|
<Name>UDS Template Profile</Name>
|
|
<RegistryRoot>root/ConnectionType/freerdp/connections/{ff064bd9-047a-45ec-b70f-04ab218186ff}</RegistryRoot>
|
|
<Target>
|
|
<Hardware>t420</Hardware>
|
|
<ImageId>T7X62022</ImageId>
|
|
<Version>6.2.0</Version>
|
|
<Config>standard</Config>
|
|
</Target>
|
|
</ProfileSettings>
|
|
<ProfileRegistry>
|
|
<NodeDir name="{ff064bd9-047a-45ec-b70f-04ab218186ff}">
|
|
<NodeDir name="rdWebFeed">
|
|
<NodeKey name="keepResourcesWindowOpened">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="autoStartSingleResource">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="autoDisconnectTimeout">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
</NodeDir>
|
|
<NodeDir name="loginfields">
|
|
<NodeKey name="username">
|
|
<NodeParam name="value">3</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="rememberme">
|
|
<NodeParam name="value">2</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="password">
|
|
<NodeParam name="value">3</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="domain">
|
|
<NodeParam name="value">3</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
</NodeDir>
|
|
<NodeDir name="authorizations">
|
|
<NodeDir name="user">
|
|
<NodeKey name="execution">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">string</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="edit">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">string</NodeParam>
|
|
</NodeKey>
|
|
</NodeDir>
|
|
</NodeDir>
|
|
<NodeKey name="address">
|
|
<NodeParam name="value"/>
|
|
<NodeParam name="type">string</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="username">
|
|
<NodeParam name="value"/>
|
|
<NodeParam name="type">string</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="password">
|
|
<NodeParam name="value">NLCR.1</NodeParam>
|
|
<NodeParam name="type">rc4</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="domain">
|
|
<NodeParam name="value"/>
|
|
<NodeParam name="type">string</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="label">
|
|
<NodeParam name="value">Template_UDS</NodeParam>
|
|
<NodeParam name="type">string</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="credentialsType">
|
|
<NodeParam name="value">password</NodeParam>
|
|
<NodeParam name="type">string</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="gatewayEnabled">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="gatewayPort">
|
|
<NodeParam name="value">443</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="gatewayUsesSameCredentials">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="gatewayCredentialsType">
|
|
<NodeParam name="value">password</NodeParam>
|
|
<NodeParam name="type">string</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="remoteDesktopService">
|
|
<NodeParam name="value">Remote Computer</NodeParam>
|
|
<NodeParam name="type">string</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="windowMode">
|
|
<NodeParam name="value">Remote Application</NodeParam>
|
|
<NodeParam name="type">string</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="seamlessWindow">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="windowType">
|
|
<NodeParam name="value">full</NodeParam>
|
|
<NodeParam name="type">string</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="windowSizePercentage">
|
|
<NodeParam name="value">70</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="windowSizeWidth">
|
|
<NodeParam name="value">1024</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="windowSizeHeight">
|
|
<NodeParam name="value">768</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="mouseMotionEvents">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="compression">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="rdpEncryption">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="offScreenBitmaps">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="attachToConsole">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="clipboardExtension">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="rdp6Buffering">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="rdpProgressiveCodec">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="securityLevel">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="tlsVersion">
|
|
<NodeParam name="value">auto</NodeParam>
|
|
<NodeParam name="type">string</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="sound">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="printerMapping">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="portMapping">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="usbStorageRedirection">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="localPartitionRedirection">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="scRedirection">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="usbMiscRedirection">
|
|
<NodeParam name="value">2</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="perfFlagNoWallpaper">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="perfFlagFontSmoothing">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="perfFlagDesktopComposition">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="perfFlagNoWindowDrag">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="perfFlagNoMenuAnimations">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="perfFlagNoTheming">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="timeoutsEnabled">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="timeoutWarning">
|
|
<NodeParam name="value">6000</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="timeoutWarningDialog">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="timeoutRecovery">
|
|
<NodeParam name="value">30000</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="timeoutError">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="showRDPDashboard">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="showConnectionGraph">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="x11Synchronous">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="x11Logging">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="x11LogAutoflush">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="x11Capture">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="SingleSignOn">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="autostart">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">number</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="waitForNetwork">
|
|
<NodeParam name="value">1</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="hasDesktopIcon">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
<NodeKey name="autoReconnect">
|
|
<NodeParam name="value">0</NodeParam>
|
|
<NodeParam name="type">bool</NodeParam>
|
|
</NodeKey>
|
|
</NodeDir>
|
|
</ProfileRegistry>
|
|
<ProfileFiles/>
|
|
</Profile>
|
|
EOF
|
|
mclient import $TMPFILE
|
|
rm $TMPFILE
|
|
}
|
|
|
|
ADDRESS=
|
|
USERNAME=
|
|
PASSWORD=
|
|
DOMAIN=
|
|
REGKEY=
|
|
CLEAR=0
|
|
|
|
# Try to locate registry key for UDS Template
|
|
getRegKey
|
|
|
|
if [ "$REGKEY" == "" ]; then
|
|
# Not found, create on based on our template
|
|
createUDSConnectionTemplate
|
|
getRegKey
|
|
fi
|
|
|
|
for param in $@; do
|
|
if [ "/u:" == "${param:0:3}" ]; then
|
|
USERNAME=${param:3}
|
|
CLEAR=1
|
|
fi
|
|
|
|
if [ "/p:" == "${param:0:3}" ]; then
|
|
PASSWORD=${param:3}
|
|
CLEAR=1
|
|
fi
|
|
|
|
if [ "/d:" == "${param:0:3}" ]; then
|
|
DOMAIN=${param:3}
|
|
CLEAR=1
|
|
fi
|
|
|
|
if [ "/v:" == "${param:0:3}" ]; then
|
|
ADDRESS=${param:3}
|
|
CLEAR=1
|
|
fi
|
|
done
|
|
|
|
if [ "$CLEAR" -eq 1 ]; then
|
|
clearParams
|
|
fi
|
|
|
|
ID=`basename $REGKEY`
|
|
RESPAWN=0
|
|
|
|
if [ "" != "$ADDRESS" ]; then
|
|
mclient set $REGKEY/address "${ADDRESS}"
|
|
RESPAWN=1
|
|
fi
|
|
|
|
if [ "" != "$USERNAME" ]; then
|
|
mclient set $REGKEY/username "${USERNAME}"
|
|
RESPAWN=1
|
|
fi
|
|
|
|
if [ "" != "$PASSWORD" ]; then
|
|
mclient set $REGKEY/password "${PASSWORD}"
|
|
RESPAWN=1
|
|
fi
|
|
|
|
if [ "" != "$DOMAIN" ]; then
|
|
mclient set $REGKEY/domain "${DOMAIN}"
|
|
RESPAWN=1
|
|
fi
|
|
|
|
if [ "$RESPAWN" -eq 1 ]; then
|
|
mclient set $REGKEY/authorizations/user/execution 1
|
|
mclient commit
|
|
exec $0 # Restart without command line
|
|
fi
|
|
|
|
process-connection $ID
|
|
|
|
clearParams
|