publish.sh 1.26 KB
Newer Older
Jeffrey Morgan's avatar
Jeffrey Morgan committed
1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/bash

mkdir -p models

# download binaries
function process_line {
    local url=$1
    local checksum=$2

    # Get the filename from the URL
    local filename=models/$(basename $url)

13
    echo "verifying $filename..."
Jeffrey Morgan's avatar
Jeffrey Morgan committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

    # If the file exists, compute its checksum
    if [ -f $filename ]; then
        local existing_checksum=$(shasum -a 256 $filename | cut -d ' ' -f1)
    fi

    # If the file does not exist, or its checksum does not match, download it
    if [ ! -f $filename ] || [ $existing_checksum != $checksum ]; then
        echo "downloading $filename..."
        
        # Download the file
        curl -L $url -o $filename

        # Compute the SHA256 hash of the downloaded file
        local computed_checksum=$(shasum -a 256 $filename | cut -d ' ' -f1)

        # Verify the checksum
        if [ $computed_checksum != $checksum ]; then
            echo "Checksum verification failed for $filename"
            exit 1
        fi
    fi
}

while IFS=' ' read -r url checksum
do
    process_line $url $checksum
done < "downloads"

# create and publish the models
for file in modelfiles/*; do
  if [ -f "$file" ]; then
    filename=$(basename "$file")
    echo $filename
    ollama create "library/${filename}" -f "$file"
    ollama push "${filename}"
  fi
done