Advertisement
jcofer555

install jdupes

Jun 7th, 2025 (edited)
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.75 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Ensure extra folder on flash drive exists
  4. echo "Checking if extra exists on the flash drive"
  5. if [ -d "/boot/extra" ]; then
  6.     echo "Extra folder already exists on the flash drive"
  7. else
  8.     echo "Extra folder does not exist, Attempting to create it on the flash drive"
  9.     if mkdir -p "/boot/extra"; then
  10.         echo "Successfully created the extra folder on the flash drive"
  11.     else
  12.         echo "Failed to create the extra folder on the flash drive"
  13.         exit 1
  14.     fi
  15. fi
  16.  
  17. # Function to download a package if it doesn't already exist
  18. download_package() {
  19.     local pkg_name=$1
  20.     local pkg_url=$2
  21.     local pkg_path="/boot/extra/$pkg_name"
  22.  
  23.     if [ -f "$pkg_path" ]; then
  24.         echo "Package $pkg_name already exists in /boot/extra/, skipping download"
  25.     else
  26.         echo "Downloading $pkg_name"
  27.         if wget -q -O "$pkg_path" "$pkg_url"; then
  28.             echo "Successfully downloaded $pkg_name to the flash drive extra folder"
  29.         else
  30.             echo "Failed to download $pkg_name from $pkg_url"
  31.             return 1
  32.         fi
  33.     fi
  34. }
  35.  
  36. # Function to install a package after verifying it exists and format is correct
  37. install_package() {
  38.     local pkg_name=$1
  39.     local pkg_url=$2
  40.     local pkg_path="/boot/extra/$pkg_name"
  41.     local check_cmd=$3
  42.  
  43.     # Ensure the package exists before checking installation status
  44.     if [ -f "$pkg_path" ]; then
  45.         echo "Package $pkg_name already exists in /boot/extra"
  46.     else
  47.         echo "Package $pkg_name not found in /boot/extra/, attempting to download"
  48.         if ! download_package "$pkg_name" "$pkg_url"; then
  49.             echo "Failed to retrieve $pkg_name, aborting installation"
  50.             return 1
  51.         fi
  52.     fi
  53.  
  54.     # Check if the file is empty. If empty delete it and redownload
  55.     if [ ! -s "$pkg_path" ]; then
  56.         echo "Error: $pkg_name exists but is empty. Deleting and redownloading"
  57.         rm -f "$pkg_path"
  58.         if ! download_package "$pkg_name" "$pkg_url"; then
  59.             echo "Failed to re-download $pkg_name, aborting installation"
  60.             return 1
  61.         fi
  62.     else
  63.         echo "Package $pkg_name is valid"
  64.     fi
  65.  
  66.     # Verify the package format. If incorrect delete it and redownload
  67.     if file "$pkg_path" | grep -q 'XZ compressed data\|gzip compressed data'; then
  68.         echo "Package $pkg_name format is correct."
  69.     else
  70.         echo "Error: $pkg_name does not appear to be a valid Slackware package. Deleting and redownloading"
  71.         rm -f "$pkg_path"
  72.         if ! download_package "$pkg_name" "$pkg_url"; then
  73.             echo "Failed to re-download $pkg_name, aborting installation"
  74.             return 1
  75.         fi
  76.     fi
  77.  
  78.     # Check if package is already installed before proceeding
  79.     if eval "$check_cmd"; then
  80.         echo "$pkg_name is already installed, skipping installation"
  81.         return 0
  82.     fi
  83.  
  84.     # Attempt installation
  85.     echo "Installing $pkg_name..."
  86.     if installpkg "$pkg_path" >/dev/null 2>&1; then
  87.         echo "$pkg_name has been successfully installed"
  88.     else
  89.         echo "Failed to install $pkg_name"
  90.         return 1
  91.     fi
  92. }
  93.  
  94. # Define package variables
  95. libjody_pkg="libjodycode-3.1.1-x86_64-2_SBo.tgz"
  96. libjody_url="https://github.com/jcofer555/unraid_packages/raw/refs/heads/main/libjodycode-3.1.1-x86_64-2_SBo.tgz"
  97. libjody_check="ldconfig -p | grep -q libjodycode.so.3"
  98.  
  99. jdupes_pkg="jdupes-1.28.0-x86_64-2_SBo.tgz"
  100. jdupes_url="https://github.com/jcofer555/unraid_packages/raw/refs/heads/main/jdupes-1.28.0-x86_64-2_SBo.tgz"
  101. jdupes_check="which jdupes >/dev/null 2>&1"
  102.  
  103. # Install libjodycode if missing
  104. install_package "$libjody_pkg" "$libjody_url" "$libjody_check"
  105.  
  106. # Install jdupes if missing
  107. install_package "$jdupes_pkg" "$jdupes_url" "$jdupes_check"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement