Hello!
I am try to delete extra admins in userScripts.
echo "Check Users" > /tmp/check_admins
for USER in $(cat /etc/passwd | grep -E '/bin/bash|/bin/clish' | awk -F: '{ print $1 }')
do
echo $USER >> /tmp/check_admins
if [ "$USER" = "admin" ]
then
echo 'OK' >> /tmp/check_admins
else
# /bin/clish -c "delete administrator username $USER" >> /tmp/check_admins
deluser $USER
echo "User $USER was deleted" >> /tmp/check_admins
fi
done
If I use the command deluser, then the admin is removed from the passwd, but remains in the web and clish interface
If I use the clish command, the admin is not deleted and I get an error: "Unexpected error: attempt to index global 'cgilua' (a nil value)".
If I run this script manually, I get an error: "Could not set administrator: Invalid action: User is logged in". Although the script is run by a different user.
How can I delete extra admins?