#!/usr/bin/env bash # This script will install JRiver Media Center and associated services # on Fedora, CentOS, Debian, and Ubuntu # Copyright (c) 2021 Bryan C. Roessler # This software is released under the Apache License. # https://www.apache.org/licenses/LICENSE-2.0 # # Use installJRMC --help to see available options or # read printHelp() below. # # TODO # 1. Raspberry Pi OS support # 2. Interactive installation (ncurses?) # 3. Additional containerization (createrepo and rpmbuild) # 4. Tests # # BUGS # 1. SUSE probably broken # 2. No createrepo on Mint shopt -s extglob SCRIPTVERSION="1.0b6" OUTPUTDIR="$PWD/output" CREATEREPO_WEBROOT="/var/www/jriver" EXEC_USER=$(whoami) SERVICEDIR="/usr/lib/systemd/system" # MC version # MCVERSION="28.0.87" # to set manually, if unset use automatic latest check printHelp() { debug "Running: ${FUNCNAME[0]}" cat <<- 'EOF' USAGE: installJRMC [[OPTION] [VALUE]]... If no options (besides -d) are provided, the script will default to '--install repo'. OPTIONS --install, -i repo|rpm repo: Install MC from repository, updates are handled by the system package manager rpm: Build and install RPM locally (RPM-based distros only) --build [TARGET DISTRO] Build RPM from source DEB but do not install. Optional parameter allows cross-building RPMs (ex. 'suse', 'fedora', 'centos'). --mcversion VERSION Specify the MC version, ex. "28.0.25" (Default: latest version) --outputdir PATH Generate rpmbuild output in this directory (Default: $PWD/output) --restorefile RESTOREFILE Restore file location for automatic license registration (Default: skip registration) --betapass PASSWORD Enter beta team password for access to beta builds --service, -s SERVICE See SERVICES section below for a list of possible services to install --service-user USER Install systemd services and containers for user USER (Default: current user) --container, -c CONTAINER (TODO: Under construction) See CONTAINERS section below for a list of possible services to install --createrepo Build rpm, copy to webroot, and run createrepo --createrepo-webroot PATH The webroot directory to install the repo (Default: /var/www/jriver) --createrepo-user USER The web server user (Default: current user) --createrepo-suse Override OS detection and run --createrepo with SUSE RPM --compat Build/install RPM without minimum version specifiers --version, -v Print this script version and exit --debug, -d Print debug output --help, -h Print help dialog and exit --uninstall, -u Uninstall JRiver MC, cleanup service files, and remove firewall rules (does not remove library files) SERVICES jriver-mediaserver Enable and start a mediaserver systemd service (requires an existing X server) jriver-mediacenter Enable and start a mediacenter systemd service (requires an existing X server) jriver-x11vnc Enable and start x11vnc for the local desktop (requires an existing X server) Usually combined with jriver-mediaserver or jriver-mediacenter services --vncpass and --display are optional (see below) jriver-xvnc Enable and start a new Xvnc session running JRiver Media Center --vncpass PASSWORD Set vnc password for x11vnc/Xvnc access. If no password is set, the script will either use existing password stored in ~/.vnc/jrmc_passwd or use no password --display DISPLAY Display to start x11vnc/Xvnc (Default: The current display (x11vnc) or the current display incremented by 1 (Xvnc)) jriver-createrepo Install hourly service to build latest MC RPM and run createrepo CONTAINERS (TODO: Under construction) mediacenter-xvnc createrepo EOF } init() { debug "Running: ${FUNCNAME[0]}" declare _version_source declare -g SERVICE_USER CREATEREPO_USER MCVERSION MVERSION getOS # Make sure universe repo is installed on Ubuntu if [[ "$ID" == "ubuntu" ]]; then if ! grep ^deb /etc/apt/sources.list|grep -q universe; then ifSudo add-apt-repository universe fi fi # Agnostic commands bash_cmd(){ ifSudo bash -c "$@"; } rm_cmd(){ ifSudo rm -rf "$@"; } cp_cmd(){ ifSudo cp -n -f "$@"; } mkdir_cmd(){ ifSudo mkdir -p "$@"; } ln_cmd(){ ifSudo ln -s "$@"; } systemctl_reload(){ ifSudo systemctl daemon-reload; } systemctl_enable(){ ifSudo systemctl enable --now "$@"; } systemctl_disable(){ ifSudo systemctl disable --now "$@"; } # OS-specific commands if [[ "$ID" =~ ^(fedora|centos)$ ]]; then pkg_install(){ ifSudo dnf install -y "$@"; } pkg_remove(){ ifSudo dnf remove -y "$@"; } pkg_update(){ ifSudo dnf makecache; } pkg_query(){ rpm -q "$@"; } firewall_cmd(){ ifSudo firewall-cmd "$@"; } elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then pkg_install(){ ifSudo apt-get install -y -q0 "$@"; } pkg_remove(){ ifSudo apt-get remove --auto-remove -y -q0 "$@"; } pkg_update(){ ifSudo apt-get update -y -q0; } pkg_query(){ dpkg -s "$@"; } firewall_cmd(){ ifSudo ufw "$@"; } elif [[ "$ID" =~ ^opensuse.* ]]; then pkg_install(){ ifSudo zypper --non-interactive -q install --force --no-confirm "$@"; } pkg_remove(){ ifSudo zypper --non-interactive -q remove --clean-deps "$@"; } pkg_update(){ ifSudo zypper --non-interactive -q refresh jriver; } pkg_query(){ rpm -q "$@"; } firewall_cmd(){ ifSudo firewall-cmd "$@"; } fi parseInput "$@" SERVICE_USER="${SERVICE_USER:-$EXEC_USER}" CREATEREPO_USER="${CREATEREPO_USER:-$EXEC_USER}" # Select MC version to work with if [[ -v MCVERSION ]]; then _version_source="user input" else getLatestVersion fi [[ ! "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]] && err "Invalid version number" && exit 1 echo "Using MC version $MCVERSION determined by $_version_source" [[ "$_version_source" != "user input" ]] && echo "To override, use --MCVERSION" # Extract major version number MVERSION="${MCVERSION%%.*}" # Saving this substituion in case it's needed in the future # _variation="${MCVERSION##*.}" } askOk() { declare _response read -r -p "$* [y/N]" _response _response=${_response,,} [[ ! "$_response" =~ ^(yes|y)$ ]] && return 1 return 0 } debug() { if [[ -v _debug ]]; then if [[ $# -gt 0 ]]; then echo "Debug: $*" fi else return 1 fi } err() { echo "Error: $*" >&2; } getOS() { debug "Running: ${FUNCNAME[0]}" if [[ -e "/etc/os-release" ]]; then source "/etc/os-release" else err "/etc/os-release not found" err "Your OS is unsupported" printHelp && exit 1 fi debug "Platform: $ID $VERSION_ID" } ifSudo() { declare _user="root" if [[ $# == 0 ]]; then [[ "$EXEC_USER" == "root" ]]; return $? elif [[ $# -eq 2 && "$1" == "-u" ]]; then _user="$2" [[ "$EXEC_USER" == "$_user" ]]; return $? elif [[ $# -gt 2 && "$1" == "-u" ]]; then _user="$2" shift 2 fi if [[ "$_user" == "$EXEC_USER" ]]; then "$@" else sudo -u "$_user" "$@" fi } parseInput() { debug "Running: ${FUNCNAME[0]}" if [[ $# -eq 0 ]] || [[ $# -eq 1 && "$1" =~ ^(--debug|-d)$ ]]; then debug "No options passed, defaulting to repo installation method" INSTALL_TYPE="repo" fi if _input=$(getopt -o +i:vdhus:c: -l install:,build::,outputdir:,mcversion:,restorefile:,betapass:,service-user:,service:,version,debug,help,uninstall,createrepo,createrepo-suse,createrepo-webroot:,createrepo-user:,vncpass:,display:,container:,tests,compat -- "$@"); then eval set -- "$_input" while true; do case "$1" in --install|-i) shift INSTALL_TYPE="$1" if [[ "$INSTALL_TYPE" == "rpm" ]]; then if [[ ! "$ID" =~ ^(fedora|centos|opensuse.*)$ ]]; then err "RPM install method not available on $ID" printHelp && exit 1 fi BUILD_SWITCH=true fi ;; --build) echo HERE echo "$1" "$2" BUILD_SWITCH=true #BUILD_TARGET="$2" shift ;; --build-suse) BUILD_SWITCH=true BUILD_SUSE_SWITCH=true ;; --outputdir) shift && OUTPUTDIR="$1" ;; --mcversion) shift && MCVERSION="$1" ;; --restorefile) shift && RESTOREFILE="$1" ;; --betapass) shift && BETAPASS="$1" ;; --service-user) shift && SERVICE_USER="$1" ;; --service|-s) shift && SERVICES+=("$1") ;; --createrepo) BUILD_SWITCH=true CREATEREPO_SWITCH=true ;; --createrepo-suse) BUILD_SWITCH=true BUILD_SUSE_SWITCH=true CREATEREPO_SWITCH=true ;; --createrepo-webroot) shift && CREATEREPO_WEBROOT="$1" ;; --createrepo-user) shift && CREATEREPO_USER="$1" ;; --vncpass) shift && VNCPASS="$1" ;; --display) shift && USER_DISPLAY="$1" ;; --compat) COMPAT_SWITCH=true ;; --container|-c) shift && CONTAINERS+=("$1") ;; --version|-v) echo "Version: $SCRIPTVERSION" exit 0 ;; --debug|-d) echo "Debugging on" echo "installJRMC version: $SCRIPTVERSION" _debug="true" ;; --help|-h) printHelp && exit $? ;; --uninstall|-u) UNINSTALL_SWITCH=true ;; --tests) echo "Running tests, all other options are skipped" tests ;; --) shift break ;; esac shift done else err "Incorrect options provided" printHelp && exit 1 fi } ####################################### # Use several methods to determine the latest JRiver MC version ####################################### getLatestVersion() { debug "Running: ${FUNCNAME[0]}" declare -g MCVERSION BASE BOARDURL # Latest defaults BASE="buster" # For container method BOARDURL="https://yabb.jriver.com/interact/index.php/board,71.0.html" # MC28 (Buster), for fallback webscrape #BASE_next="bullseye" # TODO use for fallback to smooth upgrades # Legacy #boardurl26="https://yabb.jriver.com/interact/index.php/board,64.0.html" # jessie/stretch # Peg older versions to prevent ABI and dependency mismatches in automatic mode # This can be overriden w/ --MCVERSION # TODO need user input here # disable version checks for createrepo or rpmbuild (servers) # if [[ -v INSTALL_TYPE ]]; then # if [[ "$ID" == "ubuntu" ]]; then # # [[ "$VERSION_CODENAME" =~ ^(focal|groovy|hirsute|impish)$ ]] && \ # # BASE="bullseye" # [[ "$VERSION_CODENAME" =~ ^(cosmic|disco|eoan)$ ]] && \ # BASE="buster" # [[ "$VERSION_CODENAME" =~ ^(xenial|yakkety|zesty|artful|bionic)$ ]] && \ # MCVERSION="26.0.107" # [[ "$VERSION_CODENAME" =~ ^(trusty|utopic|vivid|wily)$ ]] && \ # MCVERSION="26.0.107" # elif [[ "$ID" == "debian" ]]; then # BASE="$VERSION_CODENAME" # [[ $VERSION_ID -eq 10 ]] && \ # BASE="buster" # [[ $VERSION_ID -le 9 ]] && \ # MCVERSION="26.0.107" # For 9 and 8 # elif [[ "$ID" == "centos" ]]; then # [[ "$VERSION_ID" -eq "8" ]] && \ # BASE="buster" # [[ "$VERSION_ID" -lt "8" ]] && \ # MCVERSION="26.0.107" # Doubtful # fi # [[ -v MCVERSION ]] && \ # _version_source="compatibility lookup" && \ # debug "To override, use --MCVERSION" && \ # return 0 # fi # Use a containerized package manager # TODO but how to determine build distro ($BASE=buster)? installPackage --silent buildah if [[ -x $(command -v buildah) ]] && CNT=$(buildah from debian:$BASE); then buildah run "$CNT" -- bash -c \ "echo 'deb [trusted=no arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $BASE main' > /etc/apt/sources.list 2>&1" buildah run "$CNT" -- bash -c \ "apt-get update --allow-insecure-repositories > /dev/null 2>&1" if MCVERSION=$(buildah run "$CNT" -- apt-cache policy mediacenter?? | grep Candidate | awk '{print $2}' | sort -V | tail -n1) \ && [[ "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then _version_source="containerized package manager" fi buildah rm "$CNT" > /dev/null 2>&1 return 0 fi # Scrape from Interact installPackage --silent wget if MCVERSION=$(wget -qO- "$BOARDURL" | grep -o "[0-9][0-9]\.[0-9]\.[0-9]\+" | head -n 1); then _version_source="webscrape" fi if ! [[ -v MCVERSION ]]; then err "MC version could not be determined. Please check the boardurl: $BOARDURL or specify a version manually using --MCVERSION" exit 1 fi } ####################################### # Installs a package using the system package manager # Arguments: # One or more package names # Options: # --nocheck: Do not check if package is already installed # --nogpgcheck: Disable GPG checks for RPM based distros # --silent, -s: Do not report errors (useful if package is not strictly required and errors are noisy) ####################################### installPackage() { debug "Running: ${FUNCNAME[0]}" "$@" declare -a _pkg_array _install_flags declare _pkg _nocheck _silent _return if _input=$(getopt -o +s -l nocheck,nogpgcheck,nobest,silent -- "$@"); then eval set -- "$_input" while true; do case "$1" in --nocheck) _nocheck=true ;; --nogpgcheck) if [[ "$ID" =~ ^(fedora|centos)$ ]]; then _install_flags+=("--nogpgcheck") elif [[ "$ID" =~ ^opensuse.* ]]; then _install_flags+=("--allow-unsigned-rpm") fi ;; --nobest) if [[ "$ID" =~ ^(fedora|centos)$ ]]; then _install_flags+=("--nobest") fi ;; --silent|-s) _silent=true ;; --) shift break ;; esac shift done else err "Incorrect options provided" exit 1 fi # Aliases if [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then declare -A PKG_ALIASES PKG_ALIASES["xorg-x11-utils"]="xorg-x11" PKG_ALIASES["rpm-build"]="rpm" PKG_ALIASES["createrepo_c"]="createrepo" PKG_ALIASES["tigervnc-server"]="tigervnc-standalone-server" fi for _pkg in "$@"; do # Check for alias if [[ ! -v _nocheck && -v PKG_ALIASES[$_pkg] ]]; then _pkg=${PKG_ALIASES[$_pkg]} fi # Check if already installed if [[ -v _nocheck ]] \ || ([[ ! -x $(command -v $_pkg) ]] \ && ! pkg_query "$_pkg" > /dev/null 2>&1); then _pkg_array+=("$_pkg") fi done # Install packages from package array if [[ ${#_pkg_array[@]} -ge 1 ]]; then debug "Installing: ${_pkg_array[*]}" if debug; then debug "pkg_install ${_install_flags[*]} ${_pkg_array[*]}" pkg_install "${_install_flags[@]}" "${_pkg_array[@]}" else pkg_install "${_install_flags[@]}" "${_pkg_array[@]}" > /dev/null 2>&1 fi _return=$? [[ $_return -ne 0 && ! -v _silent ]] && err "Failed to install ${_pkg_array[*]}. Attempting to continue..." return $_return fi } ####################################### # Add the JRiver repository files ####################################### addRepo() { debug "Running: ${FUNCNAME[0]}" if [[ "$ID" =~ ^(fedora|centos)$ ]]; then bash_cmd 'cat <<- EOF > /etc/yum.repos.d/jriver.repo [jriver] name=JRiver Media Center repo by BryanC baseurl=https://repos.bryanroessler.com/jriver gpgcheck=0 EOF' elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then # MVERSION depends on $BASE unless --MCVERSION is passed installPackage --silent wget wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | ifSudo apt-key add - > /dev/null 2>&1 ifSudo wget "http://dist.jriver.com/latest/mediacenter/mediacenter$MVERSION.list" -O "/etc/apt/sources.list.d/mediacenter$MVERSION.list" > /dev/null 2>&1 elif [[ "$ID" =~ ^opensuse.* ]]; then ifSudo zypper addrepo --no-gpgcheck "https://repos.bryanroessler.com/jriver" jriver > /dev/null 2>&1 fi } ####################################### # Installs JRiver Media Center from a repository ####################################### installMCFromRepo() { debug "Running: ${FUNCNAME[0]}" declare _mcpkg echo "Installing JRiver Media Center $MCVERSION from repository." echo "Future updates will be handled by your package manager." if ! debug; then echo "This may take a few minutes to complete." echo "Use --debug for verbose output." fi addRepo # Update package list debug "Updating package list" if ! pkg_update > /dev/null 2>&1; then err "Package update failed!" exit 1 fi if [[ "$ID" =~ ^(fedora|centos|opensuse.*)$ ]]; then _mcpkg="MediaCenter" elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then _mcpkg="mediacenter$MVERSION" fi if [[ -v _specific_version ]]; then if [[ "$ID" =~ ^(fedora|centos|opensuse.*)$ ]]; then _mcpkg="$_mcpkg-$MCVERSION" elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then _mcpkg="$_mcpkg=$MCVERSION" fi fi if debug; then installPackage --nocheck --nogpgcheck "$_mcpkg" else installPackage --nocheck --nogpgcheck "$_mcpkg" > /dev/null 2>&1 fi return $? } ####################################### # Acquire the source DEB package from JRiver's servers ####################################### acquireDeb() { debug "Running: ${FUNCNAME[0]}" declare -g DEBFILENAME="$OUTPUTDIR/SOURCES/MediaCenter-$MCVERSION-amd64.deb" # If necessary, create SOURCES dir [[ ! -d "$OUTPUTDIR/SOURCES" ]] && mkdir -p "$OUTPUTDIR/SOURCES" # If deb file already exists, skip download if [[ -f "$DEBFILENAME" ]]; then echo "Using local DEB file: $DEBFILENAME" return 0 fi if [[ -v BETAPASS ]]; then echo "Checking beta repo..." if wget -q -O "$DEBFILENAME" \ "https://files.jriver.com/mediacenter/channels/v$MVERSION/beta/$BETAPASS/MediaCenter-$MCVERSION-amd64.deb"; then echo "Found!" fi elif echo "Checking test repo..." && wget -q -O "$DEBFILENAME" \ "https://files.jriver.com/mediacenter/test/MediaCenter-$MCVERSION-amd64.deb"; then echo "Found!" # Else check latest repo elif echo "Checking latest repo..." && wget -q -O "$DEBFILENAME" \ "https://files.jriver.com/mediacenter/channels/v$MVERSION/latest/MediaCenter-$MCVERSION-amd64.deb"; then echo "Found!" else err "Cannot find DEB file." exit 1 fi if [[ ! -f "$DEBFILENAME" ]]; then err "Downloaded DEB file missing or corrupted." exit 1 fi } ####################################### # Translate deb package dependencies for each distro ####################################### packageTranslations() { debug "Running: ${FUNCNAME[0]}" } ####################################### # Creates a SPEC file and builds the RPM from the source DEB using rpmbuild ####################################### buildRPM() { debug "Running: ${FUNCNAME[0]}" declare _ec id i declare -a requires recommends declare -A dupes declare -g MCRPM="$OUTPUTDIR/RPMS/x86_64/MediaCenter-$MCVERSION.x86_64.rpm" # skip rebuilding the rpm if it already exists if [[ -f "$MCRPM" ]]; then echo "$MCRPM already exists. Skipping build step." return 0 fi [[ ! -d "$OUTPUTDIR/SPECS" ]] && mkdir -p "$OUTPUTDIR/SPECS" id="$ID" # For crossbuilding, use a temp mutable ID [[ -v BUILD_SUSE_SWITCH ]] && id="opensuse" # Load deb dependencies into array IFS=',' read -ra requires <<< "$(dpkg-deb -f "$DEBFILENAME" Depends)" IFS=',' read -ra recommends <<< "$(dpkg-deb -f "$DEBFILENAME" Recommends)" # Clean up formatting requires=("${requires[@]%%|*}") requires=("${requires[@]/?:/}") requires=("${requires[@]# }") requires=("${requires[@]% }") requires=("${requires[@]//\(/}") requires=("${requires[@]//)/}") recommends=("${recommends[@]%%|*}") recommends=("${recommends[@]/?:/}") recommends=("${recommends[@]# }") recommends=("${recommends[@]% }") recommends=("${recommends[@]//\(/}") recommends=("${recommends[@]//)/}") # Translate package names case "$id" in fedora|centos) requires=("${requires[@]/libc6/glibc}") requires=("${requires[@]/libasound2/alsa-lib}") requires=("${requires[@]/libuuid1/libuuid}") requires=("${requires[@]/libx11-6/libX11}") requires=("${requires[@]/libxext6/libXext}") requires=("${requires[@]/libxcb1/libxcb}") requires=("${requires[@]/libxdmcp6/libXdmcp}") requires=("${requires[@]/libstdc++6/libstdc++}") requires=("${requires[@]/libgtk-3-0/gtk3}") requires=("${requires[@]/libgl1/mesa-libGL}") requires=("${requires[@]/libpango-1.0-0/pango}") requires=("${requires[@]/libpangoft2-1.0-0/pango}") requires=("${requires[@]/libpangox-1.0-0/pango}") requires=("${requires[@]/libpangoxft-1.0-0/pango}") requires=("${requires[@]/libnss3/nss}") requires=("${requires[@]/libnspr4/nspr}") requires=("${requires[@]/libgomp1/libgomp}") requires=("${requires[@]/libfribidi0/fribidi}") requires=("${requires[@]/libfontconfig1/fontconfig}") requires=("${requires[@]/libfreetype6/freetype}") requires=("${requires[@]/libharfbuzz0b/harfbuzz}") requires=("${requires[@]/libgbm1/mesa-libgbm}") requires=("${requires[@]/libva2/libva}") requires=("${requires[@]/libepoxy0/libepoxy}") requires=("${requires[@]/liblcms2-2/lcms2}") requires=("${requires[@]/libvulkan1/vulkan-loader}") requires=("${requires[@]/libepoxy0/libepoxy}") ;; opensuse*) requires=("${requires[@]/libc6/glibc}") requires=("${requires[@]/libasound2/alsa-lib}") requires=("${requires[@]/libx11-6/libX11-6}") requires=("${requires[@]/libxext6/libXext6}") requires=("${requires[@]/libxdmcp6/libXdmcp6}") requires=("${requires[@]/libgtk-3-0/gtk3}") requires=("${requires[@]/libgl1/Mesa-libGL1}") requires=("${requires[@]/libpango-1.0-0/pango}") requires=("${requires[@]/libpangoft2-1.0-0/pango}") requires=("${requires[@]/libpangox-1.0-0/pango}") requires=("${requires[@]/libpangoxft-1.0-0/pango}") requires=("${requires[@]/libnss3/mozilla-nss}") requires=("${requires[@]/libnspr4/mozilla-nspr}") requires=("${requires[@]/libfribidi0/fribidi}") requires=("${requires[@]/libfontconfig1/fontconfig}") requires=("${requires[@]/libfreetype6*/freetype}") # Remove minimum version specifier requires=("${requires[@]/libharfbuzz0b/libharfbuzz0}") for i in "${!requires[@]}"; do [[ "${requires[$i]}" == "mesa-vulkan-drivers" ]] && unset -v 'requires[i]' done recommends+=("libvulkan_intel") recommends+=("libvulkan_radeon") ;; esac # Remove duplicates for i in "${requires[@]}"; do if [[ ! -v dupes[${i%% *}] ]]; then tmp+=("$i") fi dupes["${i%% *}"]=1 done requires=("${tmp[@]}") # Convert array to newline delim'd string (for heredoc) printf -v requires "Requires: %s\n" "${requires[@]}" printf -v recommends "Recommends: %s\n" "${recommends[@]}" # Strip last newline requires="${requires%?}" recommends="${recommends%?}" if [[ -v COMPAT_SWITCH ]]; then # Strip minimum versions requires=$(echo "$requires" | awk -F" " 'NF == 4 {print $1 " " $2} NF != 4 {print $0}') fi # Create spec file cat <<- EOF > "$OUTPUTDIR/SPECS/mediacenter.spec" Name: MediaCenter Version: $MCVERSION Release: 1 Summary: JRiver Media Center Group: Applications/Media Source0: http://files.jriver.com/mediacenter/channels/v$MVERSION/latest/MediaCenter-$MCVERSION-amd64.deb BuildArch: x86_64 %define _rpmfilename %%{ARCH}/%%{NAME}-%%{version}.%%{ARCH}.rpm AutoReq: 0 ${requires:-} ${recommends:-} Provides: mediacenter$MVERSION License: Copyright 1998-2022, JRiver, Inc. All rights reserved. Protected by U.S. patents #7076468 and #7062468 URL: http://www.jriver.com/ %define __provides_exclude_from ^%{_libdir}/jriver/.*/.*\\.so.*$ %description Media Center is more than a world class player. %global __os_install_post %{nil} %prep %build %install dpkg -x %{S:0} %{buildroot} %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %files %{_bindir}/mediacenter$MVERSION %{_libdir}/jriver %{_datadir} %exclude %{_datadir}/applications/media_center_packageinstaller_$MVERSION.desktop /etc/security/limits.d/* EOF # Run rpmbuild echo "Building version $MCVERSION, please wait..." if debug; then rpmbuild --define="%_topdir $OUTPUTDIR" --define="%_libdir /usr/lib" -bb "$OUTPUTDIR/SPECS/mediacenter.spec" else rpmbuild --quiet --define="%_topdir $OUTPUTDIR" --define="%_libdir /usr/lib" -bb "$OUTPUTDIR/SPECS/mediacenter.spec" > /dev/null 2>&1 fi _ec=$? [[ "$_ec" == 0 ]] && echo "Build successful. The RPM file is located at: $MCRPM" return $_ec } ####################################### # Copy the RPM to createrepo-webroot and runs createrepo as the createrepo-user ####################################### runCreaterepo() { debug "Running: ${FUNCNAME[0]}" declare -a createrepo_cmd installPackage createrepo_c # If the webroot does not exist, create it if [[ ! -d "$CREATEREPO_WEBROOT" ]]; then debug "ifSudo -u $CREATEREPO_USER mkdir -p $CREATEREPO_WEBROOT" if ! ifSudo -u "$CREATEREPO_USER" mkdir -p "$CREATEREPO_WEBROOT" > /dev/null 2>&1; then debug "ifSudo mkdir -p $CREATEREPO_WEBROOT" if ifSudo mkdir -p "$CREATEREPO_WEBROOT" && \ ifSudo chown -R "$CREATEREPO_USER":"$CREATEREPO_USER" "$CREATEREPO_WEBROOT"; then : else err "Could not create the createrepo-webroot path!" err "Make sure that the createrepo-webroot is writeable by createrepo-user: $CREATEREPO_USER" return 1 fi fi fi # Copy built rpms to webroot debug "ifSudo -u $CREATEREPO_USER cp -n -f $MCRPM $CREATEREPO_WEBROOT" if ! ifSudo -u "$CREATEREPO_USER" cp -n -f "$MCRPM" "$CREATEREPO_WEBROOT" > /dev/null 2>&1; then debug "cp_cmd $MCRPM $CREATEREPO_WEBROOT" if cp_cmd "$MCRPM" "$CREATEREPO_WEBROOT" && \ ifSudo chown -R "$CREATEREPO_USER":"$CREATEREPO_USER" "$CREATEREPO_WEBROOT"; then : else err "Could not copy $MCRPM to $CREATEREPO_WEBROOT" err "Make sure that the createrepo-webroot path is writeable by createrepo-user: $CREATEREPO_USER" return 1 fi fi # Run createrepo createrepo_cmd=("sudo" "-u" "$CREATEREPO_USER" "createrepo" "-q") [[ -d "$CREATEREPO_WEBROOT/repodata" ]] && createrepo_cmd+=("--update") debug "${createrepo_cmd[*]} $CREATEREPO_WEBROOT" if "${createrepo_cmd[@]}" "$CREATEREPO_WEBROOT"; then echo "Successfully updated repo" return 0 else err "Update repo failed" return 1 fi } ####################################### # Symlink certificates where JRiver Media Center expects them to be on Fedora/CentOS ####################################### symlinkCerts() { debug "Running: ${FUNCNAME[0]}" if [[ ! -f /etc/ssl/certs/ca-certificates.crt && \ -f /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem ]]; then if ! ln_cmd /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /etc/ssl/certs/ca-certificates.crt; then err "Symlinking certificates failed" return 1 fi fi } ####################################### # Automatically restore the mjr license file if it is found next to # installJRMC or RESTOREFILE is set ####################################### restoreLicense() { debug "Running: ${FUNCNAME[0]}" declare _mjr # Allow user to put the mjr file next to installJRMC if [[ ! -v RESTOREFILE ]]; then for _mjr in "$PWD"/*.mjr; do [[ $_mjr -nt $RESTOREFILE ]] && RESTOREFILE="$_mjr" done fi # Restore license if [[ -f "$RESTOREFILE" ]]; then if ! "mediacenter$MVERSION" /RestoreFromFile "$RESTOREFILE"; then err "Automatic license restore failed" return 1 fi fi } ####################################### # Opens ports using the system firewall tool # Arguments # Pre-defined service to enable ####################################### openFirewall() { debug "Running: ${FUNCNAME[0]}" "$@" # Create OS-specific port rules based on argument (service) name declare -a _f_ports # for firewall-cmd declare _u_ports # for ufw if [[ "$1" == "jriver" ]]; then _f_ports=("52100-52200/tcp" "1900/udp") _u_ports="52100:52200/tcp|1900/udp" elif [[ "$1" =~ ^(jriver-x11vnc|jriver-xvnc)$ ]]; then _f_ports=("$_port/tcp" "1900/udp") _u_ports="$_port/tcp|1900/udp" fi # Open the ports if [[ "$ID" =~ ^(fedora|centos|opensuse.*)$ ]]; then installPackage firewalld if ! firewall_cmd --get-services | grep -q "$1"; then firewall_cmd --permanent --new-service="$1" > /dev/null 2>&1 firewall_cmd --permanent --service="$1" --set-description="$1 installed by installJRMC" > /dev/null 2>&1 firewall_cmd --permanent --service="$1" --set-short="$1" > /dev/null 2>&1 for _f_port in "${_f_ports[@]}"; do firewall_cmd --permanent --service="$1" --add-port="$_f_port" > /dev/null 2>&1 done firewall_cmd --add-service "$1" --permanent > /dev/null 2>&1 firewall_cmd --reload > /dev/null 2>&1 fi elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then # Debian ufw package state is broken on fresh installations installPackage ufw if [[ ! -f "/etc/ufw/applications.d/$1" ]]; then bash_cmd "cat <<- EOF > /etc/ufw/applications.d/$1 [$1] title=$1 description=$1 installed by installJRMC ports=$_u_ports EOF" fi firewall_cmd app update "$1" firewall_cmd allow "$1" > /dev/null 2>&1 fi # shellcheck disable=SC2181 # More concise if [[ $? -ne 0 ]]; then err "Firewall ports could not be opened" return 1 fi } ####################################### # Create the x11vnc password file ####################################### setX11VNCPass() { debug "Running: ${FUNCNAME[0]}" _vncpassfile="$HOME/.vnc/jrmc_passwd" [[ ! -d "${_vncpassfile%/*}" ]] && mkdir -p "${_vncpassfile%/*}" if [[ -f "$_vncpassfile" ]]; then if [[ ! -v VNCPASS ]]; then err "Refusing to overwrite existing $_vncpassfile with an empty password" err "Remove existing $_vncpassfile or set --vncpass to use an empty password" exit 1 else rm -f "$_vncpassfile" fi fi if [[ -v VNCPASS ]]; then if ! x11vnc -storepasswd "$VNCPASS" "$_vncpassfile"; then err "Could not create VNC password file" return 1 fi else _novncauth="true" fi } ####################################### # Create the Xvnc password file ####################################### setVNCPass() { debug "Running: ${FUNCNAME[0]}" declare _vncpassfile="$HOME/.vnc/jrmc_passwd" [[ ! -d "${_vncpassfile%/*}" ]] && mkdir -p "${_vncpassfile%/*}" if [[ -f "$_vncpassfile" ]]; then if [[ ! -v VNCPASS ]]; then err "Refusing to overwrite existing $_vncpassfile with an empty password" err "Remove existing $_vncpassfile or set --vncpass to use an empty password" exit 1 else rm -f "$_vncpassfile" fi fi if [[ -v VNCPASS ]]; then if ! echo "$VNCPASS" | vncpasswd -f > "$_vncpassfile"; then err "Could not create VNC password file" return 1 fi else _novncauth="true" fi } ####################################### # Set display and port variables ####################################### setDisplay() { debug "Running: ${FUNCNAME[0]}" # Check USER_DISPLAY, else DISPLAY, else set to :0 by default if [[ -v USER_DISPLAY ]]; then _next_display="$USER_DISPLAY" elif [[ -v DISPLAY ]]; then USER_DISPLAY="${DISPLAY}" _displaynum="${USER_DISPLAY#:}" # strip colon _displaynum="${_displaynum%.*}" # strip suffix _next_displaynum=$(( _displaynum + 1 )) _next_display=":$_next_displaynum" else USER_DISPLAY=":0" _next_display=":1" fi _displaynum="${USER_DISPLAY#:}" # strip colon _displaynum="${_displaynum%.*}" # strip suffix _next_displaynum=$(( _displaynum + 1 )) } ####################################### # Create associated service variables based on service name ####################################### setServiceVars() { debug "Running: ${FUNCNAME[0]}" if [[ "$SERVICE_USER" == "root" ]]; then _service_fname="$SERVICEDIR/${1}.service" _timer_fname="$SERVICEDIR/${1}.timer" _service_name="${1}.service" _timer_name="${1}.timer" _user_specifier="" else _service_fname="$SERVICEDIR/${1}@.service" _timer_fname="$SERVICEDIR/${1}@.timer" _service_name="${1}@$SERVICE_USER.service" _timer_name="${1}@$SERVICE_USER.timer" _user_specifier="User=%I" fi } ####################################### # Starts and enables (at startup) a JRiver Media Center service # Arguments: # Passes arguments as startup options to /usr/bin/mediacenter?? ####################################### service_jriver-mediacenter() { debug "Running: ${FUNCNAME[0]}" bash_cmd "cat <<- EOF > $_service_fname [Unit] Description=JRiver Media Center $MVERSION After=graphical.target [Service] $_user_specifier Type=simple Environment=DISPLAY=$USER_DISPLAY Environment=XAUTHORITY=$XAUTHORITY ExecStart=/usr/bin/mediacenter$MVERSION $* Restart=always RestartSec=10 KillSignal=SIGHUP TimeoutStopSec=30 [Install] WantedBy=graphical.target EOF" systemctl_reload && \ systemctl_enable "$_service_name" && \ openFirewall "jriver" } ####################################### # Starts and enables (at startup) a JRiver Media Server service ####################################### service_jriver-mediaserver() { debug "Running: ${FUNCNAME[0]}" service_jriver-mediacenter "/MediaServer" } ####################################### # Starts and enables (at startup) JRiver Media Center in a new Xvnc session ####################################### service_jriver-xvnc() { debug "Running: ${FUNCNAME[0]}" installPackage tigervnc-server setVNCPass declare _port=$(( _next_displaynum + 5900 )) if [[ -v _novncauth ]]; then _exec_start_cmd="/usr/bin/vncserver $_next_display -geometry 1440x900 -alwaysshared -name jriver$_next_display -SecurityTypes None -autokill -xstartup /usr/bin/mediacenter$MVERSION" else _exec_start_cmd="/usr/bin/vncserver $_next_display -geometry 1440x900 -alwaysshared -rfbauth $HOME/.vnc/jrmc_passwd -autokill -xstartup /usr/bin/mediacenter$MVERSION" fi bash_cmd "cat <<- EOF > $_service_fname [Unit] Description=Remote desktop service (VNC) After=syslog.target network.target [Service] Type=simple $_user_specifier ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill $_next_display > /dev/null 2>&1 || :' ExecStart=$_exec_start_cmd ExecStop=/usr/bin/vncserver -kill $_next_display Restart=always [Install] WantedBy=multi-user.target EOF" systemctl_reload && \ systemctl_enable "$_service_name" && \ echo "Xvnc running on localhost:$_port" && \ openFirewall "jriver-xvnc" && \ openFirewall "jriver" } ####################################### # Starts and enables (at startup) JRiver Media Server and x11vnc sharing the local desktop ####################################### service_jriver-x11vnc() { debug "Running: ${FUNCNAME[0]}" installPackage x11vnc setX11VNCPass declare _port=$(( _displaynum + 5900 )) # Get current desktop resolution # TODO: may need to break this out into its own function and get smarter at identifying multi-monitors _getResolution() { debug "Running: ${FUNCNAME[0]}" installPackage xorg-x11-utils _res=$(xdpyinfo | grep dimensions | awk '{print $2}') } _getResolution if [[ -v _novncauth ]]; then _exec_start_cmd="/usr/bin/x11vnc -display $USER_DISPLAY -noscr -geometry $_res -auth guess -forever -bg -nopw" else _exec_start_cmd="/usr/bin/x11vnc -display $USER_DISPLAY -noscr -geometry $_res -auth guess -forever -bg -rfbauth $HOME/.vnc/jrmc_passwd" fi bash_cmd "cat <<-EOF > $_service_fname [Unit] Description=x11vnc After=multi.service [Service] $_user_specifier Type=forking Environment=DISPLAY=$USER_DISPLAY ExecStart=$_exec_start_cmd Restart=always RestartSec=10 [Install] WantedBy=multi-user.target EOF" systemctl_reload && \ systemctl_enable "$_service_name" && \ echo "x11vnc running on localhost:$_port" && \ openFirewall "jriver-x11vnc" } ####################################### # Starts and enables (at startup) an hourly service to build the latest version of JRiver Media # Center RPM from the source DEB and create/update an RPM repository ####################################### service_jriver-createrepo() { debug "Running: ${FUNCNAME[0]}" bash_cmd "cat <<-EOF > $_service_fname [Unit] Description=Builds JRiver Media Center RPM file, moves it to the repo dir, and runs createrepo [Service] $_user_specifier ExecStart=$PWD/installJRMC --outputdir $OUTPUTDIR --createrepo --createrepo-webroot $CREATEREPO_WEBROOT --createrepo-user $CREATEREPO_USER [Install] WantedBy=default.target EOF" bash_cmd "cat <<-EOF > $_timer_fname [Unit] Description=Run JRiver MC rpmbuild hourly [Timer] OnCalendar=hourly Persistent=true [Install] WantedBy=timers.target EOF" systemctl_reload && \ systemctl_enable "$_timer_name" } ####################################### # CONTAINERS ####################################### # container_jriver-createrepo() { # : # } # container_jriver-xvnc() { # : # } # container_jriver-mediacenter() { # installPackage buildah podman # # Eventually try to switch to Debian # # if ! CNT=$(buildah from debian:$BASE); then # # echo "Bad base image for container $CNAME, skipping" # # continue # # fi # if ! CNT=$(buildah from jlesage/baseimage-gui:debian-10-v3.5.7); then # echo "Bad base image for container $CNAME, skipping" # continue # fi # buildah run "$CNT" add-pkg gnupg2 libxss1 wmctrl xdotool ca-certificates inotify-tools libgbm1 ffmpeg # # #BASEIMAGE=jlesage/baseimage-gui:debian-10-v3.5.7 # # JRIVER_RELEASE=28 # # JRIVER_TAG=stable # # ARCH=amd64 # # REBUILD_MIN=22 # # REBUILD_MAX=120 # # # JRiver Version tag (latest, stable or beta) # # ARG jriver_tag # # # JRiver Release Version (25, 26 etc.) # # ARG jriver_release # # # Image Version of the build # # ARG image_version # # # .deb download URL, if set to "repository" the JRiver repository will be used # # ARG deb_url # # RUN add-pkg gnupg2 libxss1 wmctrl xdotool ca-certificates inotify-tools libgbm1 ffmpeg # # Install JRiver # RUN \ # add-pkg --virtual build-dependencies wget && \ # # Install from Repository # if [ "${deb_url}" = "repository" ]; then \ # echo "Installing JRiver from repository ${jriver_release}:${jriver_tag}" && \ # wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | apt-key add - && \ # wget http://dist.jriver.com/${jriver_tag}/mediacenter/mediacenter${jriver_release}.list -O /etc/apt/sources.list.d/mediacenter${jriver_release}.list && \ # apt-get update && \ # add-pkg mediacenter${jriver_release}; \ # # Install from .deb URL # else \ # echo "Installing JRiver from URL: ${deb_url}" && \ # wget -q -O "jrivermc.deb" ${deb_url} && \ # add-pkg "./jrivermc.deb"; \ # fi && \ # # Cleanup # del-pkg build-dependencies && \ # rm -rf /tmp/* /tmp/.[!.]* # # Add rootfs # COPY rootfs/ / # VOLUME ["/config"] # # Application Icon # RUN \ # APP_ICON_URL=https://gitlab.com/shiomax/jrivermc-docker/raw/master/assets/Application.png && \ # install_app_icon.sh "$APP_ICON_URL" # # Various configuration vars # ENV KEEP_APP_RUNNING=1 \ # DISPLAY_WIDTH=1280 \ # DISPLAY_HEIGHT=768 \ # APP_NAME="JRiver MediaCenter ${jriver_release}" \ # MAXIMIZE_POPUPS=0 \ # S6_KILL_GRACETIME=8000 # # Modify startapp.sh and rc.xml with JRiver version # RUN sed-patch s/%%MC_VERSION%%/${jriver_release}/g \ # /startapp.sh && \ # sed-patch s/%%MC_VERSION%%/${jriver_release}/g \ # /etc/xdg/openbox/rc.xml # EXPOSE 5800 5900 52100 52101 52199 1900/udp # # Metadata. # LABEL \ # org.label-schema.name="jrivermc${jriver_release}" \ # org.label-schema.description="Docker image for JRiver Media Center ${jriver_release}." \ # org.label-schema.version="${image_version}" \ # org.label-schema.vcs-url="https://gitlab.com/shiomax/jrivermc-docker" \ # org.label-schema.schema-version="1.0" # installPackage buildah podman # cnt=$(buildah from docker.io/jlesage/baseimage-gui:debian-10) # podman_create_cmd=("podman" "create" "--name" "$CNAME") # buildah_config_cmd=("buildah" "config" \ # "--author" "bryanroessler@gmail.com" \ # "--label" "maintainer=$MAINTAINER" \ # "--env" "TZ=$TZ" \ # "--workingdir" "/app" \ # "--cmd" "mediacenter$MVERSION") # mkcdirs() { # declare dir # for dir in "$@"; do # if [[ ! -d "$dir" ]]; then # if ! mkdir -p "$dir"; then # err "Could not create directory $dir, check your permissions" # fi # fi # if ! chcon -t container_file_t -R "$dir"; then # err "Could not set container_file_t attribute for $dir, check your permissions" # fi # done # } # mkcdirs "$HOME/.jriver" # podman_create_cmd+=("-v" "$HOME/.jriver:/root/.jriver") # podman_create_cmd+=("-v" "$DOWNLOAD_ROOT:/downloads:z") # podman_create_cmd+=("-v" "$MONITOR_ROOT/nzbs:/nzbs") # podman_create_cmd+=("-p" "${CONTAINER[HOST_PORT]}:${CONTAINER[CONTAINER_PORT]}") # brc() { buildah run "$1" "${@:2}" || return 1; } # brc add-pkg gnupg2 libxss1 wmctrl xdotool ca-certificates inotify-tools libgbm1 # brc add-pkg --virtual .build-deps wget # brc sh -s <<- EOF # wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | apt-key add - > /dev/null 2>&1 # EOF # brc wget "http://dist.jriver.com/latest/mediacenter/mediacenter$MVERSION.list" -O "/etc/apt/sources.list.d/mediacenter$MVERSION.list" # brc apt-get update -y -q0 # brc add-pkg "mediacenter$MVERSION" # brc del-pkg .build-deps # } uninstall() { debug "Running: ${FUNCNAME[0]}" if ! askOk "Do you really want to uninstall JRiver Media Center"; then echo "Cancelling uninstall..." exit 0 fi debug "Stopping and removing all associated Media Center services" for _service in $(compgen -A "function" "service"); do _service="${_service##service_}" setServiceVars "$_service" for unit in "$_service_name" "$_timer_name"; do if systemctl is-active -q "$unit" > /dev/null 2>&1 || systemctl is-enabled -q "$unit" > /dev/null 2>&1; then debug "Disabling $unit" systemctl_disable "$unit" fi done for f in "$_service_fname" "$_timer_fname"; do [[ -f "$f" ]] && debug "Removing $f" && rm_cmd "$f" done systemctl_reload done debug "Removing repo files" [[ -f "/etc/yum.repos.d/jriver.repo" ]] \ && rm_cmd "/etc/yum.repos.d/jriver.repo" [[ -f "/etc/apt/sources.list.d/jriver.list" ]] \ && rm_cmd "/etc/apt/sources.list.d/jriver.list" if [[ "$ID" =~ ^opensuse.* ]]; then ifSudo zypper rr jriver > /dev/null 2>&1 fi debug "Removing firewall rules" if [[ -x $(command -v firewall-cmd) ]]; then if [[ -v debug ]]; then debug "firewall_cmd --permanent --remove-service=jriver" firewall_cmd --permanent --remove-service=jriver debug "firewall_cmd --permanent --delete-service=jriver" firewall_cmd --permanent --delete-service=jriver debug "firewall_cmd --reload" firewall_cmd --reload else firewall_cmd --permanent --remove-service=jriver > /dev/null 2>&1 firewall_cmd --permanent --delete-service=jriver > /dev/null 2>&1 firewall_cmd --reload > /dev/null 2>&1 fi elif [[ -x $(command -v ufw) ]]; then if [[ -v debug ]]; then firewall_cmd delete allow jriver else firewall_cmd delete allow jriver > /dev/null 2>&1 fi [[ -f "/etc/ufw/applications.d/jriver" ]] \ && rm_cmd /etc/ufw/applications.d/jriver fi debug "Uninstalling Media Center packages" if [[ "$ID" =~ ^(fedora|centos|opensuse.*)$ ]]; then _mcpkg="MediaCenter" elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then _mcpkg="mediacenter$MVERSION" fi if debug; then debug "pkg_remove $_mcpkg" pkg_remove "$_mcpkg" else pkg_remove "$_mcpkg" > /dev/null 2>&1 fi echo "JRiver Media Center has been completely uninstalled." echo "To remove your library files, run: rm -rf $HOME/.jriver" echo "To remove your rpmbuild output files, run: rm -rf $OUTPUTDIR" exit 0 } tests() { # To test on Mint: sudo apt-get install -y spice-vdagent ca-certificates git; export GIT_SSL_NO_VERIFY=1 exit $? } main() { debug "Running: ${FUNCNAME[0]}" init "$@" # Uninstall and exit if [[ -v UNINSTALL_SWITCH ]]; then uninstall exit $? fi # Install dependency dependencies :-) [[ "$ID" == "centos" ]] && installPackage epel-release # Install MC using package manager if [[ -v INSTALL_TYPE && "$INSTALL_TYPE" == "repo" ]]; then if [[ "$ID" =~ ^opensuse.*$ ]]; then echo "A SUSE repository is not yet available." echo "Use --install rpm to build and install a SUSE RPM instead." exit 1 fi if installMCFromRepo; then echo "JRiver Media Center installed successfully" else err "JRiver Media Center installation failed" exit 1 fi symlinkCerts restoreLicense openFirewall "jriver" fi # Build RPM from source deb package if [[ -v BUILD_SWITCH ]]; then installPackage --silent "wget" "dpkg" "rpm-build" acquireDeb if ! buildRPM; then err "Build failed." # For automation, let's remove the source DEB and reaquire it on next run # after failure in case it is corrupted or buggy [[ -f "$DEBFILENAME" ]] && echo "Removing source DEB" && rm -f "$DEBFILENAME" exit 1 fi fi # Run createrepo if [[ -v CREATEREPO_SWITCH ]]; then runCreaterepo exit $? fi # Install RPM if [[ -v INSTALL_TYPE && "$INSTALL_TYPE" == "rpm" ]]; then #rpm --upgrade "$MCRPM" if installPackage --nocheck --nogpgcheck "$MCRPM"; then echo "JRiver Media Center installed successfully" else err "JRiver Media Center installation failed" exit 1 fi symlinkCerts restoreLicense openFirewall "jriver" fi # Install services if [[ "${#SERVICES[@]}" -gt 0 ]]; then setDisplay ! [[ -d "$SERVICEDIR" ]] && ifSudo mkdir -p "$SERVICEDIR" for _service in "${SERVICES[@]}"; do setServiceVars "$_service" if ! "service_$_service"; then if [[ $? -eq 127 ]]; then err "Service $_service does not exist, check your service name" else err "Failed to create service: $_service" fi fi done fi # Install containers # for _container in "${CONTAINERS[@]}"; do # if ! "_container_$_container"; then # if [[ $? -eq 127 ]]; then # err "Container $_container does not exist, check your container name" # else # err "Failed to create container: $_container" # fi # fi # done } main "$@"