From 24d96fd4544ff46c67e5d896662b9c3269697739 Mon Sep 17 00:00:00 2001 From: Timmo Date: Sun, 12 May 2019 17:35:10 +0100 Subject: [PATCH] :hammer: Add user removal logic --- thelounge/rootfs/etc/cont-init.d/thelounge.sh | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/thelounge/rootfs/etc/cont-init.d/thelounge.sh b/thelounge/rootfs/etc/cont-init.d/thelounge.sh index 84292cb..a8ff45a 100644 --- a/thelounge/rootfs/etc/cont-init.d/thelounge.sh +++ b/thelounge/rootfs/etc/cont-init.d/thelounge.sh @@ -3,6 +3,9 @@ # Community Hass.io Add-ons: The Lounge # This adds the default user and installs any requested themes # ============================================================================== +declare users +declare user_found + export THELOUNGE_HOME=/data/thelounge # Require a user @@ -15,14 +18,33 @@ fi # List current users /usr/local/bin/thelounge list -for user in $(bashio::config "users") +users=$(bashio::config "users") + +for user in $users do - if ! bashio::fs.file "/data/thelounge/users/${user}.json"; then + if ! bashio::fs.file_exists "/data/thelounge/users/${user}.json"; then bashio::log.info "Creating user ${user} with default password.." cp /etc/thelounge/users/hassio.json "/data/thelounge/users/${user}.json" fi done +# Delete removed users +for file in /data/thelounge/users/* +do + user_found=false + for user in $users + do + if [ "$(basename "${file}" .json)" == "${user}" ]; then + user_found=true + break + fi + done + if [ ! "$user_found" == true ]; then + bashio::log.info "Removing removed user ${file}.." + rm -f "$file" + fi +done + for theme in $(bashio::config "themes") do /usr/local/bin/thelounge install "${theme}"