Cleanup latest version checks

This commit is contained in:
2022-01-12 16:56:46 -05:00
parent 1f12e56dfb
commit 032b159827
2 changed files with 44 additions and 64 deletions

View File

@@ -25,13 +25,15 @@ You can always find the latest supported options by running `installJRMC --help`
--build --build
Build RPM from source DEB but do not install Build RPM from source DEB but do not install
--target opensuse|fedora|centos --target opensuse|fedora|centos
Crossbuild RPM for target distro Crossbuild RPM for target distro
--compat
Build/install RPM without minimum library specifiers
--mcversion VERSION --mcversion VERSION
Build or install a specific MC version, ex. "28.0.25" Build or install a specific MC version, ex. "28.0.25"
--outputdir PATH --outputdir PATH
Generate rpmbuild output in this PATH (Default: ./output) Generate rpmbuild output in this PATH (Default: ./output)
--restorefile RESTOREFILE --restorefile RESTOREFILE
Restore file location for automatic license registration (Default: skip registration) Restore file location for automatic license registration
--betapass PASSWORD --betapass PASSWORD
Enter beta team password for access to beta builds Enter beta team password for access to beta builds
--service, -s SERVICE --service, -s SERVICE
@@ -45,9 +47,7 @@ You can always find the latest supported options by running `installJRMC --help`
--createrepo-webroot PATH --createrepo-webroot PATH
The webroot directory to install the repo (Default: /var/www/jriver/) The webroot directory to install the repo (Default: /var/www/jriver/)
--createrepo-user USER --createrepo-user USER
The web server user (Default: current user) The web server user if different from the current user
--compat
Build/install RPM without minimum library specifiers
--version, -v --version, -v
Print this script version and exit Print this script version and exit
--debug, -d --debug, -d
@@ -55,12 +55,12 @@ You can always find the latest supported options by running `installJRMC --help`
--help, -h --help, -h
Print help dialog and exit Print help dialog and exit
--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 or media files)
``` ```
### services ### services
When installing systemd services it is important to execute `installJRMC` as the user you wish to run the services. MC services are installed as system-level services running in the current user namespace When installing systemd services it is important to execute `installJRMC` as the user you wish to run the services. MC services are installed as system-level services (`--service-type=system`) by default. They can be manipulated by the root user: `sudo systemctl stop jriver-servicename@username.service`. It is also possible to create user-level services using `--service-type=user` that can be manipulated by the current user: `systemctl --user stop jriver-mediacenter`.
```text ```text
jriver-mediaserver jriver-mediaserver
@@ -130,7 +130,7 @@ It is possible to install multiple services at one time using multiple `--servic
* `installJRMC --install deb --compat` * `installJRMC --install deb --compat`
Install a more widely-compatible version of MC on deb-based distros Install a more widely-compatible version of MC on deb-based distros.
* `installJRMC --uninstall` * `installJRMC --uninstall`

View File

@@ -123,27 +123,6 @@ getOS() {
} }
# ifSudo() {
# declare user="root"
# if [[ $# == 0 ]]; then
# [[ "$USER" == "root" ]]
# return $?
# elif [[ $# -eq 2 && "$1" == "-u" ]]; then
# user="$2"
# [[ "$USER" == "$user" ]]
# return $?
# elif [[ $# -gt 2 && "$1" == "-u" ]]; then
# user="$2"
# shift 2
# fi
# if [[ "$user" == "$USER" ]]; then
# "$@"
# else
# sudo -u "$user" "$@"
# fi
# }
parseInput() { parseInput() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
@@ -260,35 +239,29 @@ parseInput() {
getLatestVersion() { getLatestVersion() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
declare -g MCVERSION declare -g MCVERSION BASE="buster" # For container method
declare cnt #declare -g BASE_NEXT="bullseye" # TODO possibly use for fallback to smooth upgrades
declare base="buster" # For container method
#declare base_next="bullseye" # TODO possibly use for fallback to smooth upgrades
declare boardurl="https://yabb.jriver.com/interact/index.php/board,71.0.html" # MC28 (Buster), for fallback webscrape declare boardurl="https://yabb.jriver.com/interact/index.php/board,71.0.html" # MC28 (Buster), for fallback webscrape
# Containerized package manager # Containerized package manager
# TODO but how to determine build distro ($base=buster)? # TODO but how to determine build distro ($BASE=buster)?
installPackage --silent buildah installPackage --silent buildah
if cnt=$(buildah from debian:$base) &>/dev/null; then if cnt=$(buildah from debian:$BASE) &>/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" "echo 'deb [trusted=no arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $BASE main' > /etc/apt/sources.list 2>&1" &&
buildah run "$cnt" -- bash -c \ buildah run "$cnt" -- bash -c \
"apt-get update --allow-insecure-repositories &>/dev/null" "apt-get update --allow-insecure-repositories &>/dev/null" &&
if MCVERSION=$(buildah run "$cnt" -- apt-cache policy mediacenter?? | grep Candidate | awk '{print $2}' | sort -V | tail -n1) \ MCVERSION=$(buildah run "$cnt" -- apt-cache policy mediacenter?? | grep Candidate | awk '{print $2}' | sort -V | tail -n1) &&
&& [[ "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then [[ "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]] &&
version_source="containerized package manager" VERSION_SOURCE="containerized package manager"; then
fi
buildah rm "$cnt" &>/dev/null buildah rm "$cnt" &>/dev/null
return 0 # Webscrape
elif installPackage wget && MCVERSION=$(wget -qO- "$boardurl" | grep -o "[0-9][0-9]\.[0-9]\.[0-9]\+" | head -n 1); then
VERSION_SOURCE="webscrape"
else else
installPackage wget MCVERSION="28.0.100"
if MCVERSION=$(wget -qO- "$boardurl" | grep -o "[0-9][0-9]\.[0-9]\.[0-9]\+" | head -n 1); then VERSION_SOURCE="hardcoded version"
version_source="webscrape" echo "Warning! Using hardcoded version number, this is probably not the latest"
else
err "Latest MC version could not be parsed from $boardurl"
err "Try specifying a version manually using --mcversion"
exit 1
fi
fi fi
} }
@@ -375,6 +348,7 @@ installPackage() {
addRepo() { addRepo() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
echo "Adding JRiver repository"
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
sudo bash -c 'cat <<- EOF > /etc/yum.repos.d/jriver.repo sudo bash -c 'cat <<- EOF > /etc/yum.repos.d/jriver.repo
[jriver] [jriver]
@@ -383,10 +357,16 @@ addRepo() {
gpgcheck=0 gpgcheck=0
EOF' EOF'
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint|neon)$ ]]; then elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint|neon)$ ]]; then
# MVERSION depends on $base unless --mcversion is passed # MVERSION depends on $BASE unless --mcversion is passed
installPackage wget installPackage wget
declare sources_dir="/etc/apt/sources.list.d"
[[ ! -d "$sources_dir" ]] && sudo mkdir -p "$sources_dir"
sudo bash -c "cat <<- EOF > $sources_dir/mediacenter$MVERSION.list
deb [trusted=yes arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $BASE main
EOF"
#echo "deb [trusted=yes arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $BASE main" > "$sources_dir/mediacenter$MVERSION.list" 2>&1
#sudo wget "http://dist.jriver.com/latest/mediacenter/mediacenter$MVERSION.list" -O "/etc/apt/sources.list.d/mediacenter$MVERSION.list" &>/dev/null
wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | sudo apt-key add - &>/dev/null wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | sudo apt-key add - &>/dev/null
sudo wget "http://dist.jriver.com/latest/mediacenter/mediacenter$MVERSION.list" -O "/etc/apt/sources.list.d/mediacenter$MVERSION.list" &>/dev/null
elif [[ "$ID" =~ ^opensuse.* ]]; then elif [[ "$ID" =~ ^opensuse.* ]]; then
sudo zypper addrepo --no-gpgcheck "https://repos.bryanroessler.com/jriver" jriver &>/dev/null sudo zypper addrepo --no-gpgcheck "https://repos.bryanroessler.com/jriver" jriver &>/dev/null
fi fi
@@ -1085,8 +1065,9 @@ service_jriver-createrepo() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
declare id="${TARGET:-$ID}" declare id="${TARGET:-$ID}"
declare cr_user="${CREATEREPO_USER:$USER}"
if [[ "$USER" != "${CREATEREPO_USER:-$USER}" ]]; then if [[ "$USER" != "$cr_user" ]]; then
USER="root" SERVICE_TYPE="system" setServiceVars USER="root" SERVICE_TYPE="system" setServiceVars
else else
setServiceVars setServiceVars
@@ -1098,7 +1079,7 @@ service_jriver-createrepo() {
[Service] [Service]
$USER_STRING $USER_STRING
ExecStart=$PWD/installJRMC --target $id --outputdir $OUTPUTDIR --createrepo --createrepo-webroot $CREATEREPO_WEBROOT --createrepo-user $CREATEREPO_USER ExecStart=$PWD/installJRMC --target $id --outputdir $OUTPUTDIR --createrepo --createrepo-webroot $CREATEREPO_WEBROOT --createrepo-user $cr_user
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
@@ -1139,7 +1120,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:$BASE); then
# # echo "Bad base image for container $CNAME, skipping" # # echo "Bad base image for container $CNAME, skipping"
# # continue # # continue
# # fi # # fi
@@ -1369,8 +1350,7 @@ tests() {
main() { main() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
declare version_source declare -g VERSION_SOURCE MCVERSION MVERSION MCPKG
declare -g MCVERSION MVERSION MCPKG
getOS getOS
@@ -1410,13 +1390,13 @@ main() {
# Select MC version to work with # Select MC version to work with
if [[ -v MCVERSION ]]; then if [[ -v MCVERSION ]]; then
version_source="user input" VERSION_SOURCE="user input"
else else
getLatestVersion getLatestVersion
fi fi
[[ ! "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]] && err "Invalid version number" && exit 1 [[ ! "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]] && err "Invalid version number" && exit 1
echo "Using MC version $MCVERSION determined by $version_source" echo "Using MC version $MCVERSION determined by $VERSION_SOURCE"
[[ "$version_source" != "user input" ]] && echo "To override, use --mcversion" [[ "$VERSION_SOURCE" != "user input" ]] && echo "To override, use --mcversion"
# Extract major version number # Extract major version number
MVERSION="${MCVERSION%%.*}" MVERSION="${MCVERSION%%.*}"
@@ -1424,10 +1404,10 @@ main() {
# Set target package name # Set target package name
if [[ "$ID" =~ ^(fedora|centos|opensuse.*)$ ]]; then if [[ "$ID" =~ ^(fedora|centos|opensuse.*)$ ]]; then
MCPKG="MediaCenter" MCPKG="MediaCenter"
[[ "$version_source" == "user input" ]] && MCPKG="$MCPKG-$MCVERSION" [[ "$VERSION_SOURCE" == "user input" ]] && MCPKG="$MCPKG-$MCVERSION"
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint|neon)$ ]]; then elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint|neon)$ ]]; then
MCPKG="mediacenter$MVERSION" MCPKG="mediacenter$MVERSION"
[[ "$version_source" == "user input" ]] && MCPKG="$MCPKG=$MCVERSION" [[ "$VERSION_SOURCE" == "user input" ]] && MCPKG="$MCPKG=$MCVERSION"
fi fi
if (( UNINSTALL_SWITCH )); then if (( UNINSTALL_SWITCH )); then