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