7 Commits 188269e522 ... 7d0570daff

Author SHA1 Message Date
  bryan 7d0570daff 1.4.5 release 1 week ago
  bryan a0987475d6 Add disclaimer to beta channels 1 week ago
  bryan 7f79f455a0 use noble repos on oracular 1 week ago
  bryan e4babab87f Install JRiver signing key on new Ubuntu 1 week ago
  bryan 4fc9a8380f Fix repo file creation 1 week ago
  bryan a03cd1bc84 Fix repo file creation 1 week ago
  bryan 11d3f1acb6 Only use beta repo when --betapass is passed, and prefer it 1 week ago
1 changed files with 47 additions and 16 deletions
  1. 47 16
      installJRMC

+ 47 - 16
installJRMC

@@ -18,7 +18,7 @@
 # * Be careful with tabs in heredocs
 shopt -s extglob
 
-declare -g SCRIPT_VERSION="1.4.4"
+declare -g SCRIPT_VERSION="1.4.5"
 declare -g MC_REPO="bullseye" # should match the MC_VERSION
 declare -g MC_VERSION="33.0.37" # Do find all replace
 declare -g BOARD_URL="https://yabb.jriver.com/interact/index.php/board,86.0.html" # MC33
@@ -114,10 +114,9 @@ print_help() {
 parse_input() {
   debug "Running: ${FUNCNAME[0]} $*"
   declare -g BUILD_SWITCH REPO_INSTALL_SWITCH LOCAL_INSTALL_SWITCH \
-    COMPAT_SWITCH CREATEREPO_SWITCH UNINSTALL_SWITCH \
+    CONTAINER_INSTALL_SWITCH COMPAT_SWITCH CREATEREPO_SWITCH UNINSTALL_SWITCH \
     YES_SWITCH USER_MC_VERSION USER_MC_REPO MJR_FILE \
-    BETAPASS SERVICE_TYPE VNCPASS USER_DISPLAY \
-    BUILD_TARGET CREATEREPO_TARGET
+    BETAPASS SERVICE_TYPE VNCPASS USER_DISPLAY BUILD_TARGET CREATEREPO_TARGET
   local long_opts short_opts input
   long_opts="install:,build::,outputdir:,mcversion:,arch:,mcrepo:,compat,"
   long_opts+="restorefile:,betapass:,"
@@ -139,6 +138,8 @@ parse_input() {
           case $1 in
             local|rpm|deb) BUILD_SWITCH=1; LOCAL_INSTALL_SWITCH=1 ;;
             repo|remote) REPO_INSTALL_SWITCH=1 ;;
+            container) CONTAINER_INSTALL_SWITCH=1 ;;
+            *) err "Invalid --install option passed"; exit 1 ;;
           esac
           ;;
         --build|-b) BUILD_SWITCH=1; shift; BUILD_TARGET="$1" ;;
@@ -201,6 +202,15 @@ parse_input() {
   if [[ -n $USER_MC_REPO ]] && ((LOCAL_INSTALL_SWITCH)); then
     err "--install=local is not compatible with --mcrepo as only the default ($MC_REPO) DEB is available"
   fi
+
+  if [[ -n $BETA_PASS ]] && ((REPO_INSTALL_SWITCH)); then
+    echo "Warning: not all repositories have beta channels"
+    echo "If the MC package is unavailable, try using --mcrepo to select another repository"
+  fi
+
+  if [[ -n $CONTAINER_INSTALL_SWITCH ]] && ((LOCAL_INSTALL_SWITCH || REPO_INSTALL_SWITCH)); then
+    err "Some --install methods are incompatible"
+  fi
 }
 
 # @description Perform OS detection and generate OS-specific functions
@@ -214,7 +224,7 @@ init() {
   declare -g CREATEREPO_WEBROOT="/var/www/jriver"
   declare -g CREATEREPO_USER="$USER" # can be root
   declare -g ID VERSION_ID ARCH NAME
-  declare -g MC_MVERSION MC_PKG MC_RPM MC_ROOT 
+  declare -g MC_MVERSION MC_PKG MC_RPM MC_ROOT
   declare -ga PKG_INSTALL PKG_REMOVE PKG_UPDATE PKG_QUERY
   declare -ga SERVICES CONTAINERS
 
@@ -584,7 +594,7 @@ install_mesa_freeworld() {
 # @description Installs JRiver Media Center from a remote repository
 install_mc_repo() {
   debug "Running: ${FUNCNAME[0]}"
-  local repo_file repo_text
+  local repo_file repo_text channel
 
   case $ID in
     fedora|centos)
@@ -597,28 +607,46 @@ install_mc_repo() {
 			EOF
       ;;
     debian|ubuntu)
+      [[ -n $BETAPASS ]] && channel="beta" || channel="latest"
       local major_version="${VERSION_ID%%.*}"
       local minor_version="${VERSION_ID##*.}"
       local keyfile="/usr/share/keyrings/jriver-com-archive-keyring.gpg"
       if [[ $ID == "ubuntu" ]] \
       && [[ $major_version -gt 24 || ($major_version -eq 24 && $minor_version -ge 10) ]]; then
-        repo_file="/etc/apt/sources.list.d/jriver.sources" # TODO new Ubuntu sources file format
-        local old_repo_file="/etc/apt/sources.list.d/jriver.list"
-        [[ -f $old_repo_file ]] && execute sudo rm -f "$old_repo_file"
+        if [[ $channel == "beta" ]]; then
+          repo_file="/etc/apt/sources.list.d/jriver-beta.sources"
+        else
+          repo_file="/etc/apt/sources.list.d/jriver.sources"
+        fi
+
+        old_repo_files=(
+          "/etc/apt/sources.list.d/jriver.list"
+          "/etc/apt/sources.list.d/jriver-beta.list"
+          "/etc/apt/sources.list.d/jriver_beta.list"
+        )
+
+        for f in "${old_repo_files[@]}"; do
+          [[ -f $f ]] && execute sudo rm -f "$f"
+        done
         read -r -d '' repo_text <<-EOF
 					Types: deb
-					URIs: http://dist.jriver.com/latest/mediacenter/
+					URIs: http://dist.jriver.com/$channel/mediacenter/
 					Signed-By: $keyfile
 					Suites: $MC_REPO
 					Components: main
 				EOF
       else
-        repo_file="/etc/apt/sources.list.d/jriver.list"
-        repo_text="deb [signed-by=$keyfile arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $MC_REPO main"
+        if [[ $channel == "beta" ]]; then
+          execute sudo rm -f "/etc/apt/sources.list.d/jriver_beta.list"
+          repo_file="/etc/apt/sources.list.d/jriver-beta.list"
+        else
+          repo_file="/etc/apt/sources.list.d/jriver.list"
+        fi
+        repo_text="deb [signed-by=$keyfile arch=amd64,i386,armhf,arm64] http://dist.jriver.com/$channel/mediacenter/ $MC_REPO main"
       fi
       echo "Installing JRiver Media Center RPM key"
       download "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" | 
-        gpg --dearmor | sudo tee "$keyfile" &>/dev/null
+      gpg --dearmor | sudo tee "$keyfile" &>/dev/null
       ;;
     *)
       err "An MC repository for $ID is not yet available"
@@ -628,6 +656,7 @@ install_mc_repo() {
   esac
 
   echo "Adding MC repository file: $repo_file"
+  debug "repo_text: $repo_text"
   sudo tee "$repo_file" &>/dev/null <<< "$repo_text"
 
   if ! "${PKG_UPDATE[@]}"; then
@@ -665,9 +694,11 @@ acquire_deb() {
   # Define the repositories to check
   local repos=(
     "https://files.jriver-cdn.com/mediacenter/channels/v$MC_MVERSION/latest/$fname"
-    "https://files.jriver-cdn.com/mediacenter/test/$fname"
-    "https://files.jriver-cdn.com/mediacenter/channels/v$MC_MVERSION/beta/$BETAPASS/$fname"
-  )
+    "https://files.jriver-cdn.com/mediacenter/test/$fname")
+
+  if [[ -n $BETAPASS ]]; then
+    repos=("https://files.jriver-cdn.com/mediacenter/channels/v$MC_MVERSION/beta/$BETAPASS/$fname" "${repos[@]}")
+  fi
 
   # Loop through the repositories and attempt to download
   for repo in "${repos[@]}"; do