Files
SIA/scripts/bootstrap.sh
2025-04-29 14:57:15 +00:00

119 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
#SIA_INSTALL_NO_ITB=1
#SIA_INSTALL_NO_TRAIN=1
#SIA_INSTALL_NO_NOTEBOOK=1
#SIA_INSTALL_NO_CORE=1
#SIA_BOOTSTRAP_NO_TRAIN=1
#SIA_BOOTSTRAP_NO_START=1
trap 'return 1' ERR
# Check if required environment variables are set
if [ -z "$SIA_REPO_URL" ]; then
echo "Error: SIA_REPO_URL environment variable is not set"
return 1
fi
if [ -z "$SIA_REPO_USER" ]; then
echo "Error: SIA_REPO_USER environment variable is not set"
return 1
fi
if [ -z "$SIA_REPO_PAT" ]; then
echo "Error: SIA_REPO_PAT environment variable is not set"
return 1
fi
# Install required packages
apt-get update
apt-get install -y \
build-essential \
git \
gnupg \
python3-dev \
python3-venv \
vim \
wget \
;
# Install Chrome
if [ -z "${SIA_INSTALL_NO_ITB}" ]; then
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
apt-get update && \
apt-get install -y \
google-chrome-stable
fi
# Install Rust
if [ -z "${SIA_INSTALL_NO_TRAIN}" ]; then
curl https://sh.rustup.rs -sSf | bash -s -- -y
export PATH="/root/.cargo/bin:${PATH}"
fi
# Install Node.js
if [ -z "${SIA_INSTALL_NO_CORE}" ]; then
echo "Installing Node.js..."
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
export NVM_DIR="/root/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install node
fi
# Create directory structure
echo "Creating directory structure..."
mkdir -p "/root/data/iterations"
mkdir -p "/root/desktop"
mkdir -p "/root/venvs"
# Clone SIA repository
if [ ! -d "/root/sia" ]; then
echo "Cloning SIA repository..."
git clone "https://$SIA_REPO_USER:$SIA_REPO_PAT@${SIA_REPO_URL#https://}" "/root/sia"
echo "Configuring git user and email..."
cd "/root/sia"
git config --global user.name "Niels Geens"
git config --global user.email "niels.geens@gmail.com"
git config --global core.editor vim
fi
# Build web interface
if [ -z "${SIA_INSTALL_NO_CORE}" ]; then
echo "Building web interface"
cd "/root/sia/web"
npm install
npm run build
ln -s "/root/sia/web/dist" "/root/static"
fi
# Install SIA dependencies
cd /root/desktop
source "/root/sia/scripts/install.sh"
# Add venvs to path in .bashrc
if ! grep -q "source /root/sia/scripts/add_venvs_to_path.sh" /root/.bashrc; then
echo 'source /root/sia/scripts/add_venvs_to_path.sh' >> /root/.bashrc
fi
# Add venvs to path in profile
if ! grep -q "source /root/sia/scripts/add_venvs_to_path.sh" /etc/profile; then
echo 'source /root/sia/scripts/add_venvs_to_path.sh' >> /etc/profile
fi
# Add venvs to path in current shell
source /root/sia/scripts/add_venvs_to_path.sh
# Finetune model
if [ -z "${SIA_BOOTSTRAP_NO_TRAIN}" ]; then
echo "Finetuning model..."
train /root/models/bootstrap
ln -s /root/models/bootstrap /root/models/current
fi
# Start SIA using restart script
if [ -z "${SIA_BOOTSTRAP_NO_START}" ]; then
echo "Run restart script..."
"/root/sia/scripts/restart.sh"
fi