Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Basyuk
Contributor

Delete user admin UserScript

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?

0 Kudos
7 Replies
_Val_
Admin
Admin

Run "save config" at the end

0 Kudos
Basyuk
Contributor

SMB devices do not have a 'save config' command. We use Checkpoint 1430, 1530 devices.

0 Kudos
_Val_
Admin
Admin

You never specified that in the original post.

This changes the whole thing. Gaia embedded uses different set of shells and commands. You are using regular Gaia bash commands, which may lead to corrupted admin database on SMB. Soft-reset, if the user is still there, you may need to hard reset do default and reconfigure.

0 Kudos
Basyuk
Contributor

Clish command not working in /pfrm2.0/etc/UserScript?

0 Kudos
_Val_
Admin
Admin

Once again. Native clish commands do. But calling them from bash shell is a different matter. 

0 Kudos
Basyuk
Contributor

Can't solve my problem with this script?

0 Kudos
PhoneBoy
Admin
Admin

Regardless of using SMB or not, one should never use the expert mode commands to manage users.
This needs to be done via clish only using the appropriate syntax.

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events