Last active
April 11, 2023 18:08
-
-
Save devidw/7cb1f330f476b8474b0e4bfc2b004685 to your computer and use it in GitHub Desktop.
How to deactivate a Seafile/Seahub user from the command line only?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# How to deactivate a Seafile/Seahub user from the command line only? | |
# | |
# Sometimes it's required to be able to deactivate a user account inside | |
# Seafile/Seahub, when you had more users active than your license can hold | |
# your server shuts down and the seafile server can not start because of this | |
# | |
# In this case, we can not access the Seahub web ui and therefore have to do | |
# it using the command line only | |
# | |
# Login to the seafile server using SSH | |
ssh user@example.org | |
# Give your user root privileges, if you are not logged in as root | |
sudo su | |
# In case your seafile server has its own user, we can use this | |
su seafile | |
# Go home | |
cd | |
# Open seahub configuration file to copy configured database username and password | |
cat ./conf/seahub_settings.py | |
mysql -u example -p | |
# When prompted enter password | |
# From inside the interactive mysql shell we want to connect to the `ccnet-db`, | |
# which is responsive for 'Holding User, groups, creadentials LDAP users etc.' | |
# https://forum.seafile.com/t/mysql-tables-explanation/5394/2 | |
USE ccnet-db; | |
# List all db tables inside the db | |
SHOW TABLES; | |
# Based on the fact where the user you want to deactivate is stored you will | |
# reference this table name, e.g., `EmailUser` or `LDAPUsers` | |
SELECT * FROM LDAPUsers WHERE email = "user@example.org"; | |
# If the `is_active` column for the result row is `1` the user is active, | |
# so we can deactivate it changig this information | |
UPDATE LDAPUsers SET is_active = 0 WHERE email = "user@example.org"; | |
# To double-check the modification worked, we can select the user one more time | |
# and check the `is_active` attribute of the user is set to `0` | |
# In order to apply the changes we have to restart the seafile server | |
# To do this we have to change into the seafile directory | |
cd seafile-server-directory | |
# and run the stop/start script | |
./seafile.sh stop | |
./seafile.sh start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment