Files
operating-system/buildroot-external/rootfs-overlay/usr/sbin/hassos-config
Pascal Vizeli dac76b1632 Allow udev rules & make it persistent (#210)
* Install default to lib

* Create hmip-rfusb.rules

* Create etc-udev-rules.d.mount

* Update hassos-config

* Update configuration.md

* Update rauc.sh

* Add ln
2018-10-11 20:49:20 +02:00

76 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
if ! findfs LABEL="CONFIG" > /dev/null; then
echo "[Warning] No config partition found"
exit 0
fi
# Mount config folder
systemctl start mnt-config.mount
if ! systemctl -q is-active mnt-config.mount; then
echo "[Error] Can't mount config partition"
exit 1
fi
##
# NetworkManager
if [ -d /mnt/config/network ]; then
echo "[Info] Update NetworkManager connections!"
rm -rf /etc/NetworkManager/system-connections/*
cp -f /mnt/config/network/* /etc/NetworkManager/system-connections/
chmod 600 /etc/NetworkManager/system-connections/*
nmcli con reload
fi
##
# Modules
if [ -d /mnt/config/modules ]; then
echo "[Info] Update Modules configuration!"
rm -rf /etc/modules-load.d/*
cp -f /mnt/config/modules/* /etc/modules-load.d/*
fi
##
# Udev
if [ -d /mnt/config/udev ]; then
echo "[Info] Update Udev configuration!"
rm -rf /etc/udev/rules.d/*
cp -f /mnt/config/udev/* /etc/udev/rules.d/*
fi
##
# SSH know hosts
if [ -f /mnt/config/authorized_keys ]; then
echo "[Info] Update SSH authorized_keys!"
cp -f /mnt/config/authorized_keys /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
systemctl start dropbear
else
rm -f /root/.ssh/authorized_keys
systemctl stop dropbear
fi
##
# Firmware update
UPTIME=$(awk '{printf "%0.f", $1}' /proc/uptime)
if ls /mnt/config/*.raucb > /dev/null && [ ${UPTIME} -ge 180 ]; then
echo "[Info] Performe a firmware update"
rauc_filename=$(ls /mnt/config/*.raucb | head -n 1)
if rauc install ${rauc_filename}; then
echo "[Info] Firmware update success"
systemctl reboot
else
echo "[Error] Firmware update fails"
fi
fi
# Cleanup config partition
systemctl stop mnt-config.mount