Skip to content

Commit

Permalink
Add audio support to rdesktop
Browse files Browse the repository at this point in the history
  • Loading branch information
gbraad committed Feb 1, 2025
1 parent c7c663e commit 8041a6b
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-diskimages-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ jobs:
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: 41
tag: latest
name: Latest disk images
body: ${{ env.BODY }}
artifacts: "output/bootiso/*.iso,./output/qcow2/*,"
artifacts: "output/bootiso/*.iso,./output/qcow2/*,"
12 changes: 12 additions & 0 deletions assets/generate-certs.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Generate certificates for rdesktop services
Before=kasnvncservice.service
Before=kclient.service

[Service]
Type=oneshot
ExecStart=/bin/bash -c 'if [ ! -f /opt/rdesktop/certificate.pem ]; then /etc/rdesktop/generate-certs.sh ; fi'

[Install]
WantedBy=kasmvncserver.service
WantedBy=kclient.service
10 changes: 10 additions & 0 deletions assets/generate-certs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

openssl req -new -x509 -days 3650 -nodes \
-out /etc/rdesktop/certificate.pem \
-keyout /etc/rdesktop/privatekey.key \
-subj "/C=NL/ST=none/L=none/O=SpotSnel/OU=RDesktop/CN=*"

chown :users /etc/rdesktop/certificate.pem /etc/rdesktop/privatekey.key
chmod g+r /etc/rdesktop/certificate.pem /etc/rdesktop/privatekey.key

22 changes: 22 additions & 0 deletions assets/kasmvnc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
network:
protocol: http
interface: 0.0.0.0
websocket_port: 8445
use_ipv4: true
use_ipv6: true
udp:
public_ip: auto
port: auto
stun_server: auto
ssl:
pem_certificate: /etc/rdesktop/certificate.pem
pem_key: /etc/rdesktop/privatekey.key
require_ssl: false

logging:
log_writer_name: all
log_dest: logfile
level: 1

command_line:
prompt: false
11 changes: 11 additions & 0 deletions assets/kclient.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=kclient wrapper

[Service]
Type=simple
User=gbraad
ExecStart=/usr/bin/env node /opt/kclient/index.js
Restart=on-failure

[Install]
WantedBy=multi-user.target
10 changes: 10 additions & 0 deletions assets/pulseaudio.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=PulseAudio system server

[Service]
Type=notify
ExecStart=pulseaudio --daemonize=no --system --realtime --log-target=journal
Restart=on-failure

[Install]
WantedBy=multi-user.target
5 changes: 5 additions & 0 deletions assets/rdesktop.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[rdesktop]
title = "KasmVNC Client"
exec = ""
fmhome = "/"
subfolder = "/"
6 changes: 6 additions & 0 deletions assets/rdesktopexec
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

CONFIG="/etc/rdesktop/rdesktop.ini"
alias rdesktopini="git config -f $CONFIG"

eval $(rdesktopini --get rdesktop.exec)
58 changes: 56 additions & 2 deletions containers/Containerfile-rdesktop
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
ARG BASE_IMAGE="ghcr.io/gbraad-devenv/fedora/systemd"
ARG BASE_VERSION="41"

FROM ${BASE_IMAGE}:${BASE_VERSION} as kclient-build

RUN dnf install -y \
"@development-tools" \
gcc-c++ \
nodejs \
nodejs-devel \
pulseaudio-libs-devel

RUN cd /opt \
&& git clone https://github.com/gbraad-devenv/kclient \
&& cd kclient \
&& npm install .


FROM ${BASE_IMAGE}:${BASE_VERSION}

LABEL org.opencontainers.image.source = "https://github.com/gbraad-devenv/fedora"

# audio support
RUN dnf install -y \
pulseaudio \
alsa-plugins-pulseaudio \
&& dnf clean all \
&& rm -rf /var/cache/yum

# graphical
RUN dnf install -y \
novnc \
Expand All @@ -25,27 +47,59 @@ RUN dnf install -y \
&& dnf clean all \
&& rm -rf /var/cache/yum

# kasmvnc
RUN dnf install -y https://github.com/spotsnel/AltRPMS-KasmVNC/releases/download/1.3.3/kasmvncserver-1.3.3-1.fc41.x86_64.rpm \
&& dnf clean all \
&& rm -rf /var/cache/yum \
&& usermod -a -G kasmvnc-cert gbraad

COPY assets/kasmvncserver.service /etc/systemd/system
COPY assets/kasmvnc.yaml /etc/kasmvnc/

COPY assets/pulseaudio.service /etc/systemd/system

RUN usermod -aG pulse-access gbraad \
&& mkdir -p /etc/rdesktop

COPY assets/rdesktop.ini /etc/rdesktop/rdesktop.ini
COPY assets/rdesktopexec /usr/bin

RUN chown :users /etc/rdesktop/rdesktop.ini \
&& chmod g+w /etc/rdesktop/rdesktop.ini \
&& chown :users /etc/rdesktop \
&& chmod g+w /etc/rdesktop

RUN dnf install -y \
nodejs \
&& dnf clean all \
&& rm -rf /var/cache/yum

COPY --from=kclient-build /opt/kclient /opt/kclient
COPY assets/kclient.service /etc/systemd/system

# Userspace does not expose 100.100.100.100
#RUN sed -i 's/^FLAGS=".*"/FLAGS="--tun=userspace-networking"/' /etc/default/tailscaled

COPY assets/generate-certs.service /etc/systemd/system
COPY assets/generate-certs.sh /etc/rdesktop

USER gbraad

RUN mkdir -p ~/.vnc \
&& echo $'#!/bin/sh\ni3 &' > ~/.vnc/xstartup \
&& chmod +x ~/.vnc/xstartup \
&& /bin/bash -c "echo -e 'password\npassword\n\n' | kasmvncpasswd -u gbraad -w" \
&& touch ~/.vnc/.de-was-selected
&& touch ~/.vnc/.de-was-selected

# systemd is already set up in systemd image; make sure to use root
USER root

RUN systemctl enable kasmvncserver
RUN systemctl enable kasmvncserver \
&& systemctl enable pulseaudio \
&& systemctl enable kclient \
&& systemctl enable generate-certs \
&& git config -f /etc/rdesktop/rdesktop.ini rdesktop.title "devenv rdesktop" \
&& git config -f /etc/rdesktop/rdesktop.ini rdesktop.exec "i3-sensible-terminal"

#ENTRYPOINT ["/sbin/init"]

0 comments on commit 8041a6b

Please sign in to comment.