-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·90 lines (81 loc) · 2.48 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
# Ensure NVM is loaded
export NVM_DIR="$HOME/.nvm"
if [ -s "$NVM_DIR/nvm.sh" ]; then
. "$NVM_DIR/nvm.sh" # This loads nvm
fi
if [ -s "$NVM_DIR/bash_completion" ]; then
. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
fi
# Source the appropriate shell configuration file
source_shell_config() {
if [ -n "$ZSH_VERSION" ]; then
# Running in Zsh
if [ -f "$HOME/.zshrc" ]; then
source "$HOME/.zshrc"
else
echo "Warning: ~/.zshrc not found. Skipping."
fi
elif [ -n "$BASH_VERSION" ]; then
# Running in Bash
if [ -f "$HOME/.bashrc" ]; then
source "$HOME/.bashrc"
elif [ -f "$HOME/.bash_profile" ]; then
source "$HOME/.bash_profile"
else
echo "Warning: Neither ~/.bashrc nor ~/.bash_profile found. Skipping."
fi
else
echo "Unsupported shell. Please ensure you're using Bash or Zsh."
exit 1
fi
}
# Ensure the script runs in the appropriate shell
if [ "$SHELL" = "/bin/zsh" ]; then
echo "Running in Zsh."
elif [ "$SHELL" = "/bin/bash" ]; then
echo "Running in Bash."
else
exec /bin/zsh "$0"
fi
# Fetch the most current version of the repository
echo "Fetching the latest version of the repository..."
git pull --quiet
if [ $? -eq 0 ]; then
echo "Repository updated successfully."
if command -v npm >/dev/null 2>&1 || [ ! -f dist/index.html ]; then
echo "Setting up Node environment..."
curl -s -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source_shell_config
nvm install --lts >/dev/null 2>&1
npm install --force --silent >/dev/null 2>&1
npm run format --silent
npm run build --silent
echo "Node environment setup complete."
else
echo "npm is not installed. Please install npm to proceed."
exit 1
fi
else
echo "Repository is already up to date."
fi
# Check for and create virtual environment if necessary
if [ ! -d ".venv" ]; then
echo "Virtual environment not found. Creating one..."
uv venv -p 3.12 .venv >/dev/null 2>&1
echo "Virtual environment created successfully."
else
echo "Virtual environment already exists."
fi
# Activate the virtual environment
. .venv/bin/activate
# Install dependencies
echo "Installing Python dependencies..."
uv pip install -U syftbox >/dev/null 2>&1
uv pip install -r api/requirements.txt >/dev/null 2>&1
echo "Python dependencies installed."
# Run the application
echo "Running ring with $(python3 --version) at '$(which python3)'"
python3 api/main.py
# Deactivate the virtual environment
deactivate