Fix formatting and Debian install

This commit is contained in:
2021-05-06 12:35:41 -04:00
parent 09b914d11f
commit 51e5da4795

View File

@@ -18,7 +18,7 @@ shopt -s extglob
####################################### #######################################
installJRMC() { installJRMC() {
_scriptversion="0.9.2" _scriptversion="0.9.3"
_boardurl="https://yabb.jriver.com/interact/index.php/board,67.0.html" _boardurl="https://yabb.jriver.com/interact/index.php/board,67.0.html"
_outputdir="$_basedir/output" _outputdir="$_basedir/output"
_createrepo_webroot="/srv/jriver" _createrepo_webroot="/srv/jriver"
@@ -26,16 +26,14 @@ installJRMC() {
_available_services=("jriver-createrepo" "jriver-x11vnc" "jriver-mediaserver" "jriver-mediacenter" "jriver-xvnc-mediacenter") _available_services=("jriver-createrepo" "jriver-x11vnc" "jriver-mediaserver" "jriver-mediacenter" "jriver-xvnc-mediacenter")
#_available_containers=("mediacenter-xvnc" "createrepo") #_available_containers=("mediacenter-xvnc" "createrepo")
_printHelpAndExit() { _printHelpAndExit() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
cat <<-'EOF' cat <<- 'EOF'
USAGE: USAGE:
installJRMC [[OPTION] [VALUE]]... installJRMC [[OPTION] [VALUE]]...
OPTIONS OPTIONS
--install-repo --install-repo
Install JRiver Media Center from repository using package manager (Default) Install JRiver Media Center from repository using package manager (Default)
DEB-based OSes: Official package repository DEB-based OSes: Official package repository
@@ -96,7 +94,7 @@ OPTIONS
CONTAINERS (TODO: Under construction) CONTAINERS (TODO: Under construction)
mediacenter-xvnc mediacenter-xvnc
createrepo createrepo
EOF EOF
# Exit using passed exit code # Exit using passed exit code
[[ -z $1 ]] && exit 0 || exit "$1" [[ -z $1 ]] && exit 0 || exit "$1"
@@ -104,7 +102,6 @@ EOF
_parseInput() { _parseInput() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
# set default behavior # set default behavior
@@ -190,7 +187,6 @@ EOF
fi fi
} }
err() { echo "Error: $*" >&2; } err() { echo "Error: $*" >&2; }
debug() { [[ -n $_debug ]] && echo "Debug: $*"; } debug() { [[ -n $_debug ]] && echo "Debug: $*"; }
@@ -201,7 +197,6 @@ EOF
# _exec_user # _exec_user
####################################### #######################################
_ifSudo() { _ifSudo() {
if [[ "$_exec_user" != "root" ]]; then if [[ "$_exec_user" != "root" ]]; then
sudo "$@" sudo "$@"
else else
@@ -215,7 +210,6 @@ EOF
# Used in: _buildCommands() # Used in: _buildCommands()
####################################### #######################################
_getOS() { _getOS() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
if [[ -e "/etc/os-release" ]]; then if [[ -e "/etc/os-release" ]]; then
@@ -316,7 +310,6 @@ EOF
_createrepo_cmd(){ createrepo -q "$@"; } _createrepo_cmd(){ createrepo -q "$@"; }
fi fi
fi fi
} }
@@ -599,19 +592,21 @@ EOF
# Add repository files # Add repository files
_addRepo() { _addRepo() {
debug "Running: ${FUNCNAME[0]}"
# Add repositories to OS-specific package managers # Add repositories to OS-specific package managers
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
_bash_cmd 'cat <<-EOF > /etc/yum.repos.d/jriver.repo _bash_cmd 'cat <<- EOF > /etc/yum.repos.d/jriver.repo
[jriver] [jriver]
name=JRiver Media Center repo by BryanC name=JRiver Media Center repo by BryanC
baseurl=https://repos.bryanroessler.com/jriver baseurl=https://repos.bryanroessler.com/jriver
gpgcheck=0 gpgcheck=0
EOF' EOF'
elif [[ "$ID" =~ ^(ubuntu|debian)$ ]]; then elif [[ "$ID" =~ ^(ubuntu|debian)$ ]]; then
_installPackage wget
wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | _ifSudo apt-key add - > /dev/null 2>&1 wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | _ifSudo apt-key add - > /dev/null 2>&1
_bash_cmd 'cat <<-EOF > /etc/apt/sources.list.d/jriver.list _bash_cmd 'cat <<- EOF > /etc/apt/sources.list.d/jriver.list
deb [arch=amd64,i386,armhf] http://dist.jriver.com/latest/mediacenter/ jessie main deb [arch=amd64,i386,armhf] http://dist.jriver.com/latest/mediacenter/ buster main
EOF' EOF'
fi fi
} }
_addRepo _addRepo
@@ -772,77 +767,77 @@ EOF'
fi fi
# Create spec file # Create spec file
bash -c "cat <<EOF > $_outputdir/SPECS/mediacenter.spec cat <<- EOF > "$_outputdir/SPECS/mediacenter.spec"
Name: MediaCenter Name: MediaCenter
Version: $_mcversion Version: $_mcversion
Release: 1 Release: 1
Summary: JRiver Media Center Summary: JRiver Media Center
Group: Applications/Media Group: Applications/Media
Source0: http://files.jriver.com/mediacenter/channels/v$_mversion/latest/MediaCenter-$_mcversion-amd64.deb Source0: http://files.jriver.com/mediacenter/channels/v$_mversion/latest/MediaCenter-$_mcversion-amd64.deb
$_build_requires $_build_requires
BuildArch: x86_64 BuildArch: x86_64
%define _rpmfilename %%{ARCH}/%%{NAME}-%%{version}.%%{ARCH}.rpm %define _rpmfilename %%{ARCH}/%%{NAME}-%%{version}.%%{ARCH}.rpm
AutoReq: 0 AutoReq: 0
Requires: glibc >= 2.19 Requires: glibc >= 2.19
Requires: alsa-lib >= 1.0.28 Requires: alsa-lib >= 1.0.28
Requires: libuuid >= 2.25 Requires: libuuid >= 2.25
Requires: libX11 >= 1.6 Requires: libX11 >= 1.6
Requires: libX11-common >= 1.6 Requires: libX11-common >= 1.6
Requires: libXext >= 1.3 Requires: libXext >= 1.3
Requires: libxcb >= 1.1 Requires: libxcb >= 1.1
Requires: libXdmcp >= 1.1 Requires: libXdmcp >= 1.1
Requires: libstdc++ >= 4.9 Requires: libstdc++ >= 4.9
Requires: gtk3 >= 3.14 Requires: gtk3 >= 3.14
Requires: mesa-libGL Requires: mesa-libGL
Requires: libglvnd-glx Requires: libglvnd-glx
Requires: pango >= 1.36 Requires: pango >= 1.36
$_requires $_requires
Requires: libXScrnSaver Requires: libXScrnSaver
Requires: xdg-utils Requires: xdg-utils
Requires: libgomp >= 4.9 Requires: libgomp >= 4.9
Requires: nss >= 3.26 Requires: nss >= 3.26
Requires: nspr >= 4.12 Requires: nspr >= 4.12
Requires: ca-certificates Requires: ca-certificates
Requires: python3 Requires: python3
Recommends: vorbis-tools >= 1.4.0 Recommends: vorbis-tools >= 1.4.0
Recommends: lame >= 3.0 Recommends: lame >= 3.0
Provides: mediacenter$_mversion Provides: mediacenter$_mversion
License: Copyright 1998-2020, JRiver, Inc. All rights reserved. Protected by U.S. patents #7076468 and #7062468 License: Copyright 1998-2020, JRiver, Inc. All rights reserved. Protected by U.S. patents #7076468 and #7062468
URL: http://www.jriver.com/ URL: http://www.jriver.com/
%define __provides_exclude_from ^%{_libdir}/jriver/.*/.*\\.so.*$ %define __provides_exclude_from ^%{_libdir}/jriver/.*/.*\\.so.*$
%description %description
Media Center is more than a world class player. Media Center is more than a world class player.
%global __os_install_post %{nil} %global __os_install_post %{nil}
%prep %prep
%build %build
%install %install
dpkg -x %{S:0} %{buildroot} dpkg -x %{S:0} %{buildroot}
%post -p /sbin/ldconfig %post -p /sbin/ldconfig
%postun -p /sbin/ldconfig %postun -p /sbin/ldconfig
%files %files
%{_bindir}/mediacenter$_mversion %{_bindir}/mediacenter$_mversion
%{_libdir}/jriver %{_libdir}/jriver
%{_datadir} %{_datadir}
%exclude %{_datadir}/applications/media_center_packageinstaller_$_mversion.desktop %exclude %{_datadir}/applications/media_center_packageinstaller_$_mversion.desktop
/etc/security/limits.d/* /etc/security/limits.d/*
EOF" EOF
declare -g _mcrpm="$_outputdir/RPMS/x86_64/MediaCenter-$_mcversion.x86_64.rpm" declare -g _mcrpm="$_outputdir/RPMS/x86_64/MediaCenter-$_mcversion.x86_64.rpm"
# skip rebuilding the rpm if it already exists # skip rebuilding the rpm if it already exists
if [[ -f "$_mcrpm" ]]; then if [[ -f "$_mcrpm" ]]; then
echo "$_mcrpm already exists. Skipping build step..." echo "$_mcrpm already exists. Skipping build step..."
return 0 # this is fine return 0
else else
# Run rpmbuild # Run rpmbuild
echo "Building version $_mcversion, please wait..." echo "Building version $_mcversion, please wait..."
@@ -914,7 +909,6 @@ EOF"
# 0 if symlinking is unecessary or successful, 1 if not # 0 if symlinking is unecessary or successful, 1 if not
####################################### #######################################
_symlinkCerts() { _symlinkCerts() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
if [[ ! -f /etc/ssl/certs/ca-certificates.crt && \ if [[ ! -f /etc/ssl/certs/ca-certificates.crt && \
@@ -937,7 +931,6 @@ EOF"
# 0 if license restored successfully or skipped, 1 if unsuccessful # 0 if license restored successfully or skipped, 1 if unsuccessful
####################################### #######################################
_restoreLicense() { _restoreLicense() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
local _mjr local _mjr
@@ -972,7 +965,6 @@ EOF"
# 0 if ports opened sucessfully, 1 if not # 0 if ports opened sucessfully, 1 if not
####################################### #######################################
_openFirewall() { _openFirewall() {
debug "Running: ${FUNCNAME[0]}" "$@" debug "Running: ${FUNCNAME[0]}" "$@"
# Create OS-specific port rules based on argument (service) name # Create OS-specific port rules based on argument (service) name
@@ -1006,12 +998,12 @@ EOF"
# Debian ufw package state is broken on fresh installations # Debian ufw package state is broken on fresh installations
[[ ! -x $(command -v ufw) ]] && _installPackage ufw [[ ! -x $(command -v ufw) ]] && _installPackage ufw
if [[ ! -f "/etc/ufw/applications.d/$1" ]]; then if [[ ! -f "/etc/ufw/applications.d/$1" ]]; then
_bash_cmd "cat <<-EOF > /etc/ufw/applications.d/$1 _bash_cmd "cat <<- EOF > /etc/ufw/applications.d/$1
[$1] [$1]
title=$1 title=$1
description=$1 installed by installJRMC description=$1 installed by installJRMC
ports=$_u_ports ports=$_u_ports
EOF" EOF"
fi fi
_firewall_cmd app update "$1" _firewall_cmd app update "$1"
_firewall_cmd allow "$1" > /dev/null 2>&1 _firewall_cmd allow "$1" > /dev/null 2>&1
@@ -1034,7 +1026,6 @@ EOF"
# 0 if password created sucessfully, 1 if not # 0 if password created sucessfully, 1 if not
####################################### #######################################
_setX11VNCPass() { _setX11VNCPass() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_vncpassfile="$HOME/.vnc/jrmc_passwd" _vncpassfile="$HOME/.vnc/jrmc_passwd"
@@ -1068,7 +1059,6 @@ EOF"
# 0 if password created sucessfully, 1 if not # 0 if password created sucessfully, 1 if not
####################################### #######################################
_setVNCPass() { _setVNCPass() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_vncpassfile="$HOME/.vnc/jrmc_passwd" _vncpassfile="$HOME/.vnc/jrmc_passwd"
@@ -1105,6 +1095,7 @@ EOF"
# _next_displaynum # _next_displaynum
####################################### #######################################
_setDisplay() { _setDisplay() {
debug "Running: ${FUNCNAME[0]}"
# Check _display, else DISPLAY, else set to :0 by default # Check _display, else DISPLAY, else set to :0 by default
if [[ -n $_display ]]; then if [[ -n $_display ]]; then
@@ -1138,6 +1129,7 @@ EOF"
# _user_specifier # _user_specifier
####################################### #######################################
_servicePrep() { _servicePrep() {
debug "Running: ${FUNCNAME[0]}"
if [[ "$_service_user" == "root" ]]; then if [[ "$_service_user" == "root" ]]; then
_service_fname="/usr/lib/systemd/system/${1}.service" _service_fname="/usr/lib/systemd/system/${1}.service"
@@ -1167,28 +1159,27 @@ EOF"
# XAUTHORITY # XAUTHORITY
####################################### #######################################
_service_jriver-mediacenter() { _service_jriver-mediacenter() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_bash_cmd "cat <<-EOF > $_service_fname _bash_cmd "cat <<- EOF > $_service_fname
[Unit] [Unit]
Description=JRiver Media Center $_mversion Description=JRiver Media Center $_mversion
After=graphical.target After=graphical.target
[Service] [Service]
$_user_specifier $_user_specifier
Type=simple Type=simple
Environment=DISPLAY=$_display Environment=DISPLAY=$_display
Environment=XAUTHORITY=$XAUTHORITY Environment=XAUTHORITY=$XAUTHORITY
ExecStart=/usr/bin/mediacenter$_mversion $* ExecStart=/usr/bin/mediacenter$_mversion $*
Restart=always Restart=always
RestartSec=10 RestartSec=10
KillSignal=SIGHUP KillSignal=SIGHUP
TimeoutStopSec=30 TimeoutStopSec=30
[Install] [Install]
WantedBy=graphical.target WantedBy=graphical.target
EOF" EOF"
_systemctl_reload && \ _systemctl_reload && \
_systemctl_start "$_service_name" && \ _systemctl_start "$_service_name" && \
_systemctl_enable "$_service_name" && \ _systemctl_enable "$_service_name" && \
@@ -1200,7 +1191,6 @@ EOF"
# Starts and enables (at startup) a JRiver Media Server service # Starts and enables (at startup) a JRiver Media Server service
####################################### #######################################
_service_jriver-mediaserver() { _service_jriver-mediaserver() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_service_jriver-mediacenter "/MediaServer" _service_jriver-mediacenter "/MediaServer"
@@ -1210,8 +1200,7 @@ EOF"
####################################### #######################################
# Starts and enables (at startup) JRiver Media Center in a new Xvnc session # Starts and enables (at startup) JRiver Media Center in a new Xvnc session
####################################### #######################################
_service_jriver-xvnc() { _service_jriver-xvnc-mediacenter() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_installPackage tigervnc-server _installPackage tigervnc-server
@@ -1226,22 +1215,23 @@ EOF"
_exec_start_cmd="/usr/bin/vncserver $_next_display -geometry 1440x900 -alwaysshared -rfbauth $HOME/.vnc/jrmc_passwd -autokill -xstartup /usr/bin/mediacenter$_mversion" _exec_start_cmd="/usr/bin/vncserver $_next_display -geometry 1440x900 -alwaysshared -rfbauth $HOME/.vnc/jrmc_passwd -autokill -xstartup /usr/bin/mediacenter$_mversion"
fi fi
_bash_cmd "cat <<-EOF > $_service_fname _bash_cmd "cat <<- EOF > $_service_fname
[Unit] [Unit]
Description=Remote desktop service (VNC) Description=Remote desktop service (VNC)
After=syslog.target network.target After=syslog.target network.target
[Service] [Service]
Type=simple Type=simple
$_user_specifier $_user_specifier
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill $_next_display > /dev/null 2>&1 || :' ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill $_next_display > /dev/null 2>&1 || :'
ExecStart=$_exec_start_cmd ExecStart=$_exec_start_cmd
ExecStop=/usr/bin/vncserver -kill $_next_display ExecStop=/usr/bin/vncserver -kill $_next_display
Restart=always Restart=always
[Install]
WantedBy=multi-user.target
EOF"
[Install]
WantedBy=multi-user.target
EOF"
_systemctl_reload && \ _systemctl_reload && \
_systemctl_start "$_service_name" && \ _systemctl_start "$_service_name" && \
_systemctl_enable "$_service_name" && \ _systemctl_enable "$_service_name" && \
@@ -1255,7 +1245,6 @@ EOF"
# Starts and enables (at startup) JRiver Media Server and x11vnc sharing the local desktop # Starts and enables (at startup) JRiver Media Server and x11vnc sharing the local desktop
####################################### #######################################
_service_jriver-x11vnc() { _service_jriver-x11vnc() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_installPackage x11vnc _installPackage x11vnc
@@ -1282,21 +1271,22 @@ EOF"
fi fi
_bash_cmd "cat <<-EOF > $_service_fname _bash_cmd "cat <<-EOF > $_service_fname
[Unit] [Unit]
Description=x11vnc Description=x11vnc
After=multi.service After=multi.service
[Service] [Service]
$_user_specifier $_user_specifier
Type=forking Type=forking
Environment=DISPLAY=$_display Environment=DISPLAY=$_display
ExecStart=$_exec_start_cmd ExecStart=$_exec_start_cmd
Restart=always Restart=always
RestartSec=10 RestartSec=10
[Install]
WantedBy=multi-user.target
EOF"
[Install]
WantedBy=multi-user.target
EOF"
_systemctl_reload && \ _systemctl_reload && \
_systemctl_start "$_service_name" && \ _systemctl_start "$_service_name" && \
_systemctl_enable "$_service_name" && \ _systemctl_enable "$_service_name" && \
@@ -1310,31 +1300,32 @@ EOF"
# Center RPM from the source DEB and create/update an RPM repository # Center RPM from the source DEB and create/update an RPM repository
####################################### #######################################
_service_jriver-createrepo() { _service_jriver-createrepo() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_bash_cmd "cat <<-EOF > $_service_fname _bash_cmd "cat <<-EOF > $_service_fname
[Unit] [Unit]
Description=Builds JRiver Media Center RPM file, moves it to the repo dir, and runs createrepo Description=Builds JRiver Media Center RPM file, moves it to the repo dir, and runs createrepo
[Service] [Service]
$_user_specifier $_user_specifier
ExecStart=$_basedir/installJRMC --outputdir $_outputdir --createrepo --createrepo-webroot $_createrepo_webroot --createrepo-user $_createrepo_user ExecStart=$_basedir/installJRMC --outputdir $_outputdir --createrepo --createrepo-webroot $_createrepo_webroot --createrepo-user $_createrepo_user
[Install]
WantedBy=default.target
EOF"
[Install]
WantedBy=default.target
EOF"
_bash_cmd "cat <<-EOF > $_timer_fname _bash_cmd "cat <<-EOF > $_timer_fname
[Unit] [Unit]
Description=Run JRiver MC rpmbuild hourly Description=Run JRiver MC rpmbuild hourly
[Timer] [Timer]
OnCalendar=hourly OnCalendar=hourly
Persistent=true Persistent=true
[Install]
WantedBy=timers.target
EOF"
[Install]
WantedBy=timers.target
EOF"
_systemctl_reload && \ _systemctl_reload && \
_systemctl_start "$_timer_name" && \ _systemctl_start "$_timer_name" && \
_systemctl_enable "$_timer_name" _systemctl_enable "$_timer_name"
@@ -1363,7 +1354,6 @@ EOF"
# Complete uninstall # Complete uninstall
####################################### #######################################
_uninstall() { _uninstall() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
read -r -p "Do you really want to uninstall JRiver Media Center? [y/N] " _response read -r -p "Do you really want to uninstall JRiver Media Center? [y/N] " _response
@@ -1410,7 +1400,7 @@ EOF"
} }
__main() { _main() {
# Parse input # Parse input
_parseInput "$@" _parseInput "$@"
@@ -1426,7 +1416,7 @@ EOF"
# Install MC using package manager # Install MC using package manager
if [[ -n $_repoinstall ]]; then if [[ -n $_repoinstall ]]; then
_installPackage rpmfusion-free-release epel-release [[ "$ID" =~ ^(fedora|centos)$ ]] && _installPackage rpmfusion-free-release epel-release
_installMCFromRepo _installMCFromRepo
_symlinkCerts _symlinkCerts
_restoreLicense _restoreLicense
@@ -1483,5 +1473,5 @@ EOF"
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
_basedir=$(dirname "$(readlink -f "$0")") _basedir=$(dirname "$(readlink -f "$0")")
installJRMC installJRMC
__main "$@" _main "$@"
fi fi