Home Download News FAQ / Knowledge Base Screenshots Documentation Support Site map
philosophical imaginary
Table of Contents

I want to automate certain stuff with 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 the citadel.sock UnixDomainSocket.

Sendcommand can issue one privileged command at a time to citserver; Netcat is a proper tool, if you just want to pipe the output of a shellscript 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.

Also a usefull resource could be the PHP Sample Client, that demonstrates the interference with ui and the protocol. It also shows how to create a user and modify his personal data (vcard)

Tasks to do might be...

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 required 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 criteria 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 favourite editor. Make shure 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"

Its using ASUP to remove the users from your list.

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

sh ./removeusers.sh

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.

  1. create a list of all the mails we want to delete
  2. loop over that list to remove the mails

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/raw_junkmail`
# Now we strip off the status lines: 
head -$(($LINES - 2)) /tmp/raw_junkmail| tail -$(($LINES - 7)) > /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.)

Copyright © 1987-2014 Uncensored Communications Group. All rights reserved.     Login (site admin)