Fixes in scripts

This commit is contained in:
Antonio de la Rosa 2025-04-07 17:50:23 +02:00
parent 9690b65a09
commit d3d3483d0b
3 changed files with 19 additions and 12 deletions

View file

@ -13,7 +13,7 @@ LOG_FILE="/tmp/incus_ollama_install.log"
# Función para mostrar mensajes de error y salir
die () {
echo "${RED}Error: $1${NC}" >&2
echo -e "${RED}Error: $1${NC}" >&2
exit 1
}
@ -22,7 +22,7 @@ run_command() {
local cmd="$1"
local description="$2"
echo "${YELLOW}Ejecutando: ${description}...${NC}"
echo -e "${YELLOW}Ejecutando: ${description}...${NC}"
echo "Comando: ${cmd}\n" >> "${LOG_FILE}"
eval "${cmd} < /dev/null" >> "${LOG_FILE}" 2>&1
@ -32,7 +32,7 @@ run_command() {
}
echo "Instalando Incus"
echo -e "${YELLOW}Instalando Incus"
# Configuración (puedes modificar estos valores)
STORAGE_POOL="default"
@ -44,10 +44,10 @@ NETWORK_DHCP_RANGE="10.0.0.2-10.0.0.254"
NETWORK_DHCP_STATIC="10.0.0.1"
TRUST_PASSWORD="" # Déjalo vacío para no configurar contraseña
echo "${YELLOW}Inicializando Incus con la siguiente configuración:${NC}"
echo -e "${YELLOW}Inicializando Incus con la siguiente configuración:${NC}"
echo " - Pool de almacenamiento: $STORAGE_POOL ($STORAGE_DRIVER)"
echo " - Red: $NETWORK_NAME ($NETWORK_TYPE, $NETWORK_ADDR)"
echo "${YELLOW}Esto configurará Incus con valores por defecto.${NC}"
echo -e "${YELLOW}Esto configurará Incus con valores por defecto.${NC}"
# Confirmar antes de continuar
#read -p "¿Deseas continuar? (y/N) " -n 1 -r
@ -58,7 +58,7 @@ echo "${YELLOW}Esto configurará Incus con valores por defecto.${NC}"
#fi
# Ejecutar incus admin init con las configuraciones
echo "${YELLOW}Inicializando Incus...${NC}"
echo -e "${YELLOW}Inicializando Incus...${NC}"
cat <<EOF | incus admin init --minimal
config:
@ -89,8 +89,8 @@ EOF
# Verificar si la inicialización fue exitosa
if [ $? -eq 0 ]; then
echo "${GREEN}¡Incus se ha inicializado correctamente!${NC}"
echo "Puedes ver la información con: ${YELLOW}incus info${NC}"
echo -e "${GREEN}¡Incus se ha inicializado correctamente!${NC}"
echo -e "Puedes ver la información con: ${YELLOW}incus info${NC}"
else
die "Hubo un problema al inicializar Incus"
fi
@ -106,7 +106,7 @@ IMAGE="images:debian/12"
#incus launch "${IMAGE}" "ollama-container" < /dev/null
run_command "incus launch ${IMAGE} ollama-container" "Crear contenedor Ollama"
echo "Adding gpu to container"
echo -e "${YELLOW}Adding gpu to container${NC}"
incus restart ollama-container
@ -169,9 +169,9 @@ echo "Install Ollama in container ollama-container"
#run_command "incus exec ollama-container -- apt -y install curl " ""
run_command "incus exec ollama-container -- bash -c 'curl -fsSL https://ollama.com/install.sh | sh'" "Installing Ollama..."
run_command "incus exec ollama-container -- ollama run gemma3:4b" "Installing model gemma3:4b..."
run_command "incus exec ollama-container -- ollama pull gemma3:4b" "Installing model gemma3:4b..."
echo "Done!!!"
echo -e "${GREEN}Done!!!${NC}"
sleep 3

View file

@ -6,6 +6,8 @@
echo "Install new repos for debian..."
sudo apt -y install gpg
sudo bash -c 'echo "deb http://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware" > /etc/apt/sources.list.d/backports.list'
sudo curl -fsSL https://pkgs.zabbly.com/key.asc | gpg --show-keys --fingerprint
@ -25,7 +27,7 @@ Signed-By: /etc/apt/keyrings/zabbly.asc
EOF'
sudo apt install -y software-properties-common
sudo apt install -y software-properties-common
sudo apt-add-repository -y contrib
@ -72,3 +74,6 @@ sudo apt -y install incus
sudo usermod -a -G incus,incus-admin $USER
echo "Please, reboot the server..."

View file

@ -11,6 +11,8 @@ You need execute two scripts. First script, prepare the baremetal server for use
curl -fsSL https://git.cuchulu.com/smartest/aiscripts/raw/branch/master/install_nvidia.sh | bash
```
Reboot the server for the next script.
```sh
curl -fsSL https://git.cuchulu.com/smartest/aiscripts/raw/branch/master/install_incus_ollama.sh | bash
```