6 Commits

Author SHA1 Message Date
2656a083db Alias repo and remote 2023-01-24 12:19:09 -05:00
9cc2416e01 Cleanup formatting 2023-01-24 12:18:05 -05:00
7155e1141c Assign dev version for major change 2023-01-24 11:57:48 -05:00
56898849eb Cleanup output 2023-01-24 11:52:24 -05:00
20ef1b03c5 Replace eval strings with arrays 2023-01-24 11:47:47 -05:00
703433aa94 Tighten up docs, background container work 2023-01-24 10:57:32 -05:00
2 changed files with 210 additions and 260 deletions

View File

@@ -8,7 +8,7 @@ This program will install [JRiver Media Center](https://www.jriver.com/) (JRMC)
Running `installJRMC` without any options will install the latest version of JRiver Media Center from the official JRiver repository (Ubuntu/Debian) or my [unofficial repository](https://repos.bryanroessler.com/jriver/) (Fedora/CentOS) using the system package manager (`--install repo`). If any other option is specified, then the default install method (i.e. `--install repo` or `--install local`) will need to be explicitly specified. This makes it possible to install services and containers independent of MC.
**Note**: As of 1.0b14 major version library migrations are performed if the destination config directory `$HOME/.jriver/Media Center XX` is missing for major release `XX`. However, it is still a good idea to create a manual library backup before migrating major versions.
**Note**: As of v1.0b14 major version library migrations are performed if the destination config directory `$HOME/.jriver/Media Center XX` is missing for major release `XX`. However, it is still a good idea to create a manual library backup before migrating major versions.
## Options
@@ -16,14 +16,14 @@ Running `installJRMC` without any options will install the latest version of JRi
$ installJRMC --help
--install, -i repo|local
repo: Install MC from repository, future updates will be handled by the system package manager
local: Build and install MC package locally
local: Build and install MC package locally from official source package
--build[=suse|fedora|centos]
Build RPM from source DEB but do not install
Optionally, specify a target distro for cross-building (ex. --build=suse, note the '=')
--compat
Build/install MC without minimum library specifiers
Build/install MC without minimum dependency version requirements
--mcversion VERSION
Build or install a specific MC version, ex. "30.0.17"
Build or install a specific MC version, ex. "30.0.51"
--outputdir PATH
Generate rpmbuild output in this PATH (Default: ./output)
--restorefile RESTOREFILE
@@ -33,7 +33,7 @@ $ installJRMC --help
--service, -s SERVICE
See SERVICES section below for the list of services to deploy
--service-type user|system
Starts services at boot (system) or user login (user) (Default: system)
Starts services at boot (system) or user login (user) (Default: per-service see SERVICES)
--container, -c CONTAINER (TODO: Under construction)
See CONTAINERS section below for a list of containers to deploy
--createrepo[=suse|fedora|centos]
@@ -56,20 +56,20 @@ $ installJRMC --help
## Services
```text
jriver-mediaserver
jriver-mediaserver (default --service-type=user)
Enable and start a mediaserver systemd service (requires an existing X server)
jriver-mediacenter
jriver-mediacenter (user)
Enable and start a mediacenter systemd service (requires an existing X server)
jriver-x11vnc
jriver-x11vnc (user)
Enable and start x11vnc for the local desktop (requires an existing X server, does NOT support Wayland)
--vncpass and --display are also valid options (see below)
jriver-xvnc
jriver-xvnc (system)
Enable and start a new Xvnc session running JRiver Media Center
--vncpass PASSWORD
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
--display DISPLAY
Manually specify display to use for x11vnc/Xvnc (ex. ':1')
jriver-createrepo
jriver-createrepo (system)
Install hourly service to build latest MC RPM and run createrepo
By default installs as root service to handle www permissions more gracefully
```

View File

@@ -16,12 +16,13 @@
shopt -s extglob
declare -g SCRIPTVERSION="1.0-rc4"
declare -g SCRIPTVERSION="1.0-dev"
declare -g OUTPUTDIR="$PWD/output"
declare -g BOARDURL="https://yabb.jriver.com/interact/index.php/board,76.0.html" # MC30 (Buster)
# MC30 (Buster)
declare -g BOARDURL="https://yabb.jriver.com/interact/index.php/board,76.0.html"
declare -g DEBIANBASE="buster"
declare -g MCVERSION_HARDCODE="30.0.48" # Hardcoded fallback
declare -g MCVERSION_HARDCODE="30.0.51" # Hardcoded fallback
declare -g CREATEREPO_WEBROOT="/var/www/jriver"
declare -g USER="${SUDO_USER:-$USER}"
@@ -34,36 +35,37 @@ printHelp() {
USAGE:
installJRMC [[OPTION] [VALUE]]...
If no options (excluding -d) are provided, the script will default to '--install repo'.
If no options (excluding -d or --debug) are provided installJRMC defaults to '--install repo'.
OPTIONS
--install, -i repo|local
repo: Install MC from repository, updates are handled by the system package manager
local: Build and install MC package locally
local: Build and install MC package locally from official source release
--build[=suse|fedora|centos]
Build RPM from source DEB but do not install
Optionally, specify a target distro for cross-building (ex. --build=suse, note the '=')
--compat
Build/install MC locally without minimum library specifiers
Build/install MC locally without minimum dependency version requirements
--mcversion VERSION
Specify the MC version, ex. "30.0.17" (Default: latest version)
Specify the MC version, ex. 30.0.51" (default: latest version)
--outputdir PATH
Generate rpmbuild output in this directory (Default: ./output)
Generate rpmbuild output in this directory (default: ./output)
--restorefile RESTOREFILE
Restore file location for automatic license registration (Default: skip registration)
Restore file location for automatic license registration (default: skip registration)
--betapass PASSWORD
Enter beta team password for access to beta builds
--service, -s SERVICE
See SERVICES section below for a list of possible services to install
--service-type user|system
Starts services at boot (system) or at user login (user) (Default: boot)
Starts services at boot (system) or at user login (user) (default: per service, see SERVICES)
--container, -c CONTAINER (TODO: Under construction)
See CONTAINERS section below for a list of possible services to install
--createrepo[=suse|fedora|centos]
Build rpm, copy to webroot, and run createrepo. Use in conjunction with --build=TARGET for crossbuilding repos
Build rpm, copy to webroot, and run createrepo.
Use in conjunction with --build=TARGET for crossbuilding repos
Optionally, specify a target distro for non-native repo (ex. --createrepo=fedora, note the '=')
--createrepo-webroot PATH
Specify the webroot directory to install the repo (Default: /var/www/jriver)
Specify the webroot directory to install the repo (default: /var/www/jriver)
--createrepo-user USER
Specify the web server user if it differs from $USER
--version, -v
@@ -73,27 +75,27 @@ printHelp() {
--help, -h
Print help dialog and exit
--uninstall, -u
Uninstall JRiver MC, remove services, and remove firewall rules (does not remove library files)
Uninstall JRiver MC, remove services, containers, and firewall rules (does not remove library files)
SERVICES
jriver-mediaserver
Enable and start a mediaserver systemd service (requires an existing X server) (user)
jriver-mediacenter
Enable and start a mediacenter systemd service (requires an existing X server) (user)
jriver-x11vnc
Enable and start x11vnc for the local desktop (requires an existing X server) (user)
jriver-mediaserver (default --service-type=user)
Enable and start a mediaserver systemd service (requires an existing X server)
jriver-mediacenter (user)
Enable and start a mediacenter systemd service (requires an existing X server)
jriver-x11vnc (user)
Enable and start x11vnc for the local desktop (requires an existing X server)
Usually combined with jriver-mediaserver or jriver-mediacenter services
--vncpass and --display are optional (see below)
jriver-xvnc
Enable and start a new Xvnc session running JRiver Media Center (system)
jriver-xvnc (system)
Enable and start a new Xvnc session running JRiver Media Center
--vncpass PASSWORD
Set vnc password for x11vnc/Xvnc access. If no password is set, the script
Set the vnc password for x11vnc/Xvnc access. If no password is set, installJRMC
will either use existing password stored in $HOME/.vnc/jrmc_passwd or use no password
--display DISPLAY
Display to start x11vnc/Xvnc (Default: The current display (x11vnc) or the
Display to use for x11vnc/Xvnc (default: The current display (x11vnc) or the
current display incremented by 1 (Xvnc))
jriver-createrepo
Install hourly service to build latest MC RPM and run createrepo (system)
jriver-createrepo (system)
Install hourly service to build latest MC RPM and run createrepo
CONTAINERS (TODO: Under construction)
mediacenter-xvnc
@@ -117,7 +119,8 @@ askOk() {
parseInput() {
debug "Running: ${FUNCNAME[0]}"
declare -g BUILD_SWITCH REPO_INSTALL_SWITCH COMPAT_SWITCH LOCAL_INSTALL_SWITCH CREATEREPO_SWITCH UNINSTALL_SWITCH TEST_SWITCH
declare -g BUILD_SWITCH REPO_INSTALL_SWITCH COMPAT_SWITCH
declare -g LOCAL_INSTALL_SWITCH CREATEREPO_SWITCH UNINSTALL_SWITCH TEST_SWITCH
declare -g OUTPUTDIR RESTOREFILE BETAPASS SERVICE_TYPE VNCPASS USER_DISPLAY CREATEREPO_WEBROOT
declare -ga SERVICES CONTAINERS
declare long_opts short_opts input
@@ -149,7 +152,7 @@ parseInput() {
BUILD_SWITCH=1
LOCAL_INSTALL_SWITCH=1
;;
repo)
repo|remote)
REPO_INSTALL_SWITCH=1
;;
esac
@@ -277,7 +280,7 @@ init() {
ID="debian"
;;
*)
echo "Autodetecting distro, this may be unreliable and --compat may also be required"
err "Autodetecting distro, this is unreliable and --compat may also be required"
if hash dnf &>/dev/null; then
ID="fedora"
RPM_MGR="dnf"
@@ -297,7 +300,7 @@ init() {
debug "Using host platform: $ID $VERSION_ID"
# Set distro-specific functions
# Abstract distro-specific package manager commands
case "$ID" in
fedora|centos)
pkg_install(){ sudo "$RPM_MGR" install -y "$@"; }
@@ -306,7 +309,6 @@ init() {
pkg_update(){ sudo "$RPM_MGR" makecache; }
pkg_swap() { sudo dnf swap -y "$1" "$2"; }
pkg_query(){ rpm -q "$@"; }
firewall_cmd(){ sudo firewall-cmd "$@"; }
;;
debian|ubuntu)
pkg_install(){ sudo apt-get install -y -q0 "$@"; }
@@ -314,7 +316,6 @@ init() {
pkg_remove(){ sudo apt-get remove --auto-remove -y -q0 "$@"; }
pkg_update(){ sudo apt-get update -y -q0; }
pkg_query(){ dpkg -s "$@"; }
firewall_cmd(){ sudo ufw "$@"; }
;;
suse)
pkg_install(){ sudo zypper --non-interactive -q install --force --no-confirm "$@"; }
@@ -322,7 +323,6 @@ init() {
pkg_remove(){ sudo zypper --non-interactive -q remove --clean-deps "$@"; }
pkg_update(){ sudo zypper --non-interactive -q refresh jriver; }
pkg_query(){ rpm -q "$@"; }
firewall_cmd(){ sudo firewall-cmd "$@"; }
;;
arch)
pkg_install(){ sudo pacman -Sy --noconfirm "$@"; }
@@ -330,7 +330,6 @@ init() {
pkg_remove(){ sudo pacman -Rs --noconfirm "$@"; }
pkg_update(){ sudo pacman -Syy ; }
pkg_query(){ sudo pacman -Qs "$@"; }
#firewall_cmd(){ sudo nft -A INPUT "$@"; }
;;
esac
}
@@ -373,7 +372,7 @@ setMCVersion() {
else
MCVERSION="$MCVERSION_HARDCODE"
MCVERSION_SOURCE="hardcoded version"
err "Warning! Using hardcoded version number."
err "Warning! Using hardcoded version number"
fi
MVERSION="${MCVERSION%%.*}"
@@ -391,8 +390,8 @@ setMCVersion() {
;;
esac
fi
echo "Using MC version $MCVERSION determined by $MCVERSION_SOURCE."
[[ "$MCVERSION_SOURCE" == "user input" ]] || echo "To override, use --mcversion."
echo "Using MC version $MCVERSION determined by $MCVERSION_SOURCE"
[[ "$MCVERSION_SOURCE" == "user input" ]] || echo "To override, use --mcversion"
debug "MVERSION: $MVERSION, MCVERSION: $MCVERSION, MCPKG: $MCPKG, MCRPM: $MCRPM"
}
@@ -410,8 +409,8 @@ setMCVersion() {
installPackage() {
debug "Running: ${FUNCNAME[0]}" "$@"
declare -a pkg_array install_flags
declare input pkg skip_check_installed silent pkg_install_cmd refresh allow_downgrades no_gpg_check
declare -a pkg_array install_flags pkg_install_cmd
declare input pkg skip_check_installed silent refresh allow_downgrades no_gpg_check
declare -A pkg_aliases
if input=$(getopt -o +s -l skip-check-installed,allow-downgrades,no-gpg-check,refresh,silent -- "$@"); then
@@ -483,9 +482,9 @@ installPackage() {
# Install packages from package array
if [[ ${#pkg_array[@]} -ge 1 ]]; then
pkg_install_cmd="pkg_install ${install_flags[*]} ${pkg_array[*]}"
debug "$pkg_install_cmd" || pkg_install_cmd+=" &>/dev/null"
if ! eval "$pkg_install_cmd"; then
pkg_install_cmd=(pkg_install "${install_flags[@]}" "${pkg_array[@]}")
debug "${pkg_install_cmd[*]}" || pkg_install_cmd+=(" &>/dev/null")
if ! eval "${pkg_install_cmd[*]}"; then
(( silent )) || err "Failed to install ${pkg_array[*]}. Attempting to continue"
return 1
fi
@@ -501,6 +500,7 @@ installMCFromRepo() {
debug "Running: ${FUNCNAME[0]}"
declare repo_dir
declare -a pkg_install_cmd
case "$ID" in
fedora|centos)
@@ -523,15 +523,15 @@ installMCFromRepo() {
wget -qO- "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" | sudo tee /etc/apt/trusted.gpg.d/jriver.asc &>/dev/null
;;
*)
err "An MC repository for $ID is not yet available."
err "Try using --install local to install MC on $ID."
err "An MC repository for $ID is not yet available"
err "Try using --install local to install MC on $ID"
return 1
;;
esac
declare pkg_update_cmd="pkg_update"
debug "$pkg_update_cmd" || pkg_update_cmd+=" &>/dev/null"
if ! eval "$pkg_update_cmd"; then
declare -a pkg_update_cmd=( pkg_update )
debug "${pkg_update_cmd[*]}" || pkg_update_cmd+=(" &>/dev/null")
if ! eval "${pkg_update_cmd[*]}"; then
err "Package update failed!"
return 1
fi
@@ -539,9 +539,13 @@ installMCFromRepo() {
# Install mesa-va-drivers-freeworld separately from the RPM for dnf swap
installMesa
declare pkg_install_cmd="installPackage --skip-check-installed --allow-downgrades --no-gpg-check $MCPKG"
debug "$pkg_install_cmd"
if ! eval "$pkg_install_cmd"; then
pkg_install_cmd=(installPackage
--skip-check-installed
--allow-downgrades
--no-gpg-check
"$MCPKG")
debug "${pkg_install_cmd[*]}" || pkg_install_cmd+=(" &>/dev/null")
if ! eval "${pkg_install_cmd[*]}"; then
err "Package install failed!"
return 1
fi
@@ -565,18 +569,16 @@ acquireDeb() {
return 0
fi
if [[ -v BETAPASS ]]; then
echo "Checking beta repo for DEB package"
if wget -q -O "$MCDEB" \
"https://files.jriver.com/mediacenter/channels/v$MVERSION/beta/$BETAPASS/MediaCenter-$MCVERSION-amd64.deb"; then
echo "Found!"
fi
if [[ -v BETAPASS ]] &&
echo "Checking beta repo for DEB package" && wget -q -O "$MCDEB" \
"https://files.jriver.com/mediacenter/channels/v$MVERSION/beta/$BETAPASS/MediaCenter-$MCVERSION-amd64.deb"; then
echo "Found!"
elif echo "Checking latest repo for DEB package" && wget -q -O "$MCDEB" \
"https://files.jriver.com/mediacenter/channels/v$MVERSION/latest/MediaCenter-$MCVERSION-amd64.deb"; then
echo "Found!"
"https://files.jriver.com/mediacenter/channels/v$MVERSION/latest/MediaCenter-$MCVERSION-amd64.deb"; then
echo "Found!"
elif echo "Checking test repo for DEB package" && wget -q -O "$MCDEB" \
"https://files.jriver.com/mediacenter/test/MediaCenter-$MCVERSION-amd64.deb"; then
echo "Found!"
"https://files.jriver.com/mediacenter/test/MediaCenter-$MCVERSION-amd64.deb"; then
echo "Found!"
else
err "Cannot find DEB file"
exit 1
@@ -606,7 +608,7 @@ buildRPM() {
return 0
fi
[[ ! -d "$OUTPUTDIR/SPECS" ]] && mkdir -p "$OUTPUTDIR/SPECS"
[[ -d "$OUTPUTDIR/SPECS" ]] || mkdir -p "$OUTPUTDIR/SPECS"
# Load deb dependencies into array
IFS=',' read -ra requires <<< "$(dpkg-deb -f "$MCDEB" Depends)"
@@ -746,15 +748,18 @@ buildRPM() {
# Run rpmbuild
echo "Building MC $MCVERSION RPM, this may take awhile"
rpmbuild_cmd="rpmbuild --define=\"%_topdir $OUTPUTDIR\" --define=\"%_libdir /usr/lib\" -bb"
rpmbuild_cmd+=" $OUTPUTDIR/SPECS/mediacenter.spec"
debug "$rpmbuild_cmd" || rpmbuild_cmd+=" &>/dev/null"
if eval "$rpmbuild_cmd" && [[ -f "$MCRPM" ]] ; then
rpmbuild_cmd=(rpmbuild
--define=\"%_topdir "$OUTPUTDIR"\"
--define=\"%_libdir /usr/lib\"
-bb
"$OUTPUTDIR/SPECS/mediacenter.spec")
debug "${rpmbuild_cmd[*]}" || rpmbuild_cmd+=(" &>/dev/null")
if eval "${rpmbuild_cmd[*]}" && [[ -f "$MCRPM" ]] ; then
echo "Build successful. The RPM file is located at: $MCRPM"
else
err "Build failed"
# For automation, let's remove the source DEB and reaquire it on next run
# after failure in case it is corrupted or buggy
# For automation, let's remove the source DEB and reaquire it on next
# run after failure in case it is corrupted or buggy
[[ -f "$MCDEB" ]] && echo "Removing source DEB" && rm -f "$MCDEB"
exit 1
fi
@@ -767,7 +772,11 @@ buildRPM() {
installMCDEB() {
debug "Running: ${FUNCNAME[0]}"
declare pkg_install_cmd="installPackage --skip-check-installed --no-gpg-check --allow-downgrades"
declare pkg_install_cmd
pkg_install_cmd=(installPackage
--skip-check-installed
--no-gpg-check
--allow-downgrades)
if (( COMPAT_SWITCH )); then
declare extract_dir && extract_dir="$(mktemp -d)"
pushd "$extract_dir" &>/dev/null || return
@@ -784,9 +793,9 @@ installMCDEB() {
popd &>/dev/null || return
rm -rf "$extract_dir"
fi
pkg_install_cmd+=" $MCDEB"
debug "$pkg_install_cmd" || pkg_install_cmd+=" &>/dev/null"
eval "$pkg_install_cmd"
pkg_install_cmd+=("$MCDEB")
debug "${pkg_install_cmd[*]}" || pkg_install_cmd+=(" &>/dev/null")
eval "${pkg_install_cmd[*]}"
}
@@ -809,14 +818,16 @@ installMCRPM() {
installMesa() {
debug "Running: ${FUNCNAME[0]}"
declare -a pkg_swap_cmd
# Currently only necessary in Fedora/CentOS
case "$ID" in
fedora|centos)
if ! pkg_query mesa-va-drivers-freeworld &>/dev/null; then
if pkg_query mesa-va-drivers &>/dev/null; then
declare pkg_swap_cmd="pkg_swap mesa-va-drivers mesa-va-drivers-freeworld"
debug "$pkg_swap_cmd" || pkg_swap_cmd+=" &>/dev/null"
if ! eval "$pkg_swap_cmd"; then
pkg_swap_cmd=(pkg_swap mesa-va-drivers mesa-va-drivers-freeworld)
debug "${pkg_swap_cmd[*]}" || pkg_swap_cmd+=(" &>/dev/null")
if ! eval "${pkg_swap_cmd[*]}"; then
err "Package swap failed!"
return 1
fi
@@ -835,6 +846,9 @@ installMesa() {
#######################################
installMCARCH() {
debug "Running: ${FUNCNAME[0]}"
declare -a makepkg_cmd
echo "Arch install under construction"
[[ -d "$OUTPUTDIR/PKGBUILD" ]] || mkdir -p "$OUTPUTDIR/PKGBUILD"
cat <<-EOF > "$OUTPUTDIR/PKGBUILD/mediacenter.pkgbuild"
@@ -863,13 +877,19 @@ installMCARCH() {
}
EOF
pushd "$OUTPUTDIR/PKGBUILD" &>/dev/null || return
makepkg_cmd="makepkg"
# TODO try to acquire checksums from deb
makepkg_cmd+=" --syncdeps --clean --cleanbuild --skipinteg --force --install --noconfirm"
makepkg_cmd+=" -p mediacenter.pkgbuild"
makepkg_cmd=(makepkg --install
--syncdeps
--clean
--cleanbuild
--skipinteg
--force
--noconfirm
-p mediacenter.pkgbuild)
if ! eval "${makepkg_cmd}"; then
pushd "$OUTPUTDIR/PKGBUILD" &>/dev/null || return
debug "${makepkg_cmd[*]}" || makepkg_cmd+=(" &>/dev/null")
if ! eval "${makepkg_cmd[*]}"; then
echo "makepkg failed"
exit
fi
@@ -884,20 +904,20 @@ installMCARCH() {
runCreaterepo() {
debug "Running: ${FUNCNAME[0]}"
declare cr_cmd cr_cp_cmd cr_mkdir_cmd cr_chown_cmd
declare -a cr_cmd cr_cp_cmd cr_mkdir_cmd cr_chown_cmd
installPackage createrepo_c
# If the webroot does not exist, create it
if [[ ! -d "$CREATEREPO_WEBROOT" ]]; then
cr_mkdir_cmd="sudo -u $CREATEREPO_USER mkdir -p $CREATEREPO_WEBROOT"
debug "$cr_mkdir_cmd" || cr_mkdir_cmd+=" &>/dev/null"
if ! eval "$cr_mkdir_cmd"; then
cr_mkdir_cmd="sudo mkdir -p $CREATEREPO_WEBROOT"
debug "$cr_mkdir_cmd" || cr_mkdir_cmd+=" &>/dev/null"
cr_chown_cmd="sudo chown -R $CREATEREPO_USER:$CREATEREPO_USER $CREATEREPO_WEBROOT"
debug "$cr_chown_cmd" || cr_chown_cmd+=" &>/dev/null"
if ! ( eval "$cr_mkdir_cmd" && eval "$cr_chown_cmd" ); then
cr_mkdir_cmd=(sudo -u "$CREATEREPO_USER" mkdir -p "$CREATEREPO_WEBROOT")
debug "${cr_mkdir_cmd[*]}" || cr_mkdir_cmd+=(" &>/dev/null")
if ! eval "${cr_mkdir_cmd[*]}"; then
cr_mkdir_cmd=(sudo mkdir -p "$CREATEREPO_WEBROOT")
debug "${cr_mkdir_cmd[*]}" || cr_mkdir_cmd+=(" &>/dev/null")
cr_chown_cmd=(sudo chown -R "$CREATEREPO_USER":"$CREATEREPO_USER" "$CREATEREPO_WEBROOT")
debug "${cr_chown_cmd[*]}" || cr_chown_cmd+=(" &>/dev/null")
if ! ( eval "${cr_mkdir_cmd[*]}" && eval "${cr_chown_cmd[*]}" ); then
err "Could not create the createrepo-webroot path!"
err "Make sure that the webroot $CREATEREPO_WEBROOT is writeable by user $CREATEREPO_USER"
err "Or change the repo ownership with --createrepo-user"
@@ -907,26 +927,26 @@ runCreaterepo() {
fi
# Copy built rpms to webroot
cr_cp_cmd="sudo cp -nf $MCRPM $CREATEREPO_WEBROOT"
cr_chown_cmd="sudo chown -R $CREATEREPO_USER:$CREATEREPO_USER $CREATEREPO_WEBROOT"
debug "$cr_cp_cmd" || cr_cp_cmd+=" &>/dev/null"
debug "$cr_chown_cmd" || cr_cp_cmd+=" &>/dev/null"
if ! ( eval "$cr_cp_cmd" && eval "$cr_chown_cmd" ); then
cr_cp_cmd=(sudo cp -nf "$MCRPM" "$CREATEREPO_WEBROOT")
cr_chown_cmd=(sudo chown -R "$CREATEREPO_USER":"$CREATEREPO_USER" "$CREATEREPO_WEBROOT")
debug "${cr_cp_cmd[*]}" || cr_cp_cmd+=(" &>/dev/null")
debug "${cr_chown_cmd[*]}" || cr_cp_cmd+=(" &>/dev/null")
if ! ( eval "${cr_cp_cmd[*]}" && eval "${cr_chown_cmd[*]}" ); then
err "Could not copy $MCRPM to $CREATEREPO_WEBROOT"
return 1
fi
# Run createrepo
cr_cmd="sudo -u $CREATEREPO_USER createrepo -q $CREATEREPO_WEBROOT"
[[ -d "$CREATEREPO_WEBROOT/repodata" ]] && cr_cmd+=" --update"
debug "$cr_cmd" || cr_cmd+=" &>/dev/null"
if ! eval "$cr_cmd"; then
cr_cmd="sudo createrepo -q $CREATEREPO_WEBROOT"
[[ -d "$CREATEREPO_WEBROOT/repodata" ]] && cr_cmd+=" --update"
cr_chown_cmd="sudo chown -R $CREATEREPO_USER:$CREATEREPO_USER $CREATEREPO_WEBROOT"
debug "$cr_cmd" || cr_cmd+=" &>/dev/null"
debug "$cr_chown_cmd" || cr_cp_cmd+=" &>/dev/null"
if ! ( eval "$cr_cmd" && eval "$cr_chown_cmd"); then
cr_cmd=(sudo -u "$CREATEREPO_USER" createrepo -q "$CREATEREPO_WEBROOT")
[[ -d "$CREATEREPO_WEBROOT/repodata" ]] && cr_cmd+=(--update)
debug "${cr_cmd[*]}" || cr_cmd+=(" &>/dev/null")
if ! eval "${cr_cmd[*]}"; then
cr_cmd=(sudo createrepo -q "$CREATEREPO_WEBROOT")
[[ -d "$CREATEREPO_WEBROOT/repodata" ]] && cr_cmd+=(--update)
cr_chown_cmd=(sudo chown -R "$CREATEREPO_USER":"$CREATEREPO_USER" "$CREATEREPO_WEBROOT")
debug "${cr_cmd[*]}" || cr_cmd+=(" &>/dev/null")
debug "${cr_chown_cmd[*]}" || cr_cp_cmd+=(" &>/dev/null")
if ! ( eval "${cr_cmd[*]}" && eval "${cr_chown_cmd[*]}"); then
err "Createrepo failed"
return 1
fi
@@ -940,22 +960,22 @@ runCreaterepo() {
symlinkCerts() {
debug "Running: ${FUNCNAME[0]}"
declare mc_cert_link="/usr/lib/jriver/Media Center $MVERSION/ca-certificates.crt"
declare target_cert ln_cmd
declare mc_cert_link="/usr/lib/jriver/MC30/ca-certificates.crt"
declare target_cert
declare -a ln_cmd
target_cert=$(readlink -f "$mc_cert_link")
[[ -f $target_cert ]] && return 0
# Have to use command array instead of eval because of whitespace in $mc_cert_link
if [[ -f /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem ]]; then
ln_cmd="sudo ln -fs /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \"$mc_cert_link\"" # For RHEL
ln_cmd=(sudo ln -fs /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem "$mc_cert_link") # For RHEL/CentOS
elif [[ -f /var/lib/ca-certificates/ca-bundle.pem ]]; then
ln_cmd="sudo ln -fs /var/lib/ca-certificates/ca-bundle.pem \"$mc_cert_link\"" # For SUSE
ln_cmd=(sudo ln -fs /var/lib/ca-certificates/ca-bundle.pem "$mc_cert_link") # For SUSE
fi
debug "$ln_cmd" || ln_cmd+=" &>/dev/null"
if ! eval "$ln_cmd"; then
debug "${ln_cmd[*]}" || ln_cmd+=(" &>/dev/null")
if ! eval "${ln_cmd[*]}"; then
err "Symlinking certificates failed"
return 1
fi
@@ -1014,15 +1034,15 @@ openFirewall() {
if ! case "$ID" in
fedora|centos|suse)
hash firewall-cmd 2>/dev/null || installPackage firewalld
if ! firewall_cmd --get-services | grep -q "$1"; then
firewall_cmd --permanent --new-service="$1" &>/dev/null
firewall_cmd --permanent --service="$1" --set-description="$1 installed by installJRMC" &>/dev/null
firewall_cmd --permanent --service="$1" --set-short="$1" &>/dev/null
if ! sudo firewall-cmd --get-services | grep -q "$1"; then
sudo firewall-cmd --permanent --new-service="$1" &>/dev/null
sudo firewall-cmd --permanent --service="$1" --set-description="$1 installed by installJRMC" &>/dev/null
sudo firewall-cmd --permanent --service="$1" --set-short="$1" &>/dev/null
for port in "${f_ports[@]}"; do
firewall_cmd --permanent --service="$1" --add-port="$port" &>/dev/null
sudo firewall-cmd --permanent --service="$1" --add-port="$port" &>/dev/null
done
firewall_cmd --add-service "$1" --permanent &>/dev/null
firewall_cmd --reload &>/dev/null
sudo firewall-cmd --add-service "$1" --permanent &>/dev/null
sudo firewall-cmd --reload &>/dev/null
fi
;;
debian|ubuntu)
@@ -1036,8 +1056,8 @@ openFirewall() {
ports=$u_ports
EOF"
fi
firewall_cmd app update "$1" &>/dev/null
firewall_cmd allow "$1" &>/dev/null
sudo ufw app update "$1" &>/dev/null
sudo ufw allow "$1" &>/dev/null
;;
arch)
# sysctl -w net.ipv4.ip_forward = 1
@@ -1063,7 +1083,7 @@ setVNCPass() {
debug "Running: ${FUNCNAME[0]}"
declare vncpassfile="$HOME/.vnc/jrmc_passwd"
declare vnc_pass_cmd
declare -a vnc_pass_cmd
[[ ! -d "${vncpassfile%/*}" ]] && mkdir -p "${vncpassfile%/*}"
@@ -1079,11 +1099,11 @@ setVNCPass() {
if [[ -v VNCPASS ]]; then
if [[ $1 == "xvnc" ]]; then
vnc_pass_cmd="echo $VNCPASS | vncpasswd -f > $vncpassfile"
vnc_pass_cmd=(echo "$VNCPASS" "|" vncpasswd -f ">" "$vncpassfile")
elif [[ $1 == "x11vnc" ]]; then
vnc_pass_cmd="x11vnc -storepasswd $VNCPASS $vncpassfile"
vnc_pass_cmd=(x11vnc -storepasswd "$VNCPASS" "$vncpassfile")
fi
if ! eval "$vnc_pass_cmd"; then
if ! eval "${vnc_pass_cmd[*]}"; then
err "Could not create VNC password file"
return 1
fi
@@ -1381,131 +1401,62 @@ service_jriver-createrepo() {
# installPackage buildah podman
# # Eventually try to switch to Debian
# # if ! CNT=$(buildah from debian:$DEBIANBASE); then
# # echo "Bad base image for container $CNAME, skipping"
# # continue
# # fi
# if ! CNT=$(buildah from jlesage/baseimage-gui:debian-10-v3.5.7); then
# echo "Bad base image for container $CNAME, skipping"
# continue
# if ! CNT=$(buildah from debian:$DEBIANBASE-slim); then
# echo "Bad base image for container, skipping"
# return 1
# fi
# buildah run "$CNT" add-pkg gnupg2 libxss1 wmctrl xdotool ca-certificates inotify-tools libgbm1 ffmpeg
# brc() { buildah run "$CNT" bash -c "$*"; }
# # #BASEIMAGE=jlesage/baseimage-gui:debian-10-v3.5.7
# # JRIVER_RELEASE=28
# # JRIVER_TAG=stable
# # ARCH=amd64
# # REBUILD_MIN=22
# # REBUILD_MAX=120
# # # JRiver Version tag (latest, stable or beta)
# # ARG jriver_tag
# # # JRiver Release Version (25, 26 etc.)
# # ARG jriver_release
# # # Image Version of the build
# # ARG image_version
# # # .deb download URL, if set to "repository" the JRiver repository will be used
# # ARG deb_url
# # RUN add-pkg gnupg2 libxss1 wmctrl xdotool ca-certificates inotify-tools libgbm1 ffmpeg
# brc "add-pkg gnupg2 libxss1 wmctrl xdotool ca-certificates inotify-tools libgbm1 ffmpeg"
# # Install JRiver
# RUN \
# add-pkg --virtual build-dependencies wget &&
# # Install from Repository
# if [ "${deb_url}" = "repository" ]; then \
# echo "Installing JRiver from repository ${jriver_release}:${jriver_tag}" &&
# wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | apt-key add - &&
# wget http://dist.jriver.com/${jriver_tag}/mediacenter/mediacenter${jriver_release}.list -O /etc/apt/sources.list.d/mediacenter${jriver_release}.list &&
# apt update &&
# add-pkg mediacenter${jriver_release}; \
# # Install from .deb URL
# else \
# echo "Installing JRiver from URL: ${deb_url}" &&
# wget -q -O "jrivermc.deb" ${deb_url} &&
# add-pkg "./jrivermc.deb"; \
# fi &&
# # Cleanup
# del-pkg build-dependencies &&
# rm -rf /tmp/* /tmp/.[!.]*
# brc "
# add-pkg ca-certificates gnupg &&
# add-pkg --virtual build-dependencies wget &&
# wget -qO- http://dist.jriver.com/mediacenter@jriver.com.gpg.key | tee /etc/apt/trusted.gpg.d/jriver.asc &&
# wget -O /etc/apt/sources.list.d/mediacenter${MVERSION}.list http://dist.jriver.com/latest/mediacenter/mediacenter${MVERSION}.list &&
# apt update &&
# add-pkg mediacenter${MVERSION} &&
# del-pkg build-dependencies
# "
# # Add rootfs
# COPY rootfs/ /
# VOLUME ["/config"]
# # Application Icon
# RUN \
# APP_ICON_URL=https://gitlab.com/shiomax/jrivermc-docker/raw/master/assets/Application.png &&
# install_app_icon.sh "$APP_ICON_URL"
# # Various configuration vars
# ENV KEEP_APP_RUNNING=1 \
# DISPLAY_WIDTH=1280 \
# DISPLAY_HEIGHT=768 \
# APP_NAME="JRiver MediaCenter ${jriver_release}" \
# MAXIMIZE_POPUPS=0 \
# S6_KILL_GRACETIME=8000
# # Modify startapp.sh and rc.xml with JRiver version
# RUN sed-patch s/%%MC_VERSION%%/${jriver_release}/g \
# /startapp.sh &&
# sed-patch s/%%MC_VERSION%%/${jriver_release}/g \
# /etc/xdg/openbox/rc.xml
# EXPOSE 5800 5900 52100 52101 52199 1900/udp
# # Metadata.
# LABEL \
# org.label-schema.name="jrivermc${jriver_release}" \
# org.label-schema.description="Docker image for JRiver Media Center ${jriver_release}" \
# org.label-schema.version="${image_version}" \
# org.label-schema.vcs-url="https://gitlab.com/shiomax/jrivermc-docker" \
# org.label-schema.schema-version="1.0"
# installPackage buildah podman
# cnt=$(buildah from docker.io/jlesage/baseimage-gui:debian-10)
# podman_create_cmd=(podman create --name "$CNAME")
# buildah_config_cmd=(buildah config \
# --author bryanroessler@gmail.com \
# buildah config "$CNT" \
# --author "bryanroessler@gmail.com" \
# --label maintainer="$MAINTAINER" \
# --env TZ="$TZ" \
# --workingdir /app \
# --cmd mediacenter"$MVERSION")
# --cmd "mediacenter$MVERSION"
# mkcdirs() {
# declare dir
# for dir in "$@"; do
# if [[ ! -d "$dir" ]]; then
# if ! mkdir -p "$dir"; then
# err "Could not create directory $dir, check your permissions"
# fi
# fi
# if ! chcon -t container_file_t -R "$dir"; then
# err "Could not set container_file_t attribute for $dir, check your permissions"
# fi
# done
# }
# mkcdirs "$HOME/.jriver"
# # EXPOSE 5800 5900 52100 52101 52199 1900/udp
# podman_create_cmd=(
# podman create
# --name "mediacenter$MVERSION"
# )
# podman_create_cmd+=(-v "$HOME/.jriver:/root/.jriver")
# podman_create_cmd+=(-v "$DOWNLOAD_ROOT:/downloads:z")
# podman_create_cmd+=(-v "$MONITOR_ROOT/nzbs:/nzbs")
# podman_create_cmd+=(-p "${CONTAINER[HOST_PORT]}:${CONTAINER[CONTAINER_PORT]}")
# brc() { buildah run "$1" "${@:2}" || return 1; }
# # mkcdirs() {
# # declare dir
# # for dir in "$@"; do
# # if [[ ! -d "$dir" ]]; then
# # if ! mkdir -p "$dir"; then
# # err "Could not create directory $dir, check your permissions"
# # fi
# # fi
# # if ! chcon -t container_file_t -R "$dir"; then
# # err "Could not set container_file_t attribute for $dir, check your permissions"
# # fi
# # done
# # }
# brc add-pkg gnupg2 libxss1 wmctrl xdotool ca-certificates inotify-tools libgbm1
# # mkcdirs "$HOME/.jriver"
# brc add-pkg --virtual .build-deps wget
# brc sh -s <<-EOF
# wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | apt-key add - &>/dev/null
@@ -1571,6 +1522,8 @@ uninstall() {
declare service unit f i
declare -a firewall_cmd mc_pkg_rm_cmd
echo "Stopping and removing all Media Center services"
for service in $(compgen -A "function" "service"); do
service="${service##service_}"
@@ -1603,22 +1556,19 @@ uninstall() {
echo "Removing firewall rules"
if hash firewall-cmd 2>/dev/null; then
if [[ -v debug ]]; then
debug "firewall_cmd --permanent --remove-service=jriver"
firewall_cmd --permanent --remove-service=jriver
debug "firewall_cmd --permanent --delete-service=jriver"
firewall_cmd --permanent --delete-service=jriver
debug "firewall_cmd --reload"
firewall_cmd --reload
else
firewall_cmd --permanent --remove-service=jriver &>/dev/null
firewall_cmd --permanent --delete-service=jriver &>/dev/null
firewall_cmd --reload &>/dev/null
fi
firewall_cmd=(sudo firewall-cmd --permanent --remove-service=jriver)
debug "${firewall_cmd[*]}" || firewall_cmd+=(" &>/dev/null")
eval "${firewall_cmd[*]}"
firewall_cmd=(sudo firewall-cmd --permanent --delete-service=jriver)
debug "${firewall_cmd[*]}" || firewall_cmd+=(" &>/dev/null")
eval "${firewall_cmd[*]}"
firewall_cmd=(sudo firewall-cmd --reload)
debug "${firewall_cmd[*]}" || firewall_cmd+=(" &>/dev/null")
eval "${firewall_cmd[*]}"
elif hash ufw 2>/dev/null; then
firewall_cmd="firewall_cmd delete allow jriver"
debug "$firewall_cmd" || firewall_cmd+=" &>/dev/null"
eval "$firewall_cmd"
firewall_cmd=(sudo ufw delete allow jriver)
debug "${firewall_cmd[*]}" || firewall_cmd+=(" &>/dev/null")
eval "${firewall_cmd[*]}"
[[ -f "/etc/ufw/applications.d/jriver" ]] &&
sudo rm -f /etc/ufw/applications.d/jriver
# elif hash nft 2>/dev/null; then
@@ -1626,9 +1576,9 @@ uninstall() {
fi
echo "Uninstalling JRiver Media Center package"
mc_pkg_rm_cmd="pkg_remove $MCPKG"
debug "$mc_pkg_rm_cmd" || mc_pkg_rm_cmd+=" &>/dev/null"
if eval "$mc_pkg_rm_cmd"; then
mc_pkg_rm_cmd=(pkg_remove "$MCPKG")
debug "${mc_pkg_rm_cmd[*]}" || mc_pkg_rm_cmd+=(" &>/dev/null")
if eval "${mc_pkg_rm_cmd[*]}"; then
echo "JRiver Media Center has been completely uninstalled"
echo "To remove your library files, run: rm -rf $HOME/.jriver"
elif [[ $? -eq 100 ]]; then
@@ -1669,7 +1619,7 @@ main() {
if askOk "Do you really want to uninstall JRiver Media Center?"; then
uninstall
else
echo "Uninstall canceled."
echo "Uninstall canceled"
fi
exit
fi
@@ -1679,9 +1629,9 @@ main() {
ubuntu)
if ! grep ^deb /etc/apt/sources.list|grep -q universe; then
echo "Adding universe repository"
declare add_universe_cmd="sudo add-apt-repository -y universe"
debug "$add_universe_cmd" || add_universe_cmd+=" &>/dev/null"
if ! eval "$add_universe_cmd"; then
declare -a add_universe_cmd=(sudo add-apt-repository -y universe)
debug "${add_universe_cmd[*]}" || add_universe_cmd+=(" &>/dev/null")
if ! eval "${add_universe_cmd[*]}"; then
err "Adding universe repository failed"
fi
fi