Skip to content

Instantly share code, notes, and snippets.

@Higgs1
Last active October 5, 2020 16:09
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 Higgs1/03ca835f238b1fde1f7648eb4649d409 to your computer and use it in GitHub Desktop.
Save Higgs1/03ca835f238b1fde1f7648eb4649d409 to your computer and use it in GitHub Desktop.
Various OpenSUSE guides

Execute for each repo you wish to add by URL:

sudo zypper -n ar -f <URL or path of repo file>

This command will error (with code 4) if an identical repository has already been added to the system.

sudo a2enmod <name of apache module>
dotnet --info | sed -n 's/^ RID: *//p'
  1. Determine your OpenSUSE distro slug, and assign it to the 'DISTRO' variable. If you're using tumbleweed for example, you should set it to 'openSUSE_Tumbleweed'. Other possible values are 'openSUSE_Leap_15.2' or 'SLE_15_SP2', etc. I should make a small script to automatically detect this...

    declare DISTRO='openSUSE_Tumbleweed'
    
  2. Add the following RPM repo, where $DISTRO is the distro slug you determined above:

  3. Install the following system packages:

    • 0ad
  1. Determine your OpenSUSE distro slug, and assign it to the 'DISTRO' variable. If you're using tumbleweed for example, you should set it to 'openSUSE_Tumbleweed'. Other possible values are 'openSUSE_Leap_15.2' or 'SLE_15_SP2', etc. I should make a small script to automatically detect this...

    declare DISTRO='openSUSE_Tumbleweed'
    
  2. Add the following RPM repo, where $DISTRO is the distro slug you determined above:

  3. Install the following system packages:

    • apache2-event
  4. Then, you'll probably want to start and enable apache

    sudo systemctl enable --now apache2
    
  1. Have Apache installed
  2. Have Jellyfin installed. The Jellyfin server need not be on the same server as Apache.
  3. Have these Apache modules enabled:
    • rewrite
    • proxy
    • proxy_http
    • proxy_wstunnel
  4. Choose how to serve the website. Jellyfin works at almost any address. Following are some examples

Jellyfin in a subdirectory

With this method, Jellyfin will be served in any subdirectory you desire. For example, if you choose /jellyfin then Jellyfin will be accessible at http://yourdomain.net/jellyfin. You can even choose / if you wish. Change localhost:8096/ to the path to your Jellyfin if necessary (when it's on another server, for example).

  1. Choose a web path and assign it to the JELLYFIN_PATH variable.
    declare JELLYFIN_PATH=/jellyfin
  2. Write the Apache site config
    sudo tee "/etc/apache2/conf.d/jellyfin-web.conf" > /dev/null << EOF
    ProxyPreserveHost On
    
    RewriteEngine On
    RewriteRule "^${JELLYFIN_PATH}/socket" "ws://localhost:8096/socket" [P,L]
    
    RewriteEngine On
    RewriteRule "^${JELLYFIN_PATH}$" "${JELLYFIN_PATH}/web/" [R]
    RewriteRule "^${JELLYFIN_PATH}/web/$" "${JELLYFIN_PATH}/web/index.html"
    RewriteRule "^${JELLYFIN_PATH}/(.*)$" "http://localhost:8096/$1" [P,L]
    ProxyPassReverse "${JELLYFIN_PATH}/" "/"
    EOF
  3. Reload Apache and have fun :D
    systemctl reload-or-restart apache2

Jellyfin in a virtual host

TODO

  1. Have the following RPM repo installed:

  2. Have the appropiate .NET SDK installed. At the time of writing, Jellyfin requires .NET 3.1 or later.

  3. Have the following system packages installed:

    • ffmpeg-4
    • git-core
    • libfdk-aac2
    • jq
    • yarn
  4. Choose the version of Jellyfin you wish to install. Either obtain the version number from the github repo, or run the following command to see a list of what's available:

    curl -s https://api.github.com/repos/jellyfin/jellyfin/tags | jq -rc .[].name

    Assign your choice to the "JELLYFIN_VER" variable. As of the time of writing, "v10.6.1" is a good version to choose.

    declare JELLYFIN_VER=v10.6.1
  5. Designate an account for use as the Jellyfin service account. This user may be root, but for numerous reasons that is not recommended. Let's assign the username to the "JELLYFIN_USER" variable.

    declare JELLYFIN_USER=jellyfin

    Make sure the account exists with the following command. TODO: convert to systemd-sysusers

    sudo useradd -r "$JELLYFIN_USER" 2> /dev/null
  6. Allocate several directories for different Jellyfin components to use. "JELLYFIN_INSTALL_DIR" is where the compiled Jellyfin binaries will be installed to. The other directories are explained more in depth on the Jellyfin docs, but the following paths should be pretty good for everything in a typical Linux installation. See the FHS Spec for the reasoning behind these if you're so inclined.

    declare JELLYFIN_INSTALL_DIR=/opt/jellyfin
    declare JELLYFIN_DATA_DIR=/usr/local/share/jellyfin
    declare JELLYFIN_CONFIG_DIR=/etc/opt/jellyfin
    declare JELLYFIN_CACHE_DIR=/var/cache/jellyfin
    declare JELLYFIN_LOG_DIR=/var/log/jellyfin
    declare JELLYFIN_WEB_DIR=/srv/www/jellyfin-web

    Note: remembering these values is essential for modifying the build at a later time, such as when updating or installing plugins from source.

    Make sure the data, config, cache, and web directories exist with the following command:

    sudo install -d -m 0700 -o "$JELLYFIN_USER"   \
      "$JELLYFIN_DATA_DIR" "$JELLYFIN_CONFIG_DIR" \
      "$JELLYFIN_CACHE_DIR" "$JELLYFIN_LOG_DIR"   \
      "$JELLYFIN_WEB_DIR"
  7. Download, compile, and install Jellyfin using the following code:

    time (
      set -e
      pushd "$(mktemp -d)" > /dev/null
      trap "rm -rf \"$(pwd)\"" EXIT
      git -c advice.detachedHead=false clone --depth 1 -b "$JELLYFIN_VER" \
        https://github.com/jellyfin/jellyfin.git .
      DOTNET_CLI_TELEMETRY_OPTOUT=1 DOTNET_NOLOGO=1 \
        dotnet build Jellyfin.Server       \
        -p:Configuration=Release           \
        -p:DebugSymbols=false              \
        -p:DebugType=None                  \
        -p:Deterministic=true              \
        -p:GenerateDocumentationFile=false \
        -p:Optimize=true                   \
        -p:OutDir="$JELLYFIN_INSTALL_DIR"  \
        -p:NoWarn=8767                     \
        -p:UseAppHost=false
      cd "$JELLYFIN_INSTALL_DIR"
      shopt -s extglob
      sudo rm !(jellyfin.@(runtimeconfig|deps)).json
      sudo chmod +x jellyfin.dll
    )
  8. Install the Jellyfin SystemD unit

    sudo tee "/etc/systemd/system/jellyfin.service" > /dev/null << EOF
    [Unit]
    Description=Jellyfin Media Server
    After=network.target
    
    [Service]
    Environment=JELLYFIN_CACHE_DIR=${JELLYFIN_CACHE_DIR}
    Environment=JELLYFIN_CONFIG_DIR=${JELLYFIN_CONFIG_DIR}
    Environment=JELLYFIN_DATA_DIR=${JELLYFIN_DATA_DIR}
    Environment=JELLYFIN_LOG_DIR=${JELLYFIN_LOG_DIR}
    Environment=JELLYFIN_WEB_DIR=${JELLYFIN_WEB_DIR}
    ExecStart=${JELLYFIN_INSTALL_DIR}/jellyfin.dll --service
    Group=nogroup
    LockPersonality=yes
    NoNewPrivileges=yes
    PrivateTmp=yes
    ProtectControlGroups=yes
    ProtectClock=yes
    #ProtectHome=no #required for key storage
    ProtectKernelLogs=yes
    ProtectKernelTunables=yes
    Restart=on-failure
    RestrictNamespaces=yes
    RestrictSUIDSGID=yes
    SuccessExitStatus=143
    User=${JELLYFIN_USER}
    
    [Install]
    WantedBy=multi-user.target
    EOF
    
    sudo systemctl daemon-reload
  9. Make Jellyfin logging more sensible. This will let SystemD take care of the logging for you.

    sudo tee "$JELLYFIN_CONFIG_DIR/logging.json" > /dev/null << EOF
    {
      "Serilog": {
        "MinimumLevel": {
          "Default": "Information",
          "Override": {
            "Microsoft": "Warning",
            "System": "Warning"
          }
        },
        "WriteTo":[
          {
            "Name": "Console",
            "Args": {
              "outputTemplate": "[{Level:u3}] {SourceContext}: {Message:lj}{NewLine}{Exception}"
            }
          }, {
            "Name": "File"
          }
        ],
        "Enrich": ["FromLogContext"]
      }
    } 
    EOF
  10. Download, compile, and install the Jellyfin web interface using the following code

    time (
      set -e
      pushd "$(mktemp -d)" > /dev/null
      trap "rm -rf \"$(pwd)\"" EXIT
      git -c advice.detachedHead=false clone --depth 1 -b "$JELLYFIN_VER" \
        https://github.com/jellyfin/jellyfin-web.git .
      yarn install --pure-lockfile
      sudo mv dist/* "$JELLYFIN_WEB_DIR"
      sudo chown -R $JELLYFIN_USER:nogroup "$JELLYFIN_WEB_DIR"
    )
  11. Enable and start the new Jellyfin service

    sudo systemctl enable --now jellyfin
  12. Create the first administrator account. Before you can start using Jellyfin, an initial administrator account must be created. Additional user accounts may be created afterwards. Choose the desired username and password for this account, and assign them to the JELLYFIN_USERNAME and JELLYFIN_PASSWORD variables, respectively.

    declare JELLYFIN_USERNAME='admin'
    declare JELLYFIN_PASSWORD='<s00p3r s3cr1t pa55!>'

    Then, run the following commands to create the account in Jellyfin and finish the installation.

    curl 'http://127.1:8096/Startup/User'
    curl 'http://127.1:8096/Startup/User' \
      --form-string "Name=$JELLYFIN_USERNAME" \
      --form-string "Password=$JELLYFIN_PASSWORD"
    curl 'http://127.1:8096/Startup/Complete' -d ''

Always refresh all repos before installing new software.

sudo zypper -n in <list of package names>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment