|Summary:||ASTERISK-01982: [patch] Debian init script|
|Date Opened:||2004-07-09 17:54:34||Date Closed:||2008-01-15 15:03:23.000-0600|
|Environment:||Attachments:||( 0) asterisk|
|Description:||There's init scripts for gentoo, mandrake, and redhat, but not a debian one in the CVS. The debian package has a script which I have attached. It is set up to setuid to asterisk before launching.|
****** ADDITIONAL INFORMATION ******
This script was written by Ian Murdock for the Debian distribution. I have copied the code without modification for inclusion. I hope this is OK.
|Comments:||By: Mark Spencer (markster) 2004-07-09 17:58:20|
we will need his permission to put it in place.
By: pi (pi) 2004-07-09 18:50:49
Debian Free Software Guideline clause 1:
The license of a Debian component may not restrict any party from selling or giving away the software as a component of an aggregate software distribution containing programs from several different sources. The license may not require a royalty or other fee for such sale.
The rights attached to the program must apply to all to whom the program is redistributed without the need for execution of an additional license by those parties.
I feel this constitutes permission, but I will also send an email.
By: Mark Spencer (markster) 2004-07-09 18:58:51
If nothing else it is at least a courtesy.
By: damin (damin) 2004-07-12 17:32:29
Alright.. after several months of running Asterisk under Debian and using my own startup scripts, I tried the Debian Unstable Asterisk Startup scripts and I found that they would bomb out. The reason was that the startup script was attempting to start asterisk as user "asterisk". This is accomplished by setting "NAME=asterisk" in the beginning of the file and using "start-stop-daemon --start --chuid $NAME --exec $DAEMON" to start the system.
For me, I run Asterisk as root, and I constantly update with CVS, so I simply removed the "--chuid $NAME" option and voila. It works. Attached is a lame little patch that does this.
By: zoa (zoa) 2004-07-13 02:15:25
damin, could you contribute your scripts ?
By: schurig (schurig) 2004-07-13 07:50:06
I'm not sure if there is a need for a debian initscript in Asterisk.
There is a Asterisk package in debian named asterisk-0.9-1 (braindead name, as far as I know there was never Asterisk 0.9 out there, the package should be named asterisk-0.2004mmdd-1 with mm/dd the month & date of the CVS checkout.
Anyway, this debian package contains an init script.
By: pi (pi) 2004-07-13 09:51:18
schurig - when running asterisk from CVS (not from the package) on Debian, it is useful to have it. I usually end up copying it from the machine I originally installed the package on.
In other news, i'm still awaiting a response from imurdock.
By: damin (damin) 2004-07-13 11:20:58
OK.. some thoughts before I jump willy nilly into this. Debian packages appear to run as non-root, while CVS still expects to be run as root. Is it official "policy" that the system should be run as root? If so, then I can certainly modify the init scripts that I have in my RPMs so that they function on Debian, as I did with my Zaptel init scripts. If not, that is a design change that needs to be taken into consideration. There are several different startup scripts out there for various Distros. Would it be the goal of these scripts to be separated by distribution? Or would it be the goal to have a universal script that can recognize which distribution it is running on and act accordingly? In my opinion, the later is more convenient, but more complex to architect and debug, while the former is simple, easy code that 99% of the work has been done for already.
So.. questions I need answered from the developers:
1. Run as Root? (Yes / No)
2. Distro Specific vs. Distro Agnostic Script? (Specific / Agnostic)
Gimme some direction and I'll work them up..
By: twisted (twisted) 2004-07-13 11:36:04
Actually, there was a tarball release of Asterisk 0.9. Debian is right on target there, however, I agree with the snapshot naming.... 0.9 is entierly way too out of date. Also, as far as init scripts go, I do not agree with your comments on irc to have an entire debian/ sub-tree. What we really ought to do, IMHO, is modify the top level makefile to where you would type 'make install distro' where distro is the name of the distrobution you have, and we would install the proper init scripts into the proper locations.
Just my $.02
By: pi (pi) 2004-07-14 19:16:25
the email I sent to imurdock bounced (a week after I sent it, with a host not found error...) - I sent another email to the current maintainer of the debian package and am awaiting reply.
By: pi (pi) 2004-07-15 10:11:59
On Wed, Jul 14, 2004 at 05:54:22PM -0600, Anthony Martinez wrote:
> I have submitted your /etc/init.d/asterisk script to the Asterisk CVS, but they
> require your permission to include the file.
I have just updated the init.d file to read:
# asterisk start the asterisk PBX
# (c) Mark Purcell <email@example.com>
# May be distributed under the terms of this General Public License
> I felt that it was covered under clause 1 and 7 of the DFSG, but wished to
> confirm with you to ensure safety.
The debian/copyright file states that the entire package is distributed
under the GPL. But better to be sure..
Please use this email as authorisation until the asterisk deb's are
By: damin (damin) 2004-07-17 22:53:24
Alright.. this can be closed out. BKW, BRC and I spent about an hour on this tonight and got this taken care of. I have uploaded a file "asterisk (1,226 bytes) 07-17-04 22:43" that is a modified Debian init script that takes into account many of the discussions that have taken place.
1. Debian defaults to running asterisk as a non-root user. Per Mark, he believes that this is a decision best left up to the distribution and the package maintainer, so the CVS provided script should run as root. Accordingly, our script trashes the "--chuid" option that Debian uses.
2. Our script tests for safe_asterisk and uses it. If it does not exist, then it will just call asterisk directly.
3. When "asterisk stop" is called, we opted for "stop gracefully" instead of "stop now" just because we are nice guys, and BKW advises this is a better option.
4. There is a potential race condition that can occur using safe_asterisk in the event that Asterisk is not entirely initialized before it is asked to shut down. In this instance (I.E. asterisk start called and then user three finger salutes, causing asterisk stop to be called) safe_asterisk may try to restart the system. Never fear, however, as the eventual SIGTERM sent to all processes as the system shuts down will cause asterisk to nicely commit suicide. So, this, while noted, isn't likely to be a problem unless you run Asterisk on a P133 w/ 16 megs of ram (like me! ;) and in any case Asterisk doesn't run too well when the power shuts off to the workstation.
I'd like to request that we add the "asterisk" script attached above to CVS and close out this bug report.
edited on: 07-17-04 22:39
By: Mark Spencer (markster) 2004-07-18 12:21:51
Perhaps it would be useful to have a user option in asterisk.conf and/or as a command line option to asterisk? Then Asterisk can immediately setuid when it starts if that user is specified.
By: damin (damin) 2004-07-18 12:27:22
I think that both suggestions are good ones. From a security perspective, there is no reason for Asterisk to run as root as long as the Zap devices have the appropriate permissions. However, I'm not sure that it is a relevant issue to this particular bug note, as either change would be trivial to implement/modify in the init script once it is in CVS. My suggestion is that if the decision is made to implement setuid Asterisk, then that be handled as a different bug, and if this script has the blessings of the appropriate people, lets get it into CVS.
By: Mark Spencer (markster) 2004-07-18 14:41:05
I've added -U and -G. Perhaps the script can be updated to at least show that these options can be used.
Also, not related to the script, but to packaging in general, I've also added a man page.
By: damin (damin) 2004-07-19 00:52:18
I have updated the Debian init script to contain the same logic as the RedHat init script. It works. I've also deleted, per BKW's suggestion, all the old cruft files from this bug tracker.
By: damin (damin) 2004-07-19 00:56:13
This code is based on the RedHat code that has been merged into CVS from bug 2079.
By: brc007 (brc007) 2004-07-19 02:06:02
I've tested this script and it functions as advertised for me.
I'd say it's ready for CVS.
By: brc007 (brc007) 2004-07-19 15:58:47
Note: 0002085 (Add command line arguments to safe_asterisk) needs to be committed for 0002079 (RedHat asterisk init script replacement) and 0002008 (this bug) to work properly with setting the user and group.
By: Joshua C. Colp (jcolp) 2004-07-23 20:50:10
This init script works perfectly on Debian woody. I would consider it ready to be added to the CVS as well. Thanks for a nice startup script Damin!
By: Mark Spencer (markster) 2004-07-23 23:32:33
Added to CVS. Thanks to all of you for working so hard together to make this script happen.
By: Digium Subversion (svnbot) 2008-01-15 15:03:23.000-0600
r3501 | markster | 2008-01-15 15:03:22 -0600 (Tue, 15 Jan 2008) | 2 lines
Add debian initialization script (bug ASTERISK-1982)