-
Notifications
You must be signed in to change notification settings - Fork 1
/
server_runner.sh
49 lines (40 loc) · 1.27 KB
/
server_runner.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
#!/bin/bash
# Step 1: Update and Upgrade
echo "Updating and upgrading the system..."
sudo apt update && sudo apt upgrade -y
echo
echo "Check Python 3 Installation..."
echo
if command -v python3 &>/dev/null; then
echo "Python 3 is installed."
else
echo "Python 3 is not installed. Installing Python 3..."
sudo apt install python3 -y
fi
echo
echo "Check and Install Required Pip Packages"
echo
REQUIRED_PKG=("adafruit-circuitpython-pca9685" "adafruit-circuitpython-servokit")
echo "Checking and installing required pip packages..."
for pkg in "${REQUIRED_PKG[@]}"; do
if pip3 show "$pkg" &>/dev/null; then
echo "$pkg is already installed."
else
echo "$pkg is not installed. Installing $pkg..."
sudo pip3 install "$pkg" --break-system-packages
fi
done
echo
echo "Enable I2C Interface on Raspberry Pi..."
echo
# sudo raspi-config nonint get_i2c this command will return 0 or 1 based on the status of I2C interface
if [ "$(sudo raspi-config nonint get_i2c)" -eq 0 ]; then
echo "I2C interface is already enabled."
else
echo "I2C interface is not enabled. Enabling I2C interface..."
sudo raspi-config nonint do_i2c 0
fi
echo
echo "Everything is set up. Running the Python server script..."
echo
python3 ./python_server/servo_controller.py