18 Commits

Author SHA1 Message Date
df9c1ccbea Keep /home/bryan consistent 2025-07-11 20:56:24 -04:00
d62f844371 Fix bad .jriver permissions more gracefully 2025-07-11 20:55:24 -04:00
f2d08bc3e6 Add debug output 2025-07-11 20:43:10 -04:00
ce2b1e70c6 Clobber repo files (more automatic) 2025-07-11 20:38:12 -04:00
1e1e7e3792 Make package update less noisy 2025-07-11 20:35:50 -04:00
c44bfe8aa3 Format and test 2025-07-11 20:12:10 -04:00
10d9e9e213 Remove uncessary warnings 2025-07-11 20:09:02 -04:00
f80f9ccd08 Add testing debug output 2025-07-11 19:52:38 -04:00
175c6deb5a Make package scrape prettier 2025-07-11 19:51:18 -04:00
9d8e338872 Make package scrape prettier 2025-07-11 19:50:01 -04:00
558c7a059c More explicitly fix .jriver dir permissions 2025-07-11 19:44:12 -04:00
f92a89c99c Quiet containerized package manager warning 2025-07-11 19:32:29 -04:00
68c03ab186 Make sure we pop commits after git update 2025-07-11 19:28:17 -04:00
9587308d84 Improve verbiage 2025-07-11 19:12:35 -04:00
3848e880ed Simplify build_rpm() 2025-07-11 19:09:52 -04:00
dc16e06ea8 Use --install=local by default on Mandriva 2025-07-11 18:59:26 -04:00
c5921c33cc Tighten up Mandriva support 2025-07-11 18:54:14 -04:00
0795491d61 Add Mandriva support 2025-07-11 17:55:26 -04:00
3 changed files with 147 additions and 85 deletions

View File

@@ -25,13 +25,13 @@ $ installJRMC --help
--install, -i repo|local --install, -i repo|local
repo: Install MC from repository, future updates will be handled by the system package manager repo: Install MC from repository, future updates will be handled by the system package manager
local: Build and install MC package from official source package local: Build and install MC package from official source package
--build[=suse|fedora|centos] --build[=suse|fedora|centos|mandriva]
Build RPM from source DEB but do not install Build RPM from source DEB but do not install
Optionally, specify a target distro for cross-building (ex. --build=suse, note the '=') Optionally, specify a target distro for cross-building (ex. --build=suse, note the '=')
--compat --compat
Build/install MC without minimum dependency version requirements Build/install MC without minimum dependency version requirements
--mcversion VERSION --mcversion VERSION
Specify the MC version, ex. "33", "34.0.36", or "34.0.36-1" (default: latest) Specify the MC version, ex. "33", "34.0.42", or "34.0.42-1" (default: latest)
--arch ARCH --arch ARCH
Specify the target MC architecture, ex. "amd64", "arm64", etc (default: host architecture) Specify the target MC architecture, ex. "amd64", "arm64", etc (default: host architecture)
--mcrepo REPO --mcrepo REPO
@@ -48,7 +48,7 @@ $ installJRMC --help
Starts services at boot (system) or user login (user) (default: per-service, see SERVICES) Starts services at boot (system) or user login (user) (default: per-service, see SERVICES)
--container, -c CONTAINER (TODO: Under construction) --container, -c CONTAINER (TODO: Under construction)
See CONTAINERS section below for a list of containers to deploy See CONTAINERS section below for a list of containers to deploy
--createrepo[=suse|fedora|centos] --createrepo[=suse|fedora|centos|mandriva]
Build rpm, copy to webroot, and run createrepo. Build rpm, copy to webroot, and run createrepo.
Optionally, specify a target distro for non-native repo (ex. --createrepo=fedora, note the '=') Optionally, specify a target distro for non-native repo (ex. --createrepo=fedora, note the '=')
--createrepo-webroot PATH --createrepo-webroot PATH
@@ -128,8 +128,8 @@ Install the latest version of MC33 from the best available repository with debug
Install a more widely-compatible version of the latest MC version. Install a more widely-compatible version of the latest MC version.
[code]installJRMC --install repo --service jriver-mediacenter --service-type user[/code] [code]installJRMC --install repo --service jriver-mediacenter --service-type user[/code]
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.
[code]installJRMC --install local --compat --restorefile /path/to/license.mjr --mcversion 34.0.36[/code] [code]installJRMC --install local --compat --restorefile /path/to/license.mjr --mcversion 34.0.42[/code]
Build and install an MC 34.0.36 comptability RPM locally and activate it using the /path/to/license.mjr Build and install an MC 34.0.42 comptability RPM locally and activate it using the /path/to/license.mjr
[code]installJRMC --createrepo --createrepo-webroot /srv/jriver/repo --createrepo-user www-user[/code] [code]installJRMC --createrepo --createrepo-webroot /srv/jriver/repo --createrepo-user www-user[/code]
Build an RPM locally for the current distro, move it to the webroot, and run createrepo as www-user. Build an RPM locally for the current distro, move it to the webroot, and run createrepo as www-user.
[code]installJRMC --service jriver-createrepo --createrepo-webroot /srv/jriver/repo --createrepo-user www-user[/code] [code]installJRMC --service jriver-createrepo --createrepo-webroot /srv/jriver/repo --createrepo-user www-user[/code]

View File

@@ -22,13 +22,13 @@ $ installJRMC --help
--install, -i repo|local --install, -i repo|local
repo: Install MC from repository, future updates will be handled by the system package manager repo: Install MC from repository, future updates will be handled by the system package manager
local: Build and install MC package locally from official source package local: Build and install MC package locally from official source package
--build[=suse|fedora|centos] --build[=suse|fedora|centos|mandriva]
Build RPM from source DEB but do not install Build RPM from source DEB but do not install
Optionally, specify a target distro for cross-building (ex. --build=suse, note the '=') Optionally, specify a target distro for cross-building (ex. --build=suse, note the '=')
--compat --compat
Build/install MC without minimum dependency version requirements Build/install MC without minimum dependency version requirements
--mcversion VERSION --mcversion VERSION
Build or install a specific MC version, ex. "34.0.36" or "33" (default: latest) Build or install a specific MC version, ex. "34.0.42" or "33" (default: latest)
--mcrepo REPO --mcrepo REPO
Specify the MC repository, ex. "bullseye", "bookworm", "noble", etc (default: latest official) Specify the MC repository, ex. "bullseye", "bookworm", "noble", etc (default: latest official)
--arch ARCH --arch ARCH
@@ -45,7 +45,7 @@ $ installJRMC --help
Starts services at boot (system) or user login (user) (default: per-service, see SERVICES) Starts services at boot (system) or user login (user) (default: per-service, see SERVICES)
--container, -c CONTAINER (TODO: Under construction) --container, -c CONTAINER (TODO: Under construction)
See CONTAINERS section below for a list of containers to deploy See CONTAINERS section below for a list of containers to deploy
--createrepo[=suse|fedora|centos] --createrepo[=suse|fedora|centos|mandriva]
Build rpm, copy to webroot, and run createrepo. Build rpm, copy to webroot, and run createrepo.
Optionally, specify a target distro for non-native repo (ex. --createrepo=fedora, note the '=') Optionally, specify a target distro for non-native repo (ex. --createrepo=fedora, note the '=')
--createrepo-webroot PATH --createrepo-webroot PATH
@@ -133,9 +133,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 34.0.36` * `installJRMC --install local --compat --restorefile /path/to/license.mjr --mcversion 34.0.42`
Build and install an MC 34.0.36 compatibility RPM locally and activate it using the `/path/to/license.mjr` Build and install an MC 34.0.42 compatibility 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`

View File

@@ -21,8 +21,8 @@
# shellcheck disable=SC2317 # shellcheck disable=SC2317
shopt -s extglob shopt -s extglob
declare -g SCRIPT_VERSION="1.34.3" declare -g SCRIPT_VERSION="1.34.4"
declare -g MC_VERSION="34.0.36" # do find all replace (hardcoded fallback) declare -g MC_VERSION="34.0.42" # do find all replace (hardcoded fallback)
declare -g MC_REPO="bookworm" # should match the MC_VERSION declare -g MC_REPO="bookworm" # should match the MC_VERSION
declare -g BOARD_ID="89.0" # MC34 board ID for automatic version detection declare -g BOARD_ID="89.0" # MC34 board ID for automatic version detection
declare -gi SELF_UPDATE_SWITCH=1 # 0 to disable installJRMC self-update declare -gi SELF_UPDATE_SWITCH=1 # 0 to disable installJRMC self-update
@@ -48,7 +48,7 @@ print_help() {
--install, -i repo|local --install, -i repo|local
repo: Install MC from repository, updates are handled by the system package manager repo: Install MC from repository, updates are handled by the system package manager
local: Build and install MC locally from official source package local: Build and install MC locally from official source package
--build[=suse|fedora|centos] --build[=suse|fedora|centos|mandriva]
Build RPM from source DEB but do not install Build RPM from source DEB but do not install
Optionally, specify a target distro for cross-building (ex. --build=suse, note the '=') Optionally, specify a target distro for cross-building (ex. --build=suse, note the '=')
--compat --compat
@@ -71,7 +71,7 @@ print_help() {
Starts services at boot (system) or at user login (user) (default: per service, see SERVICES) Starts services at boot (system) or at user login (user) (default: per service, see SERVICES)
--container, -c CONTAINER (TODO: Under construction) --container, -c CONTAINER (TODO: Under construction)
See CONTAINERS section below for a list of possible services to install See CONTAINERS section below for a list of possible services to install
--createrepo[=suse|fedora|centos] --createrepo[=suse|fedora|centos|mandriva]
Build rpm, copy to webroot, and run createrepo. Build rpm, copy to webroot, and run createrepo.
Use in conjunction with --build=TARGET for crossbuilding repos Use in conjunction with --build=TARGET for crossbuilding repos
Optionally, specify a target distro for non-native repo (ex. --createrepo=fedora, note the '=') Optionally, specify a target distro for non-native repo (ex. --createrepo=fedora, note the '=')
@@ -252,6 +252,8 @@ init() {
# Run the self-updater if enabled # Run the self-updater if enabled
((SELF_UPDATE_SWITCH)) && update "$@" ((SELF_UPDATE_SWITCH)) && update "$@"
fix_permissions "$HOME/.jriver" "$USER"
# Get host information # Get host information
[[ -f /etc/os-release ]] && source /etc/os-release [[ -f /etc/os-release ]] && source /etc/os-release
@@ -285,6 +287,13 @@ init() {
rhel|almalinux) ID="centos" ;; rhel|almalinux) ID="centos" ;;
linuxmint|neon|zorin|*ubuntu*) ID="ubuntu" ;; linuxmint|neon|zorin|*ubuntu*) ID="ubuntu" ;;
raspbian) ID="debian" ;; raspbian) ID="debian" ;;
*mandriva*) ID="mandriva"
if ((REPO_INSTALL_SWITCH)); then
debug "Automatically using --install=local for Mandriva"
REPO_INSTALL_SWITCH=0
BUILD_SWITCH=1
LOCAL_INSTALL_SWITCH=1
fi ;;
manjaro|arch) ID="arch" manjaro|arch) ID="arch"
if ((REPO_INSTALL_SWITCH)); then if ((REPO_INSTALL_SWITCH)); then
debug "Automatically using --install=local for Arch" debug "Automatically using --install=local for Arch"
@@ -328,7 +337,7 @@ init() {
# Set distro-specific package manager commands for normalized IDs # Set distro-specific package manager commands for normalized IDs
case $ID in case $ID in
fedora|centos) fedora|centos|mandriva)
local rpm_mgr local rpm_mgr
rpm_mgr=$(command -v dnf &>/dev/null && echo "dnf" || echo "yum") rpm_mgr=$(command -v dnf &>/dev/null && echo "dnf" || echo "yum")
PKG_INSTALL=(sudo "$rpm_mgr" install -y) PKG_INSTALL=(sudo "$rpm_mgr" install -y)
@@ -397,7 +406,7 @@ init() {
if [[ -n $USER_MC_VERSION ]]; then if [[ -n $USER_MC_VERSION ]]; then
# Append explicit package version when user provides --mcversion # Append explicit package version when user provides --mcversion
case $ID in case $ID in
fedora|centos|suse) MC_PKG+="-$MC_VERSION" ;; fedora|centos|suse|mandriva) MC_PKG+="-$MC_VERSION" ;;
debian|ubuntu) MC_PKG+="=$MC_VERSION" ;; debian|ubuntu) MC_PKG+="=$MC_VERSION" ;;
esac esac
fi fi
@@ -424,7 +433,7 @@ get_latest_mc_version() {
# Fallback to hardcoded value # Fallback to hardcoded value
else else
mc_version_source="hardcoded" mc_version_source="hardcoded"
err "Warning! Using hardcoded version number" echo "Warning! Using hardcoded version number"
fi fi
echo "Selected MC version $MC_VERSION from the $MC_REPO repo (via $mc_version_source)" echo "Selected MC version $MC_VERSION from the $MC_REPO repo (via $mc_version_source)"
@@ -461,18 +470,19 @@ install_package() {
shift shift
done done
# Define package aliases based on the distribution # Define distribution-specific package aliases
case $ID in case $ID in
debian|ubuntu) debian|ubuntu) pkg_aliases=(
pkg_aliases=(
[rpm-build]="rpm" [rpm-build]="rpm"
[createrepo_c]="createrepo" [createrepo_c]="createrepo"
[tigervnc-server]="tigervnc-standalone-server" [tigervnc-server]="tigervnc-standalone-server"
) ;; ) ;;
suse) suse) pkg_aliases=(
pkg_aliases=(
[buildah]="buildah fuse-overlayfs" [buildah]="buildah fuse-overlayfs"
) ;; ) ;;
mandriva) pkg_aliases=(
[dpkg]="dpkg gnutar"
) ;;
esac esac
# Filter out already installed packages to create pkg_array # Filter out already installed packages to create pkg_array
@@ -498,7 +508,7 @@ install_package() {
debian|ubuntu) debian|ubuntu)
((allow_downgrades)) && install_flags+=(--allow-downgrades) ((allow_downgrades)) && install_flags+=(--allow-downgrades)
((reinstall)) && install_flags+=(--reinstall) ;; ((reinstall)) && install_flags+=(--reinstall) ;;
fedora|centos) fedora|centos|mandriva)
((allow_downgrades)) && install_flags+=(--allowerasing) ((allow_downgrades)) && install_flags+=(--allowerasing)
((no_gpg_check)) && install_flags+=(--nogpgcheck) ((no_gpg_check)) && install_flags+=(--nogpgcheck)
((refresh)) && install_flags+=(--refresh) ((refresh)) && install_flags+=(--refresh)
@@ -566,6 +576,11 @@ install_external_repos() {
# execute sudo zypper --non-interactive --quiet refresh # execute sudo zypper --non-interactive --quiet refresh
# fi # fi
;; ;;
mandriva)
local branch
branch=$(grep ^PRETTY_NAME= /etc/os-release | tr -d '"' | rev | cut -d' ' -f1 | rev | tr '[:upper:]' '[:lower:]')
execute sudo dnf config-manager --set-enabled "${branch}-${ARCH}-extra"
;;
esac esac
} }
@@ -652,14 +667,13 @@ install_mc_repo() {
;; ;;
*) *)
err "An MC repository for $ID is not yet available" err "An MC repository for $ID is not yet available"
err "Use --install local to install MC on $ID" err "Use --install=local to install MC on $ID"
return 1 return 1
;; ;;
esac esac
if [[ -f $repo_file ]]; then # Remove existing repository file if it exists
ask_ok "Replace existing $repo_file repository file" && execute sudo rm -f "$repo_file" [[ -f $repo_file ]] && execute sudo rm -f "$repo_file"
fi
echo "Adding MC repository file: $repo_file" echo "Adding MC repository file: $repo_file"
debug "$repo_text" debug "$repo_text"
@@ -672,7 +686,7 @@ install_mc_repo() {
err "Failed to add temporary repository" err "Failed to add temporary repository"
return 1 return 1
fi fi
"${PKG_UPDATE[@]}" || { err "Package update failed!"; return 1; } execute "${PKG_UPDATE[@]}" || { err "Package update failed!"; return 1; }
echo "Installing $MC_PKG package" echo "Installing $MC_PKG package"
if ! install_package \ if ! install_package \
@@ -728,7 +742,7 @@ acquire_deb() {
[[ -f $MC_DEB ]] && [[ -f $MC_DEB ]] &&
execute sudo buildah umount "$CNT" && execute sudo buildah umount "$CNT" &&
execute sudo buildah rm "$CNT"; }; then execute sudo buildah rm "$CNT"; }; then
err "Failed to download DEB using containerized package manager" debug "Failed to download DEB using containerized package manager"
echo "Using legacy download method" echo "Using legacy download method"
# Define the repository search order # Define the repository search order
local -a repos local -a repos
@@ -739,12 +753,13 @@ acquire_deb() {
# Loop through the repositories and attempt to download # Loop through the repositories and attempt to download
for repo in "${repos[@]}"; do for repo in "${repos[@]}"; do
echo "Checking $repo for DEB package" echo -n "$repo --> "
if download "$repo" "$MC_DEB"; then if download "$repo" "$MC_DEB"; then
echo "Found" echo "Found!"
MC_SOURCE="$repo" MC_SOURCE="$repo"
break break
fi fi
echo "Not found"
done done
fi fi
@@ -763,7 +778,10 @@ build_rpm() {
# skip rebuilding the rpm if it already exists # skip rebuilding the rpm if it already exists
debug "Checking for existing MC RPM: $MC_RPM" debug "Checking for existing MC RPM: $MC_RPM"
if [[ -f $MC_RPM && -f $spec_file ]]; then if [[ -f $MC_RPM && -f $spec_file ]]; then
echo "Spec file and $MC_RPM already exists. Skipping build step" echo "Skipping build step: .spec and ouput RPM already exist"
debug "RPM .spec file: $spec_file"
debug "RPM: $MC_RPM"
echo "Remove either to force rebuild"
return 0 return 0
fi fi
@@ -820,16 +838,15 @@ build_rpm() {
requires=("${requires[@]/libva-drm2/libva}") requires=("${requires[@]/libva-drm2/libva}")
requires=("${requires[@]/libepoxy0/libepoxy}") requires=("${requires[@]/libepoxy0/libepoxy}")
requires=("${requires[@]/liblcms2-2/lcms2}") requires=("${requires[@]/liblcms2-2/lcms2}")
requires=("${requires[@]/python/python3}")
requires=("${requires[@]/libwebkit2gtk-4.0*/webkit2gtk4.0}") requires=("${requires[@]/libwebkit2gtk-4.0*/webkit2gtk4.0}")
requires=("${requires[@]/libwebkit2gtk-4.1*/webkit2gtk4.1}") requires=("${requires[@]/libwebkit2gtk-4.1*/webkit2gtk4.1}")
requires=("${requires[@]/libsdbus-c++1/sdbus-cpp}") requires=("${requires[@]/libsdbus-c++1/sdbus-cpp}")
recommends=("${recommends[@]/fdkaac/fdk-aac-free}")
recommends+=("mesa-va-drivers-freeworld|mesa-va-drivers") recommends+=("mesa-va-drivers-freeworld|mesa-va-drivers")
recommends+=("mesa-vulkan-drivers-freeworld|mesa-vulkan-drivers") recommends+=("mesa-vulkan-drivers-freeworld|mesa-vulkan-drivers")
recommends+=("mesa-vdpau-driver-freeworld|mesa-vdpau-driver") recommends+=("mesa-vdpau-driver-freeworld|mesa-vdpau-driver")
;; ;;
suse) suse)
requires=("${requires[@]/python*/python313}")
requires=("${requires[@]/libc6/glibc}") requires=("${requires[@]/libc6/glibc}")
requires=("${requires[@]/libasound2/alsa-lib}") requires=("${requires[@]/libasound2/alsa-lib}")
requires=("${requires[@]/libx11-6/libX11-6}") requires=("${requires[@]/libx11-6/libX11-6}")
@@ -857,6 +874,43 @@ build_rpm() {
recommends+=(libvulkan_radeon) recommends+=(libvulkan_radeon)
recommends+=(libvulkan_nouveau) recommends+=(libvulkan_nouveau)
;; ;;
mandriva)
requires=("${requires[@]/libc6/glibc}")
requires=("${requires[@]/libasound2/lib64asound2}")
requires=("${requires[@]/libuuid1/lib64uuid1}")
requires=("${requires[@]/libx11-6/lib64x11_6}")
requires=("${requires[@]/libxext6/lib64xext6}")
requires=("${requires[@]/libxcb1/lib64xcb1}")
requires=("${requires[@]/libxdmcp6/lib64xdmcp6}")
requires=("${requires[@]/libstdc++6/lib64stdc++6}")
requires=("${requires[@]/libgtk-3-0/lib64gtk3_0}")
requires=("${requires[@]/libgl1/lib64GL1}")
requires=("${requires[@]/libgles2/lib64GLESv2_2}")
requires=("${requires[@]/libegl-mesa0/lib64EGL_mesa0}")
requires=("${requires[@]/libpango1.0-0/lib64pango1.0_0}")
requires=("${requires[@]/libpango-1.0-0/lib64pango1.0_0}")
requires=("${requires[@]/libpangoft2-1.0-0/lib64pangoft2_1.0_0}")
requires=("${requires[@]/libpango-cairo-1.0-0/lib64pangocairo1.0_0}")
requires=("${requires[@]/libpangoxft-1.0-0/lib64pangoxft1.0_0}")
requires=("${requires[@]/libnss3/lib64nss3}")
requires=("${requires[@]/libnspr4/lib64nspr4}")
requires=("${requires[@]/libgomp1/lib64gomp1}")
requires=("${requires[@]/libfribidi0/lib64fribidi0}")
requires=("${requires[@]/libfontconfig1/lib64fontconfig}")
requires=("${requires[@]/libfreetype6/lib64freetype6}")
requires=("${requires[@]/libharfbuzz0b/lib64harfbuzz}")
requires=("${requires[@]/libgbm1/lib64gbm1}")
requires=("${requires[@]/libva2/lib64va2}")
requires=("${requires[@]/libva-drm2/lib64va-drm2}")
requires=("${requires[@]/libvulkan1/lib64vulkan1}")
requires=("${requires[@]/mesa-vulkan-drivers/lib64dri-drivers}")
requires=("${requires[@]/vulkan-icd/vulkan-loader}")
requires=("${requires[@]/libwebkit2gtk-4.1-0/lib64webkit2gtk4.1}")
recommends=("${recommends[@]/musepack-tools/mppenc}")
for i in "${!recommends[@]}"; do
[[ ${recommends[$i]} == "fdkaac" ]] && unset -v 'recommends[i]'
done
;;
esac esac
# Convert array to newline delim'd string (for heredoc) # Convert array to newline delim'd string (for heredoc)
@@ -935,19 +989,7 @@ build_rpm() {
-bb -bb
"$spec_file" "$spec_file"
) )
if execute "${rpmbuild_cmd[@]}" && [[ -f $MC_RPM ]] ; then execute "${rpmbuild_cmd[@]}" && [[ -f $MC_RPM ]]
echo "Build successful. The RPM file is located at: $MC_RPM"
else
err "Build failed"
# After failure, remove the source DEB and reaquire it on next run
if [[ -f $MC_DEB ]]; then
echo "Removing source DEB"
if ! execute rm -f "$MC_DEB"; then
execute sudo rm -f "$MC_DEB"
fi
fi
return 1
fi
} }
# @description Installs Media Center via DEB package w/ optional compatability fixes # @description Installs Media Center via DEB package w/ optional compatability fixes
@@ -985,7 +1027,7 @@ install_mc_deb() {
err "Failed to add temporary repository" err "Failed to add temporary repository"
return 1 return 1
fi fi
"${PKG_UPDATE[@]}" || { err "Package update failed!"; return 1; } execute "${PKG_UPDATE[@]}" || { err "Package update failed!"; return 1; }
# Copy the DEB to a temporary file so _apt can read it # Copy the DEB to a temporary file so _apt can read it
debug "Creating temporary deb file owned by _apt" debug "Creating temporary deb file owned by _apt"
@@ -1236,7 +1278,6 @@ open_firewall() {
execute sudo ufw app update "$service" execute sudo ufw app update "$service"
execute sudo ufw allow "$service" execute sudo ufw allow "$service"
else else
echo "Warning: Install firewall-cmd or ufw to open firewall ports"
return 1 return 1
fi fi
} }
@@ -1546,16 +1587,16 @@ service_jriver-createrepo() {
} }
# @description Detects if MC is installed on btrfs and disables CoW # @description Detects if MC is installed on btrfs and disables CoW
disable_btrfs_cow() { fix_dotjriver_permissions() {
debug "${FUNCNAME[0]}()" debug "${FUNCNAME[0]}()"
local mc_user_path="$HOME/.jriver"
[[ -d "$mc_user_path" ]] || execute mkdir -p "$mc_user_path"
[[ -d "$mc_user_path" ]] && execute sudo chown -R "$USER:$USER" "$mc_user_path"
# Disable btrfs CoW # Ensure the user owns their .jriver directory
if [[ $(stat -f -c %T "$mc_user_path") == "btrfs" ]]; then if [[ -d "$HOME/.jriver" ]]; then
if execute chattr -R +C "$mc_user_path"; then local owner
echo "Disabled btrfs CoW for $mc_user_path" owner=$(stat -c '%U' "$HOME/.jriver")
if [[ "$owner" != "$USER" ]]; then
ask_ok "$USER does not currently own $HOME/.jriver, attempt fix?" &&
execute sudo chown -R "$USER:$USER" "$HOME/.jriver"
fi fi
fi fi
} }
@@ -1649,11 +1690,11 @@ uninstall() {
if [[ -d $HOME/.jriver ]]; then if [[ -d $HOME/.jriver ]]; then
if ask_ok "Backup and reset your MC library?"; then if ask_ok "Backup and reset your MC library?"; then
execute mv "$HOME/.jriver" "$HOME/.jriver.bk" execute mv "$HOME/.jriver" "$HOME/.jriver.bk"
echo "Your MC library has been backed up to $HOME/.jriver.bk and reset" echo "Your MC library has been reset and backed up to $HOME/.jriver.bk"
echo "To restore your MC library backup: mv $HOME/.jriver.bk $HOME/.jriver" echo "To restore your MC library: mv $HOME/.jriver.bk $HOME/.jriver"
return return
fi fi
echo "To backup and reset your MC library: mv $HOME/.jriver $HOME/.jriver.bk" echo "To reset and backup your MC library: mv $HOME/.jriver $HOME/.jriver.bk"
echo "To remove your MC library: rm -rf $HOME/.jriver" echo "To remove your MC library: rm -rf $HOME/.jriver"
fi fi
} }
@@ -1684,28 +1725,28 @@ update() {
[[ "$(git -C "$SCRIPT_DIR" config --get remote.origin.url)" =~ installJRMC|installjrmc ]]; then [[ "$(git -C "$SCRIPT_DIR" config --get remote.origin.url)" =~ installJRMC|installjrmc ]]; then
# Get the current commit hash # Get the current commit hash
local before_pull_hash after_pull_hash local before_pull_hash
before_pull_hash=$(git -C "$SCRIPT_DIR" rev-parse HEAD) before_pull_hash=$(git -C "$SCRIPT_DIR" rev-parse HEAD)
# Stash local changes before pull # Stash local changes before pull
execute git -C "$SCRIPT_DIR" stash push --quiet execute git -C "$SCRIPT_DIR" stash push --quiet
# Pull latest changes # Pull latest changes
debug "Running git pull in $SCRIPT_DIR" execute git -C "$SCRIPT_DIR" pull --quiet
if ! git -C "$SCRIPT_DIR" pull | grep -q "Already up to date"; then
# Get the new commit hash after pull # Restore local changes
after_pull_hash=$(git -C "$SCRIPT_DIR" rev-parse HEAD) execute git -C "$SCRIPT_DIR" stash pop --quiet
debug "Current commit hash: $before_pull_hash"
debug "New commit hash: $(git -C "$SCRIPT_DIR" rev-parse HEAD)"
# If the commit hash has changed, an update occurred # If the commit hash has changed, an update occurred
if [[ "$before_pull_hash" != "$after_pull_hash" ]]; then if [[ "$before_pull_hash" != $(git -C "$SCRIPT_DIR" rev-parse HEAD) ]]; then
echo "Detected installJRMC update, restarting" echo "Detected installJRMC update, restarting"
execute git -C "$SCRIPT_DIR" stash pop --quiet
exec "$SCRIPT_PATH" "$@" "--no-update" exec "$SCRIPT_PATH" "$@" "--no-update"
fi fi
fi
execute git -C "$SCRIPT_DIR" stash pop --quiet
else else
debug "Not in a git repository or not the installJRMC repository. Checking for updates via download." debug "Not in the installJRMC repository, checking for installJRMC update via webscrape."
local tmp local tmp
tmp=$(mktemp) || { err "Failed to create temporary file."; return 1; } tmp=$(mktemp) || { err "Failed to create temporary file."; return 1; }
@@ -1776,7 +1817,6 @@ main() {
link_ssl_certs link_ssl_certs
restore_license restore_license
open_firewall "jriver-mediacenter" "52100-52200/tcp" "1900/udp" open_firewall "jriver-mediacenter" "52100-52200/tcp" "1900/udp"
disable_btrfs_cow
else else
err "JRiver Media Center installation from remote repository failed" err "JRiver Media Center installation from remote repository failed"
return 1 return 1
@@ -1786,10 +1826,22 @@ main() {
if ((BUILD_SWITCH)); then if ((BUILD_SWITCH)); then
acquire_deb || { err "Could not download Media Center DEB package"; return 1; } acquire_deb || { err "Could not download Media Center DEB package"; return 1; }
if [[ $BUILD_TARGET =~ centos|fedora|suse || $CREATEREPO_TARGET =~ centos|fedora|suse ]]; then if [[ $BUILD_TARGET =~ centos|fedora|suse|mandriva || $CREATEREPO_TARGET =~ centos|fedora|suse|mandriva ]]; then
install_package dpkg rpm-build install_package dpkg rpm-build
[[ -d $OUTPUT_DIR/SPECS ]] || execute mkdir -p "$OUTPUT_DIR/SPECS" [[ -d $OUTPUT_DIR/SPECS ]] || execute mkdir -p "$OUTPUT_DIR/SPECS"
build_rpm if build_rpm; then
echo "RPM package built successfully"
else
err "Failed to build RPM package"
# On build failure, remove the source DEB in case it is corrupted
if [[ -f $MC_DEB ]]; then
echo "Removing source DEB"
if ! execute rm -f "$MC_DEB"; then
execute sudo rm -f "$MC_DEB"
fi
fi
return 1
fi
fi fi
fi fi
@@ -1805,7 +1857,6 @@ main() {
link_ssl_certs link_ssl_certs
restore_license restore_license
open_firewall "jriver-mediacenter" "52100-52200/tcp" "1900/udp" open_firewall "jriver-mediacenter" "52100-52200/tcp" "1900/udp"
disable_btrfs_cow
fi fi
if ((CREATEREPO_SWITCH)); then if ((CREATEREPO_SWITCH)); then
@@ -1850,12 +1901,24 @@ execute() {
"$@" &>/dev/null "$@" &>/dev/null
fi fi
} }
fix_permissions() {
local dir="$1"
local user="$2"
local owner
[[ -d "$dir" ]] || return 1
owner=$(stat -c '%U' "$dir")
if [[ "$owner" != "$user" ]]; then
echo "Directory $dir is owned by $owner, not $user"
if ask_ok "Change ownership of $dir to $user?"; then
execute sudo chown -R "$user:$user" "$dir"
fi
fi
}
download() { download() {
debug "${FUNCNAME[0]}()" "$@" debug "${FUNCNAME[0]}()" "$@"
local url="$1" local url="$1"
local output="${2:-}" local output="${2:-}"
local -a cmd local -a cmd
if command -v curl &>/dev/null || install_package --silent curl; then if command -v curl &>/dev/null || install_package --silent curl; then
cmd=(curl --silent --fail --location) cmd=(curl --silent --fail --location)
if [[ -n "$output" ]]; then if [[ -n "$output" ]]; then
@@ -1870,7 +1933,6 @@ download() {
err "Unable to install wget or curl" err "Unable to install wget or curl"
return 1 return 1
fi fi
debug "${cmd[@]}" "$url" debug "${cmd[@]}" "$url"
"${cmd[@]}" "$url" "${cmd[@]}" "$url"
} }