[SOLVED] Centos 7 compatible init.d or systemd script for Asterisk 13

I solved this by:

mv /etc/init.d/asterisk ~/asterisk.init.d.bak

vi /etc/systemd/system/asterisk.service

… and I put in …

[Unit]
Description=Asterisk PBX and telephony daemon
Documentation=man:asterisk(8)
Wants=network.target
After=network.target

[Service]
Type=simple
User=asterisk
Group=asterisk
Environment=HOME=/var/lib/asterisk
WorkingDirectory=/var/lib/asterisk
ExecStart=/usr/sbin/asterisk -f -C /etc/asterisk/asterisk.conf
ExecStop=/usr/sbin/asterisk -rx 'core stop now'
ExecReload=/usr/bin/asterisk -rx 'core reload'

# safe_asterisk emulation
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

… and then running …

systemctl deamon-reload
systemctl enable asterisk
systemctl restart asterisk

Hope this helps someone.

With minor modifications, the service comes from here:

Source

3 Likes