mirror of
https://github.com/winapps-org/winapps.git
synced 2025-08-12 05:25:15 +02:00
Initial commit.
This commit is contained in:
72
bin/winapps
Executable file
72
bin/winapps
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Install windows in KVM
|
||||
# Use the user "User"
|
||||
# Name the machine "RDPWindows" in "About"
|
||||
# Allow remote desktop
|
||||
#
|
||||
# virsh autostart RDPWindows
|
||||
# For 20.04:
|
||||
# sudo ln -s /etc/apparmor.d/usr.sbin.libvirtd /etc/apparmor.d/disable/
|
||||
|
||||
# Windows Registry Editor Version 5.00
|
||||
|
||||
# [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Terminal Server\TSAppAllowList]
|
||||
# "fDisabledAllowList"=dword:00000001
|
||||
|
||||
# [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]
|
||||
# "LimitBlankPasswordUse"=dword:00000000
|
||||
|
||||
DIR="$(dirname "$(readlink -f "$0")")"
|
||||
|
||||
if [ -f /tmp/winapps ]; then
|
||||
LAST_RAN=$(stat -t -c %Y /tmp/winapps)
|
||||
touch /tmp/winapps
|
||||
THIS_RUN=$(stat -t -c %Y /tmp/winapps)
|
||||
if (( $THIS_RUN - $LAST_RAN < 2 )); then
|
||||
exit
|
||||
fi
|
||||
else
|
||||
touch /tmp/winapps
|
||||
fi
|
||||
|
||||
if [ -z "$(which xfreerdp)" ]; then
|
||||
echo "You need xfreerdp!"
|
||||
echo " sudo apt-get install -y freerdp2-x11"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -f "${HOME}/.winapps" ]; then
|
||||
echo "You need to create a ~/.winapps configuration. Exiting..."
|
||||
exit
|
||||
fi
|
||||
|
||||
. "${HOME}/.winapps"
|
||||
|
||||
if [ -z "${RDP_IP}" ]; then
|
||||
if [ -z "$(groups |grep libvirt)" ]; then
|
||||
echo "You are not a member of the libvirt group. Run the below then reboot."
|
||||
echo ' sudo usermod -a -G libvirt $(whoami)'
|
||||
echo ' sudo usermod -a -G kvm $(whoami)'
|
||||
exit
|
||||
fi
|
||||
if [ -z "$(virsh list |grep RDPWindows)" ]; then
|
||||
echo "RDPWindows is not running, run:"
|
||||
echo " virsh start RDPWindows"
|
||||
exit
|
||||
fi
|
||||
RDP_IP=$(virsh net-dhcp-leases default |grep RDPWindows |awk '{print $5}')
|
||||
RDP_IP=${RDP_IP%%\/*}
|
||||
fi
|
||||
|
||||
if [ "${1}" = "windows" ]; then
|
||||
xfreerdp /u:"${RDP_USER}" /p:"${RDP_PASS}" /v:${RDP_IP} /dynamic-resolution +auto-reconnect +home-drive /wm-class:"Microsoft Windows" 1> /dev/null 2>&1 &
|
||||
elif [ "${1}" != "install" ]; then
|
||||
. "${DIR}/../apps/${1}/info"
|
||||
if [ -n "${2}" ]; then
|
||||
FILE=$(echo "${2}" | sed 's|'"${HOME}"'|\\\\tsclient\\home|;s|/|\\|g;s|\\|\\\\|g')
|
||||
xfreerdp /u:"${RDP_USER}" /p:"${RDP_PASS}" /v:${RDP_IP} +auto-reconnect +home-drive -wallpaper /span /wm-class:"${FULL_NAME}" /app:"${WIN_EXECUTABLE}" /app-icon:"${DIR}/../apps/${1}/icon.svg" /app-cmd:"\"${FILE}\"" 1> /dev/null 2>&1 &
|
||||
else
|
||||
xfreerdp /u:"${RDP_USER}" /p:"${RDP_PASS}" /v:${RDP_IP} +auto-reconnect +home-drive -wallpaper /span /wm-class:"${FULL_NAME}" /app:"${WIN_EXECUTABLE}" /app-icon:"${DIR}/../apps/${1}/icon.svg" 1> /dev/null 2>&1 &
|
||||
fi
|
||||
fi
|
Reference in New Issue
Block a user