1 Commits

Author SHA1 Message Date
34b90d406c debug version, do not use 2020-04-26 16:42:27 -04:00

View File

@@ -31,7 +31,7 @@ installJRMC() {
_printHelpAndExit() { _printHelpAndExit() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
cat <<-'EOF' cat <<-'EOF'
USAGE: USAGE:
@@ -70,8 +70,6 @@ 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
@@ -108,7 +106,7 @@ EOF
_parseInput() { _parseInput() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
# set default behavior # set default behavior
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
@@ -116,7 +114,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,force,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,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
@@ -159,9 +157,6 @@ EOF
echo "Debugging on" echo "Debugging on"
_debug="true" _debug="true"
;; ;;
--force|-f)
_force="true"
;;
--help|-h) --help|-h)
_printHelpAndExit 0 _printHelpAndExit 0
;; ;;
@@ -200,16 +195,16 @@ EOF
err() { err() {
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2 echo "Error: $*" >&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
####################################### #######################################
_runDebug() { debug() {
[[ -n $_debug ]] && echo "Running: " "$@" [[ -n $_debug ]] && echo "Debug: $*"
} }
@@ -234,7 +229,7 @@ EOF
####################################### #######################################
_getOS() { _getOS() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
if [[ -e "/etc/os-release" ]]; then if [[ -e "/etc/os-release" ]]; then
source "/etc/os-release" source "/etc/os-release"
@@ -278,7 +273,7 @@ EOF
# Detect OS # Detect OS
_getOS _getOS
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
# Agnostic commands # Agnostic commands
_bash_cmd(){ _ifSudo bash -c "$@"; } _bash_cmd(){ _ifSudo bash -c "$@"; }
@@ -364,7 +359,7 @@ EOF
####################################### #######################################
_installPackage() { _installPackage() {
_runDebug "${FUNCNAME[0]}" "$@" debug "Running: ${FUNCNAME[0]}" "$@"
if _input=$(getopt -o +n -l noquery -- "$@"); then if _input=$(getopt -o +n -l noquery -- "$@"); then
eval set -- "$_input" eval set -- "$_input"
@@ -445,7 +440,7 @@ EOF
####################################### #######################################
_packageQuirks() { _packageQuirks() {
_runDebug "${FUNCNAME[0]}" "$@" debug "Running: ${FUNCNAME[0]}" "$@"
unset _url_pkg unset _url_pkg
@@ -486,7 +481,7 @@ EOF
####################################### #######################################
_setVersion() { _setVersion() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
if [[ -z "$_mcversion" ]]; then if [[ -z "$_mcversion" ]]; then
@@ -543,13 +538,13 @@ EOF
####################################### #######################################
_sanityChecks() { _sanityChecks() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
# Check for bad service name # Check for bad service name
# #
_checkServices() { _checkServices() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
for _service in "${_services[@]}"; do for _service in "${_services[@]}"; do
if ! _inArray "$_service" "${_available_services[@]}"; then if ! _inArray "$_service" "${_available_services[@]}"; then
@@ -562,7 +557,7 @@ EOF
_checkMCInstalled() { _checkMCInstalled() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${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
@@ -578,7 +573,7 @@ EOF
_checkUser() { _checkUser() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${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"
@@ -591,7 +586,7 @@ EOF
# Enable/disable sanity checks # Enable/disable sanity checks
if _checkServices && _checkMCInstalled && _checkUser; then if _checkServices && _checkMCInstalled && _checkUser; then
[[ -n $_debug ]] && echo "Sanity checks passed!" debug "Sanity checks passed!"
return 0 return 0
else else
err "Sanity checks failed!" err "Sanity checks failed!"
@@ -607,7 +602,7 @@ EOF
####################################### #######################################
_installMCFromRepo() { _installMCFromRepo() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
echo "Installing latest JRiver Media Center from repo..." echo "Installing latest JRiver Media Center from repo..."
@@ -657,7 +652,7 @@ EOF'
####################################### #######################################
_acquireDeb() { _acquireDeb() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
local _debfilename="$_outputdir/SOURCES/MediaCenter-${_mcversion}-amd64.deb" local _debfilename="$_outputdir/SOURCES/MediaCenter-${_mcversion}-amd64.deb"
@@ -708,7 +703,7 @@ EOF'
####################################### #######################################
_buildRPM() { _buildRPM() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
# install build dependencies # install build dependencies
_installPackage wget dpkg rpm-build _installPackage wget dpkg rpm-build
@@ -724,13 +719,11 @@ EOF'
local _build_requires='' local _build_requires=''
fi fi
if [[ "$ID" != "centos" ]]; then if [[ "$ID" == "fedora" && -n $_rpminstall ]]; 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
@@ -758,6 +751,7 @@ 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
@@ -797,7 +791,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" && -z "$_force" ]]; 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 # this is fine
else else
@@ -830,7 +824,7 @@ EOF"
####################################### #######################################
_runCreaterepo() { _runCreaterepo() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_installPackage createrepo_c _installPackage createrepo_c
@@ -871,7 +865,7 @@ EOF"
####################################### #######################################
_symlinkCerts() { _symlinkCerts() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${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
@@ -894,7 +888,7 @@ EOF"
####################################### #######################################
_restoreLicense() { _restoreLicense() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
local _mjr local _mjr
@@ -929,7 +923,7 @@ EOF"
####################################### #######################################
_openFirewall() { _openFirewall() {
_runDebug "${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
local -a _f_ports # for firewall_cmd local -a _f_ports # for firewall_cmd
@@ -988,7 +982,7 @@ EOF"
####################################### #######################################
_setX11VNCPass() { _setX11VNCPass() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_vncpassfile="$HOME/.vnc/jrmc_passwd" _vncpassfile="$HOME/.vnc/jrmc_passwd"
@@ -1022,7 +1016,7 @@ EOF"
####################################### #######################################
_setVNCPass() { _setVNCPass() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_vncpassfile="$HOME/.vnc/jrmc_passwd" _vncpassfile="$HOME/.vnc/jrmc_passwd"
@@ -1113,7 +1107,7 @@ EOF"
####################################### #######################################
_service_jriver-mediaserver() { _service_jriver-mediaserver() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_setDisplayAndPort _setDisplayAndPort
@@ -1145,7 +1139,7 @@ EOF"
_service_jriver-mediacenter() { _service_jriver-mediacenter() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_setDisplayAndPort _setDisplayAndPort
@@ -1177,7 +1171,7 @@ EOF"
_service_jriver-vnc-mediacenter() { _service_jriver-vnc-mediacenter() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_installPackage tigervnc-server _installPackage tigervnc-server
@@ -1218,7 +1212,7 @@ EOF"
_service_jriver-x11vnc() { _service_jriver-x11vnc() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_installPackage x11vnc _installPackage x11vnc
@@ -1262,7 +1256,7 @@ EOF"
_service_jriver-createrepo() { _service_jriver-createrepo() {
_runDebug "${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_bash_cmd "cat <<-EOF > $_service_fname _bash_cmd "cat <<-EOF > $_service_fname
[Unit] [Unit]
@@ -1312,7 +1306,7 @@ EOF"
_uninstall() { _uninstall() {
_runDebug "${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
_response=${_response,,} # tolower _response=${_response,,} # tolower