Gentoo doesn't provide systemd service files for net-misc/asterisk. Suggested file asterisk.service (taken from Fedora http://pkgs.fedoraproject.org/cgit/asterisk.git/tree/asterisk.service ): [Unit] Description=Asterisk PBX and telephony daemon. After=network.target [Service] Type=simple Environment=HOME=/var/lib/asterisk WorkingDirectory=/var/lib/asterisk User=asterisk Group=asterisk ExecStart=/usr/sbin/asterisk -f -C /etc/asterisk/asterisk.conf ExecStop=/usr/sbin/asterisk -rx 'core stop now' ExecReload=/usr/sbin/asterisk -rx 'core reload' # To emulate some of the features of the safe_asterisk script, copy # this file to /etc/systemd/system/asterisk.service and uncomment one # or more of the following lines. For more information on what these # parameters mean see: # # http://0pointer.de/public/systemd-man/systemd.service.html # http://0pointer.de/public/systemd-man/systemd.exec.html #Nice=0 #UMask=0002 #LimitCORE=infinity #LimitNOFILE= #Restart=always #RestartSec=4 # If you uncomment the following you should add '-c' to the ExecStart line above #TTYPath=/dev/tty7 #StandardInput=tty #StandardOutput=tty #StandardError=tty PrivateTmp=true [Install] WantedBy=multi-user.target Here's the upstream bug report: https://issues.asterisk.org/jira/browse/ASTERISK-21991 Reproducible: Always
I've put some inital service files in place - which is mainly a cleaned up version of the version coming from fedora. The user configurable part for enabling a debug console on a TTY now resides (completeyl commented in) under /etc/systemd/system/asterisk.service.d/00gentoo.conf There is a minor caveat with above configuration with the configuration and a bug in systemd, though [1]. A fix is to not set User=asterisk, Group=asterisk in the service file but in the configuration file /etc/asterisk/asterisk.conf. But due to history, this is way too dangerous to change - if a user forgets to update a modified asterisk.conf file, asterisk runs with root privileges :-/ [1] https://bugs.freedesktop.org/show_bug.cgi?id=85255 *asterisk-11.14.2-r1 (30 Dec 2014) *asterisk-11.15.0-r1 (30 Dec 2014) *asterisk-12.8.0-r1 (30 Dec 2014) *asterisk-12.7.2-r1 (30 Dec 2014) 30 Dec 2014; Matthias Maier <tamiko@gentoo.org> +asterisk-11.14.2-r1.ebuild, +asterisk-11.15.0-r1.ebuild, +asterisk-12.7.2-r1.ebuild, +asterisk-12.8.0-r1.ebuild, +files/asterisk.service, +files/asterisk.service.conf, +files/asterisk.tmpfiles.conf: provide systemd service files, bug #529192
A, I should have been a bit more precise: This bug only triggers if the optional TTY debug console is enabled. The default service file commited is unaffected.