Catégories
Uncategorized

Mise à jour d’un fichier d’alias

Dans cet article, je montre comment tester le resultat d’une commande sous bash, à utiliser à l’interieur d’un if par exemple.

Context : je m’en sert ici pour mettre à jour un fichier d’alias (addresses e-mail). Si l’addresse ne figure pas déjà dans le fichier, l’ajouter.

1/ On cherche toutes les boites qui sont dans la base de données (searchmailbox.sql est un simple script bash qui cherche des e-mails dans la base de données)

root@messagerie-secours[CHROOT]10.10.10.19 ~/SCRIPTS/MAIL # ./searchmailbox.sql @mydomain.tld | awk ‘{print $2}’

sdg.eprs@mydomain.tld
chabane.lounakel@mydomain.tld
n.chabi@mydomain.tld
saad.taraf@mydomain.tld
mustafa.benaoumeur@mydomain.tld
djilali.merad@mydomain.tld
abdelmadjid.aissa@mydomain.tld
root@messagerie-secours[CHROOT]10.10.10.19 ~/SCRIPTS/MAIL #

On peut rediriger vers un fichier temporaire pour enlever les lignes vides et les titres des colonnes (e-mail / name).

2/ Ensuite, il faut chercher chaque boite dans le fichier alias et ne lister que celles qui ne sont pas trouvées.

root@messagerie-secours[CHROOT]10.10.10.19 ~/SCRIPTS/MAIL # while read -r box; do if ! grep -q $box /etc/postfix/maps/global; then echo $box; fi; done < /tmp/allboxes
postmaster@mydomain.tld
ms.saidi@mydomain.tld
chadly-disabled@mydomain.tld
pf-admin@mydomain.tld
arch-admin@mydomain.tld
it-m.a.m@mydomain.tld
z.timtaoucine@mydomain.tld
m.stefan-disabled@mydomain.tld
ntp@mydomain.tld
it-helpdesk@mydomain.tld
owncloud@mydomain.tld
meteo@mydomain.tld
it_support@mydomain.tld
application@mydomain.tld
it-sys@mydomain.tld
panarab@mydomain.tld
saad.taraf@mydomain.tld
mustafa.benaoumeur@mydomain.tld
djilali.merad@mydomain.tld
abdelmadjid.aissa@mydomain.tld
root@messagerie-secours[CHROOT]10.10.10.19 ~/SCRIPTS/MAIL #

Il y a donc, depuis la dernière fois que j’ai mis à jour l’alias, quelques nouvelles boites, judicieusement mises à la fin, sans doute à cause de leur ordre d’insertion dans la base de données. Je n’ai plus qu’à les ajouter à mon fichier global.

 

Catégories
Uncategorized

Jun 28 15:14:25 messagerie postfix/postqueue[7275]: fatal: write error: Input/output error

Des milliers de lignes de ce type ont soudainement commencé à apparaître sur mon fichier de log

Jun 28 15:14:14 messagerie postfix/postqueue[7222]: fatal: write error: Input/output error
Jun 28 15:14:15 messagerie postfix/postqueue[7227]: fatal: write error: Input/output error
Jun 28 15:14:16 messagerie postfix/postqueue[7234]: fatal: write error: Input/output error
Jun 28 15:14:17 messagerie postfix/postqueue[7238]: fatal: write error: Input/output error
Jun 28 15:14:18 messagerie postfix/postqueue[7243]: fatal: write error: Input/output error
Jun 28 15:14:19 messagerie postfix/postqueue[7248]: fatal: write error: Input/output error
Jun 28 15:14:20 messagerie postfix/postqueue[7253]: fatal: write error: Input/output error
Jun 28 15:14:21 messagerie postfix/postqueue[7259]: fatal: write error: Input/output error
Jun 28 15:14:22 messagerie postfix/postqueue[7263]: fatal: write error: Input/output error
Jun 28 15:14:23 messagerie postfix/postqueue[7267]: fatal: write error: Input/output error
Jun 28 15:14:24 messagerie postfix/postqueue[7271]: fatal: write error: Input/output error
Jun 28 15:14:25 messagerie postfix/postqueue[7275]: fatal: write error: Input/output error

postfix stop/start n’y a rien fait !

Sur #postfix

https://i0.wp.com/i.imgur.com/Or5B8N6.png

Sur le serveur

root@messagerie[CHROOT][10.10.10.19] ~ # ps ax | grep bash
 3882 pts/5    Ss     0:00 -bash
 9155 pts/5    S+     0:00 grep --color=always bash
14591 pts/7    Ss     0:00 -bash
14614 pts/9    Ss     0:00 -bash
14657 pts/12   Ss     0:00 -bash
14775 pts/7    S      0:00 bash
 7558 ?        S      0:00 bash
14786 pts/9    S      0:00 bash
14814 pts/12   S+     0:01 bash
22057 pts/0    Ss     0:00 -bash
22149 pts/0    S+     0:00 bash
30553 pts/1    Ss     0:00 -bash
30584 pts/1    S      0:00 bash
30763 pts/2    Ss     0:00 -bash
30797 pts/2    S      0:00 bash
30898 pts/3    Ss     0:00 -bash
30932 pts/3    S      0:00 bash
root@messagerie[CHROOT][10.10.10.19] ~ #

Je détecte la ligne avec un « ? », c’est un processus qui n’est associé à aucun tty, donc potentiellement celui qui pose problème. Un petit strace pour voir un peu ce qu’il fait ?

root@messagerie[CHROOT][10.10.10.19] ~ # strace -p 7558
Process 7558 attached - interrupt to quit
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 69}], WSTOPPED|WCONTINUED, NULL) = 7238
rt_sigprocmask(SIG_BLOCK, [CHLD TSTP TTIN TTOU], [CHLD], 8) = 0
ioctl(255, TIOCSPGRP, [7558])           = -1 ENOTTY (Inappropriate ioctl for device)
rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) = 0
ioctl(255, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff0718ff00) = -1 EIO (Input/output error)
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
wait4(-1, 0x7fff0718fa9c, WNOHANG|WSTOPPED|WCONTINUED, NULL) = -1 ECHILD (No child processes)
rt_sigreturn(0xffffffffffffffff)        = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
pipe([3, 4])                            = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f86b6a7d9d0) = 7240
setpgid(7240, 7240)                     = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
close(3)                                = 0
close(4)                                = 0
ioctl(255, TIOCGPGRP, [0])              = -1 EIO (Input/output error)
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WSTOPPED|WCONTINUED, NULL) = 7240
rt_sigprocmask(SIG_BLOCK, [CHLD TSTP TTIN TTOU], [CHLD], 8) = 0
ioctl(255, TIOCSPGRP, [7558])           = -1 ENOTTY (Inappropriate ioctl for device)
rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) = 0
ioctl(255, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff0718ffb0) = -1 EIO (Input/output error)
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0

Voilà, le Input/output error semblent venir de là. La prochaine étape a été de killer tous les process bashs que j’avais créé le matin.

Catégories
Uncategorized

Batch thumbnail creation from the command line

for file in 100_029* 100_03*; do convert $file -resize 25% resized/$file; done;