7 Commits

Author SHA1 Message Date
e1e0a55101 Use a variable for fallback mcversion 2022-10-12 13:02:37 -04:00
5e70364ec9 Raise MC version variables and refactor installPackage 2022-10-12 10:45:41 -04:00
ff924bd735 Update README 2022-10-10 16:25:20 -04:00
8d89190fc5 Release 1.0-rc1 2022-10-10 16:18:54 -04:00
a9ddaf5427 Additional prep for MC30 2022-10-10 16:16:44 -04:00
d64645444e Revert to beta and fix scope 2022-10-10 15:50:35 -04:00
0c9221c52c Update for MC30 and v1.0 release 2022-10-10 14:46:03 -04:00
2 changed files with 61 additions and 52 deletions

View File

@@ -23,7 +23,7 @@ $ installJRMC --help
--compat --compat
Build/install MC without minimum library specifiers Build/install MC without minimum library specifiers
--mcversion VERSION --mcversion VERSION
Build or install a specific MC version, ex. "29.0.18" Build or install a specific MC version, ex. "30.0.17"
--outputdir PATH --outputdir PATH
Generate rpmbuild output in this PATH (Default: ./output) Generate rpmbuild output in this PATH (Default: ./output)
--restorefile RESTOREFILE --restorefile RESTOREFILE
@@ -110,9 +110,9 @@ Multiple services (but not `--service-types`) can be installed at one time using
Install MC from the repository and start/enable `jriver-mediacenter.service` as a user service. Install MC from the repository and start/enable `jriver-mediacenter.service` as a user service.
* `installJRMC --install local --compat --restorefile /path/to/license.mjr --mcversion 29.0.18` * `installJRMC --install local --compat --restorefile /path/to/license.mjr --mcversion 30.0.17`
Build and install an MC 29.0.18 comptability RPM locally and activate it using the `/path/to/license.mjr` Build and install an MC 30.0.17 comptability RPM locally and activate it using the `/path/to/license.mjr`
* `installJRMC --createrepo --createrepo-webroot /srv/jriver/repo --createrepo-user www-user` * `installJRMC --createrepo --createrepo-webroot /srv/jriver/repo --createrepo-user www-user`
@@ -138,4 +138,4 @@ Multiple services (but not `--service-types`) can be installed at one time using
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)
Did you find a bug? Let me know on [Interact!](https://yabb.jriver.com/interact/index.php/topic,123648.0.html) Did you find a bug? Let me know on [Interact!](https://yabb.jriver.com/interact/index.php/topic,134152.0.html)

View File

@@ -7,18 +7,22 @@
# https://www.apache.org/licenses/LICENSE-2.0 # https://www.apache.org/licenses/LICENSE-2.0
# #
# TODO (v2) # TODO (v2)
# 1. Raspberry Pi OS support # 1. Interactive installation (ncurses?)
# 2. Interactive installation (ncurses?) # 2. Additional containerization (createrepo and rpmbuild)
# 3. Additional containerization (createrepo and rpmbuild) # 3. Tests
# 4. Tests
# #
# BUGS # BUGS
# 1. No createrepo on Mint # 1. No createrepo on Mint
shopt -s extglob shopt -s extglob
declare -g SCRIPTVERSION="1.0b17" declare -g SCRIPTVERSION="1.0-rc1"
declare -g OUTPUTDIR="$PWD/output" declare -g OUTPUTDIR="$PWD/output"
declare -g BOARDURL="https://yabb.jriver.com/interact/index.php/board,76.0.html" # MC30 (Buster)
declare -g DEBIANBASE="buster"
declare -g MCVERSION_HARDCODE="30.0.17" # Hardcoded fallback
declare -g CREATEREPO_WEBROOT="/var/www/jriver" declare -g CREATEREPO_WEBROOT="/var/www/jriver"
declare -g USER="${SUDO_USER:-$USER}" declare -g USER="${SUDO_USER:-$USER}"
declare -g HOME; HOME=$(getent passwd "$USER" | cut -d: -f6) declare -g HOME; HOME=$(getent passwd "$USER" | cut -d: -f6)
@@ -30,7 +34,7 @@ printHelp() {
USAGE: USAGE:
installJRMC [[OPTION] [VALUE]]... installJRMC [[OPTION] [VALUE]]...
If no options (besides -d) are provided, the script will default to '--install repo'. If no options (excluding -d) are provided, the script will default to '--install repo'.
OPTIONS OPTIONS
--install, -i repo|local --install, -i repo|local
@@ -42,7 +46,7 @@ printHelp() {
--compat --compat
Build/install MC locally without minimum library specifiers Build/install MC locally without minimum library specifiers
--mcversion VERSION --mcversion VERSION
Specify the MC version, ex. "29.0.58" (Default: latest) Specify the MC version, ex. "30.0.17" (Default: latest version)
--outputdir PATH --outputdir PATH
Generate rpmbuild output in this directory (Default: ./output) Generate rpmbuild output in this directory (Default: ./output)
--restorefile RESTOREFILE --restorefile RESTOREFILE
@@ -159,7 +163,7 @@ parseInput() {
shift && OUTPUTDIR="$1" shift && OUTPUTDIR="$1"
;; ;;
--mcversion) --mcversion)
shift && MCVERSION="$1" shift && declare -g MCVERSION_INPUT="$1"
;; ;;
--restorefile) --restorefile)
shift && RESTOREFILE="$1" shift && RESTOREFILE="$1"
@@ -234,8 +238,7 @@ parseInput() {
init() { init() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
declare -g ID declare -g ID RPM_MGR
declare rpm_mgr
if [[ -e "/etc/os-release" ]]; then if [[ -e "/etc/os-release" ]]; then
source "/etc/os-release" source "/etc/os-release"
@@ -243,7 +246,7 @@ init() {
err "/etc/os-release not found" err "/etc/os-release not found"
err "Your OS is unsupported" err "Your OS is unsupported"
printHelp printHelp
exit 1 exit 1
fi fi
debug "Detected host platform: $ID $VERSION_ID" debug "Detected host platform: $ID $VERSION_ID"
@@ -252,11 +255,11 @@ init() {
case "$ID" in case "$ID" in
arch|debian) arch|debian)
;; ;;
centos|fedora) centos|fedora)
if hash dnf &>/dev/null; then if hash dnf &>/dev/null; then
rpm_mgr="dnf" RPM_MGR="dnf"
elif hash yum &>/dev/null; then elif hash yum &>/dev/null; then
rpm_mgr="yum" RPM_MGR="yum"
fi fi
;; ;;
rhel) rhel)
@@ -272,10 +275,10 @@ init() {
echo "Autodetecting distro, this may be unreliable and --compat may also be required" echo "Autodetecting distro, this may be unreliable and --compat may also be required"
if hash dnf &>/dev/null; then if hash dnf &>/dev/null; then
ID="fedora" ID="fedora"
rpm_mgr="dnf" RPM_MGR="dnf"
elif hash yum &>/dev/null; then elif hash yum &>/dev/null; then
ID="centos" ID="centos"
rpm_mgr="yum" RPM_MGR="yum"
COMPAT_SWITCH=1 COMPAT_SWITCH=1
elif hash apt &>/dev/null; then elif hash apt &>/dev/null; then
ID="ubuntu" ID="ubuntu"
@@ -292,10 +295,10 @@ init() {
# Set distro-specific functions # Set distro-specific functions
case "$ID" in case "$ID" in
fedora|centos) fedora|centos)
pkg_install(){ sudo "$rpm_mgr" install -y "$@"; } pkg_install(){ sudo "$RPM_MGR" install -y "$@"; }
pkg_install_local() { installMCRPM; } pkg_install_local() { installMCRPM; }
pkg_remove(){ sudo "$rpm_mgr" remove -y "$@"; } pkg_remove(){ sudo "$RPM_MGR" remove -y "$@"; }
pkg_update(){ sudo "$rpm_mgr" makecache; } pkg_update(){ sudo "$RPM_MGR" makecache; }
pkg_query(){ rpm -q "$@"; } pkg_query(){ rpm -q "$@"; }
firewall_cmd(){ sudo firewall-cmd "$@"; } firewall_cmd(){ sudo firewall-cmd "$@"; }
;; ;;
@@ -329,51 +332,55 @@ init() {
####################################### #######################################
# Uses several methods to determine the latest JRiver MC version # Uses several methods to determine the latest JRiver MC version
# TODO but how to determine build distro `$BASE=buster`? # TODO but how to determine build distro `$DEBIANBASE=buster`?
####################################### #######################################
getVersion() { setMCVersion() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
declare -g MCVERSION VERSION_SOURCE MVERSION MCPKG MCRPM BASE="buster" #BASE_NEXT="bullseye" declare -g MCVERSION MCVERSION_SOURCE MVERSION MCPKG MCRPM
declare boardurl="https://yabb.jriver.com/interact/index.php/board,74.0.html" # MC29 (Buster) declare cnt
# User input # User input
if [[ -v MCVERSION && "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then if [[ -v MCVERSION_INPUT ]]; then
VERSION_SOURCE="user input" if ! [[ "$MCVERSION_INPUT" =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then
err "Incorrect --mcversion format provided"
printHelp && exit 1
fi
MCVERSION="$MCVERSION_INPUT"
MCVERSION_SOURCE="user input"
# Containerized package manager # Containerized package manager
elif installPackage --silent buildah && elif installPackage --silent buildah &&
cnt=$(buildah from --quiet debian:$BASE) &>/dev/null && cnt=$(buildah from --quiet debian:$DEBIANBASE) &>/dev/null &&
buildah run "$cnt" -- bash -c \ buildah run "$cnt" -- bash -c \
"echo 'deb [trusted=no arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $BASE main' > /etc/apt/sources.list 2>&1" &>/dev/null && "echo 'deb [trusted=no arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $DEBIANBASE main' > /etc/apt/sources.list 2>&1" &>/dev/null &&
buildah run "$cnt" -- bash -c \ buildah run "$cnt" -- bash -c \
"apt update --allow-insecure-repositories &>/dev/null" &>/dev/null && "apt update --allow-insecure-repositories &>/dev/null" &>/dev/null &&
MCVERSION=$(buildah run "$cnt" -- apt-cache policy mediacenter?? | grep Candidate | awk '{print $2}' | sort -V | tail -n1) &>/dev/null && MCVERSION=$(buildah run "$cnt" -- apt-cache policy mediacenter?? | grep Candidate | awk '{print $2}' | sort -V | tail -n1) &>/dev/null &&
[[ "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]] && [[ "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then
VERSION_SOURCE="containerized package manager"; then MCVERSION_SOURCE="containerized package manager"
buildah rm "$cnt" &>/dev/null buildah rm "$cnt" &>/dev/null
# Webscrape # Webscrape
elif installPackage wget && MCVERSION=$(wget -qO- "$boardurl" | grep -o "[0-9][0-9]\.[0-9]\.[0-9]\+" | head -n 1) && elif installPackage wget && MCVERSION=$(wget -qO- "$BOARDURL" | grep -o "[0-9][0-9]\.[0-9]\.[0-9]\+" | head -n 1) &&
[[ "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then [[ "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then
VERSION_SOURCE="webscrape" MCVERSION_SOURCE="webscrape"
# Hardcoded # Hardcoded
else else
MCVERSION="29.0.58" MCVERSION="$MCVERSION_HARDCODE"
VERSION_SOURCE="hardcoded version" MCVERSION_SOURCE="hardcoded version"
err "Warning! Using hardcoded version number" err "Warning! Using hardcoded version number."
fi fi
MVERSION="${MCVERSION%%.*}" MVERSION="${MCVERSION%%.*}"
MCPKG="mediacenter$MVERSION" MCPKG="mediacenter$MVERSION"
MCRPM="$OUTPUTDIR/RPMS/x86_64/mediacenter$MVERSION-$MCVERSION.x86_64.rpm" MCRPM="$OUTPUTDIR/RPMS/x86_64/mediacenter$MVERSION-$MCVERSION.x86_64.rpm"
if [[ "$VERSION_SOURCE" == "user input" ]]; then if [[ "$MCVERSION_SOURCE" == "user input" ]]; then
# Append explicit package version when user provides --mcversion # Append explicit package version when user provides --mcversion
[[ "$ID" =~ ^(fedora|centos|suse)$ ]] && MCPKG+="-$MCVERSION" [[ "$ID" =~ ^(fedora|centos|suse)$ ]] && MCPKG+="-$MCVERSION"
[[ "$ID" =~ ^(debian|ubuntu)$ ]] && MCPKG+="=$MCVERSION" [[ "$ID" =~ ^(debian|ubuntu)$ ]] && MCPKG+="=$MCVERSION"
else
echo "To override, use --mcversion"
fi fi
echo "Using MC version $MCVERSION determined by $VERSION_SOURCE" 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" debug "MVERSION: $MVERSION, MCVERSION: $MCVERSION, MCPKG: $MCPKG, MCRPM: $MCRPM"
} }
@@ -385,7 +392,7 @@ getVersion() {
# Options: # Options:
# --skip-check-installed: Do not check if package is already installed # --skip-check-installed: Do not check if package is already installed
# --nogpgcheck: Disable GPG checks for RPM based distros # --nogpgcheck: Disable GPG checks for RPM based distros
# --allow-downgrades: Useful for installing compatability versions on DEB based distros # --allow-downgrades: Useful for installing specific MC versions
# --silent, -s: Do not report errors (useful if package is not strictly required and errors are noisy) # --silent, -s: Do not report errors (useful if package is not strictly required and errors are noisy)
####################################### #######################################
installPackage() { installPackage() {
@@ -402,8 +409,11 @@ installPackage() {
skip_check_installed=1 skip_check_installed=1
;; ;;
--allow-downgrades) --allow-downgrades)
[[ "$ID" =~ ^(debian|ubuntu)$ ]] && if [[ "$ID" =~ ^(debian|ubuntu)$ ]]; then
install_flags+=(--allow-downgrades) install_flags+=(--allow-downgrades)
elif [[ "$ID" =~ ^(fedora|centos)$ ]]; then
install_flags+=(--allowerasing)
fi
;; ;;
--nogpgcheck) --nogpgcheck)
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
@@ -483,7 +493,7 @@ installMCFromRepo() {
sudo rm -rf "$repo_dir"/mediacenter*.list sudo rm -rf "$repo_dir"/mediacenter*.list
installPackage wget installPackage wget
sudo bash -c "cat <<-EOF > $repo_dir/jriver.list sudo bash -c "cat <<-EOF > $repo_dir/jriver.list
deb [trusted=yes arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $BASE main deb [trusted=yes arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $DEBIANBASE main
EOF" EOF"
wget -qO- "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" | sudo tee /etc/apt/trusted.gpg.d/jriver.asc wget -qO- "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" | sudo tee /etc/apt/trusted.gpg.d/jriver.asc
;; ;;
@@ -494,7 +504,6 @@ installMCFromRepo() {
;; ;;
esac esac
# Update package list
declare pkg_update_cmd="pkg_update" declare pkg_update_cmd="pkg_update"
debug "$pkg_update_cmd" || pkg_update_cmd+=" &>/dev/null" debug "$pkg_update_cmd" || pkg_update_cmd+=" &>/dev/null"
if ! eval "$pkg_update_cmd"; then if ! eval "$pkg_update_cmd"; then
@@ -502,7 +511,7 @@ installMCFromRepo() {
return 1 return 1
fi fi
declare pkg_install_cmd="installPackage --skip-check-installed --nogpgcheck $MCPKG" declare pkg_install_cmd="installPackage --skip-check-installed --allow-downgrades --nogpgcheck $MCPKG"
debug "$pkg_install_cmd" || pkg_install_cmd+=" &>/dev/null" debug "$pkg_install_cmd" || pkg_install_cmd+=" &>/dev/null"
if ! eval "$pkg_install_cmd"; then if ! eval "$pkg_install_cmd"; then
err "Package install failed!" err "Package install failed!"
@@ -759,7 +768,7 @@ installMCDEB() {
####################################### #######################################
installMCRPM() { installMCRPM() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
installPackage --skip-check-installed --nogpgcheck "$MCRPM" installPackage --skip-check-installed --nogpgcheck --allow-downgrades "$MCRPM"
} }
@@ -1273,7 +1282,7 @@ service_jriver-createrepo() {
# installPackage buildah podman # installPackage buildah podman
# # Eventually try to switch to Debian # # Eventually try to switch to Debian
# # if ! CNT=$(buildah from debian:$BASE); then # # if ! CNT=$(buildah from debian:$DEBIANBASE); then
# # echo "Bad base image for container $CNAME, skipping" # # echo "Bad base image for container $CNAME, skipping"
# # continue # # continue
# # fi # # fi
@@ -1422,7 +1431,7 @@ disableCoW() {
declare mc_system_path="/usr/lib/jriver" declare mc_system_path="/usr/lib/jriver"
declare mc_user_path="$HOME/.jriver" declare mc_user_path="$HOME/.jriver"
[[ -d "$mc_user_path" ]] || mkdir -p "$mc_user_path" [[ -d "$mc_user_path" ]] || mkdir -p "$mc_user_path"
for dir in "$mc_system_path" "$mc_user_path"; do for dir in "$mc_system_path" "$mc_user_path"; do
[[ -d "$dir" ]] || return [[ -d "$dir" ]] || return
@@ -1553,7 +1562,7 @@ main() {
exit exit
fi fi
getVersion setMCVersion
if (( UNINSTALL_SWITCH )); then if (( UNINSTALL_SWITCH )); then
if askOk "Do you really want to uninstall JRiver Media Center?"; then if askOk "Do you really want to uninstall JRiver Media Center?"; then