-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
42 lines (39 loc) · 2.08 KB
/
Copy pathinstall.sh
File metadata and controls
42 lines (39 loc) · 2.08 KB
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
#!/usr/bin/env bash
set -euo pipefail
APP_DIR=/opt/minigeiger
DATA_DIR=/var/lib/minigeiger
SERVICE_USER=minigeiger
if [[ $EUID -ne 0 ]]; then echo "Bitte mit sudo ausführen."; exit 1; fi
if ! command -v apt-get >/dev/null; then echo "Raspberry Pi OS/Debian erwartet."; exit 1; fi
apt-get update
# USB audio devices sold as "mini sound cards" normally use the kernel driver
# snd-usb-audio. These packages provide ALSA device discovery, mixer profiles
# and diagnostics; no vendor binary driver is installed.
apt-get install -y python3 python3-venv python3-pip python3-gpiozero python3-lgpio portaudio19-dev libportaudio2 \
libasound2 alsa-utils alsa-ucm-conf usbutils kmod
modprobe snd-usb-audio || true
install -d /etc/modules-load.d
printf '%s\n' 'snd-usb-audio' > /etc/modules-load.d/minigeiger-usb-audio.conf
id -u "$SERVICE_USER" >/dev/null 2>&1 || useradd --system --home "$DATA_DIR" --create-home --shell /usr/sbin/nologin "$SERVICE_USER"
install -d -o "$SERVICE_USER" -g "$SERVICE_USER" "$DATA_DIR"
install -d "$APP_DIR"
cp app.py requirements.txt "$APP_DIR/"
cp -r static "$APP_DIR/"
[[ -f "$DATA_DIR/config.json" ]] || install -o "$SERVICE_USER" -g "$SERVICE_USER" -m 640 config.example.json "$DATA_DIR/config.json"
python3 -m venv --system-site-packages "$APP_DIR/.venv"
sed -i 's/^include-system-site-packages = false/include-system-site-packages = true/' "$APP_DIR/.venv/pyvenv.cfg"
"$APP_DIR/.venv/bin/pip" install --upgrade pip wheel
"$APP_DIR/.venv/bin/pip" install -r "$APP_DIR/requirements.txt"
chown -R root:root "$APP_DIR"
chmod -R a+rX "$APP_DIR"
getent group gpio >/dev/null || groupadd --system gpio
usermod -aG audio,gpio "$SERVICE_USER"
# A former manual `systemctl mask minigeiger` leaves a /dev/null symlink at
# this path. Remove that mask before installing the actual unit file.
systemctl unmask minigeiger.service || true
install -m 644 minigeiger.service /etc/systemd/system/minigeiger.service
systemctl daemon-reload
systemctl enable --now minigeiger.service
echo "Fertig. Dashboard: http://$(hostname -I | awk '{print $1}'):8734"
echo "Erkannte ALSA-Aufnahmegeräte:"
arecord -l || true