Skip to content

Instantly share code, notes, and snippets.

@mawillcockson
Last active November 2, 2021 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mawillcockson/71b7bc345c07692a4b0c2b69507c7a6a to your computer and use it in GitHub Desktop.
Save mawillcockson/71b7bc345c07692a4b0c2b69507c7a6a to your computer and use it in GitHub Desktop.
Rygel installation and configuration
#!/bin/sh
set -eu
# # For testing in LXD, start user systemd daemon
# USERNAME="$(id -nu)"
# USER_ID="$(id -u)"
# sudo loginctl --no-ask-password enable-linger "${USERNAME}"
# sudo systemctl --no-ask-password restart "user@${USER_ID}.service"
#
# This was helpful for troubleshooting:
# https://stackoverflow.com/a/18366724
leave() {
if [ -n "${TMPFILE:+"set"}" ] ; then
rm -f "${TMPFILE}" || true
unset -v TMPFILE || true
fi
if [ -n "${TMPDIR:+"set"}" ] ; then
rm -rf "${TMPDIR}" || true
unset -v TMPDIR || true
fi
}
# trap leave EXIT
# package names for ubuntu focal (20.04)
RUNTIME_DEPENDENCIES="\
gstreamer1.0-tools \
curl \
gstreamer1.0-plugins-base \
shared-mime-info \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav"
BUILD_DEPENDENCIES="\
libges-1.0-dev \
libgtk-3-dev \
libunistring-dev \
libgupnp-1.2-dev \
libgupnp-av-1.0-dev \
libgstreamer1.0-dev \
glibc-source \
libgee-0.8-dev \
libsoup2.4-dev \
libmediaart-2.0-dev \
libsqlite3-dev \
libgupnp-dlna-2.0-dev \
python3-pip \
python3-venv \
ninja-build \
valac"
if ! { [ -e /usr/local/bin/rygel ] || which rygel ; } ; then
sudo apt update
sudo apt install --assume-yes --no-install-suggests \
${RUNTIME_DEPENDENCIES} \
${BUILD_DEPENDENCIES}
python3 -m pip install --user --upgrade pip setuptools wheel
python3 -m pip install --user --upgrade pipx
python3 -m pipx ensurepath
python3 -m pipx install meson || python3 -m pipx upgrade meson
PATH="${PATH:?}:${HOME:?}/.local/bin"
TMPDIR="$(mktemp -d)"
echo "TMPDIR=${TMPDIR}"
cd "${TMPDIR}"
curl -L "https://download.gnome.org/sources/rygel/0.40/rygel-0.40.2.tar.xz" -O
tar -xf rygel-*.tar.xz -C ./
rm rygel-*.tar.xz
cd rygel-*/
meson builddir
cd builddir
meson compile
meson test
sudo "$(which meson)" install
fi
# Write rygel configuration file
TMPFILE="$(mktemp)"
cat << EOF > "${TMPFILE}"
# Configuration file for Rygel
# From:
# https://gitlab.gnome.org/GNOME/rygel/-/blob/308c261caa36b2da8dc9d2de1256451ac3a3fab2/data/rygel.conf
# General configuration options
[general]
# Set to 'false' if you don't want Rygel to run on IPv6 addresses
# Whether or not IPv6 is supported depends on how GUPnP was configured
ipv6=true
# Set it to 'false' if you want to disable transcoding support.
enable-transcoding=false
# Where video files should be saved if allow-upload is true.
# Defaults to @VIDEOS@, the standard videos folder (typically ${HOME}/Videos).
video-upload-folder=@VIDEOS@
# Where music files should be saved if allow-upload is true
# Defaults to @MUSIC@, the standard music folder (typically ${HOME}/Music).
music-upload-folder=@MUSIC@
# Where picture files should be saved if allow-upload is true
# Defaults to @PICTURES@, the standard picture folder (typically ${HOME}/Pictures).
picture-upload-folder=@PICTURES@
# Default media engine to load. If not specified, the engine directory is
# searched recursively and the first engine found is loaded.
media-engine=librygel-media-engine-gst.so
# List of network interfaces to attach rygel to. You can also use network IP or
# even ESSID for wireless networks on Linux. Leave it blank for dynamic
# configuration.
interface=
# The port to run HTTP server on. 0 means dynamic.
port=8080
# Comma-separated list of domain:level pairs to specify log level thresholds for
# individual domains. domain could be either 'rygel', name of a plugin or '*'
# for all domains. Allowed levels are:
#
# 1=critical
# 2=error
# 3=warning
# 4=message/info
# 5=debug
log-level=*:5
# Allow upload of media files?
allow-upload=false
# Allow deletion of media folders and files?
allow-deletion=false
# Semicolon-separated list of device user-agents (or parts thereof) that need
# a downgrade in the UPnP device versions
# WARNING /!\: Only change this setting when told to do so or when you know
# what you're doing. If you find that adding your device makes it
# working with Rygel, please file a bug at
# https://gitlab.gnome.org/GNOME/rygel/issues/new/?issuable_template=IOP
# so we can include it in future releases.
#force-downgrade-for=Allegro-Software-WebClient;SEC_HHP;SEC HHP;Mediabolic-IMHTTP/1;TwoPlayer;Reciva;FDSSDP;Portable SDK for UPnP devices;Darwin
# Access controll fall-back policy if no access control provider could be
# found. Default is to true which will allow any peer to access anything.
acl-fallback-policy=true
# Plugin specific sections
#
# Some options are generic and some are specific to each plugin.
# The generic ones are:
#
# * enabled: As the name suggests, to enable or disable the plugin.
# * title: The title of the plugin to advertise to UPnP clients. This can
# contain the following automatically substituted keywords:
# * @REALNAME@: The real name of the user as returned by
# g_get_real_name() function of glib library.
# * @USERNAME@: The user name of the user as returned by
# g_get_user_name() function of glib library.
# * @HOSTNAME@: The host name of the machine rygel is running on, as
# returned by g_get_host_name() function of glib library.
#
# Options related to the used media backend.
# The options shown in this configuration file are specific to GStreamer.
[GstMediaEngine]
# List of active transcoders. To disable one, remove from list.
# transcoders=mp3;lpcm;mp2ts;wmv;aac;avc
transcoders=
# Options that apply to the renderer framework in general
[Renderer]
# Default showtime in seconds to use for images in playlists if dlna:lifetime
# is not set. DLNA wants something between 5 and 15 seconds.
image-timeout = 15
[Tracker3]
enabled=false
only-export-from=@MUSIC@;@VIDEOS@;@PICTURES@
share-pictures=true
share-videos=true
share-music=true
strict-sharing=false
title=@REALNAME@'s media on @PRETTY_HOSTNAME@
[Tracker]
enabled=false
only-export-from=@MUSIC@;@VIDEOS@;@PICTURES@
share-pictures=true
share-videos=true
share-music=true
strict-sharing=false
title=@REALNAME@'s media on @PRETTY_HOSTNAME@
[LMS]
enabled=false
title=@REALNAME@'s media on @PRETTY_HOSTNAME@
[MediaExport]
enabled=true
title=@REALNAME@'s media on @PRETTY_HOSTNAME@ MediaExport
# List of URIs to export. Following variables are automatically substituted by
# the appropriate XDG standard media folders by Rygel for you.
#
# * @MUSIC@: The standard music folder (typically ${HOME}/Music).
# * @VIDEOS@: The standard videos folder (typically ${HOME}/Videos).
# * @PICTURES@: The standard pictures folder (typically ${HOME}/Pictures).
#
uris=@MUSIC@;@VIDEOS@;@PICTURES@
extract-metadata=true
monitor-changes=true
monitor-grace-timeout=5
virtual-folders=true
[Playbin]
enabled=false
title=Audio/Video playback on @PRETTY_HOSTNAME@
#audio-sink=autoaudiosink
#video-sink=fakesink
[GstLaunch]
enabled=true
title=Test streams
launch-items=audiotestsrc;videotestsrc;videotestoverlay
audiotestsrc-title=Audio test
audiotestsrc-mime=audio/x-wav
audiotestsrc-launch=audiotestsrc ! wavenc
videotestsrc-title=Video test
videotestsrc-mime=video/mpeg
videotestsrc-launch=videotestsrc ! video/x-raw,width=640,height=480 ! avenc_mpeg2video ! mpegtsmux
videotestoverlay-title=Video+Audio test
videotestoverlay-mime=video/mpeg
videotestoverlay-launch=videotestsrc ! timeoverlay ! videoconvert ! theoraenc ! queue ! oggmux name=mux audiotestsrc ! audioconvert ! vorbisenc ! queue ! mux.
[Test]
enabled=false
[ExampleServerPluginVala]
enabled=false
[ExampleServerPluginC]
enabled=false
[ExampleRendererPluginVala]
enabled=false
[ExampleRendererPluginC]
enabled=false
[MPRIS]
enabled=false
[External]
enabled=false
[Ruih]
enabled=false
title=Rygel Remote UI Server
EOF
sudo cp "${TMPFILE}" /etc/rygel.conf
sudo chmod u=rw,go=r /etc/rygel.conf
if ! getent group rygel 2>&1 > /dev/null ; then
sudo groupadd \
--system \
rygel
fi
if ! getent passwd rygel 2>&1 > /dev/null ; then
# Create the rygel user
sudo useradd \
--create-home \
--system \
--gid rygel \
--shell /bin/bash \
rygel
fi
if { ! [ -f /etc/machine-info ] ; } || { . /etc/machine-info && [ -z "${PRETTY_HOSTNAME:-"unset"}" ] ; } ; then
# rygel fails to start if /etc/machine-info isn't populated, since it uses it
# to generate @PRETTY_HOSTNAME@
# hostnamctl populates /etc/machine-info
HOSTNAME="$(hostname -s)"
sudo hostnamectl --pretty set-hostname "${HOSTNAME:-"rygel"}"
fi
# Setup and enable the systemd service
sudo cp /usr/lib/systemd/user/rygel.service /etc/systemd/system/
sudo mkdir -p /etc/systemd/system/rygel.service.d
# Override the default ExecStart to use /etc/rygel.conf
cat << EOF > "${TMPFILE}"
[Service]
ExecStart=
ExecStart=/usr/bin/rygel \\
--config /etc/rygel.conf
ExecStop=/usr/bin/rygel --shutdown
Environment=G_MESSAGES_DEBUG=all
EOF
sudo cp "${TMPFILE}" /etc/systemd/system/rygel.service.d/override.conf
sudo chmod o=rw,go=r /etc/systemd/system/rygel.service.d/override.conf
sudo systemctl --no-ask-password daemon-reload
sudo systemctl --no-ask-password enable --now rygel
sudo systemctl restart rygel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment