1 Commits

Author SHA1 Message Date
9c1ffac186 debug version, do not use 2020-04-26 16:26:09 -04:00

View File

@@ -31,7 +31,7 @@ installJRMC() {
_printHelpAndExit() { _printHelpAndExit() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
cat <<-'EOF' cat <<-'EOF'
USAGE: USAGE:
@@ -70,6 +70,8 @@ OPTIONS
Print this script version and exit Print this script version and exit
--debug, -d --debug, -d
Print debug output Print debug output
--force, -f
Force reinstallation and ignore/overwrite previous output
--help, -h --help, -h
Print help dialog and exit Print help dialog and exit
--uninstall, -u --uninstall, -u
@@ -106,7 +108,7 @@ EOF
_parseInput() { _parseInput() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
# set default behavior # set default behavior
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
@@ -114,7 +116,7 @@ EOF
return 1 return 1
fi fi
if _input=$(getopt -o +vdhus:c: -l install-repo,install-rpmbuild,rpmbuild,outputdir:,mcversion:,restorefile:,betapass:,service-user:,service:,version,debug,help,uninstall,createrepo,createrepo-webroot:,createrepo-user:,vncpass:,display:,container: -- "$@"); then if _input=$(getopt -o +vdhus:c: -l install-repo,install-rpmbuild,rpmbuild,outputdir:,mcversion:,restorefile:,betapass:,service-user:,service:,version,debug,force,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
@@ -157,6 +159,9 @@ EOF
echo "Debugging on" echo "Debugging on"
_debug="true" _debug="true"
;; ;;
--force|-f)
_force="true"
;;
--help|-h) --help|-h)
_printHelpAndExit 0 _printHelpAndExit 0
;; ;;
@@ -195,16 +200,16 @@ EOF
err() { err() {
echo "Error: $*" >&2 echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
} }
####################################### #######################################
# Call this at the beginning of every function in order to track # Call this at the beginning of every function in order to track
####################################### #######################################
debug() { _runDebug() {
[[ -n $_debug ]] && echo "Debug: $*" [[ -n $_debug ]] && echo "Running: " "$@"
} }
@@ -229,7 +234,7 @@ EOF
####################################### #######################################
_getOS() { _getOS() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
if [[ -e "/etc/os-release" ]]; then if [[ -e "/etc/os-release" ]]; then
source "/etc/os-release" source "/etc/os-release"
@@ -273,7 +278,7 @@ EOF
# Detect OS # Detect OS
_getOS _getOS
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
# Agnostic commands # Agnostic commands
_bash_cmd(){ _ifSudo bash -c "$@"; } _bash_cmd(){ _ifSudo bash -c "$@"; }
@@ -359,7 +364,7 @@ EOF
####################################### #######################################
_installPackage() { _installPackage() {
debug "Running: ${FUNCNAME[0]}" "$@" _runDebug "${FUNCNAME[0]}" "$@"
if _input=$(getopt -o +n -l noquery -- "$@"); then if _input=$(getopt -o +n -l noquery -- "$@"); then
eval set -- "$_input" eval set -- "$_input"
@@ -440,7 +445,7 @@ EOF
####################################### #######################################
_packageQuirks() { _packageQuirks() {
debug "Running: ${FUNCNAME[0]}" "$@" _runDebug "${FUNCNAME[0]}" "$@"
unset _url_pkg unset _url_pkg
@@ -481,7 +486,7 @@ EOF
####################################### #######################################
_setVersion() { _setVersion() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
if [[ -z "$_mcversion" ]]; then if [[ -z "$_mcversion" ]]; then
@@ -538,13 +543,13 @@ EOF
####################################### #######################################
_sanityChecks() { _sanityChecks() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
# Check for bad service name # Check for bad service name
# #
_checkServices() { _checkServices() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
for _service in "${_services[@]}"; do for _service in "${_services[@]}"; do
if ! _inArray "$_service" "${_available_services[@]}"; then if ! _inArray "$_service" "${_available_services[@]}"; then
@@ -557,7 +562,7 @@ EOF
_checkMCInstalled() { _checkMCInstalled() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
if [[ "${_services[*]}" =~ ^(mediacenter|mediaserver|mediacenter-vncserver)$ ]]; then if [[ "${_services[*]}" =~ ^(mediacenter|mediaserver|mediacenter-vncserver)$ ]]; then
if [[ -z $_repoinstall && -z $_rpminstall ]]; then if [[ -z $_repoinstall && -z $_rpminstall ]]; then
@@ -573,7 +578,7 @@ EOF
_checkUser() { _checkUser() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
if [[ "$_exec_user" == "root" && -z "$_service_user" && "${_services[*]}" ]]; then if [[ "$_exec_user" == "root" && -z "$_service_user" && "${_services[*]}" ]]; then
err "Attempting to install services as the root user" err "Attempting to install services as the root user"
@@ -586,7 +591,7 @@ EOF
# Enable/disable sanity checks # Enable/disable sanity checks
if _checkServices && _checkMCInstalled && _checkUser; then if _checkServices && _checkMCInstalled && _checkUser; then
debug "Sanity checks passed!" [[ -n $_debug ]] && echo "Sanity checks passed!"
return 0 return 0
else else
err "Sanity checks failed!" err "Sanity checks failed!"
@@ -602,7 +607,7 @@ EOF
####################################### #######################################
_installMCFromRepo() { _installMCFromRepo() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
echo "Installing latest JRiver Media Center from repo..." echo "Installing latest JRiver Media Center from repo..."
@@ -652,7 +657,7 @@ EOF'
####################################### #######################################
_acquireDeb() { _acquireDeb() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
local _debfilename="$_outputdir/SOURCES/MediaCenter-${_mcversion}-amd64.deb" local _debfilename="$_outputdir/SOURCES/MediaCenter-${_mcversion}-amd64.deb"
@@ -703,7 +708,7 @@ EOF'
####################################### #######################################
_buildRPM() { _buildRPM() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
# install build dependencies # install build dependencies
_installPackage wget dpkg rpm-build _installPackage wget dpkg rpm-build
@@ -719,11 +724,13 @@ EOF'
local _build_requires='' local _build_requires=''
fi fi
if [[ "$ID" == "fedora" && -n $_rpminstall ]]; then if [[ "$ID" != "centos" ]]; then
# TODO: find out why this is required since it's not easily available on CentOS
local _requires='Requires: pangox-compat >= 0.0.2' local _requires='Requires: pangox-compat >= 0.0.2'
else
local _requires='Requires: libXScrnSaver'
fi fi
# Create spec file # Create spec file
bash -c "cat <<EOF > $_outputdir/SPECS/mediacenter.spec bash -c "cat <<EOF > $_outputdir/SPECS/mediacenter.spec
Name: MediaCenter Name: MediaCenter
@@ -751,7 +758,6 @@ Requires: mesa-libGL
Requires: libglvnd-glx Requires: libglvnd-glx
Requires: pango >= 1.36 Requires: pango >= 1.36
$_requires $_requires
Requires: libXScrnSaver
Requires: xdg-utils Requires: xdg-utils
Requires: libgomp >= 4.9 Requires: libgomp >= 4.9
Requires: gstreamer1 >= 1.4.4 Requires: gstreamer1 >= 1.4.4
@@ -791,7 +797,7 @@ 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" && -z "$_force" ]]; then
echo "$_mcrpm already exists. Skipping build step..." echo "$_mcrpm already exists. Skipping build step..."
return 0 # this is fine return 0 # this is fine
else else
@@ -824,7 +830,7 @@ EOF"
####################################### #######################################
_runCreaterepo() { _runCreaterepo() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
_installPackage createrepo_c _installPackage createrepo_c
@@ -865,7 +871,7 @@ EOF"
####################################### #######################################
_symlinkCerts() { _symlinkCerts() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
if [[ ! -f /etc/ssl/certs/ca-certificates.crt && \ if [[ ! -f /etc/ssl/certs/ca-certificates.crt && \
-f /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem ]]; then -f /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem ]]; then
@@ -888,7 +894,7 @@ EOF"
####################################### #######################################
_restoreLicense() { _restoreLicense() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
local _mjr local _mjr
@@ -923,7 +929,7 @@ EOF"
####################################### #######################################
_openFirewall() { _openFirewall() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
# Create OS-specific port rules based on argument (service) name # Create OS-specific port rules based on argument (service) name
local -a _f_ports # for firewall_cmd local -a _f_ports # for firewall_cmd
@@ -982,7 +988,7 @@ EOF"
####################################### #######################################
_setX11VNCPass() { _setX11VNCPass() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
_vncpassfile="$HOME/.vnc/jrmc_passwd" _vncpassfile="$HOME/.vnc/jrmc_passwd"
@@ -1016,7 +1022,7 @@ EOF"
####################################### #######################################
_setVNCPass() { _setVNCPass() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
_vncpassfile="$HOME/.vnc/jrmc_passwd" _vncpassfile="$HOME/.vnc/jrmc_passwd"
@@ -1107,7 +1113,7 @@ EOF"
####################################### #######################################
_service_jriver-mediaserver() { _service_jriver-mediaserver() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
_setDisplayAndPort _setDisplayAndPort
@@ -1139,7 +1145,7 @@ EOF"
_service_jriver-mediacenter() { _service_jriver-mediacenter() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
_setDisplayAndPort _setDisplayAndPort
@@ -1171,7 +1177,7 @@ EOF"
_service_jriver-vnc-mediacenter() { _service_jriver-vnc-mediacenter() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
_installPackage tigervnc-server _installPackage tigervnc-server
@@ -1212,7 +1218,7 @@ EOF"
_service_jriver-x11vnc() { _service_jriver-x11vnc() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
_installPackage x11vnc _installPackage x11vnc
@@ -1256,7 +1262,7 @@ EOF"
_service_jriver-createrepo() { _service_jriver-createrepo() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
_bash_cmd "cat <<-EOF > $_service_fname _bash_cmd "cat <<-EOF > $_service_fname
[Unit] [Unit]
@@ -1306,7 +1312,7 @@ EOF"
_uninstall() { _uninstall() {
debug "Running: ${FUNCNAME[0]}" _runDebug "${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
_response=${_response,,} # tolower _response=${_response,,} # tolower