-
-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathowl_setup.sh
112 lines (90 loc) · 3.65 KB
/
owl_setup.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# Function to check the exit status of the last executed command
check_status() {
if [ $? -ne 0 ]; then
echo "[ERROR] $1 failed."
exit 1
else
echo "[INFO] $1 completed successfully."
fi
}
# Free up space
echo "[INFO] Freeing up space by removing unnecessary packages..."
sudo apt-get purge -y wolfram-engine
sudo apt-get purge -y libreoffice*
sudo apt-get clean
check_status "Cleaning up"
sudo apt-get autoremove -y
check_status "Removing unnecessary packages"
# Update the system and firmware
echo "[INFO] Updating the system and firmware..."
sudo apt-get update && sudo apt-get upgrade -y
check_status "System update and upgrade"
# Set up the virtual environment
echo "[INFO] Setting up the virtual environment..."
echo "# virtualenv and virtualenvwrapper" >> ~/.bashrc
echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.bashrc
source ~/.bashrc
check_status "Updating .bashrc for virtualenv"
# Install virtualenv and virtualenvwrapper
echo "[INFO] Installing virtualenv and virtualenvwrapper..."
sudo apt-get install -y python3-virtualenv
check_status "Installing python3-virtualenv"
sudo apt-get install -y python3-virtualenvwrapper
check_status "Installing python3-virtualenvwrapper"
echo "export WORKON_HOME=$HOME/.virtualenvs" >> ~/.bashrc
echo "source /usr/share/virtualenvwrapper/virtualenvwrapper.sh" >> ~/.bashrc
source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
check_status "Updating .bashrc for virtualenvwrapper"
sleep 1s
# Create the owl virtual environment
echo "[INFO] Creating the 'owl' virtual environment..."
mkvirtualenv --system-site-packages -p python3 owl
check_status "Creating virtual environment 'owl'"
sleep 1s
# Install OpenCV in the owl virtual environment
echo "[INFO] Installing OpenCV in the 'owl' virtual environment..."
source $HOME/.virtualenvs/owl/bin/activate
sleep 1s
pip3 install opencv-contrib-python
check_status "Installing OpenCV"
sleep 1s
# Install the OWL Python dependencies
echo "[INFO] Installing the OWL Python dependencies..."
cd ~/owl
pip install -r requirements.txt
check_status "Installing dependencies from requirements.txt"
# Make the scripts executable
echo "[INFO] Making scripts executable..."
chmod a+x owl.py
check_status "Making owl.py executable"
chmod a+x owl_boot.sh
check_status "Making owl_boot.sh executable"
chmod a+x owl_boot_wrapper.sh
check_status "Making owl_boot_wrapper.sh executable"
# Move the boot scripts to /usr/local/bin
echo "[INFO] Moving boot scripts to /usr/local/bin..."
sudo mv owl_boot.sh /usr/local/bin/owl_boot.sh
check_status "Moving owl_boot.sh"
sudo mv owl_boot_wrapper.sh /usr/local/bin/owl_boot_wrapper.sh
check_status "Moving owl_boot_wrapper.sh"
# Add the boot script to cron for startup
echo "[INFO] Adding boot script to cron..."
(crontab -l 2>/dev/null; echo "@reboot /usr/local/bin/owl_boot_wrapper.sh > /home/launch.log 2>&1") | sudo crontab -
check_status "Adding boot script to cron"
echo "[INFO] Setting owl-background.png as the desktop background..."
pcmanfm --set-wallpaper ~/owl/images/owl-background.png
check_status "Setting desktop background"
echo "[INFO] OWL setup complete."
read -p "Start OWL focusing? (y/n): " choice
case "$choice" in
y|Y ) echo "[INFO] Starting focusing..."; ./owl.py --focus;;
n|N ) echo "[INFO] Focusing skipped. Run './owl.py --focus' to focus the OWL at a later point";;
* ) echo "[ERROR] Invalid input. Please enter y or n.";;
esac
read -p "Launch OWL software? (y/n): " choice
case "$choice" in
y|Y ) echo "[INFO] Launching OWL..."; ./owl.py --show-display;;
n|N ) echo "[INFO] Skipped. Run './owl.py --show-display' to launch the OWL at a later point";;
* ) echo "[ERROR] Invalid input. Please enter y or n.";;
esac