More improvements to bootstrap
This commit is contained in:
@@ -1,8 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# bootstrap.sh - Initialize SIA (Self-Improving Agent) environment for cloud deployment
|
|
||||||
|
|
||||||
set -eo pipefail # Exit on any error, pipe failures
|
set -eo pipefail # Exit on any error, pipe failures
|
||||||
|
|
||||||
|
# Check if required environment variables are set
|
||||||
|
if [ -z "$SIA_REPO_URL" ]; then
|
||||||
|
echo "Error: SIA_REPO_URL environment variable is not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Create directory structure
|
# Create directory structure
|
||||||
echo "Creating directory structure..."
|
echo "Creating directory structure..."
|
||||||
mkdir -p "/root/data/iterations"
|
mkdir -p "/root/data/iterations"
|
||||||
@@ -29,10 +34,14 @@ npm install
|
|||||||
npm run build
|
npm run build
|
||||||
ln -s "/root/sia/web/dist" "/root/static"
|
ln -s "/root/sia/web/dist" "/root/static"
|
||||||
|
|
||||||
|
# Install SIA dependencies
|
||||||
|
echo "Installing SIA dependencies..."
|
||||||
|
"/root/sia/scripts/install.sh"
|
||||||
|
|
||||||
# Finetune model
|
# Finetune model
|
||||||
echo "Finetuning model..."
|
echo "Finetuning model..."
|
||||||
train
|
train
|
||||||
|
|
||||||
# Start SIA using restart script
|
# Start SIA using restart script
|
||||||
echo "Start restart script..."
|
echo "Run restart script..."
|
||||||
"/root/sia/scripts/restart.sh"
|
"/root/sia/scripts/restart.sh"
|
||||||
@@ -7,14 +7,9 @@ if [ -z "$SIA_GITHUB_API_KEY" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$SIA_REPO_URL" ]; then
|
|
||||||
echo "Error: SIA_REPO_URL environment variable is not set"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y jq
|
apt-get install -y jq openssh-client git
|
||||||
|
|
||||||
# Create SSH directory if it doesn't exist
|
# Create SSH directory if it doesn't exist
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
@@ -26,6 +21,10 @@ if [ ! -f ~/.ssh/sia_repo ]; then
|
|||||||
ssh-keygen -t ed25519 -f ~/.ssh/sia_repo -N ""
|
ssh-keygen -t ed25519 -f ~/.ssh/sia_repo -N ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Ensure proper permissions on SSH keys
|
||||||
|
chmod 600 ~/.ssh/sia_repo
|
||||||
|
chmod 644 ~/.ssh/sia_repo.pub
|
||||||
|
|
||||||
# Get the public key
|
# Get the public key
|
||||||
SSH_PUBLIC_KEY=$(cat ~/.ssh/sia_repo.pub)
|
SSH_PUBLIC_KEY=$(cat ~/.ssh/sia_repo.pub)
|
||||||
|
|
||||||
@@ -54,3 +53,30 @@ curl -X POST "https://api.github.com/user/keys" \
|
|||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Authorization: token $SIA_GITHUB_API_KEY" \
|
-H "Authorization: token $SIA_GITHUB_API_KEY" \
|
||||||
-d "{\"title\":\"sia\", \"key\":\"$SSH_PUBLIC_KEY\"}"
|
-d "{\"title\":\"sia\", \"key\":\"$SSH_PUBLIC_KEY\"}"
|
||||||
|
|
||||||
|
# Create SSH config file to specify which key to use for GitHub
|
||||||
|
echo "Configuring SSH to use the correct key for GitHub..."
|
||||||
|
cat > ~/.ssh/config << EOF
|
||||||
|
Host github.com
|
||||||
|
HostName github.com
|
||||||
|
User git
|
||||||
|
IdentityFile ~/.ssh/sia_repo
|
||||||
|
IdentitiesOnly yes
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod 600 ~/.ssh/config
|
||||||
|
|
||||||
|
# Start SSH agent and add the key
|
||||||
|
eval $(ssh-agent -s)
|
||||||
|
ssh-add ~/.ssh/sia_repo
|
||||||
|
|
||||||
|
# Ensure git is configured with a name and email
|
||||||
|
if ! git config --global user.email > /dev/null; then
|
||||||
|
echo "Configuring default git user email..."
|
||||||
|
git config --global user.email "niels.geens@gmail.com"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! git config --global user.name > /dev/null; then
|
||||||
|
echo "Configuring default git user name..."
|
||||||
|
git config --global user.name "Niels Geens"
|
||||||
|
fi
|
||||||
13
scripts/install.sh
Normal file
13
scripts/install.sh
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Installing ITB tool..."
|
||||||
|
python3 -m venv "/root/venvs/itb"
|
||||||
|
/root/venvs/itb/bin/pip install -e /root/sia/tools/itb/
|
||||||
|
|
||||||
|
echo "Installing Train tool..."
|
||||||
|
python3 -m venv "/root/venvs/train"
|
||||||
|
/root/venvs/train/bin/pip install -e /root/sia/tools/train/
|
||||||
|
|
||||||
|
echo "Installing SIA core..."
|
||||||
|
python3 -m venv "/root/venvs/sia"
|
||||||
|
/root/venvs/sia/bin/pip install -e /root/sia/
|
||||||
@@ -2,24 +2,9 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "=== Preparing SIA environment ==="
|
|
||||||
|
|
||||||
echo "Installing ITB tool..."
|
|
||||||
python3 -m venv "/root/venvs/itb"
|
|
||||||
/root/venvs/itb/bin/pip install -e /root/sia/tools/itb/
|
|
||||||
|
|
||||||
echo "Installing Train tool..."
|
|
||||||
python3 -m venv "/root/venvs/train"
|
|
||||||
/root/venvs/train/bin/pip install -e /root/sia/tools/train/
|
|
||||||
|
|
||||||
echo "Installing SIA core..."
|
|
||||||
python3 -m venv "/root/venvs/sia"
|
|
||||||
/root/venvs/sia/bin/pip install -e /root/sia/
|
|
||||||
|
|
||||||
echo "=== Starting SIA ==="
|
|
||||||
|
|
||||||
cd "/root/desktop"
|
cd "/root/desktop"
|
||||||
while true; do
|
while true; do
|
||||||
|
"/root/sia/scripts/init.sh"
|
||||||
sia
|
sia
|
||||||
EXIT_CODE=$?
|
EXIT_CODE=$?
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user