Refactoring
This commit is contained in:
22
README.md
22
README.md
@@ -11,21 +11,21 @@ This program will install [JRiver Media Center](https://www.jriver.com/) and ass
|
|||||||
|
|
||||||
`installJRMC [--option [ARGUMENT]]`
|
`installJRMC [--option [ARGUMENT]]`
|
||||||
|
|
||||||
Running `installJRMC` without any options will install the latest version of JRiver Media Center from the official JRiver repository (Ubuntu/Debian) or my [unofficial repository](https://repos.bryanroessler.com/jriver/) (Fedora/CentOS) using the system package manager. If any other option is specified then the default install method will need to be specified using `--install-repo` (or `--install-rpm`). This makes it possible to install services, containers, repos, etc. independent from Media Center.
|
Running `installJRMC` without any options will install the latest version of JRiver Media Center from the official JRiver repository (Ubuntu/Debian) or my [unofficial repository](https://repos.bryanroessler.com/jriver/) (Fedora/CentOS) using the system package manager. If any other option is specified then the default install method will need to be specified using `--repo` or `--rpm`. This makes it possible to install services, containers, repos, etc. independent of Media Center.
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
Here is a list of possible options that can be passed to the script. You can always find the latest supported options by running `installJRMC --help`.
|
Here is a list of possible options that can be passed to the script. You can always find the latest supported options by running `installJRMC --help`.
|
||||||
|
|
||||||
```text
|
```text
|
||||||
--install-repo
|
--repo
|
||||||
Install JRiver Media Center from repository using package manager (Default)
|
Install JRiver Media Center from repository using package manager
|
||||||
DEB-based OSes: Official package repository
|
DEB-based OSes: Official package repository
|
||||||
RPM-based OSes: BryanC's unofficial repository
|
RPM-based OSes: BryanC's unofficial repository
|
||||||
--install-rpm
|
--rpm
|
||||||
(RPM-based OSes only) Build RPM from source DEB and install it
|
Build RPM from source DEB and install it
|
||||||
--rpmbuild
|
--rpmbuild
|
||||||
Build RPM from source DEB
|
Build RPM from source DEB but do not install
|
||||||
--outputdir PATH
|
--outputdir PATH
|
||||||
Generate rpmbuild output in this directory (Default: $PWD/outputdir)
|
Generate rpmbuild output in this directory (Default: $PWD/outputdir)
|
||||||
--mcversion VERSION
|
--mcversion VERSION
|
||||||
@@ -81,7 +81,7 @@ jriver-createrepo
|
|||||||
Install hourly service to build latest MC RPM and run createrepo
|
Install hourly service to build latest MC RPM and run createrepo
|
||||||
```
|
```
|
||||||
|
|
||||||
It is possible to install multiple services at one time using multiple `--service` blocks: `installJRMC --install-repo --service jriver-x11vnc --service jriver-mediacenter`
|
It is possible to install multiple services at one time using multiple `--service` blocks: `installJRMC --repo --service jriver-x11vnc --service jriver-mediacenter`
|
||||||
|
|
||||||
#### `jriver-x11vnc` versus `jriver-xvnc-mediacenter`
|
#### `jriver-x11vnc` versus `jriver-xvnc-mediacenter`
|
||||||
|
|
||||||
@@ -105,11 +105,11 @@ It is possible to install multiple services at one time using multiple `--servic
|
|||||||
|
|
||||||
Installs the latest version of JRiver Media Center from the repository.
|
Installs the latest version of JRiver Media Center from the repository.
|
||||||
|
|
||||||
* `installJRMC --install-repo --service jriver-mediaserver`
|
* `installJRMC --repo --service jriver-mediaserver`
|
||||||
|
|
||||||
Installs JRiver Media Center from the repository and starts/enables the /MediaServer service.
|
Installs JRiver Media Center from the repository and starts/enables the /MediaServer service.
|
||||||
|
|
||||||
* `installJRMC --install-rpm --restorefile /path/to/license.mjr --mcversion 26.0.56`
|
* `installJRMC --rpm --restorefile /path/to/license.mjr --mcversion 26.0.56`
|
||||||
|
|
||||||
Builds JRiver Media Center version 26.0.56 RPM from the source DEB, installs it (RPM distros only), and activates it using the specified .mjr license file.
|
Builds JRiver Media Center version 26.0.56 RPM from the source DEB, installs it (RPM distros only), and activates it using the specified .mjr license file.
|
||||||
|
|
||||||
@@ -121,11 +121,11 @@ It is possible to install multiple services at one time using multiple `--servic
|
|||||||
|
|
||||||
Installs the jriver-createrepo timer and service to build the RPM, move it to the webroot, and run createrepo as `www-user` hourly.
|
Installs the jriver-createrepo timer and service to build the RPM, move it to the webroot, and run createrepo as `www-user` hourly.
|
||||||
|
|
||||||
* `installJRMC --install-repo --service jriver-x11vnc --service jriver-mediacenter --vncpass "letmein"`
|
* `installJRMC --repo --service jriver-x11vnc --service jriver-mediacenter --vncpass "letmein"`
|
||||||
|
|
||||||
Installs services to share the existing local desktop via VNC and automatically run Media Center on startup.
|
Installs services to share the existing local desktop via VNC and automatically run Media Center on startup.
|
||||||
|
|
||||||
* `installJRMC --install-repo --service jriver-xvnc-mediacenter --display ":2"`
|
* `installJRMC --repo --service jriver-xvnc-mediacenter --display ":2"`
|
||||||
|
|
||||||
Installs an Xvnc server on display ':2' that starts Media Center.
|
Installs an Xvnc server on display ':2' that starts Media Center.
|
||||||
|
|
||||||
|
|||||||
674
installJRMC
674
installJRMC
@@ -10,21 +10,13 @@ shopt -s extglob
|
|||||||
# 1. Raspberry Pi OS support
|
# 1. Raspberry Pi OS support
|
||||||
# 2. Interactive installation (ncurses?)
|
# 2. Interactive installation (ncurses?)
|
||||||
#
|
#
|
||||||
# installJRMC can be run directly or sourced as a function (by sourcing this file)
|
|
||||||
# Arguments:
|
|
||||||
# see _printHelpAndExit() and _parseInput() for available options
|
|
||||||
# Returns:
|
|
||||||
# 0 if critical functions complete successfully
|
|
||||||
#######################################
|
#######################################
|
||||||
installJRMC() {
|
|
||||||
|
|
||||||
_scriptversion="0.9.5"
|
_scriptversion="0.9.6"
|
||||||
_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="$PWD/output"
|
||||||
_createrepo_webroot="/srv/jriver"
|
_createrepo_webroot="/srv/jriver"
|
||||||
_exec_user="$(whoami)"
|
_exec_user="$(whoami)"
|
||||||
_available_services=("jriver-createrepo" "jriver-x11vnc" "jriver-mediaserver" "jriver-mediacenter" "jriver-xvnc-mediacenter")
|
|
||||||
#_available_containers=("mediacenter-xvnc" "createrepo")
|
|
||||||
|
|
||||||
_printHelpAndExit() {
|
_printHelpAndExit() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
@@ -33,15 +25,17 @@ installJRMC() {
|
|||||||
USAGE:
|
USAGE:
|
||||||
installJRMC [[OPTION] [VALUE]]...
|
installJRMC [[OPTION] [VALUE]]...
|
||||||
|
|
||||||
|
If no options (besides -d) are provided, the script will default to --repo
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
--install-repo
|
--repo
|
||||||
Install JRiver Media Center from repository using package manager (Default)
|
Install JRiver Media Center from repository using package manager
|
||||||
DEB-based OSes: Official package repository
|
DEB-based OSes: JRiver official package repository
|
||||||
RPM-based OSes: BryanC unofficial repository
|
RPM-based OSes: BryanC unofficial repository
|
||||||
--install-rpm
|
--rpm
|
||||||
(RPM-based OSes only) Build RPM from source DEB and install it
|
Build RPM from source DEB and install it
|
||||||
--rpmbuild
|
--rpmbuild
|
||||||
Build RPM from source DEB
|
Build RPM from source DEB (no installation)
|
||||||
--outputdir PATH
|
--outputdir PATH
|
||||||
Generate rpmbuild output in this directory (Default: $PWD/outputdir)
|
Generate rpmbuild output in this directory (Default: $PWD/outputdir)
|
||||||
--mcversion VERSION
|
--mcversion VERSION
|
||||||
@@ -51,7 +45,7 @@ installJRMC() {
|
|||||||
--betapass PASSWORD
|
--betapass PASSWORD
|
||||||
Enter beta team password for access to beta builds
|
Enter beta team password for access to beta builds
|
||||||
--service-user USER
|
--service-user USER
|
||||||
Install systemd services and containers for USER
|
Install systemd services and containers for USER (Default: current user)
|
||||||
--service, -s SERVICE
|
--service, -s SERVICE
|
||||||
See SERVICES section below for a list of possible services to install
|
See SERVICES section below for a list of possible services to install
|
||||||
--container, -c CONTAINER (TODO: Under construction)
|
--container, -c CONTAINER (TODO: Under construction)
|
||||||
@@ -101,22 +95,178 @@ installJRMC() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_parseInput() {
|
_init() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
# set default behavior
|
_getOS
|
||||||
|
|
||||||
|
_parseInput "$@"
|
||||||
|
|
||||||
|
# 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 -y -q0 "$@"; }
|
||||||
|
_pkg_update(){ _ifSudo apt-get update -y -q0; }
|
||||||
|
_pkg_query(){ _ifSudo dpkg -s "$@"; }
|
||||||
|
_firewall_cmd(){ _ifSudo ufw "$@"; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set defaults
|
||||||
if [[ $# -eq 0 ]] || [[ $# -eq 1 && "$1" =~ ^(--debug|-d)$ ]]; then
|
if [[ $# -eq 0 ]] || [[ $# -eq 1 && "$1" =~ ^(--debug|-d)$ ]]; then
|
||||||
|
debug "No options passed, defaulting to --repo installation method"
|
||||||
_repoinstall="true"
|
_repoinstall="true"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if _input=$(getopt -o +vdhus:c: -l install-repo,install-rpm,rpmbuild,outputdir:,mcversion:,restorefile:,betapass:,service-user:,service:,version,debug,help,uninstall,createrepo,createrepo-webroot:,createrepo-user:,vncpass:,display:,container: -- "$@"); then
|
_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
|
||||||
|
[[ ! -v _mcversion ]] && _installPackage wget
|
||||||
|
|
||||||
|
# Set MC version
|
||||||
|
_setVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_main() {
|
||||||
|
|
||||||
|
_init "$@"
|
||||||
|
|
||||||
|
# Uninstall and exit
|
||||||
|
if [[ -v _uninstall ]]; then
|
||||||
|
_uninstall
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install MC using package manager
|
||||||
|
if [[ -v _repoinstall ]]; then
|
||||||
|
_installMCFromRepo
|
||||||
|
_symlinkCerts
|
||||||
|
_restoreLicense
|
||||||
|
_openFirewall "jriver"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build RPM from source deb package
|
||||||
|
if [[ -v _rpmbuild ]]; then
|
||||||
|
_acquireDeb
|
||||||
|
_buildRPM
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run createrepo
|
||||||
|
if [[ -v _createrepo ]]; then
|
||||||
|
_runCreaterepo "$_mcrpm"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install the rpm
|
||||||
|
if [[ -v _rpminstall ]]; then
|
||||||
|
_installPackage --noquery "$_mcrpm"
|
||||||
|
_symlinkCerts
|
||||||
|
_restoreLicense
|
||||||
|
_openFirewall "jriver"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install services
|
||||||
|
_setDisplay
|
||||||
|
for _service in "${_services[@]}"; do
|
||||||
|
_servicePrep "$_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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# Helper functions
|
||||||
|
#######################################
|
||||||
|
err() { echo "Error: $*" >&2; }
|
||||||
|
debug() {
|
||||||
|
if [[ -v _debug ]]; then
|
||||||
|
if [[ $# -gt 0 ]]; then
|
||||||
|
echo "Debug: $*"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# Prepend this to any command that you wish to execute with sudo
|
||||||
|
# Requires:
|
||||||
|
# _exec_user
|
||||||
|
#######################################
|
||||||
|
_ifSudo() {
|
||||||
|
if [[ "$_exec_user" != "root" ]]; then
|
||||||
|
sudo "$@"
|
||||||
|
else
|
||||||
|
"$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# Parse CLI input from the user w/ getopt
|
||||||
|
#######################################
|
||||||
|
_parseInput() {
|
||||||
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
|
if _input=$(getopt -o +vdhus:c: -l repo,rpm,rpmbuild,outputdir:,mcversion:,restorefile:,betapass:,service-user:,service:,version,debug,help,uninstall,createrepo,createrepo-webroot:,createrepo-user:,vncpass:,display:,container: -- "$@"); then
|
||||||
eval set -- "$_input"
|
eval set -- "$_input"
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--install-repo)
|
--repo)
|
||||||
_repoinstall="true"
|
_repoinstall="true"
|
||||||
;;
|
;;
|
||||||
--install-rpm)
|
--rpm)
|
||||||
|
[[ ! "$ID" =~ ^(fedora|centos)$ ]] && \
|
||||||
|
err "RPM installation not available on $ID" && \
|
||||||
|
_printHelpAndExit 1
|
||||||
_rpmbuild="true"
|
_rpmbuild="true"
|
||||||
_rpminstall="true"
|
_rpminstall="true"
|
||||||
;;
|
;;
|
||||||
@@ -141,6 +291,22 @@ installJRMC() {
|
|||||||
--service|-s)
|
--service|-s)
|
||||||
shift && _services+=("$1")
|
shift && _services+=("$1")
|
||||||
;;
|
;;
|
||||||
|
--createrepo)
|
||||||
|
_rpmbuild="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)
|
--container|-c)
|
||||||
shift && _containers+=("$1")
|
shift && _containers+=("$1")
|
||||||
;;
|
;;
|
||||||
@@ -159,22 +325,6 @@ installJRMC() {
|
|||||||
--uninstall|-u)
|
--uninstall|-u)
|
||||||
_uninstall="true"
|
_uninstall="true"
|
||||||
;;
|
;;
|
||||||
--createrepo)
|
|
||||||
_createrepo="true"
|
|
||||||
_rpmbuild="true"
|
|
||||||
;;
|
|
||||||
--createrepo-webroot)
|
|
||||||
shift && _createrepo_webroot="$1"
|
|
||||||
;;
|
|
||||||
--createrepo-user)
|
|
||||||
shift && _createrepo_user="$1"
|
|
||||||
;;
|
|
||||||
--vncpass)
|
|
||||||
shift && _vncpass="$1"
|
|
||||||
;;
|
|
||||||
--display)
|
|
||||||
shift && _display="$1"
|
|
||||||
;;
|
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
@@ -188,27 +338,9 @@ installJRMC() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
err() { echo "Error: $*" >&2; }
|
|
||||||
|
|
||||||
debug() { [[ -v _debug ]] && echo "Debug: $*"; }
|
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Prepend this to any command that you wish to execute with sudo
|
# Get host OS from /etc/os-release
|
||||||
# Requires:
|
|
||||||
# _exec_user
|
|
||||||
#######################################
|
|
||||||
_ifSudo() {
|
|
||||||
if [[ "$_exec_user" != "root" ]]; then
|
|
||||||
sudo "$@"
|
|
||||||
else
|
|
||||||
"$@"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#######################################
|
|
||||||
# Sources /etc/os-release so we know which OS we're running on
|
|
||||||
# Used in: _buildCommands()
|
|
||||||
#######################################
|
#######################################
|
||||||
_getOS() {
|
_getOS() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
@@ -216,7 +348,7 @@ installJRMC() {
|
|||||||
if [[ -e "/etc/os-release" ]]; then
|
if [[ -e "/etc/os-release" ]]; then
|
||||||
source "/etc/os-release"
|
source "/etc/os-release"
|
||||||
else
|
else
|
||||||
err "No /etc/os-release found"
|
err "/etc/os-release not found"
|
||||||
err "Your OS is unsupported"
|
err "Your OS is unsupported"
|
||||||
_printHelpAndExit 1
|
_printHelpAndExit 1
|
||||||
fi
|
fi
|
||||||
@@ -226,80 +358,29 @@ installJRMC() {
|
|||||||
|
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Creates some OS-specific functions to query, install, and remove packages and edit
|
# Get our MC working version from input argument or scraping Interact
|
||||||
# firewalls, run bash, remove and copy files, etc.
|
# Requires:
|
||||||
|
# _boardurl
|
||||||
#######################################
|
#######################################
|
||||||
_buildCommands() {
|
_setVersion() {
|
||||||
|
|
||||||
# Detect OS
|
|
||||||
_getOS
|
|
||||||
|
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
# Agnostic commands
|
# If user does not specify a version, scrape the latest from Interact
|
||||||
_bash_cmd(){ _ifSudo bash -c "$@"; }
|
if [[ ! -v _mcversion ]]; then
|
||||||
_rm_cmd(){ _ifSudo rm -rf "$@"; }
|
echo "Scraping latest MC version number from Interact..."
|
||||||
_cp_cmd(){ _ifSudo cp -n "$@"; }
|
if ! _mcversion=$(wget -qO- "$_boardurl" | grep -o "[0-9][0-9]\.[0-9]\.[0-9]\+" | head -n 1); then
|
||||||
_mkdir_cmd(){ _ifSudo mkdir -p "$@"; }
|
err "MC version could not be scraped. Please recheck the boardurl: $_boardurl or specify a version manually using --mcversion"
|
||||||
_ln_cmd(){ _ifSudo ln -s "$@"; }
|
_printHelpAndExit 1
|
||||||
_systemctl_reload(){ _ifSudo systemctl daemon-reload; }
|
|
||||||
_systemctl_start(){
|
|
||||||
echo "Starting $*"
|
|
||||||
if ! _ifSudo systemctl start "$@"; then
|
|
||||||
err "Could not start $*"
|
|
||||||
err "Check service status using \"sudo systemctl status $*\""
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
_systemctl_enable(){ _ifSudo systemctl enable "$@"; }
|
|
||||||
_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 -y -q0 "$@"; }
|
|
||||||
_pkg_update(){ _ifSudo apt-get update -y -q0; }
|
|
||||||
_pkg_query(){ _ifSudo dpkg -s "$@"; }
|
|
||||||
_firewall_cmd(){ _ifSudo ufw "$@"; }
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Some additional commands specifically for createrepo (primarily to handle user rights)
|
|
||||||
# Could also go in runCreaterepo() but let's leave it here for now
|
|
||||||
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
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
|
echo "Using version: $_mcversion"
|
||||||
|
|
||||||
#######################################
|
# Extract major version number
|
||||||
# Sets default user variables
|
_mversion="${_mcversion%%.*}"
|
||||||
#######################################
|
|
||||||
_setUser() {
|
|
||||||
|
|
||||||
[[ ! -v _service_user ]] && _service_user="$_exec_user"
|
# Saving this substituion in case it's needed in the future
|
||||||
[[ ! -v _createrepo_user ]] && _createrepo_user="$_exec_user"
|
#_variation="${_mcversion##*.}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -313,7 +394,6 @@ installJRMC() {
|
|||||||
# Will exit 1 if failed
|
# Will exit 1 if failed
|
||||||
#######################################
|
#######################################
|
||||||
_installPackage() {
|
_installPackage() {
|
||||||
|
|
||||||
debug "Running: ${FUNCNAME[0]}" "$@"
|
debug "Running: ${FUNCNAME[0]}" "$@"
|
||||||
|
|
||||||
if _input=$(getopt -o +n -l noquery -- "$@"); then
|
if _input=$(getopt -o +n -l noquery -- "$@"); then
|
||||||
@@ -339,12 +419,10 @@ installJRMC() {
|
|||||||
local -a _pkg_array
|
local -a _pkg_array
|
||||||
local -a _url_pkg_array
|
local -a _url_pkg_array
|
||||||
|
|
||||||
# parse arguments (packages)
|
# Parse packages
|
||||||
for _pkg in "$@"; do
|
for _pkg in "$@"; do
|
||||||
# Clean up package name and handle OS-specific tweaks
|
[[ -v PKG_ALIASES && -v PKG_ALIASES["$_pkg"] ]] && _pkg=PKG_ALIASES["$_pkg"]
|
||||||
_packageQuirks "$_pkg"
|
|
||||||
# Insert the package name to test if already installed
|
# Insert the package name to test if already installed
|
||||||
if [[ "$_pkg" != "" ]]; then
|
|
||||||
if [[ -v _noquery ]] || ! _pkg_query "$_pkg" > /dev/null 2>&1; then
|
if [[ -v _noquery ]] || ! _pkg_query "$_pkg" > /dev/null 2>&1; then
|
||||||
if [[ -v _url_pkg ]]; then
|
if [[ -v _url_pkg ]]; then
|
||||||
_url_pkg_array+=("$_url_pkg")
|
_url_pkg_array+=("$_url_pkg")
|
||||||
@@ -352,13 +430,12 @@ installJRMC() {
|
|||||||
_pkg_array+=("$_pkg")
|
_pkg_array+=("$_pkg")
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Install from package name (with gpg check)
|
# Install from package name (with gpg check)
|
||||||
if [[ ${#_pkg_array[@]} -ge 1 ]]; then
|
if [[ ${#_pkg_array[@]} -ge 1 ]]; then
|
||||||
echo "Installing:" "${_pkg_array[@]}"
|
echo "Installing:" "${_pkg_array[@]}"
|
||||||
if [[ -v _debug ]]; then
|
if debug; then
|
||||||
if ! _pkg_install "${_pkg_array[@]}"; then
|
if ! _pkg_install "${_pkg_array[@]}"; then
|
||||||
err "Failed to install package. Attempting to continue..."
|
err "Failed to install package. Attempting to continue..."
|
||||||
return 1
|
return 1
|
||||||
@@ -372,7 +449,7 @@ installJRMC() {
|
|||||||
# Install from package url (without gpg check)
|
# Install from package url (without gpg check)
|
||||||
if [[ ${#_url_pkg_array[@]} -ge 1 ]]; then
|
if [[ ${#_url_pkg_array[@]} -ge 1 ]]; then
|
||||||
echo "Installing:" "${_url_pkg_array[@]}"
|
echo "Installing:" "${_url_pkg_array[@]}"
|
||||||
if [[ -v _debug ]]; then
|
if debug; then
|
||||||
if ! _pkg_install_nogpg "${_url_pkg_array[@]}"; then
|
if ! _pkg_install_nogpg "${_url_pkg_array[@]}"; then
|
||||||
err "Failed to install package. Attempting to continue..."
|
err "Failed to install package. Attempting to continue..."
|
||||||
return 1
|
return 1
|
||||||
@@ -385,170 +462,6 @@ installJRMC() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#######################################
|
|
||||||
# Handles OS-specific package name tweaks and source urls
|
|
||||||
# Arguments:
|
|
||||||
# A package name
|
|
||||||
# Globals:
|
|
||||||
# _pkg
|
|
||||||
# _url_pkg
|
|
||||||
#######################################
|
|
||||||
_packageQuirks() {
|
|
||||||
|
|
||||||
debug "Running: ${FUNCNAME[0]}" "$@"
|
|
||||||
|
|
||||||
unset _url_pkg
|
|
||||||
|
|
||||||
if [[ "$1" == "xorg-x11-utils" && "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
|
|
||||||
_pkg="x11-utils"
|
|
||||||
elif [[ "$1" == "rpm-build" && "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
|
|
||||||
_pkg="rpm"
|
|
||||||
elif [[ "$1" == "createrepo_c" && "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
|
|
||||||
_pkg="createrepo"
|
|
||||||
elif [[ "$1" == "rpmfusion-free-release" ]]; then
|
|
||||||
if [[ "$ID" == "fedora" ]]; then
|
|
||||||
# As of MC26 and Fedora 32 I don't believe that the rpmfusion repo is necessary
|
|
||||||
#_url_pkg="https://download1.rpmfusion.org/free/$ID/rpmfusion-free-release-$VERSION_ID.noarch.rpm"
|
|
||||||
#_pkg="$1"
|
|
||||||
_pkg=""
|
|
||||||
elif [[ "$ID" == "centos" ]]; then
|
|
||||||
_url_pkg="https://download1.rpmfusion.org/free/el/rpmfusion-free-release-$VERSION_ID.noarch.rpm"
|
|
||||||
_pkg="$1"
|
|
||||||
else
|
|
||||||
_pkg=""
|
|
||||||
fi
|
|
||||||
elif [[ "$1" == "epel-release" && "$ID" != "centos" ]]; then
|
|
||||||
_pkg=""
|
|
||||||
elif [[ "$1" == "tigervnc-server" && "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
|
|
||||||
_pkg="tigervnc-standalone-server"
|
|
||||||
else
|
|
||||||
_pkg="$1"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#######################################
|
|
||||||
# Get our MC working version from input argument or scraping Interact
|
|
||||||
# Requires:
|
|
||||||
# _boardurl
|
|
||||||
# _installPackage
|
|
||||||
# Globals:
|
|
||||||
# _mcversion
|
|
||||||
# _mversion
|
|
||||||
#######################################
|
|
||||||
_setVersion() {
|
|
||||||
|
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
|
||||||
|
|
||||||
if [[ ! -v _mcversion ]]; then
|
|
||||||
|
|
||||||
_installPackage wget
|
|
||||||
|
|
||||||
# Get latest version from Interact
|
|
||||||
echo "Scraping latest MC version number from Interact..."
|
|
||||||
if ! _mcversion=$(wget -qO- "$_boardurl" | grep -o "[0-9][0-9]\.[0-9]\.[0-9]\+" | head -n 1); then
|
|
||||||
err "MC version could not be scraped. Please specify a version manually using --mcversion or check your --boardurl"
|
|
||||||
_printHelpAndExit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Using version: $_mcversion"
|
|
||||||
|
|
||||||
# Extract major version number
|
|
||||||
_mversion="${_mcversion%%.*}"
|
|
||||||
|
|
||||||
# Saving this substituion in case it's needed in the future
|
|
||||||
#_variation="${_mcversion##*.}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#######################################
|
|
||||||
# Check if an argument exists in an array
|
|
||||||
# Arguments:
|
|
||||||
# The first argument is the string to match to the following arguments
|
|
||||||
# Example:
|
|
||||||
# _inArray "zebra" "${animals_arr[@]}"
|
|
||||||
# Returns:
|
|
||||||
# 0 if a match is found, 1 if not
|
|
||||||
#######################################
|
|
||||||
_inArray() {
|
|
||||||
|
|
||||||
local _match="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
local _item
|
|
||||||
for _item in "$@"; do
|
|
||||||
[[ "$_item" == "$_match" ]] && return 0
|
|
||||||
done
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#######################################
|
|
||||||
# Clean up nonsensical user input
|
|
||||||
# Notes:
|
|
||||||
# I try to keep this function as short as possible and provide better input options and
|
|
||||||
# sensible defaults than workarounds
|
|
||||||
# Test:
|
|
||||||
# _installJRMC should run sucessfully even without running _sanityChecks()
|
|
||||||
#######################################
|
|
||||||
_sanityChecks() {
|
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
|
||||||
|
|
||||||
# Check for bad service name
|
|
||||||
_checkServices() {
|
|
||||||
|
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
|
||||||
|
|
||||||
for _service in "${_services[@]}"; do
|
|
||||||
if ! _inArray "$_service" "${_available_services[@]}"; then
|
|
||||||
echo "Incorrect service type provided"
|
|
||||||
_printHelpAndExit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_checkMCInstalled() {
|
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
|
||||||
|
|
||||||
for _service in "${_services[@]}"; do
|
|
||||||
if [[ "$_service" =~ ^(jriver-mediacenter|jriver-mediaserver|jriver-xvnc-mediacenter|jriver-x11vnc)$ ]] \
|
|
||||||
&& [[ ! -v _repoinstall && ! -v _rpminstall ]] \
|
|
||||||
&& [[ ! -x $(command -v "mediacenter$_mversion") ]]; then
|
|
||||||
err "You are attempting to install a service that depends on JRiver Media Center"
|
|
||||||
err "without installing JRiver Media Center"
|
|
||||||
err "Automatically enabling --repo-install"
|
|
||||||
_repoinstall="true"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_checkUser() {
|
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
|
||||||
|
|
||||||
if [[ "$_exec_user" == "root" && ! -v _service_user && "${_services[*]}" ]]; then
|
|
||||||
err "Attempting to install services as the root user"
|
|
||||||
err "This is not recommended and we are exiting now to prevent permission hell"
|
|
||||||
err "You can override this safety check by manually specifying --user root"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Enable/disable sanity checks
|
|
||||||
if _checkServices && _checkMCInstalled && _checkUser; then
|
|
||||||
debug "Sanity checks passed!"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
err "Sanity checks failed!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Installs JRiver Media Center from a repository
|
# Installs JRiver Media Center from a repository
|
||||||
# Returns:
|
# Returns:
|
||||||
@@ -558,8 +471,9 @@ installJRMC() {
|
|||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
echo "Installing JRiver Media Center from repo..."
|
echo "Installing JRiver Media Center from repo..."
|
||||||
[[ ! -v _debug ]] && \
|
|
||||||
echo "This may take a few minutes"; \
|
! debug && \
|
||||||
|
echo "This may take a few minutes to complete"; \
|
||||||
echo "Use --debug for verbose output"
|
echo "Use --debug for verbose output"
|
||||||
|
|
||||||
local _mcpkg
|
local _mcpkg
|
||||||
@@ -567,7 +481,7 @@ installJRMC() {
|
|||||||
# Add repository files
|
# Add repository files
|
||||||
_addRepo() {
|
_addRepo() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
# 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]
|
||||||
@@ -592,21 +506,13 @@ installJRMC() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If user specifies a version, use that
|
|
||||||
if [[ -v _mcversion ]]; then
|
|
||||||
_setVersion
|
|
||||||
local _specific_version="true"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local _mcpkg
|
local _mcpkg
|
||||||
|
|
||||||
# Fedora/CentOS use a universal package name -- easy
|
# Fedora/CentOS use a universal package name -- easy
|
||||||
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
||||||
_mcpkg="MediaCenter"
|
_mcpkg="MediaCenter"
|
||||||
fi
|
|
||||||
|
|
||||||
# Ubuntu/Debian incorporate the mversion into the package name -- more fun!
|
# Ubuntu/Debian incorporate the mversion into the package name -- more fun!
|
||||||
if [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
|
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
|
||||||
if [[ ! -v _mversion ]]; then
|
if [[ ! -v _mversion ]]; then
|
||||||
# Try parsing the latest mversion from the repo
|
# Try parsing the latest mversion from the repo
|
||||||
if _mcpkg=$(apt-get install mediacenter?? -s -q0 | grep "selecting" | tail -1| awk '{print $3}'); then
|
if _mcpkg=$(apt-get install mediacenter?? -s -q0 | grep "selecting" | tail -1| awk '{print $3}'); then
|
||||||
@@ -614,7 +520,6 @@ installJRMC() {
|
|||||||
_mcpkg="${_mcpkg#\'}"
|
_mcpkg="${_mcpkg#\'}"
|
||||||
# Scrape Interact
|
# Scrape Interact
|
||||||
else
|
else
|
||||||
_setVersion
|
|
||||||
_mcpkg="mediacenter$_mversion"
|
_mcpkg="mediacenter$_mversion"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@@ -629,20 +534,20 @@ installJRMC() {
|
|||||||
|
|
||||||
if [[ -v _specific_version ]]; then
|
if [[ -v _specific_version ]]; then
|
||||||
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
||||||
if [[ -v _debug ]]; then
|
if debug; then
|
||||||
_installPackage "$_mcpkg-$_mcversion"
|
_installPackage "$_mcpkg-$_mcversion"
|
||||||
else
|
else
|
||||||
_installPackage "$_mcpkg-$_mcversion" > /dev/null 2>&1
|
_installPackage "$_mcpkg-$_mcversion" > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
|
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
|
||||||
if [[ -v _debug ]]; then
|
if debug; then
|
||||||
_installPackage "$_mcpkg=$_mcversion"
|
_installPackage "$_mcpkg=$_mcversion"
|
||||||
else
|
else
|
||||||
_installPackage "$_mcpkg=$_mcversion" > /dev/null 2>&1
|
_installPackage "$_mcpkg=$_mcversion" > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [[ -v _debug ]]; then
|
if debug; then
|
||||||
_installPackage "$_mcpkg"
|
_installPackage "$_mcpkg"
|
||||||
else
|
else
|
||||||
_installPackage "$_mcpkg" > /dev/null 2>&1
|
_installPackage "$_mcpkg" > /dev/null 2>&1
|
||||||
@@ -650,14 +555,12 @@ installJRMC() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# shellcheck disable=SC2181
|
# shellcheck disable=SC2181
|
||||||
# Rationale: More compact to check this once
|
if [[ $? -ne 0 ]]; then
|
||||||
if [[ $? -eq 0 ]]; then
|
|
||||||
echo "JRiver Media Center installed successfully"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
err "JRiver Media Center installation failed"
|
err "JRiver Media Center installation failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "JRiver Media Center installed successfully"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -669,7 +572,7 @@ installJRMC() {
|
|||||||
_acquireDeb() {
|
_acquireDeb() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
local _debfilename="$_outputdir/SOURCES/MediaCenter-${_mcversion}-amd64.deb"
|
local _debfilename="$_outputdir/SOURCES/MediaCenter-$_mcversion-amd64.deb"
|
||||||
|
|
||||||
# If necessary, create SOURCES dir
|
# If necessary, create SOURCES dir
|
||||||
[[ ! -d "$_outputdir/SOURCES" ]] && mkdir -p "$_outputdir/SOURCES"
|
[[ ! -d "$_outputdir/SOURCES" ]] && mkdir -p "$_outputdir/SOURCES"
|
||||||
@@ -680,16 +583,16 @@ installJRMC() {
|
|||||||
# Else check beta repo
|
# Else check beta repo
|
||||||
elif [[ -v _betapass ]]; then
|
elif [[ -v _betapass ]]; then
|
||||||
if wget -q -O "$_debfilename" \
|
if wget -q -O "$_debfilename" \
|
||||||
"https://files.jriver.com/mediacenter/channels/v${_mversion}/beta/${_betapass}/MediaCenter-${_mcversion}-amd64.deb"; then
|
"https://files.jriver.com/mediacenter/channels/v$_mversion/beta/$_betapass/MediaCenter-$_mcversion-amd64.deb"; then
|
||||||
true
|
true
|
||||||
fi
|
fi
|
||||||
# Else check test repo
|
# Else check test repo
|
||||||
elif wget -q -O "$_debfilename" \
|
elif wget -q -O "$_debfilename" \
|
||||||
"https://files.jriver.com/mediacenter/test/MediaCenter-${_mcversion}-amd64.deb"; then
|
"https://files.jriver.com/mediacenter/test/MediaCenter-$_mcversion-amd64.deb"; then
|
||||||
true
|
true
|
||||||
# Else check latest repo
|
# Else check latest repo
|
||||||
elif wget -q -O "$_debfilename" \
|
elif wget -q -O "$_debfilename" \
|
||||||
"https://files.jriver.com/mediacenter/channels/v${_mversion}/latest/MediaCenter-${_mcversion}-amd64.deb"; then
|
"https://files.jriver.com/mediacenter/channels/v$_mversion/latest/MediaCenter-$_mcversion-amd64.deb"; then
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
err "Cannot find DEB file. Exiting..."
|
err "Cannot find DEB file. Exiting..."
|
||||||
@@ -769,7 +672,7 @@ installJRMC() {
|
|||||||
|
|
||||||
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-2021, 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.*$
|
||||||
@@ -802,10 +705,11 @@ installJRMC() {
|
|||||||
if [[ -f "$_mcrpm" ]]; then
|
if [[ -f "$_mcrpm" ]]; then
|
||||||
echo "$_mcrpm already exists. Skipping build step..."
|
echo "$_mcrpm already exists. Skipping build step..."
|
||||||
return 0
|
return 0
|
||||||
else
|
fi
|
||||||
|
|
||||||
# Run rpmbuild
|
# Run rpmbuild
|
||||||
echo "Building version $_mcversion, please wait..."
|
echo "Building version $_mcversion, please wait..."
|
||||||
if [[ -v _debug ]]; then
|
if debug; then
|
||||||
rpmbuild --define="%_topdir $_outputdir" --define="%_libdir /usr/lib" -bb "$_outputdir/SPECS/mediacenter.spec"
|
rpmbuild --define="%_topdir $_outputdir" --define="%_libdir /usr/lib" -bb "$_outputdir/SPECS/mediacenter.spec"
|
||||||
else
|
else
|
||||||
rpmbuild --quiet --define="%_topdir $_outputdir" --define="%_libdir /usr/lib" -bb "$_outputdir/SPECS/mediacenter.spec" > /dev/null 2>&1
|
rpmbuild --quiet --define="%_topdir $_outputdir" --define="%_libdir /usr/lib" -bb "$_outputdir/SPECS/mediacenter.spec" > /dev/null 2>&1
|
||||||
@@ -819,7 +723,6 @@ installJRMC() {
|
|||||||
else
|
else
|
||||||
echo "Build successful. The RPM file is located at: $_mcrpm"
|
echo "Build successful. The RPM file is located at: $_mcrpm"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -835,6 +738,23 @@ installJRMC() {
|
|||||||
_runCreaterepo() {
|
_runCreaterepo() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
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
|
_installPackage createrepo_c
|
||||||
|
|
||||||
local _rpmfile="$1"
|
local _rpmfile="$1"
|
||||||
@@ -843,7 +763,7 @@ installJRMC() {
|
|||||||
if [[ ! -d "$_createrepo_webroot" ]]; then
|
if [[ ! -d "$_createrepo_webroot" ]]; then
|
||||||
if ! _cr_mkdir_cmd "$_createrepo_webroot"; then
|
if ! _cr_mkdir_cmd "$_createrepo_webroot"; then
|
||||||
err "Could not create the createrepo-webroot path!"
|
err "Could not create the createrepo-webroot path!"
|
||||||
err "Make sure that the createrepo-webroot is writeable by createrepo-user"
|
err "Make sure that the createrepo-webroot is writeable by createrepo-user: $_createrepo_user"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -851,7 +771,7 @@ installJRMC() {
|
|||||||
# Copy built rpms to webroot
|
# Copy built rpms to webroot
|
||||||
if ! _cr_cp_cmd -f "$_rpmfile" "$_createrepo_webroot"; then
|
if ! _cr_cp_cmd -f "$_rpmfile" "$_createrepo_webroot"; then
|
||||||
err "Could not copy the RPM to the createrepo-webroot path"
|
err "Could not copy the RPM to the createrepo-webroot path"
|
||||||
err "Make sure that the createrepo-webroot path is writeable by createrepo-user"
|
err "Make sure that the createrepo-webroot path is writeable by createrepo-user: $_createrepo_user"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -900,14 +820,14 @@ installJRMC() {
|
|||||||
|
|
||||||
# Allow user to drop an mjr file next to installJRMC
|
# Allow user to drop an mjr file next to installJRMC
|
||||||
if [[ ! -v _restorefile ]]; then
|
if [[ ! -v _restorefile ]]; then
|
||||||
for _mjr in "$_basedir"/*.mjr; do
|
for _mjr in "$PWD"/*.mjr; do
|
||||||
[[ $_mjr -nt $_restorefile ]] && _restorefile="$_mjr"
|
[[ $_mjr -nt $_restorefile ]] && _restorefile="$_mjr"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restore license
|
# Restore license
|
||||||
if [[ -f "$_restorefile" ]]; then
|
if [[ -f "$_restorefile" ]]; then
|
||||||
if ! "mediacenter${_mversion}" /RestoreFromFile "$_restorefile"; then
|
if ! "mediacenter$_mversion" /RestoreFromFile "$_restorefile"; then
|
||||||
err "Automatic license restore failed"
|
err "Automatic license restore failed"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@@ -918,7 +838,7 @@ installJRMC() {
|
|||||||
#######################################
|
#######################################
|
||||||
# Opens ports using the system firewall tool
|
# Opens ports using the system firewall tool
|
||||||
# Arguments
|
# Arguments
|
||||||
# Takes one argument, the pre-specified name of the service to enable
|
# Service to enable (pre-defined)
|
||||||
# Requires:
|
# Requires:
|
||||||
# ID
|
# ID
|
||||||
# _bash_cmd
|
# _bash_cmd
|
||||||
@@ -937,11 +857,8 @@ installJRMC() {
|
|||||||
_f_ports=("52100-52200/tcp" "1900/udp")
|
_f_ports=("52100-52200/tcp" "1900/udp")
|
||||||
_u_ports="52100:52200/tcp|1900/udp"
|
_u_ports="52100:52200/tcp|1900/udp"
|
||||||
elif [[ "$1" =~ ^(jriver-x11vnc|jriver-xvnc)$ ]]; then
|
elif [[ "$1" =~ ^(jriver-x11vnc|jriver-xvnc)$ ]]; then
|
||||||
_f_ports=("$_port/tcp")
|
_f_ports=("$_port/tcp" "1900/udp")
|
||||||
_u_ports="$_port/tcp"
|
_u_ports="$_port/tcp|1900/udp"
|
||||||
else
|
|
||||||
err "_openFirewall unrecognized service name"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Open the ports
|
# Open the ports
|
||||||
@@ -1110,10 +1027,6 @@ installJRMC() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#######################################
|
|
||||||
# SERVICES
|
|
||||||
#######################################
|
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Starts and enables (at startup) a JRiver Media Center service
|
# Starts and enables (at startup) a JRiver Media Center service
|
||||||
# Arguments:
|
# Arguments:
|
||||||
@@ -1143,8 +1056,8 @@ installJRMC() {
|
|||||||
[Install]
|
[Install]
|
||||||
WantedBy=graphical.target
|
WantedBy=graphical.target
|
||||||
EOF"
|
EOF"
|
||||||
|
|
||||||
_systemctl_reload && \
|
_systemctl_reload && \
|
||||||
_systemctl_start "$_service_name" && \
|
|
||||||
_systemctl_enable "$_service_name" && \
|
_systemctl_enable "$_service_name" && \
|
||||||
_openFirewall "jriver"
|
_openFirewall "jriver"
|
||||||
}
|
}
|
||||||
@@ -1196,7 +1109,6 @@ installJRMC() {
|
|||||||
EOF"
|
EOF"
|
||||||
|
|
||||||
_systemctl_reload && \
|
_systemctl_reload && \
|
||||||
_systemctl_start "$_service_name" && \
|
|
||||||
_systemctl_enable "$_service_name" && \
|
_systemctl_enable "$_service_name" && \
|
||||||
echo "Xvnc running on localhost:$_port" && \
|
echo "Xvnc running on localhost:$_port" && \
|
||||||
_openFirewall "jriver-xvnc" && \
|
_openFirewall "jriver-xvnc" && \
|
||||||
@@ -1251,7 +1163,6 @@ installJRMC() {
|
|||||||
EOF"
|
EOF"
|
||||||
|
|
||||||
_systemctl_reload && \
|
_systemctl_reload && \
|
||||||
_systemctl_start "$_service_name" && \
|
|
||||||
_systemctl_enable "$_service_name" && \
|
_systemctl_enable "$_service_name" && \
|
||||||
echo "x11vnc running on localhost:$_port" && \
|
echo "x11vnc running on localhost:$_port" && \
|
||||||
_openFirewall "jriver-x11vnc"
|
_openFirewall "jriver-x11vnc"
|
||||||
@@ -1271,7 +1182,7 @@ installJRMC() {
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
$_user_specifier
|
$_user_specifier
|
||||||
ExecStart=$_basedir/installJRMC --outputdir $_outputdir --createrepo --createrepo-webroot $_createrepo_webroot --createrepo-user $_createrepo_user
|
ExecStart=$PWD/installJRMC --outputdir $_outputdir --createrepo --createrepo-webroot $_createrepo_webroot --createrepo-user $_createrepo_user
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=default.target
|
WantedBy=default.target
|
||||||
@@ -1290,7 +1201,6 @@ installJRMC() {
|
|||||||
EOF"
|
EOF"
|
||||||
|
|
||||||
_systemctl_reload && \
|
_systemctl_reload && \
|
||||||
_systemctl_start "$_timer_name" && \
|
|
||||||
_systemctl_enable "$_timer_name"
|
_systemctl_enable "$_timer_name"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1325,7 +1235,7 @@ installJRMC() {
|
|||||||
|
|
||||||
# Uninstall services
|
# Uninstall services
|
||||||
echo "Stopping and removing all associated Media Center services"
|
echo "Stopping and removing all associated Media Center services"
|
||||||
for _service in "${_available_services[@]}"; do
|
for _service in $(compgen -A "function" "_service"); do
|
||||||
_servicePrep "$_service"
|
_servicePrep "$_service"
|
||||||
_systemctl_disable "$_service_name"
|
_systemctl_disable "$_service_name"
|
||||||
_systemctl_disable "$_timer_name"
|
_systemctl_disable "$_timer_name"
|
||||||
@@ -1363,78 +1273,4 @@ installJRMC() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_main() {
|
|
||||||
|
|
||||||
# Parse input
|
|
||||||
_parseInput "$@"
|
|
||||||
|
|
||||||
# Sanity checks
|
|
||||||
_sanityChecks
|
|
||||||
|
|
||||||
# Set user variables
|
|
||||||
_setUser
|
|
||||||
|
|
||||||
# Build some OS-specific commands based on the selected OS
|
|
||||||
_buildCommands
|
|
||||||
|
|
||||||
# Install MC using package manager
|
|
||||||
if [[ -v _repoinstall ]]; then
|
|
||||||
[[ "$ID" =~ ^(fedora|centos)$ ]] && _installPackage rpmfusion-free-release epel-release
|
|
||||||
_installMCFromRepo
|
|
||||||
_symlinkCerts
|
|
||||||
_restoreLicense
|
|
||||||
_openFirewall "jriver"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set version to install/uninstall
|
|
||||||
_setVersion
|
|
||||||
|
|
||||||
# Uninstall and exit
|
|
||||||
if [[ -v _uninstall ]]; then
|
|
||||||
_uninstall
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Build RPM from source DEB
|
|
||||||
if [[ -v _rpmbuild ]]; then
|
|
||||||
_installPackage epel-release
|
|
||||||
_acquireDeb
|
|
||||||
_buildRPM
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run createrepo
|
|
||||||
if [[ -v _createrepo ]]; then
|
|
||||||
_runCreaterepo "$_mcrpm"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install the rpm
|
|
||||||
if [[ -v _rpminstall ]]; then
|
|
||||||
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
|
||||||
_installPackage rpmfusion-free-release epel-release
|
|
||||||
_installPackage --noquery "$_mcrpm"
|
|
||||||
_symlinkCerts
|
|
||||||
_restoreLicense
|
|
||||||
_openFirewall "jriver"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install services
|
|
||||||
_setDisplay
|
|
||||||
for _service in "${_services[@]}"; do
|
|
||||||
_servicePrep "$_service"
|
|
||||||
"_service_$_service"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Install containers
|
|
||||||
for _container in "${_containers[@]}"; do
|
|
||||||
"_container_$_container"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Allow this file to be executed directly if not being sourced
|
|
||||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
||||||
_basedir=$(dirname "$(readlink -f "$0")")
|
|
||||||
installJRMC
|
|
||||||
_main "$@"
|
_main "$@"
|
||||||
fi
|
|
||||||
|
|||||||
Reference in New Issue
Block a user