Asterisk connect error: /var/run/asterisk/asterisk.ctl?


#1

After installing asterisk on Fedora Core 14 according to Get Started document, the service can be started successfully.

service asterisk start

service asterisk status

asterisk (pid 25897) is running…

ps aux | grep asterisk

root 26125 0.0 0.0 5136 552 pts/0 S 12:02 0:00 /bin/sh /usr/sbin/safe_asterisk
root 26127 116 0.7 36244 15568 ? Rl 12:02 0:03 /usr/sbin/asterisk -f -vvvg -c
root 26169 0.0 0.0 4416 712 pts/0 S+ 12:02 0:00 grep --color=auto asterisk

asterisk -r

Asterisk 1.8.7.0, Copyright © 1999 - 2011 Digium, Inc. and others.
Created by Mark Spencer markster@digium.com
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘core show license’ for details.

Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)

After stop the asterisk, and start it by safe_asterisk, it works

safe_asterisk

ps aux | grep asterisk

root 26001 0.0 0.0 5084 552 pts/0 S 11:59 0:00 /bin/sh /usr/sbin/safe_asterisk
root 26003 2.5 0.7 37768 15600 pts/0 Sl 11:59 0:00 /usr/sbin/asterisk -f -vvvg -c
root 26045 0.0 0.0 4416 708 pts/0 S+ 11:59 0:00 grep --color=auto asterisk

asterisk -r

Asterisk 1.8.7.0, Copyright © 1999 - 2011 Digium, Inc. and others.
Created by Mark Spencer markster@digium.com
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘core show license’ for details.

Connected to Asterisk 1.8.7.0 currently running on server1 (pid = 26003)
Verbosity is at least 3
server1*CLI>

We need to start asterisk on system boot. How to solve this problem?
Thanks for help.
Dave


#2

Tried asterisk in console mode

asterisk -vvvc

It says: Asterisk Ready.
no errors.

Successful in connecting from another terminal:

asterisk -r

Asterisk 1.8.7.0, Copyright © 1999 - 2011 Digium, Inc. and others.
Created by Mark Spencer markster@digium.com
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘core show license’ for details.

Connected to Asterisk 1.8.7.0 currently running on server1 (pid = 26381)
Verbosity is at least 3
server1*CLI>

Thanks for help.
Dave


#3

Hello Dave,

If that is what You need , You can set it in /etc/rc.local script , which will be executed every time at system boot.
to perform this just add /usr/sbin/safe_asterisk in new line of this script.

Good luck.


#4

There is a better way of doing this, as there are proper startup scripts.

He has run those manually, so it doesn’t look as though the problem relates to not running them.


#5

[quote=“david55”]There is a better way of doing this, as there are proper startup scripts.
[/quote]
Yep , maybe it’s not the best way - but I use it on some of my servers without any problems .

to Dave
Please could you sent output from bash -x /etc/init.d/asterisk start , maybe is there something wrong or PID is created somewhere else.


#6

Thanks for reply.

#bash -x /etc/init.d/asterisk start

  • AST_SBIN=/usr/sbin

  • . /etc/rc.d/init.d/functions
    ++ TEXTDOMAIN=initscripts
    ++ umask 022
    ++ PATH=/sbin:/usr/sbin:/bin:/usr/bin
    ++ export PATH
    ++ ‘[’ 2133 -ne 1 -a -z ‘’ ‘]’
    ++ /bin/mountpoint -q /cgroup/systemd
    ++ /bin/mountpoint -q /sys/fs/cgroup/systemd
    ++ ‘[’ -z ‘’ ‘]’
    ++ COLUMNS=80
    ++ ‘[’ -z ‘’ ‘]’
    +++ /sbin/consoletype
    ++ CONSOLETYPE=pty
    ++ ‘[’ -z ‘’ ‘]’
    ++ ‘[’ -z ‘’ ‘]’
    ++ ‘[’ -f /etc/sysconfig/i18n ‘]’
    ++ . /etc/profile.d/lang.sh
    ++ unset LANGSH_SOURCED
    ++ ‘[’ -z ‘’ ‘]’
    ++ ‘[’ -f /etc/sysconfig/init ‘]’
    ++ . /etc/sysconfig/init
    +++ BOOTUP=color
    +++ RES_COL=60
    +++ MOVE_TO_COL=‘echo -en \033[60G’
    +++ SETCOLOR_SUCCESS=‘echo -en \033[0;32m’
    +++ SETCOLOR_FAILURE=‘echo -en \033[0;31m’
    +++ SETCOLOR_WARNING=‘echo -en \033[0;33m’
    +++ SETCOLOR_NORMAL=‘echo -en \033[0;39m’
    +++ AUTOSWAP=no
    +++ ACTIVE_CONSOLES=’/dev/tty[1-6]’
    +++ SINGLE=/sbin/sushell
    ++ ‘[’ pty = serial ‘]’
    ++ __sed_discard_ignored_files=’/(~|.bak|.orig|.rpmnew|.rpmorig|.rpmsave)$/d’
    ++ ‘[’ ‘’ = 1 ‘]’

  • ‘[’ -x /usr/sbin/asterisk ‘]’

  • ‘[’ -d ‘]’

  • DAEMON=/usr/sbin/asterisk

  • SAFE_ASTERISK=/usr/sbin/safe_asterisk
    ++ readlink /etc/init.d/asterisk

  • CONFIG0=

  • ‘[’ ‘’ = ‘’ ‘]’
    ++ basename /etc/init.d/asterisk

  • CONFIGFILE=/etc/sysconfig/asterisk

  • ‘[’ -r /etc/sysconfig/asterisk ‘]’

  • . /etc/sysconfig/asterisk
    ++ COLOR=yes

  • RETVAL=0

  • case “$1” in

  • start
    ++ /usr/sbin/asterisk -rx ‘core show version’

  • VERSION=‘Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)’
    ++ echo Unable to connect to remote asterisk ‘(does’ /var/run/asterisk/asterisk.ctl ‘exist?)’
    ++ cut -c 1-8

  • ‘[’ ‘Unable t’ = Asterisk ‘]’

  • echo -n 'Starting asterisk: '
    Starting asterisk: + ‘[’ -f /usr/sbin/safe_asterisk ‘]’

  • DAEMON=/usr/sbin/safe_asterisk

  • ‘[’ ‘]’

  • ‘[’ ‘]’

  • ‘[’ ‘]’

  • ‘[’ ‘]’

  • ‘[’ x = xyes ‘]’

  • ‘[’ 0 -gt 0 ‘]’

  • ‘[’ 0 -gt 0 ‘]’

  • ‘[’ 0 -gt 0 ‘]’

  • ‘[’ x = xyes ‘]’

  • ‘[’ x = xyes -o x = xyes ‘]’

  • ‘[’ xyes = xyes ‘]’

  • export TERM=linux

  • TERM=linux

  • RETVAL=0

  • ‘[’ 0 -eq 0 ‘]’

  • touch /var/lock/subsys/asterisk

  • daemon sh -c ‘/usr/sbin/safe_asterisk -c’

  • echo

  • return 0

  • exit 0


#bash -x /etc/init.d/asterisk start
asterisk -r works,

asterisk -r

Asterisk 1.8.7.0, Copyright © 1999 - 2011 Digium, Inc. and others.
Created by Mark Spencer markster@digium.com
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘core show license’ for details.

Connected to Asterisk 1.8.7.0 currently running on server1 (pid = 2808)
Verbosity is at least 3
server1*CLI>


but if
/etc/init.d/asterisk start
without bash -x,

asterisk -r reports the error.

what is the differences?

Thanks for help.
Dave


#7

It’s interesting, but -x option just echoes the result of each command in some kind of short form.
but nothing else.

Like I see asterisk is in both mentioned cases running so problem is you can’t connect to console, it might be because of permissions.

Please tell us if you are performing all commands from root only.


#8

Yes. I exec all commands using root on Fedoare core 14.
Possibly related to sheel?

Thanks for help.
Dave


#9

Shooting from the hip here but… Is selinux enabled or disabled?

file: /etc/selinux/config
line: SELINUX=disabled

If it is enabled, you should try setting to disabled and restart the OS.


#10

It works great after disabling selinux.

Thanks.
Dave


#11

to disable selinux please use the following either directly in rc.local or in a shell script:
echo 0 > /selinux/enforce

If this is run at startup it will disable every time