Merge pull request #589 from jmorganca/mxyng/install.sh
update install.sh
This commit is contained in:
commit
ed94a3dd02
1 changed files with 21 additions and 11 deletions
|
@ -35,7 +35,7 @@ SUDO=
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
# Running as root, no need for sudo
|
# Running as root, no need for sudo
|
||||||
if ! command -v sudo >/dev/null; then
|
if ! command -v sudo >/dev/null; then
|
||||||
error "Ollama install.sh requires elevated privileges. Please re-run as root."
|
error "This script requires superuser permissions. Please re-run as root."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SUDO="sudo"
|
SUDO="sudo"
|
||||||
|
@ -43,7 +43,11 @@ fi
|
||||||
|
|
||||||
MISSING_TOOLS=$(required_tools curl awk grep sed tee xargs)
|
MISSING_TOOLS=$(required_tools curl awk grep sed tee xargs)
|
||||||
if [ -n "$MISSING_TOOLS" ]; then
|
if [ -n "$MISSING_TOOLS" ]; then
|
||||||
error "The following tools are required but missing: $MISSING_TOOLS"
|
status "ERROR: The following tools are required but missing:"
|
||||||
|
for MISSING_TOOL in $MISSING_TOOLS; do
|
||||||
|
echo " - $MISSING_TOOL"
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
status "Downloading ollama..."
|
status "Downloading ollama..."
|
||||||
|
@ -81,12 +85,15 @@ Environment="HOME=/usr/share/ollama"
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=default.target
|
WantedBy=default.target
|
||||||
EOF
|
EOF
|
||||||
if [ "$(systemctl is-system-running || echo 'not running')" = 'running' ]; then
|
SYSTEMCTL_RUNNING="$(systemctl is-system-running)"
|
||||||
status "Enabling and starting ollama service..."
|
case $SYSTEMCTL_RUNNING in
|
||||||
$SUDO systemctl daemon-reload
|
running|degraded)
|
||||||
$SUDO systemctl enable ollama
|
status "Enabling and starting ollama service..."
|
||||||
$SUDO systemctl restart ollama
|
$SUDO systemctl daemon-reload
|
||||||
fi
|
$SUDO systemctl enable ollama
|
||||||
|
$SUDO systemctl restart ollama
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
if command -v systemctl >/dev/null; then
|
if command -v systemctl >/dev/null; then
|
||||||
|
@ -118,7 +125,7 @@ install_cuda_driver_yum() {
|
||||||
$SUDO $PACKAGE_MANAGER-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/$1$2/$(uname -m)/cuda-$1$2.repo
|
$SUDO $PACKAGE_MANAGER-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/$1$2/$(uname -m)/cuda-$1$2.repo
|
||||||
;;
|
;;
|
||||||
dnf)
|
dnf)
|
||||||
$SUDO dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/$1$2/$(uname -m)/cuda-$1$2.repo
|
$SUDO $PACKAGE_MANAGER config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/$1$2/$(uname -m)/cuda-$1$2.repo
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -156,7 +163,9 @@ install_cuda_driver_apt() {
|
||||||
status 'Installing CUDA driver...'
|
status 'Installing CUDA driver...'
|
||||||
$SUDO dpkg -i $TEMP_DIR/cuda-keyring.deb
|
$SUDO dpkg -i $TEMP_DIR/cuda-keyring.deb
|
||||||
$SUDO apt-get update
|
$SUDO apt-get update
|
||||||
$SUDO DEBIAN_FRONTEND=noninteractive apt-get -y install cuda-drivers -q
|
|
||||||
|
[ -n "$SUDO" ] && SUDO_E="$SUDO -E" || SUDO_E=
|
||||||
|
DEBIAN_FRONTEND=noninteractive $SUDO_E apt-get -y install cuda-drivers -q
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ ! -f "/etc/os-release" ]; then
|
if [ ! -f "/etc/os-release" ]; then
|
||||||
|
@ -184,7 +193,8 @@ if ! check_gpu nvidia-smi || [ -z "$(nvidia-smi | grep -o "CUDA Version: [0-9]*\
|
||||||
centos|rhel) install_cuda_driver_yum 'rhel' $OS_VERSION ;;
|
centos|rhel) install_cuda_driver_yum 'rhel' $OS_VERSION ;;
|
||||||
rocky) install_cuda_driver_yum 'rhel' $(echo $OS_VERSION | cut -c1) ;;
|
rocky) install_cuda_driver_yum 'rhel' $(echo $OS_VERSION | cut -c1) ;;
|
||||||
fedora) install_cuda_driver_dnf $OS_NAME $OS_VERSION ;;
|
fedora) install_cuda_driver_dnf $OS_NAME $OS_VERSION ;;
|
||||||
debian|ubuntu) install_cuda_driver_apt $OS_NAME $OS_VERSION ;;
|
debian) install_cuda_driver_apt $OS_NAME $OS_VERSION ;;
|
||||||
|
ubuntu) install_cuda_driver_apt $OS_NAME $(echo $OS_VERSION | sed 's/\.//') ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue