Add Pi Zero headless serial bridge with AP portal and daily RTC-based logs
This commit is contained in:
59
install.sh
Normal file
59
install.sh
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ "${EUID}" -ne 0 ]]; then
|
||||
echo "Bitte als root ausfuehren: sudo ./install.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
APP_ROOT="/opt/serial-bridge"
|
||||
CONFIG_ROOT="/etc/serial-bridge"
|
||||
|
||||
apt-get update
|
||||
apt-get install -y \
|
||||
python3 \
|
||||
python3-venv \
|
||||
python3-pip \
|
||||
hostapd \
|
||||
dnsmasq \
|
||||
iw \
|
||||
wpasupplicant \
|
||||
iproute2 \
|
||||
rfkill \
|
||||
i2c-tools
|
||||
|
||||
install -d -m 755 "${APP_ROOT}" "${APP_ROOT}/src" "${APP_ROOT}/templates" "${APP_ROOT}/static" "${CONFIG_ROOT}"
|
||||
|
||||
cp -a "${PROJECT_ROOT}/src/." "${APP_ROOT}/src/"
|
||||
cp -a "${PROJECT_ROOT}/templates/." "${APP_ROOT}/templates/"
|
||||
cp -a "${PROJECT_ROOT}/static/." "${APP_ROOT}/static/"
|
||||
cp "${PROJECT_ROOT}/requirements.txt" "${APP_ROOT}/requirements.txt"
|
||||
|
||||
python3 -m venv "${APP_ROOT}/.venv"
|
||||
"${APP_ROOT}/.venv/bin/pip" install --upgrade pip
|
||||
"${APP_ROOT}/.venv/bin/pip" install -r "${APP_ROOT}/requirements.txt"
|
||||
|
||||
install -m 644 "${PROJECT_ROOT}/config/hostapd.conf" "${CONFIG_ROOT}/hostapd.conf"
|
||||
install -m 644 "${PROJECT_ROOT}/config/dnsmasq.conf" "${CONFIG_ROOT}/dnsmasq.conf"
|
||||
|
||||
install -m 644 "${PROJECT_ROOT}/systemd/serial-hostapd.service" "/etc/systemd/system/serial-hostapd.service"
|
||||
install -m 644 "${PROJECT_ROOT}/systemd/serial-dnsmasq.service" "/etc/systemd/system/serial-dnsmasq.service"
|
||||
install -m 644 "${PROJECT_ROOT}/systemd/serial-bridge.service" "/etc/systemd/system/serial-bridge.service"
|
||||
|
||||
WPA_CONF="/etc/wpa_supplicant/wpa_supplicant.conf"
|
||||
touch "${WPA_CONF}"
|
||||
grep -q '^ctrl_interface=' "${WPA_CONF}" || echo 'ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev' >> "${WPA_CONF}"
|
||||
grep -q '^update_config=' "${WPA_CONF}" || echo 'update_config=1' >> "${WPA_CONF}"
|
||||
|
||||
systemctl disable --now hostapd.service || true
|
||||
systemctl disable --now dnsmasq.service || true
|
||||
|
||||
install -d -m 755 /home/pi
|
||||
chown pi:pi /home/pi || true
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable serial-bridge.service
|
||||
systemctl restart serial-bridge.service
|
||||
|
||||
echo "Installation abgeschlossen. Logs: journalctl -u serial-bridge -f"
|
||||
Reference in New Issue
Block a user