Skip to content

Commit a4465da

Browse files
author
Yutaro-B18016
committed
Add openSUSE install script
1 parent a1028d3 commit a4465da

6 files changed

Lines changed: 265 additions & 0 deletions

File tree

suse/opensuse/leap/15.2/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Script to enable XRDP on openSUSE Tumbleweed
2+
3+
## Info
4+
5+
- Designed to be idempotent, you can run it repeatedly
6+
- Installs required packages
7+
- Configures XRDP ini files
8+
- Will compile selinux module in case SELinux is installed on machine (it doesn't need to be enabled though)
9+
- support changing session to KDE Plasma
10+
11+
## Run
12+
13+
- If using GNOME
14+
15+
```sh
16+
sudo sh install.sh
17+
```
18+
19+
- If using KDE
20+
21+
```sh
22+
sudo sh install.sh --kde
23+
```
24+
25+
If using different DE
26+
27+
Looks like xrdp on openSUSE leap 15.2 supports below DEs by default
28+
29+
```sh
30+
sudo sed -i_orig -e 's/SESSION=".*"/SESSION="sle"/g' /etc/xrdp/startwm.sh # set to 'SLE classic'
31+
sudo sed -i_orig -e 's/SESSION=".*"/SESSION="gnome"/g' /etc/xrdp/startwm.sh # set to 'GNOME'
32+
sudo sed -i_orig -e 's/SESSION=".*"/SESSION="plasma"/g' /etc/xrdp/startwm.sh # set to 'KDE'
33+
sudo sed -i_orig -e 's/SESSION=".*"/SESSION="icewm"/g' /etc/xrdp/startwm.sh # set to 'IceWM'
34+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module allow-vsock 1.0;
2+
3+
require {
4+
type unconfined_service_t;
5+
type unlabeled_t;
6+
class vsock_socket { getattr read write };
7+
}
8+
9+
#============= unconfined_service_t ==============
10+
allow unconfined_service_t unlabeled_t:vsock_socket { getattr read write };

suse/opensuse/leap/15.2/install.sh

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/bin/bash
2+
3+
#
4+
# This script is for openSUSE Tumbleweed Linux to configure XRDP for enhanced session mode
5+
#
6+
# The confioguration is adapted from the Arch script.
7+
#
8+
9+
# Set desktop environment, used later to change SESSION="*****" in /etc/xrdp/starwm.sh
10+
desktop_env=gnome
11+
# Change to kde if --kde passed
12+
if [ $# -gt 0 ] && [ $1 = "--kde" ]; then
13+
desktop_env=plasma
14+
fi
15+
16+
###############################################################
17+
# Install XRDP
18+
#
19+
if [ "$(id -u)" -ne 0 ]; then
20+
echo 'This script must be run with root privileges' >&2
21+
exit 1
22+
fi
23+
24+
# Use rpm -q to check for exact package name, install if missing
25+
if ! rpm -q xrdp 2>&1 > /dev/null ; then
26+
echo 'Refreshing repo cache'
27+
zypper refresh
28+
echo 'Installing missing xrdp package using zypper'
29+
zypper -n install xrdp
30+
fi
31+
32+
###############################################################
33+
# Configure XRDP
34+
#
35+
systemctl enable xrdp
36+
systemctl enable xrdp-sesman
37+
38+
XRDP_INI_FILE=/etc/xrdp/xrdp.ini
39+
XRDP_INI_BAK_FILE=$XRDP_INI_FILE.enh_sess_orig.bak
40+
# Create backup of original XRDP ini file
41+
if [ ! -f "$XRDP_INI_BAK_FILE" ]; then
42+
cp $XRDP_INI_FILE $XRDP_INI_BAK_FILE
43+
echo "Original config file saved in $XRDP_INI_BAK_FILE"
44+
fi
45+
# Configure the installed XRDP ini files
46+
# use vsock transport
47+
sed -i_orig -e 's/port=3389/port=vsock:\/\/-1:3389/g' $XRDP_INI_FILE
48+
# use rdp security
49+
sed -i_orig -e 's/security_layer=negotiate/security_layer=rdp/g' $XRDP_INI_FILE
50+
# remove encryption validation
51+
sed -i_orig -e 's/crypt_level=high/crypt_level=none/g' $XRDP_INI_FILE
52+
# disable bitmap compression since its local its much faster
53+
sed -i_orig -e 's/bitmap_compression=true/bitmap_compression=false/g' $XRDP_INI_FILE
54+
#
55+
# sed -n -e 's/max_bpp=32/max_bpp=24/g' $XRDP_INI_FILE
56+
57+
XRDP_SESMAN_INI_FILE=/etc/xrdp/sesman.ini
58+
# use the default lightdm x display
59+
sed -i_orig -e 's/X11DisplayOffset=10/X11DisplayOffset=0/g' $XRDP_SESMAN_INI_FILE
60+
# rename the redirected drives to 'shared-drives'
61+
sed -i_orig -e 's/FuseMountName=thinclient_drives/FuseMountName=shared-drives/g' $XRDP_SESMAN_INI_FILE
62+
63+
# adjust startwm.sh (this is needed only in Leap, not needed in Tumbleweed)
64+
if [ "$(grep -e 'SESSION=".*"' /etc/xrdp/startwm.sh)" ]; then
65+
sed -i_orig -e "s/SESSION=\".*\"/SESSION=\"$desktop_env\"/g" /etc/xrdp/startwm.sh
66+
echo "Changed session to '${desktop_env^^}'"
67+
fi
68+
69+
# Change the allowed_users
70+
echo "allowed_users=anybody" > /etc/X11/Xwrapper.config
71+
72+
# Ensure hv_sock gets loaded
73+
if [ ! -e /etc/modules-load.d/hv_sock.conf ]; then
74+
echo "hv_sock" > /etc/modules-load.d/hv_sock.conf
75+
fi
76+
77+
# Configure the policy xrdp session
78+
cat > /etc/polkit-1/rules.d/02-allow-colord.rules <<EOF
79+
polkit.addRule(function(action, subject) {
80+
if ((action.id == "org.freedesktop.color-manager.create-device" ||
81+
action.id == "org.freedesktop.color-manager.modify-profile" ||
82+
action.id == "org.freedesktop.color-manager.delete-device" ||
83+
action.id == "org.freedesktop.color-manager.create-profile" ||
84+
action.id == "org.freedesktop.color-manager.modify-profile" ||
85+
action.id == "org.freedesktop.color-manager.delete-profile") &&
86+
subject.isInGroup("users"))
87+
{
88+
return polkit.Result.YES;
89+
}
90+
});
91+
EOF
92+
93+
# Compile selinux module IF selinux is installed
94+
if rpm -q selinux 2>&1 > /dev/null ; then
95+
checkmodule -M -m -o allow-vsock.mod allow-vsock.te
96+
semodule_package -o allow-vsock.pp -m allow-vsock.mod
97+
# Install the selinux module!
98+
semodule -i allow-vsock.pp
99+
fi
100+
101+
###############################################################################
102+
103+
echo "####### Configuration Done #######"
104+
echo "Next to do"
105+
echo "Shutdown this VM"
106+
echo "On your host machine in an Administrator powershell prompt, execute this command: "
107+
echo " Set-VM -VMName <your_vm_name> -EnhancedSessionTransportType HvSocket"
108+
echo "Start this VM, and you will see Enhanced mode available!"

suse/opensuse/tumbleweed/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Script to enable XRDP on openSUSE Tumbleweed
2+
3+
## Info
4+
5+
- Designed to be idempotent, you can run it repeatedly
6+
- Installs required packages
7+
- Configures XRDP ini files
8+
- Will compile selinux module in case SELinux is installed on machine (it doesn't need to be enabled though)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module allow-vsock 1.0;
2+
3+
require {
4+
type unconfined_service_t;
5+
type unlabeled_t;
6+
class vsock_socket { getattr read write };
7+
}
8+
9+
#============= unconfined_service_t ==============
10+
allow unconfined_service_t unlabeled_t:vsock_socket { getattr read write };
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/bash
2+
3+
#
4+
# This script is for openSUSE Tumbleweed Linux to configure XRDP for enhanced session mode
5+
#
6+
# The confioguration is adapted from the Arch script.
7+
#
8+
9+
###############################################################
10+
# Install XRDP
11+
#
12+
if [ "$(id -u)" -ne 0 ]; then
13+
echo 'This script must be run with root privileges' >&2
14+
exit 1
15+
fi
16+
17+
# Use rpm -q to check for exact package name, install if missing
18+
if ! rpm -q xrdp 2>&1 > /dev/null ; then
19+
echo 'Refreshing repo cache'
20+
zypper refresh
21+
echo 'Installing missing xrdp package using zypper'
22+
zypper -n install xrdp
23+
fi
24+
25+
###############################################################
26+
# Configure XRDP
27+
#
28+
systemctl enable xrdp
29+
systemctl enable xrdp-sesman
30+
31+
XRDP_INI_FILE=/etc/xrdp/xrdp.ini
32+
XRDP_INI_BAK_FILE=$XRDP_INI_FILE.enh_sess_orig.bak
33+
# Create backup of original XRDP ini file
34+
if [ ! -f "$XRDP_INI_BAK_FILE" ]; then
35+
cp $XRDP_INI_FILE $XRDP_INI_BAK_FILE
36+
echo "Original config file saved in $XRDP_INI_BAK_FILE"
37+
fi
38+
# Configure the installed XRDP ini files
39+
# use vsock transport
40+
sed -i_orig -e 's/port=3389/port=vsock:\/\/-1:3389/g' $XRDP_INI_FILE
41+
# use rdp security
42+
sed -i_orig -e 's/security_layer=negotiate/security_layer=rdp/g' $XRDP_INI_FILE
43+
# remove encryption validation
44+
sed -i_orig -e 's/crypt_level=high/crypt_level=none/g' $XRDP_INI_FILE
45+
# disable bitmap compression since its local its much faster
46+
sed -i_orig -e 's/bitmap_compression=true/bitmap_compression=false/g' $XRDP_INI_FILE
47+
#
48+
# sed -n -e 's/max_bpp=32/max_bpp=24/g' $XRDP_INI_FILE
49+
50+
XRDP_SESMAN_INI_FILE=/etc/xrdp/sesman.ini
51+
# use the default lightdm x display
52+
#sed -i_orig -e 's/X11DisplayOffset=200/X11DisplayOffset=0/g' $XRDP_SESMAN_INI_FILE
53+
# rename the redirected drives to 'shared-drives'
54+
sed -i_orig -e 's/FuseMountName=thinclient_drives/FuseMountName=shared-drives/g' $XRDP_SESMAN_INI_FILE
55+
56+
# Change the allowed_users
57+
echo "allowed_users=anybody" > /etc/X11/Xwrapper.config
58+
59+
# Ensure hv_sock gets loaded
60+
if [ ! -e /etc/modules-load.d/hv_sock.conf ]; then
61+
echo "hv_sock" > /etc/modules-load.d/hv_sock.conf
62+
fi
63+
64+
# Configure the policy xrdp session
65+
cat > /etc/polkit-1/rules.d/02-allow-colord.rules <<EOF
66+
polkit.addRule(function(action, subject) {
67+
if ((action.id == "org.freedesktop.color-manager.create-device" ||
68+
action.id == "org.freedesktop.color-manager.modify-profile" ||
69+
action.id == "org.freedesktop.color-manager.delete-device" ||
70+
action.id == "org.freedesktop.color-manager.create-profile" ||
71+
action.id == "org.freedesktop.color-manager.modify-profile" ||
72+
action.id == "org.freedesktop.color-manager.delete-profile") &&
73+
subject.isInGroup("users"))
74+
{
75+
return polkit.Result.YES;
76+
}
77+
});
78+
EOF
79+
80+
# Compile selinux module IF selinux is installed
81+
if rpm -q selinux 2>&1 > /dev/null ; then
82+
checkmodule -M -m -o allow-vsock.mod allow-vsock.te
83+
semodule_package -o allow-vsock.pp -m allow-vsock.mod
84+
# Install the selinux module!
85+
semodule -i allow-vsock.pp
86+
fi
87+
88+
###############################################################################
89+
90+
echo "####### Configuration Done #######"
91+
echo "Next to do"
92+
echo "Shutdown this VM"
93+
echo "On your host machine in an Administrator powershell prompt, execute this command: "
94+
echo " Set-VM -VMName <your_vm_name> -EnhancedSessionTransportType HvSocket"
95+
echo "Start this VM, and you will see Enhanced mode available!"

0 commit comments

Comments
 (0)