Tuesday, June 13, 2017

Postfix can not start via systemd (simple fix)

Solving problem related to systemd process

I like postfix.   This is really smart and secure mail server. I'm helping above  dozen clients around the world and  tunning  postfix is really fun task. This morning I was downgrading postfix  to the stable version for one of the my friends and come across interesting issue. 

root@newserver:/etc/init.d# systemctl  status  postfix 
● postfix.service
   Loaded: masked (/dev/null; bad)
   Active: inactive (dead) since вт 2017-06-13 14:35:41 EEST; 1h 48min ago
 Main PID: 25145 (code=exited, status=0/SUCCESS)

чер 13 14:47:09 newserver systemd[1]: Stopped postfix.service.
чер 13 14:47:29 newserver systemd[1]: Stopped postfix.service.
чер 13 14:58:22 newserver systemd[1]: Stopped postfix.service.
чер 13 14:58:23 newserver systemd[1]: Stopped postfix.service.
чер 13 15:05:20 newserver systemd[1]: Stopped postfix.service.
чер 13 15:29:06 newserver systemd[1]: Stopped postfix.service.
чер 13 15:29:06 newserver systemd[1]: Stopped postfix.service.
чер 13 15:32:06 newserver systemd[1]: Stopped postfix.service.
чер 13 15:32:07 newserver systemd[1]: Stopped postfix.service.
чер 13 15:35:54 newserver systemd[1]: Stopped postfix.service.
Warning: postfix.service changed on disk. Run 'systemctl daemon-reload' to reload units.

 I don't like systemd.  This service takes so much responsibility IMHO.  I'm preferring  init.d  scripts  (looks like I'm old fashion guy). If service can not start then checking startup files is correct way.
I have not seen it in default  systemd directory and  check  that other files are present  and are correct. finally detect it under /etc/default:
root@newserver:/lib/systemd/system# ls pos*
postgresql.service  postgresql@.service
root@newserver:/lib/systemd/system# cat postgresql.service 
# systemd service for managing all PostgreSQL clusters on the system. This
# service is actually a systemd target, but we are using a service since
# targets cannot be reloaded.

[Unit]
Description=PostgreSQL RDBMS

[Service]
Type=oneshot
ExecStart=/bin/true
ExecReload=/bin/true
RemainAfterExit=on

[Install]
WantedBy=multi-user.target

root@newserver:/lib/systemd/system# ls /etc/systemd/system/
clamav-daemon.socket.d/      network-online.target.wants/ sockets.target.wants/        syslog.service               
getty.target.wants/          paths.target.wants/          sshd.service                 timers.target.wants/         
multi-user.target.wants/     postfix.service              sysinit.target.wants/        


But  this file is  softlink   to /dev/null only:

root@newserver:/lib/systemd/system# ls /etc/systemd/system/postfix.service  -la
lrwxrwxrwx 1 root root 9 чер 13 14:35 /etc/systemd/system/postfix.service -> /dev/null

I've  deleted this only and reinstalled postfix for generating new one. After this postfix  is going to be green.
root@newserver:/lib/systemd/system# systemctl  daemon-reload
root@newserver:/lib/systemd/system# systemctl   status postfix
● postfix.service - LSB: Postfix Mail Transport Agent
   Loaded: loaded (/etc/init.d/postfix; bad; vendor preset: enabled)
  Drop-In: /run/systemd/generator/postfix.service.d
           └─50-postfix-$mail-transport-agent.conf
   Active: inactive (dead) since вт 2017-06-13 14:35:41 EEST; 1h 57min ago
     Docs: man:systemd-sysv-generator(8)
 Main PID: 25145 (code=exited, status=0/SUCCESS)

чер 13 14:47:09 newserver systemd[1]: Stopped postfix.service.
чер 13 14:47:29 newserver systemd[1]: Stopped postfix.service.
чер 13 14:58:22 newserver systemd[1]: Stopped postfix.service.
чер 13 14:58:23 newserver systemd[1]: Stopped postfix.service.
чер 13 15:05:20 newserver systemd[1]: Stopped postfix.service.
чер 13 15:29:06 newserver systemd[1]: Stopped postfix.service.
чер 13 15:29:06 newserver systemd[1]: Stopped postfix.service.
чер 13 15:32:06 newserver systemd[1]: Stopped postfix.service.
чер 13 15:32:07 newserver systemd[1]: Stopped postfix.service.
чер 13 15:35:54 newserver systemd[1]: Stopped postfix.service.
root@newserver:/lib/systemd/system# apt-get install  --reinstall  postfix
Зчитування переліків пакунків... Виконано
Побудова дерева залежностей                        
Зчитування інформації про стан... Виконано
оновлено 0, встановлено 0 нових, 1 перевстановлено, 0 відмічено для видалення і 8 не оновлено.
Необхідно завантажити 0 B/1 374 kB архівів.
Після цієї операції об'єм зайнятого дискового простору зросте на 0 B.
Передналаштування пакунків...
(Reading database ... 73453 files and directories currently installed.)
Preparing to unpack .../postfix_2.11.3-1+deb8u2_amd64.deb ...
Unpacking postfix (2.11.3-1+deb8u2) over (2.11.3-1+deb8u2) ...
Processing triggers for man-db (2.7.4-1) ...
Processing triggers for ufw (0.33-2) ...
Processing triggers for systemd (229-2) ...
Setting up postfix (2.11.3-1+deb8u2) ...

Postfix configuration was not changed.  If you need to make changes, edit
/etc/postfix/main.cf (and others) as needed.  To view Postfix configuration
values, see postconf(1).

After modifying main.cf, be sure to run '/etc/init.d/postfix reload'.

Running newaliases
root@newserver:/lib/systemd/system# systemctl  daemon-reload
root@newserver:/lib/systemd/system# systemctl   status postfix
● postfix.service - LSB: Postfix Mail Transport Agent
   Loaded: loaded (/etc/init.d/postfix; bad; vendor preset: enabled)
  Drop-In: /run/systemd/generator/postfix.service.d
           └─50-postfix-$mail-transport-agent.conf
   Active: active (running) since вт 2017-06-13 16:34:26 EEST; 12s ago
     Docs: man:systemd-sysv-generator(8)
 Main PID: 25145 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/postfix.service
           ├─20894 /usr/lib/postfix/master
           ├─20895 pickup -l -t unix -u -c
           └─20896 qmgr -l -t unix -u

чер 13 16:34:26 newserver systemd[1]: Starting LSB: Postfix Mail Transport Agent...
чер 13 16:34:26 newserver postfix[20782]: Starting Postfix Mail Transport Agent: postfix.
чер 13 16:34:26 newserver systemd[1]: Started LSB: Postfix Mail Transport Agent.
чер 13 16:34:26 newserver postfix/master[20894]: daemon started -- version 2.11.3, configuration /etc/postfix