1 Commits

Author SHA1 Message Date
e44e8d1df6 Update README 2020-04-25 14:11:33 -04:00
2 changed files with 157 additions and 178 deletions

View File

@@ -5,8 +5,7 @@ This script will help install [JRiver Media Center](https://www.jriver.com/) and
## Notes ## Notes
1. This script will not point major upgrades (i.e. from v25 to v26) to your old library. You should **first perform a library backup**, install the new major version, and then restore the library backup in the new version. 1. This script will not point major upgrades (i.e. from v25 to v26) to your old library. You should **first perform a library backup**, install the new major version, and then restore the library backup in the new version.
2. In **most** cases `installJRMC` should be **executed as your normal user** (i.e. don't run it with `sudo`). Services are installed for the user that executes the script so do not execute as root unless you want to install system-wide services like `createrepo` (see services section below for more information). Doing so may lead to permissions issues. 2. It is recommended to run `installJRMC` as your normal system user (i.e. don't run it with `sudo`). Services are installed for the user that executes the script so do not execute as root unless you want to install system-wide services like `createrepo` (see services section below for more information).
3. I do my best to test on Fedora/CentOS/Ubuntu/Debian but there are a lot of quirks to support
## Options ## Options
@@ -19,7 +18,7 @@ Here is a list of additional options that can be passed to the script. You can a
DEB-based OSes: Official package repository DEB-based OSes: Official package repository
RPM-based OSes: BryanC unofficial repository RPM-based OSes: BryanC unofficial repository
--install-rpmbuild --install-rpmbuild
(RPM-based OSes only) Build RPM from source DEB and install it (RPM-based OSes only!) Build RPM from source DEB and install it
--rpmbuild --rpmbuild
Build RPM from source DEB Build RPM from source DEB
--outputdir PATH --outputdir PATH
@@ -30,8 +29,6 @@ Here is a list of additional options that can be passed to the script. You can a
Restore file location for registration (Default: skip registration) Restore file location for registration (Default: skip registration)
--betapass PASSWORD --betapass PASSWORD
Enter beta team password for access to beta builds Enter beta team password for access to beta builds
--service-user USER
Install systemd services and containers for USER
--service, -s SERVICE --service, -s SERVICE
See SERVICES section below for a list of possible services to install See SERVICES section below for a list of possible services to install
--container, -c CONTAINER --container, -c CONTAINER
@@ -53,7 +50,7 @@ Here is a list of additional options that can be passed to the script. You can a
--uninstall, -u --uninstall, -u
Uninstall JRiver MC, cleanup service files, and remove firewall rules (does not remove library files) Uninstall JRiver MC, cleanup service files, and remove firewall rules (does not remove library files)
``` ```
**Some options are incompatible**, for example it is not possible to install the `mediaserver` service on Ubuntu/Debian when using `--rpmbuild` or `--createrepo` since those options do not actually install Media Center. `installJRMC` does perform sanity checks to automatically fix conflicting options, but it may not catch all edge cases. **Some options are incompatible** with each other, for example it is not possible to install the `mediaserver` service on Ubuntu/Debian when using `--rpmbuild` or `--createrepo` since those options do not actually install Media Center. `installJRMC` does perform sanity checks to automatically fix conflicting options, but it may not catch all edge cases.
@@ -62,22 +59,21 @@ When installing systemd services it is important to execute `installJRMC` as the
It is possible to specify multiple services: `installJRMC --service x11vnc --service mediacenter` It is possible to specify multiple services: `installJRMC --service x11vnc --service mediacenter`
```text ```text
jriver-mediaserver 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 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 x11vnc
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 mediacenter-vncserver
Enable and start a vncserver running JRiver Media Center 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 access. If no password is set, the script will either
will either use existing password stored in ~/.vnc/jrmc_passwd or use no password 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 vncserver/x11vnc (Default: The current display (x11vnc) or next available display (vncserver))
available display (vncserver)) 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
``` ```
@@ -91,7 +87,7 @@ jriver-createrepo
Installs the latest version of JRiver Media Center from the repository. Installs the latest version of JRiver Media Center from the repository.
* `installJRMC --install-repo --service jriver-mediaserver` * `installJRMC --install-repo --service mediaserver`
Installs JRiver Media Center from the repository and starts/enables the mediaserver service. Installs JRiver Media Center from the repository and starts/enables the mediaserver service.
@@ -103,21 +99,20 @@ jriver-createrepo
Builds the RPM, moves it to the webroot, and runs createrepo as `www-user`. Builds the RPM, moves it to the webroot, and runs createrepo as `www-user`.
* `installJRMC --service jriver-createrepo --createrepo-webroot /srv/jriver/repo --createrepo-user www-user` * `installJRMC --service createrepo --createrepo-webroot /srv/jriver/repo --createrepo-user www-user`
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 run createrepo as `www-user`.
* `installJRMC --install-repo --service jriver-x11vnc --service jriver-mediacenter --vncpass "letmein"` * `installJRMC --install-repo --service x11vnc --service 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
* `installJRMC --install-repo --service jriver-vnc-mediacenter` * `installJRMC --install-repo --service mediacenter-vncserver --vncpass "letmein"`
Installs a service that starts a vncserver containing Media Center. Installs a service that starts a vncserver containing Media Center
* `installJRMC --uninstall` * `installJRMC --uninstall`
Uninstalls JRiver Media Center and its associated services and firewall rules. This will **not** remove your media library and database in case you want to reinstall. Uninstalls JRiver Media Center and its associated services and firewall rules. This will **not** remove your media library and database in case you want to reinstall.
### Donations
Did you find `installJRMC` useful? [Buy me a coffee!](https://paypal.me/bryanroessler?locale.x=en_US) Did you find `installJRMC` useful? [Buy me a coffee!](https://paypal.me/bryanroessler?locale.x=en_US)

View File

@@ -20,12 +20,13 @@ shopt -s extglob
####################################### #######################################
installJRMC() { installJRMC() {
_scriptversion="0.4" _scriptversion="0.3"
_boardurl="https://yabb.jriver.com/interact/index.php/board,64.0.html" _boardurl="https://yabb.jriver.com/interact/index.php/board,64.0.html"
_outputdir="$_basedir/output" _outputdir="$_basedir/output"
_createrepo_webroot="/srv/jriver" _createrepo_webroot="/srv/jriver"
_exec_user="$(whoami)" _createrepo_user="$(whoami)"
_available_services=("jriver-createrepo" "jriver-x11vnc" "jriver-mediaserver" "jriver-mediacenter" "jriver-vnc-mediacenter") _user="$(whoami)"
_available_services=("createrepo" "x11vnc" "mediaserver" "mediacenter" "mediacenter-vncserver")
#_available_containers=("mediacenter-vncserver" "createrepo") #_available_containers=("mediacenter-vncserver" "createrepo")
@@ -54,8 +55,6 @@ OPTIONS
Restore file location for registration (Default: skip registration) Restore file location for registration (Default: skip registration)
--betapass PASSWORD --betapass PASSWORD
Enter beta team password for access to beta builds Enter beta team password for access to beta builds
--service-user USER
Install systemd services and containers for USER
--service, -s SERVICE --service, -s SERVICE
See SERVICES section below for a list of possible services to install See SERVICES section below for a list of possible services to install
--container, -c CONTAINER --container, -c CONTAINER
@@ -78,22 +77,21 @@ OPTIONS
Uninstall JRiver MC, cleanup service files, and remove firewall rules (does not remove library files) Uninstall JRiver MC, cleanup service files, and remove firewall rules (does not remove library files)
SERVICES SERVICES
jriver-mediaserver 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 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 x11vnc
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 mediacenter-vncserver
Enable and start a vncserver running JRiver Media Center 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 access. If no password is set, the script will either
will either use existing password stored in ~/.vnc/jrmc_passwd or use no password 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 vncserver/x11vnc (Default: The current display (x11vnc) or next available display (vncserver))
available display (vncserver)) 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
@@ -116,7 +114,7 @@ EOF
return 1 return 1
fi 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:,version,debug,force,help,uninstall,createrepo,createrepo-webroot:,createrepo-user:,vncpass:,display:,container: -- "$@"); then
eval set -- "$_input" eval set -- "$_input"
while true; do while true; do
case "$1" in case "$1" in
@@ -142,9 +140,6 @@ EOF
--betapass) --betapass)
shift && _betapass="$1" shift && _betapass="$1"
;; ;;
--service-user)
shift && _service_user="$1"
;;
--service|-s) --service|-s)
shift && _services+=("$1") shift && _services+=("$1")
;; ;;
@@ -214,13 +209,11 @@ EOF
####################################### #######################################
# Prepend this to any command that you wish to execute with sudo # Prepend this to any command that you wish to execute with sudo (i.e. when _user is NOT root)
# Requires:
# _exec_user
####################################### #######################################
_ifSudo() { _ifSudo() {
if [[ "$_exec_user" != "root" ]]; then if [[ "$_user" != "root" ]]; then
sudo "$@" sudo "$@"
else else
"$@" "$@"
@@ -228,6 +221,25 @@ EOF
} }
_checkUser() {
_runDebug "${FUNCNAME[0]}"
if [[ "$_user" == "root" ]]; then
cat <<EOF
Warning! You are currently running installJRMC as the root user. This is not recommended! When
running as a regular user, installJRMC will ask you for your sudo password when necessary.
Installation will continue but any systemd services will be installed as system services and you
may run into permissions issues.
EOF
else
[[ -n $_debug ]] && echo "Installing as user: $_user"
fi
}
####################################### #######################################
# Sources /etc/os-release so we know which OS we're running on # Sources /etc/os-release so we know which OS we're running on
# Used in: _buildCommands() # Used in: _buildCommands()
@@ -236,8 +248,8 @@ EOF
_runDebug "${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
if [[ -e "/etc/os-release" ]]; then if [[ -e /etc/os-release ]]; then
source "/etc/os-release" source /etc/os-release
else else
err "No /etc/os-release found" err "No /etc/os-release found"
err "Your OS is unsupported" err "Your OS is unsupported"
@@ -325,8 +337,8 @@ EOF
else else
_createrepo_cmd(){ sudo -u "$_createrepo_user" createrepo -q "$@"; } _createrepo_cmd(){ sudo -u "$_createrepo_user" createrepo -q "$@"; }
fi fi
_cr_mkdir_cmd(){ sudo -u "$_createrepo_user" mkdir -p "$@"; } _mkdir_cmd(){ sudo -u "$_createrepo_user" mkdir -p "$@"; }
_cr_cp_cmd(){ sudo -u "$_createrepo_user" cp -n "$@"; } _cp_cmd(){ sudo -u "$_createrepo_user" cp -n "$@"; }
else else
if [[ -d "$_createrepo_webroot/repodata" ]]; then if [[ -d "$_createrepo_webroot/repodata" ]]; then
_createrepo_cmd(){ createrepo -q --update "$@"; } _createrepo_cmd(){ createrepo -q --update "$@"; }
@@ -338,21 +350,6 @@ EOF
} }
#######################################
# Sets default user variables
# Requires:
# _exec_user
# Globals
# _service_user
# _createrepo_user
#######################################
_setUser() {
[[ -z $_service_user ]] && _service_user="$_exec_user"
[[ -z $_createrepo_user ]] && _createrepo_user="$_exec_user"
}
####################################### #######################################
# Installs a package using the system package manager # Installs a package using the system package manager
# Arguments: # Arguments:
@@ -548,9 +545,6 @@ EOF
# Check for bad service name # Check for bad service name
# #
_checkServices() { _checkServices() {
_runDebug "${FUNCNAME[0]}"
for _service in "${_services[@]}"; do for _service in "${_services[@]}"; do
if ! _inArray "$_service" "${_available_services[@]}"; then if ! _inArray "$_service" "${_available_services[@]}"; then
echo "Incorrect service type provided" echo "Incorrect service type provided"
@@ -560,43 +554,33 @@ EOF
} }
_checkMCInstalled() { _createrepoBuild() {
_runDebug "${FUNCNAME[0]}" if _inArray "createrepo" "${_services[@]}"; then
echo "Incorrect service type provided"
_printHelpAndExit 1
fi
}
_checkMCInstalled() {
if [[ "${_services[*]}" =~ ^(mediacenter|mediaserver|mediacenter-vncserver)$ ]]; then if [[ "${_services[*]}" =~ ^(mediacenter|mediaserver|mediacenter-vncserver)$ ]]; then
if [[ -z $_repoinstall && -z $_rpminstall ]]; then if [[ -z $_repoinstall && -z $_rpminstall ]]; then
if [[ -x $(command -v "mediacenter$_mversion") ]]; then if [[ -x $(command -v "mediacenter$_mversion") ]]; then
err "You are attempting to install a service that relies on mediacenter$_mversion but --install-repo/--install-rpmbuild are not set and mediacenter$_mversion is not installed" err "You are attempting to install a service that relies on mediacenter$_mversion but --install-repo/--install-rpmbuild are not set and mediacenter$_mversion is not installed"
return 1 _printHelpAndExit 1
fi fi
fi fi
fi fi
} }
_checkUser() {
_runDebug "${FUNCNAME[0]}"
if [[ "$_exec_user" == "root" && -z "$_service_user" && "${_services[*]}" ]]; then
err "Attempting to install services as the root user"
err "This is not recommended and we are exiting now to prevent permission hell"
err "You can override this safety check by manually specifying --user root"
return 1
fi
}
# Enable/disable sanity checks # Enable/disable sanity checks
if _checkServices && _checkMCInstalled && _checkUser; then _checkServices
[[ -n $_debug ]] && echo "Sanity checks passed!" _checkMCInstalled
return 0 #_createrepoBuild
else
err "Sanity checks failed!"
exit 1
fi
} }
@@ -838,7 +822,7 @@ EOF"
# If the webroot does not exist, create it # If the webroot does not exist, create it
if [[ ! -d "$_createrepo_webroot" ]]; then if [[ ! -d "$_createrepo_webroot" ]]; then
if ! _cr_mkdir_cmd "$_createrepo_webroot"; then if ! _mkdir_cmd "$_createrepo_webroot"; then
err "Could not create the createrepo-webroot path!" err "Could not create the createrepo-webroot path!"
err "Make sure that the createrepo-webroot is writeable by createrepo-user" err "Make sure that the createrepo-webroot is writeable by createrepo-user"
return 1 return 1
@@ -846,7 +830,7 @@ EOF"
fi fi
# Copy built rpms to webroot # Copy built rpms to webroot
if ! _cr_cp_cmd "$_rpmfile" "$_createrepo_webroot"; then if ! _cp_cmd "$_rpmfile" "$_createrepo_webroot"; then
err "Could not copy the RPM to the createrepo-webroot path" err "Could not copy the RPM to the createrepo-webroot path"
err "Make sure that the createrepo-webroot path is writeable by createrepo-user" err "Make sure that the createrepo-webroot path is writeable by createrepo-user"
return 1 return 1
@@ -940,9 +924,6 @@ EOF"
elif [[ "$1" =~ ^(x11vnc|vncserver)$ ]]; then elif [[ "$1" =~ ^(x11vnc|vncserver)$ ]]; then
_f_ports=("$_port/tcp") _f_ports=("$_port/tcp")
_u_ports="$_port/tcp" _u_ports="$_port/tcp"
else
err "_openFirewall unrecognized service name"
exit 1
fi fi
# Open the ports # Open the ports
@@ -1049,60 +1030,24 @@ EOF"
} }
#######################################
# Set display and port variables
# Arguments:
# One optional integer argument to increment _service_display by
# Globals:
# _service_display
# _service_displaynum
# _port
#######################################
_setDisplayandPort() {
declare -g _service_display
declare -g _service_displaynum
declare -g _port
if [[ -n $_display ]]; then
_service_display="$_display"
elif [[ -n $DISPLAY ]]; then
_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 ))
}
####################################### #######################################
# Create associated service variables based on service name # Create associated service variables based on service name
# Requires: # Arguments:
# _service_user # Requires exactly one argument, the name of the service to parse
# Globals:
# _service_fname
# _timer_fname
# _service_name
# _timer_name
# _user_specifier
####################################### #######################################
_servicePrep() { _servicePrep() {
if [[ "$_service_user" == "root" ]]; then if [[ "$_user" == "root" ]]; then
_service_fname="/usr/lib/systemd/system/${1}.service" _service_fname="/usr/lib/systemd/system/jriver-${1}.service"
_timer_fname="/usr/lib/systemd/system/${1}.timer" _timer_fname="/usr/lib/systemd/system/jriver-${1}.timer"
_service_name="jriver-${1}.service" _service_name="jriver-${1}.service"
_timer_name="jriver-${1}}.timer" _timer_name="jriver-${1}}.timer"
_user_specifier="" _user_specifier=""
else else
_service_fname="/usr/lib/systemd/system/${1}@.service" _service_fname="/usr/lib/systemd/system/jriver-${1}@.service"
_timer_fname="/usr/lib/systemd/system/${1}@.timer" _timer_fname="/usr/lib/systemd/system/jriver-${1}@.timer"
_service_name="${1}@$_service_user.service" _service_name="jriver-${1}@$_user.service"
_timer_name="${1}@$_service_user.timer" _timer_name="jriver-${1}@$_user.timer"
_user_specifier="User=%I" _user_specifier="User=%I"
fi fi
} }
@@ -1111,11 +1056,11 @@ EOF"
####################################### #######################################
# SERVICES # SERVICES
####################################### #######################################
_service_jriver-mediaserver() { _serviceMediaserver() {
_runDebug "${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
_setDisplay [[ -z $_display ]] && _display="${DISPLAY:-":0"}"
_bash_cmd "cat <<-EOF > $_service_fname _bash_cmd "cat <<-EOF > $_service_fname
[Unit] [Unit]
@@ -1138,16 +1083,16 @@ WantedBy=graphical.target
EOF" EOF"
_systemctl_reload && \ _systemctl_reload && \
_systemctl_start "$_service_name" && \ _systemctl_start "$_service_name" && \
_systemctl_enable "$_service_name" && \ _systemctl_enable "$_service_name"
_openFirewall "jriver"
} }
_service_jriver-mediacenter() { _serviceMediacenter() {
_runDebug "${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
_setDisplay # Set the display to use
[[ -z $_display ]] && _display="${DISPLAY:-":0"}"
_bash_cmd "cat <<-EOF > $_service_fname _bash_cmd "cat <<-EOF > $_service_fname
[Unit] [Unit]
@@ -1157,7 +1102,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
@@ -1170,27 +1115,36 @@ WantedBy=graphical.target
EOF" EOF"
_systemctl_reload && \ _systemctl_reload && \
_systemctl_start "$_service_name" && \ _systemctl_start "$_service_name" && \
_systemctl_enable "$_service_name" && \ _systemctl_enable "$_service_name"
_openFirewall "jriver"
} }
_service_jriver-vnc-mediacenter() { _serviceVNC() {
_runDebug "${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
_installPackage tigervnc-server _installPackage tigervnc-server
_setDisplay 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 $_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 $_display -geometry 1440x900 -alwaysshared -fg -rfbauth $HOME/.vnc/jrmc_passwd -xstartup /usr/bin/mediacenter$_mversion"
fi fi
declare -g _port=$(( ${_service_display#:} + 5900 )) # Set the display to use
if [[ -z $_display ]]; then
# If we are running on existing X server then increment DISPLAY by one
if [[ -n $DISPLAY ]]; then
_display=$(( ${DISPLAY#:} + 1 ))
_display=":$_display"
else
_display=":0"
fi
fi
declare -g _port=$(( ${_display#:} + 5900 ))
_bash_cmd "cat <<-EOF > $_service_fname _bash_cmd "cat <<-EOF > $_service_fname
[Unit] [Unit]
@@ -1200,9 +1154,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 $_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 $_display
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
@@ -1210,30 +1164,31 @@ 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" && \ echo "vncserver running on localhost:$_port"
_openFirewall "vncserver" && \
_openFirewall "jriver"
} }
_service_jriver-x11vnc() { _serviceX11VNC() {
_runDebug "${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
_installPackage x11vnc _installPackage x11vnc
_setDisplay
_setX11VNCPass _setX11VNCPass
[[ -z $_display ]] && _display="${DISPLAY:-":0"}"
declare -g _port=$(( ${_display#:} + 5900 ))
# Get current desktop resolution # Get current desktop resolution
# TODO: may need to break this out into its own function and get smarter at identifying multi-monitors # TODO: may need to break this out into its own function and get smarter at identifying multi-monitors
local _res local _res
_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
@@ -1244,7 +1199,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
@@ -1254,13 +1209,12 @@ WantedBy=multi-user.target
EOF" EOF"
_systemctl_reload && \ _systemctl_reload && \
_systemctl_start "$_service_name" && \ _systemctl_start "$_service_name" && \
_systemctl_enable "$_service_name" && \ _systemctl_enable "$_service_name"
echo "x11vnc running on localhost:$_port" && \ echo "x11vnc running on localhost:$_port"
_openFirewall "x11vnc"
} }
_service_jriver-createrepo() { _serviceCreaterepo() {
_runDebug "${FUNCNAME[0]}" _runDebug "${FUNCNAME[0]}"
@@ -1360,21 +1314,21 @@ EOF"
__main() { __main() {
# Check user
_checkUser
# Parse input # Parse input
_parseInput "$@" _parseInput "$@"
# Sanity checks
_sanityChecks
# Set user variables
_setUser
# 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 # 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
@@ -1415,12 +1369,42 @@ EOF"
# Install services # Install services
for _service in "${_services[@]}"; do for _service in "${_services[@]}"; do
_servicePrep "$_service" _servicePrep "$_service"
"_service_$_service" case "$_service" in
createrepo)
_serviceCreaterepo
;;
x11vnc)
_serviceX11VNC
_openFirewall "x11vnc"
;;
mediaserver)
_serviceMediaserver
;;
mediacenter)
_serviceMediacenter
;;
mediacenter-vncserver)
_serviceVNC
_openFirewall "vncserver"
;;
*)
esac
done done
# Install containers # Install containers
for _container in "${_containers[@]}"; do for _container in "${_containers[@]}"; do
"_container_$_container" case "$_container" in
createrepo)
_containerCreaterepo
;;
mediacenter-vncserver)
_containerVNC
;;
mediacenter)
_containerMC
;;
*)
esac
done done
} }
} }