Skip to content

Commit 07154e2

Browse files
committed
feat: camera-stack updater (from git)
1 parent 25354a9 commit 07154e2

File tree

2 files changed

+80
-11
lines changed

2 files changed

+80
-11
lines changed

scripts/10-install-camera-streamer

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@ install_cleanup_trap
88

99
### --- install the new stuff -----------------------------------------------
1010

11+
USERID=1000
12+
REPO=https://github.com/OctoPrint/camera-streamer-stack.git
13+
1114
# install camera-streamer and dependencies
1215
apt-get install --yes camera-streamer-raspi
1316

14-
# install units, configs & helpers
15-
pushd /tmp
16-
apt-get install --yes v4l-utils
17-
git clone https://github.com/OctoPrint/camera-streamer-stack.git
18-
pushd camera-streamer-stack
19-
make install
20-
popd
21-
rm -rf camera-streamer-stack
17+
# install camera-streamer-stack
18+
apt-get install --yes v4l-utils
19+
install -d --owner=$USERID /opt/camera-streamer-stack
20+
pushd /opt/camera-streamer-stack
21+
sudo -u "#$USERID" git clone "$REPO" .
22+
make CONFIG_DIR=$BOOT_PATH/camera-streamer install
23+
ln -s $BOOT_PATH/camera-streamer /etc/camera-streamer.conf.d
2224
popd
2325

24-
# put configs on fat partition on OctoPi
25-
mv /etc/camera-streamer.conf.d $BOOT_PATH/camera-streamer
26-
ln -s $BOOT_PATH/camera-streamer /etc/camera-streamer.conf.d
26+
# install update-script
27+
cp /files/camera-streamer-stack-update /usr/local/bin/camera-streamer-stack-update
28+
chmod +x /usr/local/bin/camera-streamer-stack-update
2729

2830
# only run stack if mjpeg is selected as streamer
2931
for unit in camera-streamer camera-streamer-usb@ camera-streamer-libcamera; do
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
CHECKOUT="/opt/camera-streamer-stack"
6+
CONFIG="/boot/firmware/camera-streamer"
7+
if [ ! -d "$CONFIG" ]; then
8+
CONFIG="/boot/camera-streamer"
9+
fi
10+
11+
if [ ! -d "$CHECKOUT" ]; then
12+
echo "Checkout folder at /opt/camera-streamer-stack does not exist"
13+
exit 1
14+
fi
15+
16+
if [ ! -d "$CONFIG" ]; then
17+
echo "Can't locate config folder, it's neither in /boot/firmware nor in /boot."
18+
exit 1
19+
fi
20+
21+
pushd $CHECKOUT
22+
git fetch
23+
if [ $(git rev-parse HEAD) == $(git rev-parse @{u}) ]; then
24+
echo "Already up to date!"
25+
exit 0
26+
fi
27+
28+
git pull
29+
30+
# update systemd files & scripts
31+
sudo make systemd scripts
32+
33+
# update default configs
34+
echo "Updating configs..."
35+
for config in configs/*.conf; do
36+
name=$(basename $config)
37+
target="$CONFIG/$name"
38+
39+
if [ ! -e "$target" ]; then
40+
sudo install --mode=0644 "$config" "$target"
41+
continue
42+
fi
43+
44+
changes=$(diff "$config" "$target" || true)
45+
if [ "$changes" != "" ]; then
46+
echo "$config and $target differ:"
47+
echo -n "$changes"
48+
echo ""
49+
read -n1 -p "Overwrite your local copy? (y)es or (n)o: " overwrite
50+
echo
51+
if [ "$overwrite" == "y" -o "$overwrite" == "Y"]; then
52+
sudo install --backup=simple --suffix=.backup --mode=0644 "$config" "$target"
53+
echo "New version of $target installed, backup at $target.backup"
54+
else
55+
echo "Skipping $config, check manually if local copy requires any updates!"
56+
fi
57+
else
58+
echo "$config and $target are identical, no need to update"
59+
fi
60+
done
61+
62+
echo "Reloading systemd units & restarting camera-streamer..."
63+
sudo systemctl daemon-reload
64+
sudo systemctl restart camera-streamer
65+
66+
echo "Update process complete!"
67+
popd

0 commit comments

Comments
 (0)