mirror of
https://github.com/hassio-addons/addon-thelounge.git
synced 2025-05-04 19:11:27 +00:00
🔨 Add user removal logic
This commit is contained in:
parent
f3ad6b92a1
commit
24d96fd454
1 changed files with 24 additions and 2 deletions
|
@ -3,6 +3,9 @@
|
||||||
# Community Hass.io Add-ons: The Lounge
|
# Community Hass.io Add-ons: The Lounge
|
||||||
# This adds the default user and installs any requested themes
|
# This adds the default user and installs any requested themes
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
declare users
|
||||||
|
declare user_found
|
||||||
|
|
||||||
export THELOUNGE_HOME=/data/thelounge
|
export THELOUNGE_HOME=/data/thelounge
|
||||||
|
|
||||||
# Require a user
|
# Require a user
|
||||||
|
@ -15,14 +18,33 @@ fi
|
||||||
# List current users
|
# List current users
|
||||||
/usr/local/bin/thelounge list
|
/usr/local/bin/thelounge list
|
||||||
|
|
||||||
for user in $(bashio::config "users")
|
users=$(bashio::config "users")
|
||||||
|
|
||||||
|
for user in $users
|
||||||
do
|
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.."
|
bashio::log.info "Creating user ${user} with default password.."
|
||||||
cp /etc/thelounge/users/hassio.json "/data/thelounge/users/${user}.json"
|
cp /etc/thelounge/users/hassio.json "/data/thelounge/users/${user}.json"
|
||||||
fi
|
fi
|
||||||
done
|
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")
|
for theme in $(bashio::config "themes")
|
||||||
do
|
do
|
||||||
/usr/local/bin/thelounge install "${theme}"
|
/usr/local/bin/thelounge install "${theme}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue