1278 lines
39 KiB
Bash
Executable File
1278 lines
39 KiB
Bash
Executable File
#!/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
|
|
|
|
shopt -s extglob
|
|
|
|
_scriptversion="1.0b1"
|
|
_outputdir="$PWD/output"
|
|
_createrepo_webroot="/srv/jriver"
|
|
_exec_user="$(whoami)"
|
|
|
|
# Version control
|
|
_boardurl="https://yabb.jriver.com/interact/index.php/board,71.0.html" # Media Center 28, only required if buildah is unavailable
|
|
# _mcversion="28.0.84" # set manually
|
|
|
|
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
|
|
Build RPM from source DEB (but don't install it)
|
|
--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: /srv/jriver/)
|
|
--createrepo-user USER
|
|
The web server user (Default: current user)
|
|
--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 'jriver-xvnc-mediacenter' below)
|
|
jriver-xvnc-mediacenter
|
|
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]}"
|
|
|
|
getOS
|
|
|
|
# Agnostic commands
|
|
bash_cmd(){ ifSudo bash -c "$@"; }
|
|
rm_cmd(){ ifSudo rm -rf "$@"; }
|
|
#cp_cmd(){ ifSudo cp -n "$@"; }
|
|
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_reinstall(){ ifSudo dnf reinstall -y "$@"; }
|
|
pkg_install_nogpg(){ ifSudo dnf install --nogpgcheck -y "$@"; }
|
|
pkg_remove(){ ifSudo dnf remove -y "$@"; }
|
|
pkg_update(){ ifSudo dnf makecache; }
|
|
pkg_query(){ ifSudo rpm -q "$@"; }
|
|
firewall_cmd(){ ifSudo firewall-cmd "$@"; }
|
|
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
|
|
pkg_install(){ ifSudo apt-get install -y -q0 "$@"; }
|
|
pkg_reinstall(){ ifSudo apt-get reinstall -y -q0 "$@"; }
|
|
pkg_install_nogpg(){ 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(){ ifSudo dpkg -s "$@"; }
|
|
firewall_cmd(){ ifSudo ufw "$@"; }
|
|
fi
|
|
|
|
parseInput "$@"
|
|
|
|
_service_user="${_service_user:-$_exec_user}"
|
|
_createrepo_user="${_createrepo_user:-$_exec_user}"
|
|
|
|
# Set package aliases
|
|
if [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
|
|
declare -Ag 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
|
|
|
|
# Install script dependencies
|
|
[[ "$ID" == "centos" ]] && installPackage epel-release
|
|
|
|
if [[ -v _mcversion ]]; then
|
|
_version_source="user input"
|
|
else
|
|
getLatestVersion
|
|
fi
|
|
|
|
[[ ! "$_mcversion" =~ ([0-9]+.[0-9]+.[0-9]+) ]] && err "Invalid version number" && exit 1
|
|
|
|
debug "Using MC version $_mcversion determined by $_version_source"
|
|
|
|
# Extract major version number
|
|
_mversion="${_mcversion%%.*}"
|
|
|
|
# Saving this substituion in case it's needed in the future
|
|
# _variation="${_mcversion##*.}"
|
|
}
|
|
|
|
# Some helper functions
|
|
askOk() {
|
|
local _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() {
|
|
if [[ "$_exec_user" != "root" ]]; then
|
|
sudo "$@"
|
|
else
|
|
"$@"
|
|
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="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-webroot:,createrepo-user:,vncpass:,display:,container:,tests -- "$@"); then
|
|
eval set -- "$_input"
|
|
while true; do
|
|
case "$1" in
|
|
--install|-i)
|
|
shift
|
|
_install="$1"
|
|
if [[ "$_install" == "rpm" ]]; then
|
|
if [[ ! "$ID" =~ ^(fedora|centos)$ ]]; then
|
|
err "RPM install method not available on $ID"
|
|
printHelp && exit 1
|
|
fi
|
|
_build=true
|
|
fi
|
|
;;
|
|
--build)
|
|
_build=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=true
|
|
_createrepo=true
|
|
;;
|
|
--createrepo-webroot)
|
|
shift && _createrepo_webroot="$1"
|
|
;;
|
|
--createrepo-user)
|
|
shift && _createrepo_user="$1"
|
|
;;
|
|
--vncpass)
|
|
shift && _vncpass="$1"
|
|
;;
|
|
--display)
|
|
shift && _display="$1"
|
|
;;
|
|
--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=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
|
|
|
|
# Use a containerized package manager
|
|
[[ ! -x $(command -v buildah) ]] && installPackage --silent buildah
|
|
if [[ -x $(command -v buildah) ]] && CNT=$(buildah from ubuntu:18.04); then
|
|
buildah run "$CNT" -- bash -c \
|
|
"echo 'deb [trusted=yes arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ buster main' > /etc/apt/sources.list 2>&1"
|
|
buildah run "$CNT" -- bash -c \
|
|
"apt-get update --allow-insecure-repositories -y > /dev/null 2>&1"
|
|
if _mcversion=$(buildah run "$CNT" -- apt-cache policy mediacenter?? | grep Candidate | awk '{print $2}' | sort -V | tail -n1); then
|
|
_version_source="containerized package manager"
|
|
fi
|
|
buildah rm "$CNT" > /dev/null 2>&1
|
|
# Else scrape from Interact
|
|
elif _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:
|
|
# --noquery, -n: Do not query the package state (useful if installing a local RPM)
|
|
# --silent, -s: Do not report errors (useful if package is not strictly required)
|
|
#######################################
|
|
installPackage() {
|
|
debug "Running: ${FUNCNAME[0]}" "$@"
|
|
|
|
if _input=$(getopt -o +ns -l noquery,silent -- "$@"); then
|
|
eval set -- "$_input"
|
|
while true; do
|
|
case "$1" in
|
|
--noquery|-n)
|
|
local _noquery="true"
|
|
;;
|
|
--silent|-s)
|
|
local _silent=true
|
|
;;
|
|
--)
|
|
shift
|
|
break
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
else
|
|
err "Incorrect options provided"
|
|
exit 1
|
|
fi
|
|
|
|
local -a _pkg_array _url_pkg_array
|
|
local -a _pkg
|
|
|
|
# Parse packages
|
|
for _pkg in "$@"; do
|
|
[[ -v PKG_ALIASES && -v PKG_ALIASES["$_pkg"] ]] && _pkg=PKG_ALIASES["$_pkg"]
|
|
# Insert the package name to test if already installed
|
|
if [[ -v _noquery ]] || ! pkg_query "$_pkg" > /dev/null 2>&1; then
|
|
if [[ -v _url_pkg ]]; then
|
|
_url_pkg_array+=("$_url_pkg")
|
|
else
|
|
_pkg_array+=("$_pkg")
|
|
fi
|
|
fi
|
|
done
|
|
|
|
# Install from package name (with gpg check)
|
|
if [[ ${#_pkg_array[@]} -ge 1 ]]; then
|
|
echo "Installing:" "${_pkg_array[@]}"
|
|
if debug; then
|
|
if ! pkg_install "${_pkg_array[@]}"; then
|
|
[[ ! -v _silent ]] && err "Failed to install package. Attempting to continue..."
|
|
return 1
|
|
fi
|
|
elif ! pkg_install "${_pkg_array[@]}" > /dev/null 2>&1; then
|
|
[[ ! -v _silent ]] && err "Failed to install package. Attempting to continue..."
|
|
return 1
|
|
fi
|
|
fi
|
|
|
|
# Install from package url (without gpg check)
|
|
if [[ ${#_url_pkg_array[@]} -ge 1 ]]; then
|
|
echo "Installing: " "${_url_pkg_array[@]}"
|
|
if debug; then
|
|
if ! pkg_install_nogpg "${_url_pkg_array[@]}"; then
|
|
[[ ! -v _silent ]] && err "Failed to install package. Attempting to continue..."
|
|
return 1
|
|
fi
|
|
elif ! pkg_install_nogpg "${_url_pkg_array[@]}" > /dev/null 2>&1; then
|
|
[[ ! -v _silent ]] && err "Failed to install package. Attempting to continue..."
|
|
return 1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
|
|
#######################################
|
|
# Adds the JRiver repos
|
|
#######################################
|
|
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
|
|
installPackage 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
|
|
fi
|
|
}
|
|
|
|
|
|
#######################################
|
|
# Installs JRiver Media Center from a repository
|
|
#######################################
|
|
installMCFromRepo() {
|
|
debug "Running: ${FUNCNAME[0]}"
|
|
|
|
local _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)$ ]]; then
|
|
_mcpkg="MediaCenter"
|
|
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
|
|
_mcpkg="mediacenter$_mversion"
|
|
fi
|
|
|
|
if [[ -v _specific_version ]]; then
|
|
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
|
if debug; then
|
|
installPackage "$_mcpkg-$_mcversion"
|
|
else
|
|
installPackage "$_mcpkg-$_mcversion" > /dev/null 2>&1
|
|
fi
|
|
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
|
|
if debug; then
|
|
installPackage "$_mcpkg=$_mcversion"
|
|
else
|
|
installPackage "$_mcpkg=$_mcversion" > /dev/null 2>&1
|
|
fi
|
|
fi
|
|
else
|
|
if debug; then
|
|
installPackage "$_mcpkg"
|
|
else
|
|
installPackage "$_mcpkg" > /dev/null 2>&1
|
|
fi
|
|
fi
|
|
|
|
return $?
|
|
}
|
|
|
|
|
|
#######################################
|
|
# Acquire the source DEB package from JRiver's servers
|
|
#######################################
|
|
acquireDeb() {
|
|
debug "Running: ${FUNCNAME[0]}"
|
|
|
|
declare -g DEBFILENAME
|
|
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"
|
|
elif [[ -v _betapass ]]; then
|
|
echo -n "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 -n "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 -n "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. Exiting..."
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -f "$DEBFILENAME" ]]; then
|
|
err "Downloaded DEB file missing or corrupted, exiting..."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
|
|
#######################################
|
|
# Creates a SPEC file and builds the RPM from the source DEB using rpmbuild
|
|
#######################################
|
|
buildRPM() {
|
|
debug "Running: ${FUNCNAME[0]}"
|
|
|
|
# install build dependencies
|
|
installPackage wget dpkg rpm-build
|
|
|
|
# If necessary, make build directories
|
|
[[ ! -d "$_outputdir/SPECS" ]] && mkdir -p "$_outputdir/SPECS"
|
|
|
|
# rpmbuild uses rpm to check for build dependencies
|
|
# this will fail on non-rpm distros
|
|
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
|
local _build_requires=$'BuildRequires: rpm >= 4.11.0\nBuildRequires: dpkg'
|
|
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
|
|
${_build_requires:-}
|
|
BuildArch: x86_64
|
|
%define _rpmfilename %%{ARCH}/%%{NAME}-%%{version}.%%{ARCH}.rpm
|
|
|
|
AutoReq: 0
|
|
Requires: glibc >= 2.28
|
|
Requires: alsa-lib >= 1.1.8
|
|
Requires: libuuid >= 2.33
|
|
Requires: libX11 >= 1.6
|
|
Requires: libX11-common >= 1.6
|
|
Requires: libXext >= 1.3
|
|
Requires: libxcb >= 1.1
|
|
Requires: libXdmcp >= 1.1
|
|
Requires: libstdc++ >= 7.4
|
|
Requires: gtk3 >= 3.24
|
|
Requires: mesa-libGL
|
|
Requires: libglvnd-glx
|
|
Requires: pango >= 1.42
|
|
Requires: nss >= 3.42
|
|
Requires: nspr >= 4.20
|
|
Requires: python3
|
|
Requires: xdg-utils
|
|
Requires: libgomp >= 7.4
|
|
Requires: fribidi >= 1.0.5
|
|
Requires: fontconfig >= 2.13
|
|
Requires: freetype >= 2.9.1
|
|
Requires: harfbuzz >= 2.3.1
|
|
Requires: mesa-libgbm >= 18.3.6
|
|
Requires: libva >= 2.4.0
|
|
Requires: libepoxy >= 1.5.3
|
|
Requires: lcms2 >= 2.9
|
|
Requires: vulkan-headers >= 1.1
|
|
Requires: mesa-vulkan-drivers
|
|
Requires: ca-certificates
|
|
Requires: libXScrnSaver
|
|
|
|
Recommends: vorbis-tools >= 1.4.0
|
|
Recommends: lame >= 3.0
|
|
|
|
Provides: mediacenter$_mversion
|
|
|
|
License: Copyright 1998-2021, 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
|
|
|
|
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
|
|
|
|
# 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
|
|
|
|
return $?
|
|
}
|
|
|
|
|
|
#######################################
|
|
# Copy the RPM to createrepo-webroot and runs createrepo as the createrepo-user
|
|
#######################################
|
|
runCreaterepo() {
|
|
debug "Running: ${FUNCNAME[0]}"
|
|
|
|
# Some additional commands specifically for createrepo (primarily to handle user rights)
|
|
if [[ $_createrepo_user != "root" ]]; then
|
|
if [[ -d "$_createrepo_webroot/repodata" ]]; then
|
|
createrepo_cmd(){ sudo -u "$_createrepo_user" createrepo -q --update "$@"; }
|
|
else
|
|
createrepo_cmd(){ sudo -u "$_createrepo_user" createrepo -q "$@"; }
|
|
fi
|
|
cr_mkdir_cmd(){ sudo -u "$_createrepo_user" mkdir -p "$@"; }
|
|
cr_cp_cmd(){ sudo -u "$_createrepo_user" cp -n "$@"; }
|
|
else
|
|
if [[ -d "$_createrepo_webroot/repodata" ]]; then
|
|
createrepo_cmd(){ createrepo -q --update "$@"; }
|
|
else
|
|
createrepo_cmd(){ createrepo -q "$@"; }
|
|
fi
|
|
fi
|
|
|
|
installPackage createrepo_c
|
|
|
|
# If the webroot does not exist, create it
|
|
if [[ ! -d "$_createrepo_webroot" ]]; then
|
|
if ! cr_mkdir_cmd "$_createrepo_webroot"; then
|
|
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
|
|
|
|
# Copy built rpms to webroot
|
|
if ! cr_cp_cmd -f "$_mcrpm" "$_createrepo_webroot"; then
|
|
err "Could not copy the RPM to the createrepo-webroot path"
|
|
err "Make sure that the createrepo-webroot path is writeable by createrepo-user: $_createrepo_user"
|
|
return 1
|
|
fi
|
|
|
|
# Run createrepo
|
|
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]}"
|
|
|
|
local _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
|
|
local -a _f_ports # for firewall-cmd
|
|
local _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)$ ]]; then
|
|
[[ ! -x $(command -v firewall-cmd) ]] && 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
|
|
[[ ! -x $(command -v ufw) ]] && 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]}"
|
|
|
|
_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 _display, else DISPLAY, else set to :0 by default
|
|
if [[ -v _display ]]; then
|
|
_next_display="$_display"
|
|
elif [[ -v DISPLAY ]]; then
|
|
_display="${DISPLAY}"
|
|
_displaynum="${_display#:}" # strip colon
|
|
_displaynum="${_displaynum%.*}" # strip suffix
|
|
_next_displaynum=$(( _displaynum + 1 ))
|
|
_next_display=":$_next_displaynum"
|
|
else
|
|
_display=":0"
|
|
_next_display=":1"
|
|
fi
|
|
|
|
_displaynum="${_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="/usr/lib/systemd/system/${1}.service"
|
|
_timer_fname="/usr/lib/systemd/system/${1}.timer"
|
|
_service_name="jriver-${1}.service"
|
|
_timer_name="jriver-${1}}.timer"
|
|
_user_specifier=""
|
|
else
|
|
_service_fname="/usr/lib/systemd/system/${1}@.service"
|
|
_timer_fname="/usr/lib/systemd/system/${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=$_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-mediacenter() {
|
|
debug "Running: ${FUNCNAME[0]}"
|
|
|
|
installPackage tigervnc-server
|
|
|
|
setVNCPass
|
|
|
|
local _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
|
|
|
|
local _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 $_display -noscr -geometry $_res -auth guess -forever -bg -nopw"
|
|
else
|
|
_exec_start_cmd="/usr/bin/x11vnc -display $_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=$_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
|
|
#######################################
|
|
# containerCreaterepo() {
|
|
# :
|
|
# }
|
|
|
|
|
|
# containerVNC() {
|
|
# :
|
|
# }
|
|
|
|
|
|
# containerMC() {
|
|
# 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() {
|
|
# local 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
|
|
|
|
echo "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."{service,timer}; 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
|
|
debug "Removing $f"
|
|
rm_cmd "$f"
|
|
done
|
|
systemctl_reload
|
|
done
|
|
|
|
echo "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"
|
|
|
|
echo "Removing firewall rules"
|
|
if [[ -x $(command -v firewall-cmd) ]]; then
|
|
firewall_cmd --permanent --remove-service=jriver > /dev/null 2>&1
|
|
firewall_cmd --permanent --delete-service=jriver > /dev/null 2>&1
|
|
firewall_cmd --reload
|
|
elif [[ -x $(command -v ufw) ]]; then
|
|
firewall_cmd delete allow jriver > /dev/null 2>&1
|
|
[[ -f "/etc/ufw/applications.d/jriver" ]] \
|
|
&& rm_cmd /etc/ufw/applications.d/jriver
|
|
fi
|
|
|
|
echo "Uninstalling Media Center packages"
|
|
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
|
pkg_remove "MediaCenter"
|
|
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
|
|
pkg_remove "mediacenter$_mversion"
|
|
fi
|
|
|
|
echo "JRiver Media Center has been completely uninstalled"
|
|
echo "If you wish to remove your library files: rm -rf $HOME/.jriver"
|
|
echo "If you wish to remove your rpmbuild output files: rm -rf $_outputdir"
|
|
}
|
|
|
|
|
|
tests() {
|
|
# To test on Mint: sudo apt-get install -y spice-vdagent ca-certificates git
|
|
exit $?
|
|
}
|
|
|
|
|
|
main() {
|
|
debug "Running: ${FUNCNAME[0]}"
|
|
|
|
init "$@"
|
|
|
|
# Uninstall and exit
|
|
if [[ -v _uninstall ]]; then
|
|
uninstall
|
|
exit $?
|
|
fi
|
|
|
|
# Install MC using package manager
|
|
if [[ -v _install && "$_install" == "repo" ]]; then
|
|
if ! installMCFromRepo; then
|
|
err "JRiver Media Center installation failed"
|
|
exit 1
|
|
else
|
|
echo "JRiver Media Center installed successfully"
|
|
fi
|
|
symlinkCerts
|
|
restoreLicense
|
|
openFirewall "jriver"
|
|
fi
|
|
|
|
# Build RPM from source deb package
|
|
if [[ -v _build ]]; then
|
|
acquireDeb
|
|
if ! buildRPM || [[ ! -f "$_mcrpm" ]] ; then
|
|
err "Build failed. Exiting..."
|
|
[[ -f "$DEBFILENAME" ]] && echo "Removing source DEB" && rm -f "$DEBFILENAME"
|
|
exit 1
|
|
else
|
|
echo "Build successful. The RPM file is located at: $_mcrpm"
|
|
fi
|
|
fi
|
|
|
|
# Run createrepo
|
|
if [[ -v _createrepo ]]; then
|
|
runCreaterepo
|
|
fi
|
|
|
|
# Install RPM
|
|
if [[ -v _install && "$_install" == "rpm" ]]; then
|
|
installPackage --noquery "$_mcrpm"
|
|
symlinkCerts
|
|
restoreLicense
|
|
openFirewall "jriver"
|
|
fi
|
|
|
|
# Install services
|
|
setDisplay
|
|
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
|
|
|
|
# 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 "$@" |