From c00256f7238c2ee81bb3f542764ec1ec78209130 Mon Sep 17 00:00:00 2001 From: Niels Geens Date: Tue, 1 Apr 2025 16:30:42 +0200 Subject: [PATCH] Clean up install script --- scripts/add_to_environment.sh | 18 ++++++++++++++++++ scripts/bootstrap.sh | 1 + scripts/install.sh | 25 +++---------------------- 3 files changed, 22 insertions(+), 22 deletions(-) create mode 100644 scripts/add_to_environment.sh diff --git a/scripts/add_to_environment.sh b/scripts/add_to_environment.sh new file mode 100644 index 0000000..81bd81a --- /dev/null +++ b/scripts/add_to_environment.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +add_to_environment() { + local path="$1" + # Check if the path is already in the environment file + if ! grep -q "$path" /etc/environment; then + # Get current PATH from environment file + current_path=$(grep "^PATH=" /etc/environment | cut -d'"' -f2) + + if [ -z "$current_path" ]; then + # If PATH doesn't exist in the file, create it + echo "PATH=\"\$PATH:$path\"" >> /etc/environment + else + # Replace existing PATH line with updated one + sed -i "s|^PATH=.*|PATH=\"$path:$current_path\"|" /etc/environment + fi + fi +} \ No newline at end of file diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 21efb4f..ef41e4f 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -61,6 +61,7 @@ ln -s "/root/sia/web/dist" "/root/static" # Install SIA dependencies source "/root/sia/scripts/install.sh" +source "/etc/environment" ## Finetune model #echo "Finetuning model..." diff --git a/scripts/install.sh b/scripts/install.sh index dc25a33..53630a6 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,36 +1,17 @@ #!/bin/bash -add_to_environment() { - local path="$1" - # Check if the path is already in the environment file - if ! grep -q "$path" /etc/environment; then - # Get current PATH from environment file - current_path=$(grep "^PATH=" /etc/environment | cut -d'"' -f2) - - if [ -z "$current_path" ]; then - # If PATH doesn't exist in the file, create it - echo "PATH=\"\$PATH:$path\"" >> /etc/environment - else - # Replace existing PATH line with updated one - sed -i "s|^PATH=.*|PATH=\"$path:$current_path\"|" /etc/environment - fi - fi -} - echo "Installing ITB tool..." python3 -m venv "/root/venvs/itb" /root/venvs/itb/bin/pip install -e /root/sia/tools/itb/ -add_to_environment "/root/venvs/itb/bin" +/root/sia/scripts/add_to_environment "/root/venvs/itb/bin" echo "Installing Train tool..." python3 -m venv "/root/venvs/train" /root/venvs/train/bin/pip install -e /root/sia/tools/train/ /root/venvs/train/bin/ipython kernel install --name=train -add_to_environment "/root/venvs/train/bin" +/root/sia/scripts/add_to_environment "/root/venvs/train/bin" echo "Installing SIA core..." python3 -m venv "/root/venvs/sia" /root/venvs/sia/bin/pip install -e /root/sia/ -add_to_environment "/root/venvs/sia/bin" - -source "/etc/environment \ No newline at end of file +/root/sia/scripts/add_to_environment "/root/venvs/sia/bin" \ No newline at end of file