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,9 +26,7 @@ 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'
@@ -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,6 +592,7 @@ 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
@@ -608,9 +602,10 @@ 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
} }
@@ -772,7 +767,7 @@ 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
@@ -835,14 +830,14 @@ dpkg -x %{S:0} %{buildroot}
%{_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
@@ -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,7 +1159,6 @@ 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
@@ -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
@@ -1242,6 +1231,7 @@ Restart=always
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF" 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
@@ -1297,6 +1286,7 @@ RestartSec=10
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF" EOF"
_systemctl_reload && \ _systemctl_reload && \
_systemctl_start "$_service_name" && \ _systemctl_start "$_service_name" && \
_systemctl_enable "$_service_name" && \ _systemctl_enable "$_service_name" && \
@@ -1310,7 +1300,6 @@ 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
@@ -1324,6 +1313,7 @@ ExecStart=$_basedir/installJRMC --outputdir $_outputdir --createrepo --createrep
[Install] [Install]
WantedBy=default.target WantedBy=default.target
EOF" 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
@@ -1335,6 +1325,7 @@ Persistent=true
[Install] [Install]
WantedBy=timers.target WantedBy=timers.target
EOF" 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