-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·55 lines (46 loc) · 2.24 KB
/
install.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
#!/bin/bash
set -ex # -e: exit immediately if there are errors. -x: print out every line that runs
if [[ "$(whoami)" != "root" ]] ; then
echo "We must run as root, but currently we're $(whoami) instead."
exit 1
fi
# See https://stackoverflow.com/a/1482133 for an explanation of this next line. It gets the
# directory in which this script resides.
this_dir="$(dirname -- "$( readlink -f -- "$0"; )")";
echo "this_dir is $this_dir"
pushd "$this_dir" > /dev/null
# This next line basically means "it's okay for the root user to update the repo from within a cron
# job, even if the repo is owned by a normal non-root user."
git config --global --add safe.directory "$this_dir"
# Create a virtual environment.
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# Install the RDK server
curl "https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-latest-$(uname -m).AppImage" -o viam-server
chmod 755 viam-server
./viam-server --aix-install
# Install a systemctl file for the canary server
cp viam-canary.service /etc/systemd/system
systemctl daemon-reload
# Create a crontab to run the script. Overwrite anything that had been there previously, in case
# we're installing updates to an old version. We use '%' as the regex delimiter for sed instead of
# the more traditional '/' because there are slashes within $this_dir and we don't want too many
# slashes to confuse the parser.
cat crontab_template.txt | sed "s%CANARY_DIR%$this_dir%g" > /etc/cron.d/viam-board-canary
sudo service cron reload
# Remind the user of the steps they need to do manually
set +x # Stop printing every line: we're going to print them ourselves
echo ""
echo ""
echo "%%%%%%%%%%%%%"
echo "% REMINDER! %"
echo "%%%%%%%%%%%%%"
echo "There are four manual things to do:"
echo "- Set up a robot on app.viam.com, and download its config to"
echo " /etc/viam-canary.json (not the default /etc/viam.json!)."
echo "- Copy canary_config.example.py into canary_config.py and edit it to be"
echo " specific to your board."
echo "- Copy slack_reporter_config.example.py into slack_reporter_config.py"
echo " and edit it to be specific to your board."
echo "- Update monitor_config.py on the monitor board (likely the pi5 canary) to include the new board."