Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 170080 - asterisk init.d scipt without bash
Summary: asterisk init.d scipt without bash
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High enhancement
Assignee: voip herd (OBSOLETE)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-09 10:23 UTC by Natanael Copa
Modified: 2007-03-09 21:00 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
00-unbash.patch (00-unbash.patch,5.71 KB, patch)
2007-03-09 13:19 UTC, Natanael Copa
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Natanael Copa 2007-03-09 10:23:25 UTC
asterisk init.d script uses bash specific features.
Its trivial to make it run with busybox ash for embedded:

diff -ruN data.orig/etc/init.d/asterisk data/etc/init.d/asterisk
--- data.orig/etc/init.d/asterisk       2006-12-20 10:13:39 +0000
+++ data/etc/init.d/asterisk    2006-12-21 13:30:39 +0000
@@ -174,7 +174,7 @@
        fi

        if [[ -n "${ASTERISK_USER}" ]]; then
-               USER=${ASTERISK_USER/:*/}
+               USER=$(echo $ASTERISK_USER | sed 's/:.*//')
                GROUP=$(echo $ASTERISK_USER | awk -F: '/.*:.*/ { print $2 }')
                if [[ -n "${USER}" ]]; then
                        ASTERISK_OPTS="${ASTERISK_OPTS} -U ${USER}"
@@ -191,15 +191,17 @@
        if [[ "$(echo ${ASTERISK_WRAPPER} | tr [:upper:] [:lower:])" != "yes" ]]; then
                start-stop-daemon --start --exec /usr/sbin/asterisk \
                        ${OPTS} -- ${ASTERISK_OPTS}
+               result=$?
        else
                asterisk_run_loop ${ASTERISK_OPTS} 2>/dev/null &
+               result=$?
        fi

        if [[ $result -eq 0 ]]; then
                # 2 seconds should be enough for asterisk to start
-               sleep 2
-
-               result=$(is_running)
+               sleep 2 
+               is_running
+               result=$?
        fi

        eend $result
Comment 1 Natanael Copa 2007-03-09 13:19:47 UTC
Created attachment 112700 [details, diff]
00-unbash.patch

The patch also replaces all [[ with [
Comment 2 solar (RETIRED) gentoo-dev 2007-03-09 15:29:22 UTC
Just a note:

solar@here ~ $ echo FooBar | tr [:upper:] [:lower:]
FooBar
solar@here ~ $ echo FooBar | tr '[:upper:]' '[:lower:]'
foobar
Comment 3 Natanael Copa 2007-03-09 15:36:28 UTC
(In reply to comment #2)
> Just a note:
> 
> solar@here ~ $ echo FooBar | tr [:upper:] [:lower:]
> FooBar
> solar@here ~ $ echo FooBar | tr '[:upper:]' '[:lower:]'
> foobar
> 

what shell is that?

# busybox ash
$ echo FooBar | tr [:upper:] [:lower:]
foobar

Should I submit a new patch?
Comment 4 solar (RETIRED) gentoo-dev 2007-03-09 16:23:04 UTC
> what shell is that?

default shell was bash

But I get the same behavior in both busybox and bash where it needs single ticks.

> Should I submit a new patch?

naa. I'll see if stkn is ok with me commiting your update. I or he will fix it then.

Comment 5 solar (RETIRED) gentoo-dev 2007-03-09 21:00:56 UTC
  09 Mar 2007; <solar@gentoo.org> files/1.2.0/asterisk.rc6:
  - posix compliant init.d script from Natanael Copa. bug 170080

Thanks.