🔨 Add user removal logic

This commit is contained in:
Timmo 2019-05-12 17:35:10 +01:00
parent f3ad6b92a1
commit 24d96fd454

View file

@ -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}"