publish.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. mkdir -p models
  3. # download binaries
  4. function process_line {
  5. local url=$1
  6. local checksum=$2
  7. # Get the filename from the URL
  8. local filename=models/$(basename $url)
  9. # If the file exists, compute its checksum
  10. if [ -f $filename ]; then
  11. local existing_checksum=$(shasum -a 256 $filename | cut -d ' ' -f1)
  12. fi
  13. # If the file does not exist, or its checksum does not match, download it
  14. if [ ! -f $filename ] || [ $existing_checksum != $checksum ]; then
  15. echo "downloading $filename..."
  16. # Download the file
  17. curl -L $url -o $filename
  18. # Compute the SHA256 hash of the downloaded file
  19. local computed_checksum=$(shasum -a 256 $filename | cut -d ' ' -f1)
  20. # Verify the checksum
  21. if [ $computed_checksum != $checksum ]; then
  22. echo "Checksum verification failed for $filename"
  23. exit 1
  24. fi
  25. fi
  26. }
  27. while IFS=' ' read -r url checksum
  28. do
  29. process_line $url $checksum
  30. done < "downloads"
  31. # create and publish the models
  32. for file in modelfiles/*; do
  33. if [ -f "$file" ]; then
  34. filename=$(basename "$file")
  35. echo $filename
  36. ollama create "library/${filename}" -f "$file"
  37. ollama push "${filename}"
  38. fi
  39. done