Compare commits
5 Commits
460658f29f
...
2c3f1ee6f1
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c3f1ee6f1 | |||
| cc85f59c31 | |||
| 2143aa10b5 | |||
| 326dc9ea66 | |||
| d5d51ab506 |
124
installJRMC
124
installJRMC
@@ -45,8 +45,10 @@ USAGE:
|
|||||||
installJRMC [[OPTION] [VALUE]]...
|
installJRMC [[OPTION] [VALUE]]...
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
--rpmbuild
|
--repo
|
||||||
Build RPM from source DEB
|
Install JRiver MC repository using the OS package manager (recommended)
|
||||||
|
--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
|
||||||
@@ -106,17 +108,23 @@ 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 rpmbuild,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 repo,build,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
|
||||||
--rpmbuild)
|
--repo)
|
||||||
_rpmbuild="true"
|
echo "Installing JRMC from repository"
|
||||||
|
_installrepo="true"
|
||||||
|
;;
|
||||||
|
--build)
|
||||||
|
echo "Using build only mode"
|
||||||
|
_buildonly="true"
|
||||||
;;
|
;;
|
||||||
--outputdir)
|
--outputdir)
|
||||||
shift && _outputdir="$1"
|
shift && _outputdir="$1"
|
||||||
@@ -151,6 +159,7 @@ EOF
|
|||||||
_printHelpAndExit 0
|
_printHelpAndExit 0
|
||||||
;;
|
;;
|
||||||
--uninstall|-u)
|
--uninstall|-u)
|
||||||
|
echo "Uninstalling..."
|
||||||
_uninstall="true"
|
_uninstall="true"
|
||||||
;;
|
;;
|
||||||
--createrepo)
|
--createrepo)
|
||||||
@@ -211,14 +220,25 @@ 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|centos)$ ]]; then
|
if [[ "$ID" == "fedora" || "$ID" == "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|debian)$ ]]; then
|
elif [[ "$ID" == "ubuntu" || "$ID" == "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")
|
||||||
@@ -308,20 +328,6 @@ 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 () {
|
||||||
|
|
||||||
@@ -347,7 +353,7 @@ EOF
|
|||||||
|
|
||||||
_installPackage wget gnupg
|
_installPackage wget gnupg
|
||||||
|
|
||||||
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
if [[ "$ID" == "fedora" || "$ID" == "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
|
||||||
@@ -438,7 +444,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|centos)$ ]]; then
|
if [[ "$ID" == "fedora" || "$ID" == "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=''
|
||||||
@@ -615,10 +621,10 @@ EOF"
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_openFirewall () {
|
_openFirewallPorts () {
|
||||||
|
|
||||||
# RHEL
|
# RHEL
|
||||||
if [[ "$ID" =~ ^(fedora|centos)$ ]] && [[ -x $(command -v firewall-cmd) ]]; then
|
if [[ "$ID" == "fedora" || "$ID" == "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")
|
||||||
@@ -635,7 +641,7 @@ EOF"
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Ubuntu
|
# Ubuntu
|
||||||
elif [[ "$ID" =~ ^(ubuntu|debian)$ ]] && [[ -x $(command -v ufw) ]]; then
|
elif [[ "$ID" == "ubuntu" && -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]
|
||||||
@@ -830,9 +836,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|centos)$ ]]; then
|
if [[ "$ID" == "fedora" || "$ID" == "centos" ]]; then
|
||||||
sudo dnf remove MediaCenter -y
|
sudo dnf remove MediaCenter -y
|
||||||
elif [[ "$ID" =~ ^(ubuntu|debian)$ ]]; then
|
elif [[ "$ID" == "ubuntu" || "$ID" == "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"
|
||||||
@@ -840,7 +846,6 @@ EOF"
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
__main () {
|
__main () {
|
||||||
|
|
||||||
# Check user
|
# Check user
|
||||||
@@ -852,15 +857,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/uninstall
|
# Set version to install
|
||||||
_setVersion
|
_setVersion
|
||||||
|
|
||||||
# Sanity checks
|
|
||||||
_sanityChecks
|
|
||||||
|
|
||||||
# Uninstall and exit
|
# Uninstall and exit
|
||||||
if [[ -n $_uninstall ]]; then
|
if [[ -n $_uninstall ]]; then
|
||||||
_uninstall
|
_uninstall
|
||||||
@@ -870,38 +875,53 @@ EOF"
|
|||||||
# Install external repos
|
# Install external repos
|
||||||
_installExternalRepos
|
_installExternalRepos
|
||||||
|
|
||||||
# install MC using package manager (default)
|
# install repo file and install MC using package manager
|
||||||
if [[ -z $_rpmbuild ]]; then
|
if [[ -n $_installrepo ]]; then
|
||||||
_installRepo
|
_installRepo
|
||||||
_symlinkCerts
|
_symlinkCerts
|
||||||
_restoreLicense
|
_restoreLicense
|
||||||
_openFirewall
|
return $?
|
||||||
else
|
|
||||||
_acquireDeb
|
|
||||||
_buildRPM
|
|
||||||
if [[ -n $_createrepo ]]; then
|
|
||||||
_runCreateRepo
|
|
||||||
# Go ahead and install MC from RPM if on a supported platform
|
|
||||||
elif [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
|
||||||
_installRPM
|
|
||||||
_symlinkCerts
|
|
||||||
_restoreLicense
|
|
||||||
_openFirewall
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install systemd services
|
# Acquire source deb package
|
||||||
|
_acquireDeb
|
||||||
|
|
||||||
|
# build
|
||||||
|
_buildRPM
|
||||||
|
if [[ -n $_buildonly ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# create repo at webroot
|
||||||
|
if [[ -n $_createrepo ]]; then
|
||||||
|
_runCreateRepo
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install createrepo systemd service
|
||||||
if [[ "$_service" == "createrepo" ]]; then
|
if [[ "$_service" == "createrepo" ]]; then
|
||||||
_serviceCreaterepo
|
_serviceCreaterepo
|
||||||
elif [[ "$_service" == "x11vnc-mediaserver" ]]; then
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# install MC
|
||||||
|
_installRPM
|
||||||
|
_symlinkCerts
|
||||||
|
_restoreLicense
|
||||||
|
_openFirewallPorts
|
||||||
|
|
||||||
|
# Install MC systemd services
|
||||||
|
if [[ "$_service" == "x11vnc-mediaserver" ]]; then
|
||||||
_serviceMediaserver
|
_serviceMediaserver
|
||||||
_serviceX11VNC
|
_serviceX11VNC
|
||||||
elif [[ "$_service" == "mediaserver" ]]; then
|
fi
|
||||||
|
|
||||||
|
if [[ "$_service" == "mediaserver" ]]; then
|
||||||
_serviceMediaserver
|
_serviceMediaserver
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Execute main function when called
|
# Execute function when called
|
||||||
__main "$@"
|
__main "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user