Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Quick and dirty script to set up a terminal server with xfce

Who needs proprietary OSes and CALs to use a terminal server? Not this guy! Here's the guidelines I use when standing up a new terminal server with Xfce, because Gnome operates too slowly and is bloated. This is my file named el7ts201.txt.

# How to install terminal server

sudo su -
sed -i -r -e '/10\.200/s/^[^#]/#/;' -e '/^\&/s/^/#/;' /etc/rsyslog.conf
systemctl restart rsyslog

# install epel
# reference: https://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/
cd
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install epel-release-latest-7.noarch.rpm

# install xrdp
yum -y groupinstall xfce ; yum -y install xrdp tigervnc-server patch xfce4-whiskermenu-plugin ; yum -y remove gnome-session

# install fonts
yum -y install gnu-free-*-fonts open-sans-fonts libXfont xorg-x11-font*

tf=/usr/lib/firewalld/services/xrdp.xml
touch "${tf}" ; chmod 0644 "${tf}" ; restorecon "${tf}" ; chown root.root "${tf}"
cat <<'EOF' 1> "${tf}"
<?xml version="1.0" encoding="utf-8"?>
<service>
  <short>ms-wbt</short>
  <description>Terminal services</description>
  <port protocol="tcp" port="3389"/>
</service>
EOF
firewall-cmd --reload
firewall-cmd --add-service=xrdp --permanent
firewall-cmd --reload

##############################################
# add XFCE to the /etc/X11/xinit/Xclients file
tf=/etc/X11/xinit/Xclients
cp -p "${tf}" "${tf}.$( date "+%s" )"
cat <<'EOFXCLIENTS' 1> "${tf}"
#!/bin/bash

STARTXFCE="$(type -p startxfce4)"

# check to see if the user has a preferred desktop
PREFERRED=XFCE
exec "$STARTXFCE"

# We should also support /etc/X11/xinit/Xclients.d scripts
XCLIENTS_D=/etc/X11/xinit/Xclients.d
if [ "$#" -eq 1 ] && [ -x "$XCLIENTS_D/Xclients.$1.sh" ]; then
    exec -l $SHELL -c "$SSH_AGENT $XCLIENTS_D/Xclients.$1.sh"
fi

# Failsafe.

# these files are left sitting around by TheNextLevel.
rm -f $HOME/Xrootenv.0
EOFXCLIENTS

###############################################
systemctl enable xrdp xrdp-sesman
systemctl start xrdp xrdp-sesman

echo done

# Next steps
# apply valid ssl certificate

Comments