Compare commits
1 Commits
2c3f1ee6f1
...
460658f29f
| Author | SHA1 | Date | |
|---|---|---|---|
| 460658f29f |
118
installJRMC
118
installJRMC
@@ -45,10 +45,8 @@ USAGE:
|
|||||||
installJRMC [[OPTION] [VALUE]]...
|
installJRMC [[OPTION] [VALUE]]...
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
--repo
|
--rpmbuild
|
||||||
Install JRiver MC repository using the OS package manager (recommended)
|
Build RPM from source DEB
|
||||||
--build
|
|
||||||
Build the rpm, do nothing else
|
|
||||||
--buildpath PATH
|
--buildpath PATH
|
||||||
Run rpmbuild in this directory (Default: the current working directory)
|
Run rpmbuild in this directory (Default: the current working directory)
|
||||||
--mcversion VERSION
|
--mcversion VERSION
|
||||||
@@ -108,23 +106,17 @@ EOF
|
|||||||
|
|
||||||
# Exit using passed exit code
|
# Exit using passed exit code
|
||||||
[[ -z $1 ]] && exit 0 || exit "$1"
|
[[ -z $1 ]] && exit 0 || exit "$1"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_parseInput () {
|
_parseInput () {
|
||||||
|
|
||||||
if _input=$(getopt -o +vdhu -l repo,build,outputdir:,mcversion:,restorefile:,boardurl:,deburl:,betapass:,service:,version,debug,help,uninstall,createrepo,createrepo-webroot:,createrepo-user:,vncpass:,display: -- "$@"); then
|
if _input=$(getopt -o +vdhu -l rpmbuild,outputdir:,mcversion:,restorefile:,boardurl:,deburl:,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
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--repo)
|
--rpmbuild)
|
||||||
echo "Installing JRMC from repository"
|
_rpmbuild="true"
|
||||||
_installrepo="true"
|
|
||||||
;;
|
|
||||||
--build)
|
|
||||||
echo "Using build only mode"
|
|
||||||
_buildonly="true"
|
|
||||||
;;
|
;;
|
||||||
--outputdir)
|
--outputdir)
|
||||||
shift && _outputdir="$1"
|
shift && _outputdir="$1"
|
||||||
@@ -159,7 +151,6 @@ EOF
|
|||||||
_printHelpAndExit 0
|
_printHelpAndExit 0
|
||||||
;;
|
;;
|
||||||
--uninstall|-u)
|
--uninstall|-u)
|
||||||
echo "Uninstalling..."
|
|
||||||
_uninstall="true"
|
_uninstall="true"
|
||||||
;;
|
;;
|
||||||
--createrepo)
|
--createrepo)
|
||||||
@@ -220,25 +211,14 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_sanityChecks () {
|
|
||||||
|
|
||||||
if ! [[ "$ID" == "fedora" || "$ID" == "centos" ]] && \
|
|
||||||
[[ -z $_installrepo && -z $_buildonly && -z $_createrepo ]]; then
|
|
||||||
echo "You must specify --repo, --build, or --createrepo on non-RHEL distributions!"
|
|
||||||
_printHelpAndExit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_buildCommands () {
|
_buildCommands () {
|
||||||
|
|
||||||
# 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" || "$ID" == "centos" ]]; then
|
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
||||||
_install_cmd=("dnf" "install" "-y")
|
_install_cmd=("dnf" "install" "-y")
|
||||||
_update_cmd=("dnf" "update" "-y")
|
_update_cmd=("dnf" "update" "-y")
|
||||||
_pkg_query_cmd=("rpm" "-q")
|
_pkg_query_cmd=("rpm" "-q")
|
||||||
elif [[ "$ID" == "ubuntu" || "$ID" == "debian" ]]; then
|
elif [[ "$ID" =~ ^(ubuntu|debian)$ ]]; then
|
||||||
_install_cmd=("apt-get" "install" "-y")
|
_install_cmd=("apt-get" "install" "-y")
|
||||||
_update_cmd=("apt-get" "update" "-y")
|
_update_cmd=("apt-get" "update" "-y")
|
||||||
_pkg_query_cmd=("dpkg" "-l")
|
_pkg_query_cmd=("dpkg" "-l")
|
||||||
@@ -328,6 +308,20 @@ EOF
|
|||||||
#_variation="${_mcversion##*.}"
|
#_variation="${_mcversion##*.}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_sanityChecks () {
|
||||||
|
|
||||||
|
# Cannot create a repo without an rpm
|
||||||
|
if [[ -n $_createrepo ]]; then
|
||||||
|
_rpmbuild="true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for bad service name
|
||||||
|
if [[ -n $_service && ! "$_service" =~ ^(mediaserver|x11vnc-mediaserver|createrepo)$ ]]; then
|
||||||
|
echo "Incorrect service type provided!"
|
||||||
|
_printHelpAndExit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_installExternalRepos () {
|
_installExternalRepos () {
|
||||||
|
|
||||||
@@ -353,7 +347,7 @@ EOF
|
|||||||
|
|
||||||
_installPackage wget gnupg
|
_installPackage wget gnupg
|
||||||
|
|
||||||
if [[ "$ID" == "fedora" || "$ID" == "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]
|
||||||
name=JRiver Media Center repo by BryanC
|
name=JRiver Media Center repo by BryanC
|
||||||
@@ -444,7 +438,7 @@ EOF'
|
|||||||
|
|
||||||
# rpmbuild uses rpm to check for build dependencies
|
# rpmbuild uses rpm to check for build dependencies
|
||||||
# this will fail on non-rpm distros
|
# this will fail on non-rpm distros
|
||||||
if [[ "$ID" == "fedora" || "$ID" == "centos" ]]; then
|
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
||||||
_build_requires=$'BuildRequires: rpm >= 4.11.0\nBuildRequires: dpkg'
|
_build_requires=$'BuildRequires: rpm >= 4.11.0\nBuildRequires: dpkg'
|
||||||
else
|
else
|
||||||
_build_requires=''
|
_build_requires=''
|
||||||
@@ -621,10 +615,10 @@ EOF"
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_openFirewallPorts () {
|
_openFirewall () {
|
||||||
|
|
||||||
# RHEL
|
# RHEL
|
||||||
if [[ "$ID" == "fedora" || "$ID" == "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
|
||||||
if [[ "$_user" == "root" ]]; then
|
if [[ "$_user" == "root" ]]; then
|
||||||
_firewallcmd=("firewall-cmd")
|
_firewallcmd=("firewall-cmd")
|
||||||
@@ -641,7 +635,7 @@ EOF"
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Ubuntu
|
# Ubuntu
|
||||||
elif [[ "$ID" == "ubuntu" && -x $(command -v ufw) ]]; then
|
elif [[ "$ID" =~ ^(ubuntu|debian)$ ]] && [[ -x $(command -v ufw) ]]; then
|
||||||
if [[ ! -f "/etc/ufw/applications.d/jriver.service" ]]; then
|
if [[ ! -f "/etc/ufw/applications.d/jriver.service" ]]; then
|
||||||
"${_bash_cmd[@]}" "cat <<-EOF > /etc/ufw/applications.d/jriver.service
|
"${_bash_cmd[@]}" "cat <<-EOF > /etc/ufw/applications.d/jriver.service
|
||||||
[jriver]
|
[jriver]
|
||||||
@@ -836,9 +830,9 @@ EOF"
|
|||||||
[[ -f "/etc/ufw/applications.d/jriver.service" ]] && sudo rm /etc/ufw/applications.d/jriver.service
|
[[ -f "/etc/ufw/applications.d/jriver.service" ]] && sudo rm /etc/ufw/applications.d/jriver.service
|
||||||
fi
|
fi
|
||||||
echo "Uninstalling Media Center"
|
echo "Uninstalling Media Center"
|
||||||
if [[ "$ID" == "fedora" || "$ID" == "centos" ]]; then
|
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
||||||
sudo dnf remove MediaCenter -y
|
sudo dnf remove MediaCenter -y
|
||||||
elif [[ "$ID" == "ubuntu" || "$ID" == "debian" ]]; then
|
elif [[ "$ID" =~ ^(ubuntu|debian)$ ]]; then
|
||||||
sudo apt-get remove "mediacenter$_mversion" -y
|
sudo apt-get remove "mediacenter$_mversion" -y
|
||||||
fi
|
fi
|
||||||
echo "JRiver Media Center has been completely uninstalled"
|
echo "JRiver Media Center has been completely uninstalled"
|
||||||
@@ -846,6 +840,7 @@ EOF"
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
__main () {
|
__main () {
|
||||||
|
|
||||||
# Check user
|
# Check user
|
||||||
@@ -857,15 +852,15 @@ EOF"
|
|||||||
# Detect OS
|
# Detect OS
|
||||||
_getOS
|
_getOS
|
||||||
|
|
||||||
# Sanity checks
|
|
||||||
_sanityChecks
|
|
||||||
|
|
||||||
# Build some commands based on the selected OS
|
# Build some commands based on the selected OS
|
||||||
_buildCommands
|
_buildCommands
|
||||||
|
|
||||||
# Set version to install
|
# Set version to install/uninstall
|
||||||
_setVersion
|
_setVersion
|
||||||
|
|
||||||
|
# Sanity checks
|
||||||
|
_sanityChecks
|
||||||
|
|
||||||
# Uninstall and exit
|
# Uninstall and exit
|
||||||
if [[ -n $_uninstall ]]; then
|
if [[ -n $_uninstall ]]; then
|
||||||
_uninstall
|
_uninstall
|
||||||
@@ -875,53 +870,38 @@ EOF"
|
|||||||
# Install external repos
|
# Install external repos
|
||||||
_installExternalRepos
|
_installExternalRepos
|
||||||
|
|
||||||
# install repo file and install MC using package manager
|
# install MC using package manager (default)
|
||||||
if [[ -n $_installrepo ]]; then
|
if [[ -z $_rpmbuild ]]; then
|
||||||
_installRepo
|
_installRepo
|
||||||
_symlinkCerts
|
_symlinkCerts
|
||||||
_restoreLicense
|
_restoreLicense
|
||||||
return $?
|
_openFirewall
|
||||||
fi
|
else
|
||||||
|
|
||||||
# Acquire source deb package
|
|
||||||
_acquireDeb
|
_acquireDeb
|
||||||
|
|
||||||
# build
|
|
||||||
_buildRPM
|
_buildRPM
|
||||||
if [[ -n $_buildonly ]]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# create repo at webroot
|
|
||||||
if [[ -n $_createrepo ]]; then
|
if [[ -n $_createrepo ]]; then
|
||||||
_runCreateRepo
|
_runCreateRepo
|
||||||
return $?
|
# Go ahead and install MC from RPM if on a supported platform
|
||||||
fi
|
elif [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
||||||
|
|
||||||
# Install createrepo systemd service
|
|
||||||
if [[ "$_service" == "createrepo" ]]; then
|
|
||||||
_serviceCreaterepo
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# install MC
|
|
||||||
_installRPM
|
_installRPM
|
||||||
_symlinkCerts
|
_symlinkCerts
|
||||||
_restoreLicense
|
_restoreLicense
|
||||||
_openFirewallPorts
|
_openFirewall
|
||||||
|
fi
|
||||||
# Install MC systemd services
|
|
||||||
if [[ "$_service" == "x11vnc-mediaserver" ]]; then
|
|
||||||
_serviceMediaserver
|
|
||||||
_serviceX11VNC
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$_service" == "mediaserver" ]]; then
|
# Install systemd services
|
||||||
|
if [[ "$_service" == "createrepo" ]]; then
|
||||||
|
_serviceCreaterepo
|
||||||
|
elif [[ "$_service" == "x11vnc-mediaserver" ]]; then
|
||||||
|
_serviceMediaserver
|
||||||
|
_serviceX11VNC
|
||||||
|
elif [[ "$_service" == "mediaserver" ]]; then
|
||||||
_serviceMediaserver
|
_serviceMediaserver
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Execute function when called
|
# Execute main function when called
|
||||||
__main "$@"
|
__main "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user