2 Commits

Author SHA1 Message Date
45f61ac3a0 Update README 2020-04-26 22:47:36 -04:00
abd0f43ad1 Refactor 2020-04-26 22:38:57 -04:00
2 changed files with 85 additions and 75 deletions

View File

@@ -46,8 +46,6 @@ Here is a list of additional options that can be passed to the script. You can a
Print this script version and exit Print this script version and exit
--debug, -d --debug, -d
Print debug output Print debug output
--force, -f
Force reinstallation and ignore/overwrite previous output
--help, -h --help, -h
Print help dialog and exit Print help dialog and exit
--uninstall, -u --uninstall, -u
@@ -66,21 +64,27 @@ jriver-mediaserver
Enable and start a mediaserver systemd service (requires an existing X server) Enable and start a mediaserver systemd service (requires an existing X server)
jriver-mediacenter jriver-mediacenter
Enable and start a mediacenter systemd service (requires an existing X server) Enable and start a mediacenter systemd service (requires an existing X server)
jriver-x11vnc jriver-x11vnc-mediacenter
Enable and start x11vnc for the local desktop (requires an existing X server) Enable and start x11vnc for the local desktop (requires an existing X server)
--vncpass and --display are also valid options (see below)
jriver-vnc-mediacenter
Enable and start a vncserver running JRiver Media Center
--vncpass PASSWORD --vncpass PASSWORD
Set vnc password for x11vnc/vncserver access. If no password is set, the script Set vnc password for x11vnc/Xvnc access. If no password is set, the script
will either use existing password stored in ~/.vnc/jrmc_passwd or use no password will either use existing password stored in ~/.vnc/jrmc_passwd or use no password
--display DISPLAY --display DISPLAY
Display to start vncserver/x11vnc (Default: The current display (x11vnc) or next Display to start x11vnc/Xvnc (Default: The current display (x11vnc) or the
available display (vncserver)) current display incremented by 1 (Xvnc))
jriver-xvnc-mediacenter
Enable and start an Xvnc session running JRiver Media Center
--vncpass and --display are also valid options (see above)
jriver-createrepo jriver-createrepo
Install hourly service to build latest MC RPM and run createrepo Install hourly service to build latest MC RPM and run createrepo
``` ```
#### `jriver-x11vnc-mediacenter` versus `jriver-xvnc-mediacenter`
`x11vnc` shares your existing X display via vnc, `xvnc` creates a new display and shares it via vnc. Both services will also start a Media Center service on their respective displays.
**Note**: If `jriver-xvnc-mediacenter` finds an existing display it will attempt to increment the display number by 1. This should work fine in 99% of cases, but if you have multiple running X servers on your host machine you should use the `--display` option to specify a free display.
#### containers #### containers
**Coming soon!** **Coming soon!**
@@ -107,7 +111,7 @@ jriver-createrepo
Installs the jriver-createrepo timer and service to build the RPM, move it to the webroot, and runs createrepo as `www-user`. Installs the jriver-createrepo timer and service to build the RPM, move it to the webroot, and runs createrepo as `www-user`.
* `installJRMC --install-repo --service jriver-x11vnc --service jriver-mediacenter --vncpass "letmein"` * `installJRMC --install-repo --service jriver-x11vnc-mediacenter --service jriver-mediacenter --vncpass "letmein"`
Installs services to share the existing local desktop via VNC and automatically run Media Center. Installs services to share the existing local desktop via VNC and automatically run Media Center.

View File

@@ -25,8 +25,8 @@ installJRMC() {
_outputdir="$_basedir/output" _outputdir="$_basedir/output"
_createrepo_webroot="/srv/jriver" _createrepo_webroot="/srv/jriver"
_exec_user="$(whoami)" _exec_user="$(whoami)"
_available_services=("jriver-createrepo" "jriver-x11vnc" "jriver-mediaserver" "jriver-mediacenter" "jriver-vnc-mediacenter") _available_services=("jriver-createrepo" "jriver-x11vnc-mediacenter" "jriver-mediaserver" "jriver-mediacenter" "jriver-xvnc-mediacenter")
#_available_containers=("mediacenter-vncserver" "createrepo") #_available_containers=("mediacenter-xvnc" "createrepo")
_printHelpAndExit() { _printHelpAndExit() {
@@ -80,22 +80,22 @@ OPTIONS
Enable and start a mediaserver systemd service (requires an existing X server) Enable and start a mediaserver systemd service (requires an existing X server)
jriver-mediacenter jriver-mediacenter
Enable and start a mediacenter systemd service (requires an existing X server) Enable and start a mediacenter systemd service (requires an existing X server)
jriver-x11vnc jriver-x11vnc-mediacenter
Enable and start x11vnc for the local desktop (requires an existing X server) Enable and start x11vnc for the local desktop (requires an existing X server)
--vncpass and --display are also valid options (see below) --vncpass and --display are also valid options (see below)
jriver-vnc-mediacenter jriver-xvnc-mediacenter
Enable and start a vncserver running JRiver Media Center Enable and start an Xvnc session running JRiver Media Center
--vncpass PASSWORD --vncpass PASSWORD
Set vnc password for x11vnc/vncserver access. If no password is set, the script Set vnc password for x11vnc/Xvnc access. If no password is set, the script
will either use existing password stored in ~/.vnc/jrmc_passwd or use no password will either use existing password stored in ~/.vnc/jrmc_passwd or use no password
--display DISPLAY --display DISPLAY
Display to start vncserver/x11vnc (Default: The current display (x11vnc) or next Display to start x11vnc/Xvnc (Default: The current display (x11vnc) or the
available display (vncserver)) current display incremented by 1 (Xvnc))
jriver-createrepo jriver-createrepo
Install hourly service to build latest MC RPM and run createrepo Install hourly service to build latest MC RPM and run createrepo
CONTAINERS CONTAINERS
mediacenter-vncserver (Under construction) mediacenter-xvnc (Under construction)
createrepo (Under construction) createrepo (Under construction)
EOF EOF
@@ -558,7 +558,7 @@ EOF
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
for _service in "${_services[@]}"; do for _service in "${_services[@]}"; do
if [[ "$_service" =~ ^(jriver-mediacenter|jriver-mediaserver|jriver-vnc-mediacenter)$ ]] \ if [[ "$_service" =~ ^(jriver-mediacenter|jriver-mediaserver|jriver-xvnc-mediacenter)$ ]] \
&& [[ -z $_repoinstall && -z $_rpminstall ]] \ && [[ -z $_repoinstall && -z $_rpminstall ]] \
&& [[ ! -x $(command -v "mediacenter$_mversion") ]]; then && [[ ! -x $(command -v "mediacenter$_mversion") ]]; then
err "You are attempting to install a service that depends on JRiver Media Center" err "You are attempting to install a service that depends on JRiver Media Center"
@@ -605,6 +605,8 @@ EOF
echo "Installing latest JRiver Media Center from repo..." echo "Installing latest JRiver Media Center from repo..."
local _mcpkg
# Add repositories to OS-specific package managers # Add repositories to OS-specific package managers
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
@@ -614,21 +616,38 @@ name=JRiver Media Center repo by BryanC
baseurl=https://repos.bryanroessler.com/jriver baseurl=https://repos.bryanroessler.com/jriver
gpgcheck=0 gpgcheck=0
EOF' EOF'
local _mcpkg="MediaCenter" _mcpkg="MediaCenter"
elif [[ "$ID" =~ ^(ubuntu|debian)$ ]]; then elif [[ "$ID" =~ ^(ubuntu|debian)$ ]]; then
wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | _ifSudo apt-key add - > /dev/null 2>&1 wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | _ifSudo apt-key add - > /dev/null 2>&1
_bash_cmd 'cat <<-EOF > /etc/apt/sources.list.d/jriver.list _bash_cmd 'cat <<-EOF > /etc/apt/sources.list.d/jriver.list
deb [arch=amd64,i386,armhf] http://dist.jriver.com/latest/mediacenter/ jessie main deb [arch=amd64,i386,armhf] http://dist.jriver.com/latest/mediacenter/ jessie main
EOF' EOF'
local _mcpkg="mediacenter$_mversion"
fi fi
# Update packages and install JRiver Media Center # Update package list
if ! _pkg_update; then
err "Package update failed!"
exit 1
fi
# Find latest mversion to install on Ubuntu/Debian
if [[ "$ID" =~ ^(ubuntu|debian)$ ]]; then
# Try parsing the latest mediacenter?? version from the repo
if _mcpkg=$(apt-get install mediacenter?? -s -q0 | grep "selecting" | tail -1| awk '{print $3}'); then
_mcpkg="${_mcpkg%\'}"
_mcpkg="${_mcpkg#\'}"
fi
# If that fails, fall back to scraping Interact
if ! [[ "$_mcpkg" =~ ^[0-9][0-9]\.[0-9]\.[0-9]\+$ ]]; then
_setVersion
_mcpkg="mediacenter$_mversion"
fi
fi
if [[ -n $_debug ]]; then if [[ -n $_debug ]]; then
_pkg_update && \
_installPackage "$_mcpkg" _installPackage "$_mcpkg"
else else
_pkg_update > /dev/null 2>&1 && \
_installPackage "$_mcpkg" > /dev/null 2>&1 _installPackage "$_mcpkg" > /dev/null 2>&1
fi fi
@@ -930,7 +949,7 @@ EOF"
if [[ "$1" == "jriver" ]]; then if [[ "$1" == "jriver" ]]; then
_f_ports=("52100-52200/tcp" "1900/udp") _f_ports=("52100-52200/tcp" "1900/udp")
_u_ports="52100:52200/tcp|1900/udp" _u_ports="52100:52200/tcp|1900/udp"
elif [[ "$1" =~ ^(x11vnc|vncserver)$ ]]; then elif [[ "$1" =~ ^(x11vnc|xvnc)$ ]]; then
_f_ports=("$_port/tcp") _f_ports=("$_port/tcp")
_u_ports="$_port/tcp" _u_ports="$_port/tcp"
else else
@@ -1012,7 +1031,7 @@ EOF"
####################################### #######################################
# Create the vncserver password file # Create the Xvnc password file
# Returns: # Returns:
# 0 if password created sucessfully, 1 if not # 0 if password created sucessfully, 1 if not
####################################### #######################################
@@ -1047,31 +1066,19 @@ EOF"
####################################### #######################################
# Set display and port variables # Set display and port variables
# Arguments:
# One optional integer argument to increment _service_display by
# Globals: # Globals:
# _service_display # _display
# _service_displaynum # _displaynum
# _port # _port
####################################### #######################################
_setDisplayAndPort() { _setDisplayAndPort() {
declare -g _service_display # Check _display, else DISPLAY, else set to :0 by default
declare -g _service_displaynum [[ -z $_display ]] && _display="${DISPLAY-":0"}"
declare -g _port
if [[ -n $_display ]]; then _displaynum="${_display#:}" # strip colon
_service_display="$_display" _displaynum="${_displaynum%.*}" # strip suffix
elif [[ -n $DISPLAY ]]; then _port=$(( _displaynum + 5900 ))
_service_displaynum="${DISPLAY#:}" # strip colon
_service_displaynum="${_service_displaynum%.*}" # strip suffix
_service_displaynum=$(( _service_displaynum + "${1:-0}" )) # incr by $1
_service_display=":$_service_displaynum"
else
_service_display=":0"
fi
_port=$(( _service_displaynum + 5900 ))
} }
@@ -1111,8 +1118,6 @@ EOF"
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_setDisplayAndPort
_bash_cmd "cat <<-EOF > $_service_fname _bash_cmd "cat <<-EOF > $_service_fname
[Unit] [Unit]
Description=JRiver Media Center $_mversion Media Server Description=JRiver Media Center $_mversion Media Server
@@ -1143,8 +1148,6 @@ EOF"
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_setDisplayAndPort
_bash_cmd "cat <<-EOF > $_service_fname _bash_cmd "cat <<-EOF > $_service_fname
[Unit] [Unit]
Description=JRiver Media Center $_mversion Description=JRiver Media Center $_mversion
@@ -1153,7 +1156,7 @@ After=graphical.target
[Service] [Service]
$_user_specifier $_user_specifier
Type=simple Type=simple
Environment=DISPLAY=$_service_display Environment=DISPLAY=$_display
Environment=XAUTHORITY=$XAUTHORITY Environment=XAUTHORITY=$XAUTHORITY
ExecStart=/usr/bin/mediacenter$_mversion ExecStart=/usr/bin/mediacenter$_mversion
Restart=always Restart=always
@@ -1171,23 +1174,24 @@ EOF"
} }
_service_jriver-vnc-mediacenter() { _service_jriver-xvnc-mediacenter() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_installPackage tigervnc-server _installPackage tigervnc-server
_setDisplayAndPort 1 local _next_displaynum=$(( _displaynum + 1 ))
_next_display=":$_next_displaynum"
#local _service_port=$(( _port + 1 ))
_setVNCPass _setVNCPass
if [[ -n $_novncauth ]]; then if [[ -n $_novncauth ]]; then
_exec_start_cmd="/usr/bin/vncserver $_service_display -geometry 1440x900 -alwaysshared -fg -SecurityTypes None -xstartup /usr/bin/mediacenter$_mversion" _exec_start_cmd="/usr/bin/vncserver $_next_display -geometry 1440x900 -alwaysshared -fg -SecurityTypes None -xstartup /usr/bin/mediacenter$_mversion"
else else
_exec_start_cmd="/usr/bin/vncserver $_service_display -geometry 1440x900 -alwaysshared -fg -rfbauth $HOME/.vnc/jrmc_passwd -xstartup /usr/bin/mediacenter$_mversion" _exec_start_cmd="/usr/bin/vncserver $_next_display -geometry 1440x900 -alwaysshared -fg -rfbauth $HOME/.vnc/jrmc_passwd -xstartup /usr/bin/mediacenter$_mversion"
fi fi
declare -g _port=$(( ${_service_display#:} + 5900 ))
_bash_cmd "cat <<-EOF > $_service_fname _bash_cmd "cat <<-EOF > $_service_fname
[Unit] [Unit]
Description=Remote desktop service (VNC) Description=Remote desktop service (VNC)
@@ -1196,9 +1200,9 @@ After=syslog.target network.target
[Service] [Service]
Type=simple Type=simple
$_user_specifier $_user_specifier
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill $_service_display > /dev/null 2>&1 || :' ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill $_next_display > /dev/null 2>&1 || :'
ExecStart=$_exec_start_cmd ExecStart=$_exec_start_cmd
ExecStop=/usr/bin/vncserver -kill $_service_display ExecStop=/usr/bin/vncserver -kill $_next_display
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
@@ -1206,19 +1210,18 @@ EOF"
_systemctl_reload && \ _systemctl_reload && \
_systemctl_start "$_service_name" && \ _systemctl_start "$_service_name" && \
_systemctl_enable "$_service_name" && \ _systemctl_enable "$_service_name" && \
echo "vncserver running on localhost:$_port" && \ vncserver --list && \
_openFirewall "vncserver" && \ _openFirewall "xvnc" && \
_openFirewall "jriver" _openFirewall "jriver"
} }
_service_jriver-x11vnc() { _service_jriver-x11vnc-mediacenter() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
_installPackage x11vnc _installPackage x11vnc
_setDisplayAndPort
_setX11VNCPass _setX11VNCPass
# Get current desktop resolution # Get current desktop resolution
@@ -1227,9 +1230,9 @@ EOF"
_res=$(xdpyinfo | grep dimensions | awk '{print $2}') _res=$(xdpyinfo | grep dimensions | awk '{print $2}')
if [[ -n $_novncauth ]]; then if [[ -n $_novncauth ]]; then
_exec_start_cmd="/usr/bin/x11vnc -display $_service_display -noscr -geometry $_res -auth guess -forever -bg -nopw" _exec_start_cmd="/usr/bin/x11vnc -display $_display -noscr -geometry $_res -auth guess -forever -bg -nopw"
else else
_exec_start_cmd="/usr/bin/x11vnc -display $_service_display -noscr -geometry $_res -auth guess -forever -bg -rfbauth $HOME/.vnc/jrmc_passwd" _exec_start_cmd="/usr/bin/x11vnc -display $_display -noscr -geometry $_res -auth guess -forever -bg -rfbauth $HOME/.vnc/jrmc_passwd"
fi fi
_bash_cmd "cat <<-EOF > $_service_fname _bash_cmd "cat <<-EOF > $_service_fname
@@ -1240,7 +1243,7 @@ After=multi.service
[Service] [Service]
$_user_specifier $_user_specifier
Type=forking Type=forking
Environment=DISPLAY=$_service_display Environment=DISPLAY=$_display
ExecStart=$_exec_start_cmd ExecStart=$_exec_start_cmd
Restart=always Restart=always
RestartSec=10 RestartSec=10
@@ -1253,6 +1256,8 @@ EOF"
_systemctl_enable "$_service_name" && \ _systemctl_enable "$_service_name" && \
echo "x11vnc running on localhost:$_port" && \ echo "x11vnc running on localhost:$_port" && \
_openFirewall "x11vnc" _openFirewall "x11vnc"
_service_jriver-mediacenter
} }
@@ -1368,15 +1373,6 @@ EOF"
# Build some OS-specific commands based on the selected OS # Build some OS-specific commands based on the selected OS
_buildCommands _buildCommands
# Set version to install/uninstall
_setVersion
# Uninstall and exit
if [[ -n $_uninstall ]]; then
_uninstall
exit $?
fi
# Install MC using package manager # Install MC using package manager
if [[ -n $_repoinstall ]]; then if [[ -n $_repoinstall ]]; then
_installPackage rpmfusion-free-release epel-release _installPackage rpmfusion-free-release epel-release
@@ -1386,6 +1382,15 @@ EOF"
_openFirewall "jriver" _openFirewall "jriver"
fi fi
# Set version to install/uninstall
_setVersion
# Uninstall and exit
if [[ -n $_uninstall ]]; then
_uninstall
exit $?
fi
# Build RPM from source DEB # Build RPM from source DEB
if [[ -n $_rpmbuild ]]; then if [[ -n $_rpmbuild ]]; then
_acquireDeb _acquireDeb
@@ -1409,6 +1414,7 @@ EOF"
fi fi
# Install services # Install services
_setDisplayAndPort
for _service in "${_services[@]}"; do for _service in "${_services[@]}"; do
_servicePrep "$_service" _servicePrep "$_service"
"_service_$_service" "_service_$_service"