Compare commits
7 Commits
affd74edb5
...
e1e0a55101
| Author | SHA1 | Date | |
|---|---|---|---|
| e1e0a55101 | |||
| 5e70364ec9 | |||
| ff924bd735 | |||
| 8d89190fc5 | |||
| a9ddaf5427 | |||
| d64645444e | |||
| 0c9221c52c |
@@ -23,7 +23,7 @@ $ installJRMC --help
|
||||
--compat
|
||||
Build/install MC without minimum library specifiers
|
||||
--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
|
||||
Generate rpmbuild output in this PATH (Default: ./output)
|
||||
--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.
|
||||
|
||||
* `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`
|
||||
|
||||
@@ -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 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)
|
||||
|
||||
105
installJRMC
105
installJRMC
@@ -7,18 +7,22 @@
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# TODO (v2)
|
||||
# 1. Raspberry Pi OS support
|
||||
# 2. Interactive installation (ncurses?)
|
||||
# 3. Additional containerization (createrepo and rpmbuild)
|
||||
# 4. Tests
|
||||
# 1. Interactive installation (ncurses?)
|
||||
# 2. Additional containerization (createrepo and rpmbuild)
|
||||
# 3. Tests
|
||||
#
|
||||
# BUGS
|
||||
# 1. No createrepo on Mint
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
declare -g SCRIPTVERSION="1.0b17"
|
||||
declare -g SCRIPTVERSION="1.0-rc1"
|
||||
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 USER="${SUDO_USER:-$USER}"
|
||||
declare -g HOME; HOME=$(getent passwd "$USER" | cut -d: -f6)
|
||||
@@ -30,7 +34,7 @@ printHelp() {
|
||||
USAGE:
|
||||
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
|
||||
--install, -i repo|local
|
||||
@@ -42,7 +46,7 @@ printHelp() {
|
||||
--compat
|
||||
Build/install MC locally without minimum library specifiers
|
||||
--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
|
||||
Generate rpmbuild output in this directory (Default: ./output)
|
||||
--restorefile RESTOREFILE
|
||||
@@ -159,7 +163,7 @@ parseInput() {
|
||||
shift && OUTPUTDIR="$1"
|
||||
;;
|
||||
--mcversion)
|
||||
shift && MCVERSION="$1"
|
||||
shift && declare -g MCVERSION_INPUT="$1"
|
||||
;;
|
||||
--restorefile)
|
||||
shift && RESTOREFILE="$1"
|
||||
@@ -234,8 +238,7 @@ parseInput() {
|
||||
init() {
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
declare -g ID
|
||||
declare rpm_mgr
|
||||
declare -g ID RPM_MGR
|
||||
|
||||
if [[ -e "/etc/os-release" ]]; then
|
||||
source "/etc/os-release"
|
||||
@@ -243,7 +246,7 @@ init() {
|
||||
err "/etc/os-release not found"
|
||||
err "Your OS is unsupported"
|
||||
printHelp
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
debug "Detected host platform: $ID $VERSION_ID"
|
||||
@@ -252,11 +255,11 @@ init() {
|
||||
case "$ID" in
|
||||
arch|debian)
|
||||
;;
|
||||
centos|fedora)
|
||||
if hash dnf &>/dev/null; then
|
||||
rpm_mgr="dnf"
|
||||
centos|fedora)
|
||||
if hash dnf &>/dev/null; then
|
||||
RPM_MGR="dnf"
|
||||
elif hash yum &>/dev/null; then
|
||||
rpm_mgr="yum"
|
||||
RPM_MGR="yum"
|
||||
fi
|
||||
;;
|
||||
rhel)
|
||||
@@ -272,10 +275,10 @@ init() {
|
||||
echo "Autodetecting distro, this may be unreliable and --compat may also be required"
|
||||
if hash dnf &>/dev/null; then
|
||||
ID="fedora"
|
||||
rpm_mgr="dnf"
|
||||
RPM_MGR="dnf"
|
||||
elif hash yum &>/dev/null; then
|
||||
ID="centos"
|
||||
rpm_mgr="yum"
|
||||
RPM_MGR="yum"
|
||||
COMPAT_SWITCH=1
|
||||
elif hash apt &>/dev/null; then
|
||||
ID="ubuntu"
|
||||
@@ -292,10 +295,10 @@ init() {
|
||||
# Set distro-specific functions
|
||||
case "$ID" in
|
||||
fedora|centos)
|
||||
pkg_install(){ sudo "$rpm_mgr" install -y "$@"; }
|
||||
pkg_install(){ sudo "$RPM_MGR" install -y "$@"; }
|
||||
pkg_install_local() { installMCRPM; }
|
||||
pkg_remove(){ sudo "$rpm_mgr" remove -y "$@"; }
|
||||
pkg_update(){ sudo "$rpm_mgr" makecache; }
|
||||
pkg_remove(){ sudo "$RPM_MGR" remove -y "$@"; }
|
||||
pkg_update(){ sudo "$RPM_MGR" makecache; }
|
||||
pkg_query(){ rpm -q "$@"; }
|
||||
firewall_cmd(){ sudo firewall-cmd "$@"; }
|
||||
;;
|
||||
@@ -329,51 +332,55 @@ init() {
|
||||
|
||||
#######################################
|
||||
# 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]}"
|
||||
|
||||
declare -g MCVERSION VERSION_SOURCE MVERSION MCPKG MCRPM BASE="buster" #BASE_NEXT="bullseye"
|
||||
declare boardurl="https://yabb.jriver.com/interact/index.php/board,74.0.html" # MC29 (Buster)
|
||||
declare -g MCVERSION MCVERSION_SOURCE MVERSION MCPKG MCRPM
|
||||
declare cnt
|
||||
|
||||
# User input
|
||||
if [[ -v MCVERSION && "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then
|
||||
VERSION_SOURCE="user input"
|
||||
if [[ -v MCVERSION_INPUT ]]; then
|
||||
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
|
||||
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 \
|
||||
"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 \
|
||||
"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" =~ ([0-9]+.[0-9]+.[0-9]+) ]] &&
|
||||
VERSION_SOURCE="containerized package manager"; then
|
||||
[[ "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then
|
||||
MCVERSION_SOURCE="containerized package manager"
|
||||
buildah rm "$cnt" &>/dev/null
|
||||
# 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
|
||||
VERSION_SOURCE="webscrape"
|
||||
MCVERSION_SOURCE="webscrape"
|
||||
# Hardcoded
|
||||
else
|
||||
MCVERSION="29.0.58"
|
||||
VERSION_SOURCE="hardcoded version"
|
||||
err "Warning! Using hardcoded version number"
|
||||
MCVERSION="$MCVERSION_HARDCODE"
|
||||
MCVERSION_SOURCE="hardcoded version"
|
||||
err "Warning! Using hardcoded version number."
|
||||
fi
|
||||
|
||||
MVERSION="${MCVERSION%%.*}"
|
||||
MCPKG="mediacenter$MVERSION"
|
||||
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
|
||||
[[ "$ID" =~ ^(fedora|centos|suse)$ ]] && MCPKG+="-$MCVERSION"
|
||||
[[ "$ID" =~ ^(debian|ubuntu)$ ]] && MCPKG+="=$MCVERSION"
|
||||
else
|
||||
echo "To override, use --mcversion"
|
||||
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"
|
||||
}
|
||||
|
||||
@@ -385,7 +392,7 @@ getVersion() {
|
||||
# Options:
|
||||
# --skip-check-installed: Do not check if package is already installed
|
||||
# --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)
|
||||
#######################################
|
||||
installPackage() {
|
||||
@@ -402,8 +409,11 @@ installPackage() {
|
||||
skip_check_installed=1
|
||||
;;
|
||||
--allow-downgrades)
|
||||
[[ "$ID" =~ ^(debian|ubuntu)$ ]] &&
|
||||
if [[ "$ID" =~ ^(debian|ubuntu)$ ]]; then
|
||||
install_flags+=(--allow-downgrades)
|
||||
elif [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
||||
install_flags+=(--allowerasing)
|
||||
fi
|
||||
;;
|
||||
--nogpgcheck)
|
||||
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
||||
@@ -483,7 +493,7 @@ installMCFromRepo() {
|
||||
sudo rm -rf "$repo_dir"/mediacenter*.list
|
||||
installPackage wget
|
||||
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"
|
||||
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
|
||||
|
||||
# Update package list
|
||||
declare pkg_update_cmd="pkg_update"
|
||||
debug "$pkg_update_cmd" || pkg_update_cmd+=" &>/dev/null"
|
||||
if ! eval "$pkg_update_cmd"; then
|
||||
@@ -502,7 +511,7 @@ installMCFromRepo() {
|
||||
return 1
|
||||
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"
|
||||
if ! eval "$pkg_install_cmd"; then
|
||||
err "Package install failed!"
|
||||
@@ -759,7 +768,7 @@ installMCDEB() {
|
||||
#######################################
|
||||
installMCRPM() {
|
||||
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
|
||||
|
||||
# # 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"
|
||||
# # continue
|
||||
# # fi
|
||||
@@ -1422,7 +1431,7 @@ disableCoW() {
|
||||
declare mc_system_path="/usr/lib/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
|
||||
[[ -d "$dir" ]] || return
|
||||
@@ -1553,7 +1562,7 @@ main() {
|
||||
exit
|
||||
fi
|
||||
|
||||
getVersion
|
||||
setMCVersion
|
||||
|
||||
if (( UNINSTALL_SWITCH )); then
|
||||
if askOk "Do you really want to uninstall JRiver Media Center?"; then
|
||||
|
||||
Reference in New Issue
Block a user