Skip to content

Commit 9a8d364

Browse files
committed
feat: add automation installer script for SOC
1 parent f662505 commit 9a8d364

File tree

1 file changed

+167
-0
lines changed

1 file changed

+167
-0
lines changed

soc_installer.sh

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#!/bin/bash
2+
#
3+
# SOC Installer Script v0.0.1
4+
# GitHub: https://github.com/OthersideAI/self-operating-computer
5+
# Issues: https://github.com/OthersideAI/self-operating-computer/issues
6+
# Requires: bash, curl/wget, python3, pip, git
7+
#
8+
# Currently this only work on MacOS systems.
9+
# Please open an issue if you notice any bugs.
10+
#
11+
#
12+
# This script is create by centopw
13+
#
14+
#
15+
clear
16+
echo -e "\e[0m\c"
17+
LOG_FILE="install_log.txt"
18+
# shellcheck disable=SC2016
19+
echo '
20+
21+
$$$$$$\ $$$$$$\ $$$$$$\
22+
$$ __$$\ $$ __$$\ $$ __$$\
23+
$$ / \__|$$ / $$ |$$ / \__|
24+
\$$$$$$\ $$ | $$ |$$ |
25+
\____$$\ $$ | $$ |$$ |
26+
$$\ $$ |$$ | $$ |$$ | $$\
27+
\$$$$$$ | $$$$$$ |\$$$$$$ |
28+
\______/ \______/ \______/
29+
30+
Self-Operating-Computer
31+
--- Created by OthersideAI ---
32+
33+
'
34+
35+
36+
# Function to log errors
37+
log_error() {
38+
echo "Error at $(date): $1" >> "$LOG_FILE"
39+
}
40+
41+
# Function to check if a command exists
42+
command_exists() {
43+
command -v "$1" &> /dev/null
44+
}
45+
46+
# Function to install packages based on the operating system
47+
install_packages() {
48+
if [ "$os" == "Linux" ]; then
49+
# Use the appropriate package manager for Linux
50+
if command_exists apt-get; then
51+
sudo apt-get install -y "$1" || { log_error "Unable to install $1."; exit 1; }
52+
elif command_exists yum; then
53+
sudo yum install -y "$1" || { log_error "Unable to install $1."; exit 1; }
54+
else
55+
log_error "Unsupported package manager. Please install $1 manually."
56+
exit 1
57+
fi
58+
elif [ "$os" == "Darwin" ]; then
59+
# Use Homebrew for macOS
60+
if command_exists brew; then
61+
brew install "$1" || { log_error "Unable to install $1."; exit 1; }
62+
else
63+
log_error "Homebrew not found. Please install Homebrew and then $1 manually."
64+
exit 1
65+
fi
66+
elif [ "$os" == "MINGW64_NT-10.0" ]; then
67+
# Use Chocolatey for Windows
68+
if command_exists choco; then
69+
choco install "$1" -y || { log_error "Unable to install $1."; exit 1; }
70+
else
71+
log_error "Chocolatey not found. Please install Chocolatey and then $1 manually."
72+
exit 1
73+
fi
74+
else
75+
log_error "Unsupported operating system. Please install $1 manually."
76+
exit 1
77+
fi
78+
}
79+
80+
# Function to run a script and log errors
81+
run_script() {
82+
eval "$1" || { log_error "Error running $1."; exit 1; }
83+
}
84+
85+
# Check the operating system
86+
os=$(uname -s)
87+
88+
# Check if Python is installed
89+
if ! command_exists python3; then
90+
echo "Python not found. Installing Python..."
91+
install_packages python3
92+
fi
93+
94+
# Check if pip is installed
95+
if ! command_exists pip; then
96+
echo "pip not found. Installing pip..."
97+
install_packages python3-pip
98+
fi
99+
100+
# Check if git is installed
101+
if ! command_exists git; then
102+
echo "Git not found. Installing Git..."
103+
install_packages git
104+
fi
105+
106+
# Check if the directory exists and is not empty
107+
if [ -d "self-operating-computer" ] && [ "$(ls -A self-operating-computer)" ]; then
108+
echo "Directory 'self-operating-computer' already exists and is not empty. Skipping clone operation..."
109+
else
110+
# Clone the repository
111+
run_script "git clone https://github.com/OthersideAI/self-operating-computer.git"
112+
fi
113+
114+
# Change directory
115+
cd self-operating-computer || { log_error "Unable to navigate to the project directory."; exit 1; }
116+
117+
# Create a Python virtual environment
118+
run_script "python3 -m venv venv"
119+
120+
# Activate the virtual environment
121+
source venv/bin/activate || { log_error "Unable to activate the virtual environment."; exit 1; }
122+
123+
# Install project requirements
124+
run_script "pip install -r requirements.txt"
125+
126+
# Install Project and Command-Line Interface
127+
run_script "pip install ."
128+
129+
# Check if the .env file exists and the OPENAI_API_KEY is set in it
130+
if [ -f .env ] && grep -q "OPENAI_API_KEY" .env; then
131+
echo "OpenAI API key found in .env file. Skipping prompt..."
132+
else
133+
# Prompt user for Open AI key
134+
read -p "Enter your OpenAI API key: " openai_key
135+
136+
# Set the API key as an environment variable
137+
export OPENAI_API_KEY="$openai_key"
138+
139+
# Create a new .env file
140+
touch .env
141+
142+
# Write the API key to the .env file
143+
echo "OPENAI_API_KEY='$openai_key'" > .env
144+
fi
145+
146+
# Notify the user about the last step
147+
echo "Final Step: As a last step, the Terminal app will ask for permission for 'Screen Recording' and 'Accessibility' in the 'Security & Privacy' page of Mac's 'System Preferences.'"
148+
149+
echo "Operating system: $os"
150+
151+
if [ "$os" == "Darwin" ]; then
152+
echo "Attempting to open Security & Privacy settings..."
153+
open /System/Library/PreferencePanes/Security.prefPane
154+
read -p "Have you granted the necessary permissions in the Security & Privacy settings? (y/n): " confirm
155+
if [ "$confirm" != "y" ]; then
156+
echo "Please grant the necessary permissions and then rerun the script."
157+
exit 1
158+
fi
159+
else
160+
echo "Not a macOS system, skipping..."
161+
fi
162+
163+
# End of the script
164+
echo "Installation complete. Enjoy using the Self-Operating Computer Framework!"
165+
166+
# Run the framework
167+
run_script "operate"

0 commit comments

Comments
 (0)