|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# |
| 4 | +# This script is for Kubuntu 20.04 Focal Fossa to download and install XRDP+XORGXRDP via |
| 5 | +# source. |
| 6 | +# |
| 7 | +# Major thanks to: http://c-nergy.be/blog/?p=11336 for the tips. |
| 8 | +# |
| 9 | + |
| 10 | +############################################################################### |
| 11 | +# Use HWE kernel packages |
| 12 | +# |
| 13 | +HWE="" |
| 14 | +#HWE="-hwe-20.04" |
| 15 | + |
| 16 | +############################################################################### |
| 17 | +# Update our machine to the latest code if we need to. |
| 18 | +# |
| 19 | + |
| 20 | +if [ "$(id -u)" -ne 0 ]; then |
| 21 | + echo 'This script must be run with root privileges' >&2 |
| 22 | + exit 1 |
| 23 | +fi |
| 24 | + |
| 25 | +apt update && apt upgrade -y |
| 26 | + |
| 27 | +if [ -f /var/run/reboot-required ]; then |
| 28 | + echo "A reboot is required in order to proceed with the install." >&2 |
| 29 | + echo "Please reboot and re-run this script to finish the install." >&2 |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | + |
| 33 | +############################################################################### |
| 34 | +# XRDP |
| 35 | +# |
| 36 | + |
| 37 | +# Install hv_kvp utils |
| 38 | +apt install -y linux-tools-virtual${HWE} |
| 39 | +apt install -y linux-cloud-tools-virtual${HWE} |
| 40 | + |
| 41 | +# Install the xrdp service so we have the auto start behavior |
| 42 | +apt install -y xrdp |
| 43 | + |
| 44 | +systemctl stop xrdp |
| 45 | +systemctl stop xrdp-sesman |
| 46 | + |
| 47 | +# Configure the installed XRDP ini files. |
| 48 | +# do not use vsock transport since newer versions of xrdp do not support it. |
| 49 | +sed -i_orig -e 's/port=3389/port=vsock:\/\/-1:3389/g' /etc/xrdp/xrdp.ini |
| 50 | +# use rdp security. |
| 51 | +sed -i_orig -e 's/security_layer=negotiate/security_layer=rdp/g' /etc/xrdp/xrdp.ini |
| 52 | +# remove encryption validation. |
| 53 | +sed -i_orig -e 's/crypt_level=high/crypt_level=none/g' /etc/xrdp/xrdp.ini |
| 54 | +# disable bitmap compression since its local its much faster |
| 55 | +sed -i_orig -e 's/bitmap_compression=true/bitmap_compression=false/g' /etc/xrdp/xrdp.ini |
| 56 | + |
| 57 | +# Add script to setup the kubuntu session properly |
| 58 | +if [ ! -e /etc/xrdp/startkubuntu.sh ]; then |
| 59 | +cat >> /etc/xrdp/startkubuntu.sh << EOF |
| 60 | +#!/bin/sh |
| 61 | +export XDG_CURRENT_DESKTOP=KDE |
| 62 | +export XDG_SESSION_DESKTOP=KDE |
| 63 | +export XDG_DATA_DIRS=/usr/share/plasma:/usr/local/share:/usr/share:/var/lib/snapd/desktop |
| 64 | +export XDG_CONFIG_DIRS=/etc/xdg/xdg-plasma:/etc/xdg:/usr/share/kubuntu-default-settings/kf5-settings |
| 65 | +exec /etc/xrdp/startwm.sh |
| 66 | +EOF |
| 67 | +chmod a+x /etc/xrdp/startkubuntu.sh |
| 68 | +fi |
| 69 | + |
| 70 | +# use the script to setup the kubuntu session |
| 71 | +sed -i_orig -e 's/startwm/startkubuntu/g' /etc/xrdp/sesman.ini |
| 72 | + |
| 73 | +# rename the redirected drives to 'shared-drives' |
| 74 | +sed -i -e 's/FuseMountName=thinclient_drives/FuseMountName=shared-drives/g' /etc/xrdp/sesman.ini |
| 75 | + |
| 76 | +# Changed the allowed_users |
| 77 | +sed -i_orig -e 's/allowed_users=console/allowed_users=anybody/g' /etc/X11/Xwrapper.config |
| 78 | + |
| 79 | +# Blacklist the vmw module |
| 80 | +if [ ! -e /etc/modprobe.d/blacklist_vmw_vsock_vmci_transport.conf ]; then |
| 81 | +cat >> /etc/modprobe.d/blacklist_vmw_vsock_vmci_transport.conf <<EOF |
| 82 | +blacklist vmw_vsock_vmci_transport |
| 83 | +EOF |
| 84 | +fi |
| 85 | + |
| 86 | +# Ensure hv_sock gets loaded |
| 87 | +if [ ! -e /etc/modules-load.d/hv_sock.conf ]; then |
| 88 | +echo "hv_sock" > /etc/modules-load.d/hv_sock.conf |
| 89 | +fi |
| 90 | + |
| 91 | +# Retrieve all available polkit actions and separate them accordingly |
| 92 | +pkaction > /tmp/available_actions |
| 93 | +actions=$(sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/;/g' /tmp/available_actions) |
| 94 | +rm /tmp/available_actions |
| 95 | + |
| 96 | +# Configure the policies for xrdp session |
| 97 | +cat > /etc/polkit-1/localauthority/50-local.d/xrdp-allow-all.pkla <<EOF |
| 98 | +[Allow all for all sudoers] |
| 99 | +Identity=unix-group:sudo |
| 100 | +Action=$actions |
| 101 | +ResultAny=yes |
| 102 | +ResultInactive=yes |
| 103 | +ResultActive=yes |
| 104 | +EOF |
| 105 | + |
| 106 | +# reconfigure the service |
| 107 | +systemctl daemon-reload |
| 108 | +systemctl start xrdp |
| 109 | + |
| 110 | +# |
| 111 | +# End XRDP |
| 112 | +############################################################################### |
| 113 | + |
| 114 | +echo "Install is complete." |
| 115 | +echo "Reboot your machine to begin using XRDP." |
0 commit comments