Add a ton of debugging

This commit is contained in:
2020-04-15 18:42:51 -04:00
parent 14f815632c
commit 20177ec52c

View File

@@ -40,6 +40,8 @@ installJRMC () {
_printHelpAndExit () { _printHelpAndExit () {
_runDebug "${FUNCNAME[0]}"
cat <<-'EOF' cat <<-'EOF'
USAGE: USAGE:
installJRMC [[OPTION] [VALUE]]... installJRMC [[OPTION] [VALUE]]...
@@ -103,6 +105,8 @@ EOF
_parseInput () { _parseInput () {
_runDebug "${FUNCNAME[0]}"
if _input=$(getopt -o +vdhu -l rpmbuild,outputdir:,mcversion:,restorefile:,betapass:,service:,version,debug,help,uninstall,createrepo,createrepo-webroot:,createrepo-user:,vncpass:,display: -- "$@"); then if _input=$(getopt -o +vdhu -l rpmbuild,outputdir:,mcversion:,restorefile:,betapass:,service:,version,debug,help,uninstall,createrepo,createrepo-webroot:,createrepo-user:,vncpass:,display: -- "$@"); then
eval set -- "$_input" eval set -- "$_input"
while true; do while true; do
@@ -168,8 +172,16 @@ EOF
} }
_runDebug () {
[[ -n $_debug ]] && echo "Running: " "$@"
}
_checkUser () { _checkUser () {
_runDebug "${FUNCNAME[0]}"
if [[ "$_user" == "root" ]]; then if [[ "$_user" == "root" ]]; then
cat <<EOF cat <<EOF
@@ -187,6 +199,8 @@ EOF
_getOS () { _getOS () {
_runDebug "${FUNCNAME[0]}"
if [[ -e /etc/os-release ]]; then if [[ -e /etc/os-release ]]; then
source /etc/os-release source /etc/os-release
else else
@@ -194,11 +208,15 @@ EOF
echo "Your OS is unsupported" echo "Your OS is unsupported"
_printHelpAndExit 1 _printHelpAndExit 1
fi fi
[[ -n $_debug ]] && echo "Platform: $ID $VERSION_ID"
} }
_buildCommands () { _buildCommands () {
_runDebug "${FUNCNAME[0]}"
# build some basic command arrays based on OS and user input # build some basic command arrays based on OS and user input
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
_install_cmd=("dnf" "install" "-y") _install_cmd=("dnf" "install" "-y")
@@ -238,6 +256,8 @@ EOF
_installPackage () { _installPackage () {
_runDebug "${FUNCNAME[0]}" "$@"
# We will add packages to this array if their command is not available # We will add packages to this array if their command is not available
local -a _pkg_array local -a _pkg_array
local -a _url_pkg_array local -a _url_pkg_array
@@ -270,6 +290,8 @@ EOF
_packageQuirks () { _packageQuirks () {
_runDebug "${FUNCNAME[0]}" "$@"
unset _url_pkg unset _url_pkg
if [[ "$1" == "rpm-build" && "$ID" =~ ^(ubuntu|debian)$ ]]; then if [[ "$1" == "rpm-build" && "$ID" =~ ^(ubuntu|debian)$ ]]; then
@@ -296,6 +318,8 @@ EOF
_setVersion () { _setVersion () {
_runDebug "${FUNCNAME[0]}"
if [[ -z "$_mcversion" ]]; then if [[ -z "$_mcversion" ]]; then
_installPackage wget _installPackage wget
@@ -321,8 +345,10 @@ EOF
_sanityChecks () { _sanityChecks () {
_runDebug "${FUNCNAME[0]}"
# Cannot create a repo without an rpm # Cannot create a repo without an rpm
if [[ -n $_createrepo || -n $_mcversion ]]; then if [[ -n $_createrepo || "$_service" == "createrepo" ]]; then
_rpmbuild="true" _rpmbuild="true"
fi fi
@@ -336,15 +362,22 @@ EOF
_installExternalRepos () { _installExternalRepos () {
_runDebug "${FUNCNAME[0]}"
_installPackage rpmfusion-free-release epel-release _installPackage rpmfusion-free-release epel-release
} }
_installRepo () { _installRepo () {
_runDebug "${FUNCNAME[0]}"
_installPackage wget gnupg _installPackage wget gnupg
echo "$ID"
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
echo "here!"
"${_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
@@ -386,6 +419,8 @@ EOF'
_acquireDeb () { _acquireDeb () {
_runDebug "${FUNCNAME[0]}"
# If necessary, create SOURCES dir # If necessary, create SOURCES dir
[[ ! -d "$_outputdir/SOURCES" ]] && mkdir -p "$_outputdir/SOURCES" [[ ! -d "$_outputdir/SOURCES" ]] && mkdir -p "$_outputdir/SOURCES"
@@ -420,6 +455,8 @@ EOF'
_buildRPM () { _buildRPM () {
_runDebug "${FUNCNAME[0]}"
# install build dependencies # install build dependencies
_installPackage wget dpkg rpm-build _installPackage wget dpkg rpm-build
@@ -524,6 +561,8 @@ EOF"
_runCreateRepo () { _runCreateRepo () {
_runDebug "${FUNCNAME[0]}"
_installPackage createrepo_c _installPackage createrepo_c
unset _prefix unset _prefix
@@ -564,6 +603,8 @@ EOF"
_installRPM () { _installRPM () {
_runDebug "${FUNCNAME[0]}"
# skip installing same version # skip installing same version
_installed_ver="$(rpm --query MediaCenter)" _installed_ver="$(rpm --query MediaCenter)"
_to_be_installed_ver="MediaCenter-$_mcversion.x86_64" _to_be_installed_ver="MediaCenter-$_mcversion.x86_64"
@@ -591,6 +632,8 @@ EOF"
_symlinkCerts () { _symlinkCerts () {
_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
echo "Symlinking /etc/ssl/certs/ca-certificates.crt to /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" echo "Symlinking /etc/ssl/certs/ca-certificates.crt to /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"
@@ -605,6 +648,8 @@ EOF"
_restoreLicense () { _restoreLicense () {
_runDebug "${FUNCNAME[0]}"
# Allow user to drop an mjr file next to installJRMC # Allow user to drop an mjr file next to installJRMC
if [[ -z $_restorefile ]]; then if [[ -z $_restorefile ]]; then
for _mjr in "$_basedir"/*.mjr; do for _mjr in "$_basedir"/*.mjr; do
@@ -623,6 +668,8 @@ EOF"
_openFirewall () { _openFirewall () {
_runDebug "${FUNCNAME[0]}"
# RHEL # RHEL
if [[ "$ID" =~ ^(fedora|centos)$ ]] && [[ -x $(command -v firewall-cmd) ]]; then if [[ "$ID" =~ ^(fedora|centos)$ ]] && [[ -x $(command -v firewall-cmd) ]]; then
if ! firewall-cmd --get-services | grep -q jriver; then if ! firewall-cmd --get-services | grep -q jriver; then
@@ -653,6 +700,8 @@ EOF"
_setVNCPass () { _setVNCPass () {
_runDebug "${FUNCNAME[0]}"
_vncpassfile="$HOME/.vnc/jrmc_passwd" _vncpassfile="$HOME/.vnc/jrmc_passwd"
if [[ -n $_vncpass ]]; then if [[ -n $_vncpass ]]; then
@@ -668,6 +717,8 @@ EOF"
_systemctlReloadAndEnable () { _systemctlReloadAndEnable () {
_runDebug "${FUNCNAME[0]}"
echo "Enabling $1" echo "Enabling $1"
if [[ "$_user" == "root" ]]; then if [[ "$_user" == "root" ]]; then
@@ -682,6 +733,8 @@ EOF"
_generateServiceVars () { _generateServiceVars () {
_runDebug "${FUNCNAME[0]}"
unset _service_fname _service_name _timer_fname _timer_name _user_specifier unset _service_fname _service_name _timer_fname _timer_name _user_specifier
if [[ "$_user" == "root" ]]; then if [[ "$_user" == "root" ]]; then
@@ -702,6 +755,8 @@ EOF"
_serviceMediaserver () { _serviceMediaserver () {
_runDebug "${FUNCNAME[0]}"
_generateServiceVars "jriver-mediaserver" _generateServiceVars "jriver-mediaserver"
"${_bash_cmd[@]}" "cat <<-EOF > $_service_fname "${_bash_cmd[@]}" "cat <<-EOF > $_service_fname
@@ -728,6 +783,8 @@ EOF"
_serviceX11VNC () { _serviceX11VNC () {
_runDebug "${FUNCNAME[0]}"
_installPackage x11vnc _installPackage x11vnc
_setVNCPass _setVNCPass
@@ -761,6 +818,8 @@ EOF"
_serviceCreaterepo () { _serviceCreaterepo () {
_runDebug "${FUNCNAME[0]}"
_generateServiceVars "jriver-createrepo" _generateServiceVars "jriver-createrepo"
"${_bash_cmd[@]}" "cat <<-EOF > $_service_fname "${_bash_cmd[@]}" "cat <<-EOF > $_service_fname
@@ -791,6 +850,8 @@ EOF"
_uninstall () { _uninstall () {
_runDebug "${FUNCNAME[0]}"
read -r -p "Do you really want to uninstall all JRiver Media Center files? [y/N] " _response read -r -p "Do you really want to uninstall all JRiver Media Center files? [y/N] " _response
_response=${_response,,} # tolower _response=${_response,,} # tolower
[[ ! "$_response" =~ ^(yes|y)$ ]] && echo "Cancelling uninstall..." && exit 0 [[ ! "$_response" =~ ^(yes|y)$ ]] && echo "Cancelling uninstall..." && exit 0