This commit is contained in:
Eric Platon 2026-01-06 08:25:48 +01:00 committed by GitHub
commit 4aa57e12ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 30 additions and 11 deletions

View File

@ -11,9 +11,24 @@ status() { echo ">>> $*" >&2; }
error() { echo "${red}ERROR:${plain} $*"; exit 1; } error() { echo "${red}ERROR:${plain} $*"; exit 1; }
warning() { echo "${red}WARNING:${plain} $*"; } warning() { echo "${red}WARNING:${plain} $*"; }
TEMP_DIR=$(mktemp -d) TEMP_ROOT_DIR=/tmp/ollama
cleanup() { rm -rf $TEMP_DIR; } TEMP_DIR=${TEMP_ROOT_DIR}/install
trap cleanup EXIT mkdir -p $TEMP_DIR
cleanup () {
if [ -n "$1" ]; then
>&2 echo "Aborted by $1"
elif [ $status -ne 0 ]; then
>&2 echo "Failure (status $status). Current progress can be resumed and available in ${TEMP_DIR}"
else
rm -rf $TEMP_DIR
# If install is the only tmp content, remove all traces
rmdir --ignore-fail-on-non-empty $TEMP_ROOT_DIR || true
fi
}
trap 'status=$?; cleanup ""; exit $status' EXIT
trap 'trap - HUP; cleanup SIGHUP; kill -HUP $$' HUP
trap 'trap - INT; cleanup SIGINT; kill -INT $$' INT
trap 'trap - TERM; cleanup SIGTERM; kill -TERM $$' TERM
available() { command -v $1 >/dev/null; } available() { command -v $1 >/dev/null; }
require() { require() {
@ -80,8 +95,9 @@ $SUDO install -o0 -g0 -m755 -d $BINDIR
$SUDO install -o0 -g0 -m755 -d "$OLLAMA_INSTALL_DIR/lib/ollama" $SUDO install -o0 -g0 -m755 -d "$OLLAMA_INSTALL_DIR/lib/ollama"
status "Downloading Linux ${ARCH} bundle" status "Downloading Linux ${ARCH} bundle"
curl --fail --show-error --location --progress-bar \ curl --fail --show-error --location --progress-bar \
"https://ollama.com/download/ollama-linux-${ARCH}.tgz${VER_PARAM}" | \ --output-dir $TEMP_DIR --continue-at - --remote-name \
$SUDO tar -xzf - -C "$OLLAMA_INSTALL_DIR" "https://ollama.com/download/ollama-linux-${ARCH}.tgz${VER_PARAM}"
$SUDO tar -xzf "${TEMP_DIR}/ollama-linux-${ARCH}.tgz${VER_PARAM}" -C "$OLLAMA_INSTALL_DIR"
if [ "$OLLAMA_INSTALL_DIR/bin/ollama" != "$BINDIR/ollama" ] ; then if [ "$OLLAMA_INSTALL_DIR/bin/ollama" != "$BINDIR/ollama" ] ; then
status "Making ollama accessible in the PATH in $BINDIR" status "Making ollama accessible in the PATH in $BINDIR"
@ -93,13 +109,15 @@ if [ -f /etc/nv_tegra_release ] ; then
if grep R36 /etc/nv_tegra_release > /dev/null ; then if grep R36 /etc/nv_tegra_release > /dev/null ; then
status "Downloading JetPack 6 components" status "Downloading JetPack 6 components"
curl --fail --show-error --location --progress-bar \ curl --fail --show-error --location --progress-bar \
"https://ollama.com/download/ollama-linux-${ARCH}-jetpack6.tgz${VER_PARAM}" | \ --output-dir $TEMP_DIR --continue-at - --remote-name \
$SUDO tar -xzf - -C "$OLLAMA_INSTALL_DIR" "https://ollama.com/download/ollama-linux-${ARCH}-jetpack6.tgz${VER_PARAM}"
$SUDO tar -xzf "${TEMP_DIR}/ollama-linux-${ARCH}.tgz${VER_PARAM}" -C "$OLLAMA_INSTALL_DIR"
elif grep R35 /etc/nv_tegra_release > /dev/null ; then elif grep R35 /etc/nv_tegra_release > /dev/null ; then
status "Downloading JetPack 5 components" status "Downloading JetPack 5 components"
curl --fail --show-error --location --progress-bar \ curl --fail --show-error --location --progress-bar \
"https://ollama.com/download/ollama-linux-${ARCH}-jetpack5.tgz${VER_PARAM}" | \ --output-dir $TEMP_DIR --continue-at - --remote-name \
$SUDO tar -xzf - -C "$OLLAMA_INSTALL_DIR" "https://ollama.com/download/ollama-linux-${ARCH}-jetpack5.tgz${VER_PARAM}"
$SUDO tar -xzf "${TEMP_DIR}/ollama-linux-${ARCH}-jetpack5.tgz${VER_PARAM}" -C "$OLLAMA_INSTALL_DIR"
else else
warning "Unsupported JetPack version detected. GPU may not be supported" warning "Unsupported JetPack version detected. GPU may not be supported"
fi fi
@ -224,8 +242,9 @@ fi
if check_gpu lspci amdgpu || check_gpu lshw amdgpu; then if check_gpu lspci amdgpu || check_gpu lshw amdgpu; then
status "Downloading Linux ROCm ${ARCH} bundle" status "Downloading Linux ROCm ${ARCH} bundle"
curl --fail --show-error --location --progress-bar \ curl --fail --show-error --location --progress-bar \
"https://ollama.com/download/ollama-linux-${ARCH}-rocm.tgz${VER_PARAM}" | \ --output-dir $TEMP_DIR --continue-at - --remote-name \
$SUDO tar -xzf - -C "$OLLAMA_INSTALL_DIR" "https://ollama.com/download/ollama-linux-${ARCH}-rocm.tgz${VER_PARAM}"
$SUDO tar -xzf "${TEMP_DIR}/ollama-linux-${ARCH}-rocm.tgz${VER_PARAM}" -C "$OLLAMA_INSTALL_DIR"
install_success install_success
status "AMD GPU ready." status "AMD GPU ready."