Move execute up for all pm commands

This commit is contained in:
2023-03-23 13:33:38 -04:00
parent 57e58e6c4e
commit 439361e4cb

View File

@@ -143,7 +143,7 @@ init() {
fi fi
# Detect architecture and translate to MC convention # Detect architecture and translate to MC convention
# Also catch user input in getopt # Override with user input with getopt
ARCH=$(uname -m) ARCH=$(uname -m)
case "$ARCH" in case "$ARCH" in
x86_64) x86_64)
@@ -204,30 +204,30 @@ init() {
# Abstract distro-specific package manager commands # Abstract distro-specific package manager commands
case "$ID" in case "$ID" in
fedora|centos) fedora|centos)
PKG_INSTALL=(sudo "$RPM_MGR" install -y) PKG_INSTALL=(execute sudo "$RPM_MGR" install -y)
PKG_REMOVE=(sudo "$RPM_MGR" remove -y) PKG_REMOVE=(execute udo "$RPM_MGR" remove -y)
PKG_UPDATE=(sudo "$RPM_MGR" makecache) PKG_UPDATE=(execute sudo "$RPM_MGR" makecache)
PKG_QUERY(){ rpm -q "$@"; } PKG_QUERY(){ rpm -q "$@"; }
PKG_INSTALL_LOCAL(){ installMCRPM; } PKG_INSTALL_LOCAL(){ installMCRPM; }
;; ;;
debian|ubuntu) debian|ubuntu)
PKG_INSTALL=(sudo apt-get -f install -y -q0) PKG_INSTALL=(execute sudo apt-get -f install -y -q0)
PKG_REMOVE=(sudo apt-get remove --auto-remove -y -q0) PKG_REMOVE=(execute sudo apt-get remove --auto-remove -y -q0)
PKG_UPDATE=(sudo apt-get update -y -q0) PKG_UPDATE=(execute sudo apt-get update -y -q0)
PKG_QUERY(){ dpkg -s "$@"; } PKG_QUERY(){ dpkg -s "$@"; }
PKG_INSTALL_LOCAL(){ installMCDEB; } PKG_INSTALL_LOCAL(){ installMCDEB; }
;; ;;
suse) suse)
PKG_INSTALL=(sudo zypper --non-interactive -q install --force --no-confirm) PKG_INSTALL=(execute sudo zypper --non-interactive -q install --force --no-confirm)
PKG_REMOVE=(sudo zypper --non-interactive -q remove --clean-deps) PKG_REMOVE=(execute sudo zypper --non-interactive -q remove --clean-deps)
PKG_UPDATE=(sudo zypper --non-interactive -q refresh jriver) PKG_UPDATE=(execute sudo zypper --non-interactive -q refresh jriver)
PKG_QUERY(){ rpm -q "$@"; } PKG_QUERY(){ rpm -q "$@"; }
PKG_INSTALL_LOCAL(){ installMCRPM; } PKG_INSTALL_LOCAL(){ installMCRPM; }
;; ;;
arch) arch)
PKG_INSTALL=(sudo pacman -Sy --noconfirm) PKG_INSTALL=(execute sudo pacman -Sy --noconfirm)
PKG_REMOVE=(sudo pacman -Rs --noconfirm) PKG_REMOVE=(execute sudo pacman -Rs --noconfirm)
PKG_UPDATE=(sudo pacman -Syy) PKG_UPDATE=(execute sudo pacman -Syy)
PKG_QUERY(){ sudo pacman -Qs "$@"; } PKG_QUERY(){ sudo pacman -Qs "$@"; }
PKG_INSTALL_LOCAL(){ installMCARCH; } PKG_INSTALL_LOCAL(){ installMCARCH; }
;; ;;
@@ -534,7 +534,7 @@ installPackage() {
# Install packages from package array # Install packages from package array
if [[ ${#pkg_array[@]} -ge 1 ]]; then if [[ ${#pkg_array[@]} -ge 1 ]]; then
if ! execute "${PKG_INSTALL[@]}" "${install_flags[@]}" "${pkg_array[@]}"; then if ! "${PKG_INSTALL[@]}" "${install_flags[@]}" "${pkg_array[@]}"; then
(( silent )) || err "Failed to install ${pkg_array[*]}. Attempting to continue" (( silent )) || err "Failed to install ${pkg_array[*]}. Attempting to continue"
return 1 return 1
fi fi
@@ -561,7 +561,7 @@ installMesa() {
return 1 return 1
fi fi
else else
execute "${PKG_INSTALL[@]}" mesa-va-drivers-freeworld "${PKG_INSTALL[@]}" mesa-va-drivers-freeworld
fi fi
fi fi
;; ;;
@@ -603,7 +603,7 @@ installMCFromRepo() {
;; ;;
esac esac
if ! execute "${PKG_UPDATE[@]}"; then if ! "${PKG_UPDATE[@]}"; then
err "Package update failed!" err "Package update failed!"
return 1 return 1
fi fi
@@ -922,6 +922,7 @@ installMCARCH() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
[[ -d "$OUTPUTDIR/PKGBUILD" ]] || mkdir -p "$OUTPUTDIR/PKGBUILD" [[ -d "$OUTPUTDIR/PKGBUILD" ]] || mkdir -p "$OUTPUTDIR/PKGBUILD"
cat <<-EOF > "$OUTPUTDIR/PKGBUILD/mediacenter.pkgbuild" cat <<-EOF > "$OUTPUTDIR/PKGBUILD/mediacenter.pkgbuild"
pkgname=mediacenter$MVERSION pkgname=mediacenter$MVERSION
pkgver=$MCVERSION pkgver=$MCVERSION
@@ -1057,7 +1058,7 @@ restoreLicense() {
) )
shopt -u nullglob shopt -u nullglob
if [[ ${#mjrfiles[@]} -ge 1 ]]; then if [[ ${#mjrfiles[@]} -gt 0 ]]; then
debug "mjrfiles=(${mjrfiles[*]})" debug "mjrfiles=(${mjrfiles[*]})"
@@ -1188,7 +1189,7 @@ setServiceVars() {
declare -g SERVICE_NAME SERVICE_FNAME TIMER_NAME TIMER_FNAME declare -g SERVICE_NAME SERVICE_FNAME TIMER_NAME TIMER_FNAME
declare -g USER_STRING DISPLAY_STRING GRAPHICAL_TARGET declare -g USER_STRING DISPLAY_STRING GRAPHICAL_TARGET
declare -g RELOAD ENABLE DISABLE IS_ENABLED IS_ACTIVE declare -ga RELOAD ENABLE DISABLE IS_ENABLED IS_ACTIVE
declare -a systemctl_prefix declare -a systemctl_prefix
declare service_name="$1" declare service_name="$1"
declare service_type="${2:-${SERVICE_TYPE:-system}}" declare service_type="${2:-${SERVICE_TYPE:-system}}"
@@ -1209,11 +1210,11 @@ setServiceVars() {
fi fi
# systemctl commands # systemctl commands
RELOAD="${systemctl_prefix[*]} daemon-reload" RELOAD=(execute "${systemctl_prefix[@]}" daemon-reload)
ENABLE="${systemctl_prefix[*]} enable --now" ENABLE=(execute "${systemctl_prefix[@]}" enable --now)
DISABLE="${systemctl_prefix[*]} disable --now" DISABLE=(execute "${systemctl_prefix[@]}" disable --now)
IS_ENABLED="${systemctl_prefix[*]} is-enabled -q" IS_ENABLED=(execute "${systemctl_prefix[@]}" is-enabled -q)
IS_ACTIVE="${systemctl_prefix[*]} is-active -q" IS_ACTIVE=(execute "${systemctl_prefix[@]}" is-active -q)
[[ -d "$service_dir" ]] || execute sudo mkdir -p "$service_dir" [[ -d "$service_dir" ]] || execute sudo mkdir -p "$service_dir"
@@ -1275,8 +1276,8 @@ service_jriver-mediacenter() {
WantedBy=$GRAPHICAL_TARGET WantedBy=$GRAPHICAL_TARGET
EOF" EOF"
execute "$RELOAD" && "${RELOAD[@]}" &&
execute "$ENABLE" "$SERVICE_NAME" && "${ENABLE[@]}" "$SERVICE_NAME" &&
openFirewall "jriver-mediacenter" "52100-52200/tcp" "1900/udp" openFirewall "jriver-mediacenter" "52100-52200/tcp" "1900/udp"
} }
@@ -1351,8 +1352,9 @@ service_jriver-xvnc() {
WantedBy=multi-user.target WantedBy=multi-user.target
EOF" EOF"
execute "$RELOAD" "${RELOAD[@]}"
if ! execute "$ENABLE" "$SERVICE_NAME"; then
if ! execute "${ENABLE[@]}" "$SERVICE_NAME"; then
err "vncserver failed to start on DISPLAY $NEXT_DISPLAY" err "vncserver failed to start on DISPLAY $NEXT_DISPLAY"
err "Incrementing DISPLAY and retrying" err "Incrementing DISPLAY and retrying"
service_jriver-xvnc increment service_jriver-xvnc increment
@@ -1421,8 +1423,8 @@ service_jriver-x11vnc() {
WantedBy=$GRAPHICAL_TARGET WantedBy=$GRAPHICAL_TARGET
EOF" EOF"
execute "$RELOAD" && "${RELOAD[@]}" &&
execute "$ENABLE" "$SERVICE_NAME" && "${ENABLE[@]}" "$SERVICE_NAME" &&
echo "x11vnc running on localhost:$PORT" && echo "x11vnc running on localhost:$PORT" &&
openFirewall "jriver-x11vnc" "$PORT/tcp" openFirewall "jriver-x11vnc" "$PORT/tcp"
} }
@@ -1465,8 +1467,8 @@ service_jriver-createrepo() {
WantedBy=timers.target WantedBy=timers.target
EOF" EOF"
execute "$RELOAD" && "${RELOAD[@]}" &&
execute "$ENABLE" "$TIMER_NAME" "${ENABLE[@]}" "$TIMER_NAME"
} }
@@ -1612,20 +1614,22 @@ uninstall() {
for i in user system; do for i in user system; do
setServiceVars "$service" "$i"; setServiceVars "$service" "$i";
for unit in "$SERVICE_NAME" "$TIMER_NAME"; do for unit in "$SERVICE_NAME" "$TIMER_NAME"; do
if execute "$IS_ACTIVE" "$unit" || if "${IS_ACTIVE[@]}" "$unit" ||
execute "$IS_ENABLED" "$unit"; then "${IS_ENABLED[@]}" "$unit"; then
execute "$DISABLE" "$unit" "${DISABLE[@]}" "$unit"
fi fi
done done
for f in "$SERVICE_FNAME" "$TIMER_FNAME"; do for f in "$SERVICE_FNAME" "$TIMER_FNAME"; do
[[ -f "$f" ]] && [[ -f "$f" ]] &&
execute sudo rm -f "$f" execute sudo rm -f "$f"
done done
execute "$RELOAD" "${RELOAD[@]}"
unset f
done done
for f in /etc/systemd/system/jriver-*; do for f in /etc/systemd/system/jriver-*; do
execute sudo rm -f "$f" execute sudo rm -f "$f"
done done
unset f
done done
echo "Removing repo files" echo "Removing repo files"
@@ -1648,7 +1652,7 @@ uninstall() {
fi fi
echo "Uninstalling JRiver Media Center package" echo "Uninstalling JRiver Media Center package"
if execute "${PKG_REMOVE[@]}" "$MCPKG"; then if "${PKG_REMOVE[@]}" "$MCPKG"; then
echo "JRiver Media Center has been completely uninstalled" echo "JRiver Media Center has been completely uninstalled"
echo "To remove your library files, run: rm -rf $HOME/.jriver" echo "To remove your library files, run: rm -rf $HOME/.jriver"
elif [[ $? -eq 100 ]]; then elif [[ $? -eq 100 ]]; then