Home Download FAQ / Knowledge Base Screenshots Documentation Support

I want to automate certain tasks by scripting the Citadel server. How would I do that?

Citadel speaks its own protocol registered to IANA TCP Port 504. This protocol can be found on the Citadel Protocol Definition Page. You can either speak to your citadel server via TCP Port 504, or on a unix domain socket called citadel.socket in your server's working directory.

sendcommand can issue one command at a time to the Citadel server. These commands will execute in a highly privileged mode, so this utility should be handled with care. netcat is a proper tool, if you just want to pipe the output of a shell script over to your Citadel server.

Note that you need proper authentication to execute commands, and that you may use TLS encryption to secure your traffic over the net.

If you want to see some reallife communication use for example Wireshark to follow webcit or the citadel commandline client talking to the Citadel server.

Example: Cleaning up the Citadel User List / Global Address Book

by Danboid

In this guide we'll demonstrate how you find and then bulk remove a number of users who have citadel accounts but have never logged on. These instructions are easily modified to achieve the same for those who have never posted.

First thing we do do is fetch a list of all users into a text file (except the **'SYS_'** users generated by Citadel):

sendcommand list |grep -v ^SYS_ > /tmp/allusers.txt

Now we want to filter off just the users that have a **login count** of **0** into a separate file; i.e. we want just the lines that have a **0** in **column 5**. We'll put those that match this criterion into another text file called /tmp/0login.txt :

awk -F"|" '$5 == "0"' /tmp/allusers.txt > /tmp/0login.txt

If you wanted to remove users that had never posted, you would substitute $5 for $6 in the previous command. Now we have a list of all the users we want deleted in 0login but we only actually need the user names for this process so we can strip away the other columns to give us a file just containing the usernames that we'll call /tmp/removelist.txt using this command:

awk -F"|" '{print $1}' /tmp/0login.txt > /tmp/removelist.txt

You now might want to review that list using your favorite editor. Make sure sendcommand is in your $PATH . In this same folder you need to create a file called removeusers.sh containing the following:

#!/bin/bash
while read -r line
do
sendcommand "ASUP $line|0|0|0|0|0|"
done < "/tmp/removelist"

It is using the ASUP server command to remove the users from your list.

The final step is to simply execute the removeusers.sh script: sh ./removeusers.sh

Example: Cleaning an overpopulated Mailbox (Trash, spam... )

- By Danboid

I recently had a Citadel user complaining that their trash was overly full- it contained over 27000 messages. She tried to delete them under webcit but it ground to a halt when that was attempted. Hence we had to find another way and this is how it was achieved.

... this list comprising of the numerical indices used to reference each unwanted mail in the citadel database. We'll call this script **//dumptrash//**; replace username & password:

 
#!/bin/bash
(printf "USER username\nPASS password\nGOTO _TRASH_\nMSGS ALL\n
QUIT\n"; sleep 2)|nc your.citadel.host.org 504 > /tmp/raw_junkmail
# count lines in total: 
LINES=`wc -l  /tmp/junkmail 
This will take us into the trash room of user **//username//** and dump all message indices we will later feed back to citadel so it deletes them. Now we need to create and execute a shell script to remove every mail listed in the file 'junkmail' like so:
#!/bin/bash
(
printf "USER username\n"
sleep 1
printf "PASS passwd\n"
sleep 1
printf "GOTO _TRASH_\n"
sleep 1
while read -r line; do
  printf "DELE $line\n"
  sleep 1
done < /tmp/junkmail
sleep 10
) | nc your.citadel.host.org 504
(if its to slow, remove the //sleep 1// from the loop, and, maybe increase the //sleep 10// at the end.)
There are no social media links here. Enjoy a friendly Citadel community instead. Or go outside.