Compare commits
1 Commits
9c1ffac186
...
34b90d406c
| Author | SHA1 | Date | |
|---|---|---|---|
| 34b90d406c |
76
installJRMC
76
installJRMC
@@ -31,7 +31,7 @@ installJRMC() {
|
||||
|
||||
_printHelpAndExit() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
cat <<-'EOF'
|
||||
USAGE:
|
||||
@@ -70,8 +70,6 @@ OPTIONS
|
||||
Print this script version and exit
|
||||
--debug, -d
|
||||
Print debug output
|
||||
--force, -f
|
||||
Force reinstallation and ignore/overwrite previous output
|
||||
--help, -h
|
||||
Print help dialog and exit
|
||||
--uninstall, -u
|
||||
@@ -108,7 +106,7 @@ EOF
|
||||
|
||||
_parseInput() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
# set default behavior
|
||||
if [[ $# == 0 ]]; then
|
||||
@@ -116,7 +114,7 @@ EOF
|
||||
return 1
|
||||
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"
|
||||
while true; do
|
||||
case "$1" in
|
||||
@@ -159,9 +157,6 @@ EOF
|
||||
echo "Debugging on"
|
||||
_debug="true"
|
||||
;;
|
||||
--force|-f)
|
||||
_force="true"
|
||||
;;
|
||||
--help|-h)
|
||||
_printHelpAndExit 0
|
||||
;;
|
||||
@@ -200,16 +195,16 @@ EOF
|
||||
|
||||
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
|
||||
#######################################
|
||||
_runDebug() {
|
||||
debug() {
|
||||
|
||||
[[ -n $_debug ]] && echo "Running: " "$@"
|
||||
[[ -n $_debug ]] && echo "Debug: $*"
|
||||
}
|
||||
|
||||
|
||||
@@ -234,7 +229,7 @@ EOF
|
||||
#######################################
|
||||
_getOS() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
if [[ -e "/etc/os-release" ]]; then
|
||||
source "/etc/os-release"
|
||||
@@ -278,7 +273,7 @@ EOF
|
||||
# Detect OS
|
||||
_getOS
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
# Agnostic commands
|
||||
_bash_cmd(){ _ifSudo bash -c "$@"; }
|
||||
@@ -364,7 +359,7 @@ EOF
|
||||
#######################################
|
||||
_installPackage() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}" "$@"
|
||||
debug "Running: ${FUNCNAME[0]}" "$@"
|
||||
|
||||
if _input=$(getopt -o +n -l noquery -- "$@"); then
|
||||
eval set -- "$_input"
|
||||
@@ -445,7 +440,7 @@ EOF
|
||||
#######################################
|
||||
_packageQuirks() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}" "$@"
|
||||
debug "Running: ${FUNCNAME[0]}" "$@"
|
||||
|
||||
unset _url_pkg
|
||||
|
||||
@@ -486,7 +481,7 @@ EOF
|
||||
#######################################
|
||||
_setVersion() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
if [[ -z "$_mcversion" ]]; then
|
||||
|
||||
@@ -543,13 +538,13 @@ EOF
|
||||
#######################################
|
||||
_sanityChecks() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
# Check for bad service name
|
||||
#
|
||||
_checkServices() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
for _service in "${_services[@]}"; do
|
||||
if ! _inArray "$_service" "${_available_services[@]}"; then
|
||||
@@ -562,7 +557,7 @@ EOF
|
||||
|
||||
_checkMCInstalled() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
if [[ "${_services[*]}" =~ ^(mediacenter|mediaserver|mediacenter-vncserver)$ ]]; then
|
||||
if [[ -z $_repoinstall && -z $_rpminstall ]]; then
|
||||
@@ -578,7 +573,7 @@ EOF
|
||||
|
||||
_checkUser() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
if [[ "$_exec_user" == "root" && -z "$_service_user" && "${_services[*]}" ]]; then
|
||||
err "Attempting to install services as the root user"
|
||||
@@ -591,7 +586,7 @@ EOF
|
||||
|
||||
# Enable/disable sanity checks
|
||||
if _checkServices && _checkMCInstalled && _checkUser; then
|
||||
[[ -n $_debug ]] && echo "Sanity checks passed!"
|
||||
debug "Sanity checks passed!"
|
||||
return 0
|
||||
else
|
||||
err "Sanity checks failed!"
|
||||
@@ -607,7 +602,7 @@ EOF
|
||||
#######################################
|
||||
_installMCFromRepo() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
echo "Installing latest JRiver Media Center from repo..."
|
||||
|
||||
@@ -657,7 +652,7 @@ EOF'
|
||||
#######################################
|
||||
_acquireDeb() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
local _debfilename="$_outputdir/SOURCES/MediaCenter-${_mcversion}-amd64.deb"
|
||||
|
||||
@@ -708,7 +703,7 @@ EOF'
|
||||
#######################################
|
||||
_buildRPM() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
# install build dependencies
|
||||
_installPackage wget dpkg rpm-build
|
||||
@@ -724,13 +719,11 @@ EOF'
|
||||
local _build_requires=''
|
||||
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'
|
||||
else
|
||||
local _requires='Requires: libXScrnSaver'
|
||||
fi
|
||||
|
||||
|
||||
# Create spec file
|
||||
bash -c "cat <<EOF > $_outputdir/SPECS/mediacenter.spec
|
||||
Name: MediaCenter
|
||||
@@ -758,6 +751,7 @@ Requires: mesa-libGL
|
||||
Requires: libglvnd-glx
|
||||
Requires: pango >= 1.36
|
||||
$_requires
|
||||
Requires: libXScrnSaver
|
||||
Requires: xdg-utils
|
||||
Requires: libgomp >= 4.9
|
||||
Requires: gstreamer1 >= 1.4.4
|
||||
@@ -797,7 +791,7 @@ EOF"
|
||||
declare -g _mcrpm="$_outputdir/RPMS/x86_64/MediaCenter-$_mcversion.x86_64.rpm"
|
||||
|
||||
# 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..."
|
||||
return 0 # this is fine
|
||||
else
|
||||
@@ -830,7 +824,7 @@ EOF"
|
||||
#######################################
|
||||
_runCreaterepo() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
_installPackage createrepo_c
|
||||
|
||||
@@ -871,7 +865,7 @@ EOF"
|
||||
#######################################
|
||||
_symlinkCerts() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
if [[ ! -f /etc/ssl/certs/ca-certificates.crt && \
|
||||
-f /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem ]]; then
|
||||
@@ -894,7 +888,7 @@ EOF"
|
||||
#######################################
|
||||
_restoreLicense() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
local _mjr
|
||||
|
||||
@@ -929,7 +923,7 @@ EOF"
|
||||
#######################################
|
||||
_openFirewall() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
# Create OS-specific port rules based on argument (service) name
|
||||
local -a _f_ports # for firewall_cmd
|
||||
@@ -988,7 +982,7 @@ EOF"
|
||||
#######################################
|
||||
_setX11VNCPass() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
_vncpassfile="$HOME/.vnc/jrmc_passwd"
|
||||
|
||||
@@ -1022,7 +1016,7 @@ EOF"
|
||||
#######################################
|
||||
_setVNCPass() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
_vncpassfile="$HOME/.vnc/jrmc_passwd"
|
||||
|
||||
@@ -1113,7 +1107,7 @@ EOF"
|
||||
#######################################
|
||||
_service_jriver-mediaserver() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
_setDisplayAndPort
|
||||
|
||||
@@ -1145,7 +1139,7 @@ EOF"
|
||||
|
||||
_service_jriver-mediacenter() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
_setDisplayAndPort
|
||||
|
||||
@@ -1177,7 +1171,7 @@ EOF"
|
||||
|
||||
_service_jriver-vnc-mediacenter() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
_installPackage tigervnc-server
|
||||
|
||||
@@ -1218,7 +1212,7 @@ EOF"
|
||||
|
||||
_service_jriver-x11vnc() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
_installPackage x11vnc
|
||||
|
||||
@@ -1262,7 +1256,7 @@ EOF"
|
||||
|
||||
_service_jriver-createrepo() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
_bash_cmd "cat <<-EOF > $_service_fname
|
||||
[Unit]
|
||||
@@ -1312,7 +1306,7 @@ EOF"
|
||||
|
||||
_uninstall() {
|
||||
|
||||
_runDebug "${FUNCNAME[0]}"
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
read -r -p "Do you really want to uninstall JRiver Media Center? [y/N] " _response
|
||||
_response=${_response,,} # tolower
|
||||
|
||||
Reference in New Issue
Block a user