publish.sh 1.3 KB

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