Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gromox-cleanup.sh script #111

Closed
wants to merge 5 commits into from
Closed

Conversation

deajan
Copy link

@deajan deajan commented Nov 25, 2024

Purpose of this PR: Keep gromox folders clean

While playing with gromox, I wrote a prometheus exporter here after which I noticed that some mailboxes were quite huge, even when the ondisk maidir was twice as small.

Discussing with @WalterHof and @crpb, they suggested to run various cleanups.
I was wondering why that wasn't "standard" for Grommunio, so here's a script that perhaps should be added by default to Grommunio's setup via a systemd timer / or even as fs-hook/thaw for VM environments.

Currently tested on two Grommunio servers running gromox 2.37.

Thanks for considering this.

@WalterHof
Copy link
Member

Do not write to a log file (/var/log/${SCRIPT_NAME}.log). Write to systemd logging instead,

@crpb
Copy link
Contributor

crpb commented Nov 25, 2024

Write to systemd logging instead,

ahh right. and with the .service you can just echo you to stdout and it will show up in the journal under --unit grommunio-cleanup or however it might be called in the end.
And for different levels logger/systemd-cat -p err/info/...

@deajan
Copy link
Author

deajan commented Nov 25, 2024

Pull request updated as per your suggestions. New script has been tested again.
@crpb Note that I have changed the timer to make it run everyday at 2am.

There's just one thing, I don't know where @jengelh would place the script, so I cannot convert the systemd unit file to a template file.

@jengelh
Copy link
Member

jengelh commented Dec 12, 2024

for maildir in $(grommunio-admin user query maildir | awk '{if ($1~gromox_mail) {print $1}}' gromox="${GROMOX_MAILDIR_PATH}"); do

Ugh, this is ugly. We have for-all-users echo-username since gromox-2.35-45-g34e58d9f2 .

And now, since gromox-2.38-17-gdde284b64 , it also knows for-all-users \( purge-softdelete ... \) \( purge-datafiles \), so the loop can also go away. ;-)

@crpb
Copy link
Contributor

crpb commented Dec 14, 2024

We have for-all-users echo-username

Which will print out groups aswell which don't have any maildirs and therefore will give me an error on use or not? Same with the "admin" user.
These ugly hacks are there for a reason or we just need to have some guidance on how to do it better as i can't seem to get it going here.

grom-test-2:~ # rpm -q gromox
gromox-2.38.17.gdde284b-lp156.20.1.x86_64
grom-test-2:~ # gromox-mbop for-all-users \( purge-datafiles \)
purge-datafiles: the operation failed
grom-test-2:~ # gromox-mbop for-all-users purge-datafiles
purge-datafiles: the operation failed
grom-test-2:~ # man gromox-mbop
grom-test-2:~ # gromox-mbop for-all-users -j 10 purge-datafiles
purge-datafiles: the operation failed
grom-test-2:~ # gromox-mbop for-all-users echo-username |wc -l
25

@WalterHof
Copy link
Member

WalterHof commented Dec 14, 2024 via email

@deajan
Copy link
Author

deajan commented Dec 14, 2024

I'll remove my ugly hacks in favor of the recent commands somewhere around this weekend and update the PR ;)

@crpb
Copy link
Contributor

crpb commented Dec 15, 2024

Oh and not only groups but contacts aswell what will look a bit confusing on usage 🙈

armitage:~ # ./scripts/tools/g_user_count.sh

Count grommunio Users / Mailboxes
V.: 1.1, (c) 2023 by [email protected] and cb

Counting items please wait ...

  52 users / mailboxes to be licensed, includes 0 suspended users, rooms and equipment,
  21 shared mailboxes (free),
  61 groups / distribution lists (free),
  73 mailboxes total.
 138 contacts.

armitage:~ # gromox-mbop for-all-users echo-username |wc -l
273
armitage:~ # gromox-mbop for-all-users purge-datafiles
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
purge-datafiles: the operation failed
armitage:~ # echo $?
1

@jengelh
Copy link
Member

jengelh commented Dec 18, 2024

new iteration verbs added, cf. gromox-2.38-33-gb00c21f49
unit tryout: refs/heads/cleaner
Unit still needs extra conditions and only makes sense to run when gromox-http is operating.

@deajan
Copy link
Author

deajan commented Dec 26, 2024

So basically this script is not needed anymore, closing in favor of #117.

@deajan deajan closed this Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants