Changeset 4599

Show
Ignore:
Timestamp:
07/28/07 14:09:05 (6 years ago)
Author:
p_lindheimer
Message:

added a start_asterisk script for first time installs to make sure asterisk is running as user asterisk, and modified install_amp instructions to use that script. The issue if, if you start with safe_asterisk, it will start as root

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.3/install_amp

    r4536 r4599  
    691691if ($ret) { 
    692692  out("FAILED"); 
    693   fatal($argv[0]."\n\tAsterisk must be running. If this is a first time install,you should start\n\tAsterisk with the 'safe_asterisk' command (e.g. /usr/sbin/safe_asterisk)\n\tFor upgrading, you should run 'amportal start'"); 
     693  fatal($argv[0]."\n\tAsterisk must be running. If this is a first time install, you should start\n\tAsterisk by typing './start_asterisk start'\n\tFor upgrading, you should run 'amportal start'"); 
    694694} 
    695695out("running with PID: ".$pid_val[0]."..OK"); 
  • freepbx/branches/2.3/start_asterisk

    r4536 r4599  
    33ROOT_UID=0   # root uid is 0 
    44E_NOTROOT=67   # Non-root exit error 
    5  
    65 
    76echo 
     
    1312  exit $E_NOTROOT 
    1413fi 
    15  
    16 # make sure config file exists 
    17 if [ ! -e "/etc/amportal.conf" ]       # Check if file exists. 
    18   then 
    19     echo; 
    20     echo "/etc/amportal.conf does not exist!"; 
    21   echo "Have you installed the AMP configuration?"; 
    22   exit; 
    23 fi 
    24 . /etc/amportal.conf 
    25  
    26 if [ $ASTRUNDIR = /var/run ] 
    27   then 
    28     echo "**** ERROR IN CONFIGURATION ****" 
    29     echo "astrundir in /etc/asterisk/asterisk.conf is set to '/var/run' - THIS IS WRONG." 
    30     echo "Please change it to something sensible (eg, '/var/run/asterisk') and re-run" 
    31     echo "install_amp" 
    32     exit; 
    33 fi 
    34  
    35 chown_asterisk() { 
    36   echo SETTING FILE PERMISSIONS 
    37  
    38   chown -R asterisk:asterisk $ASTRUNDIR 
    39   chown -R asterisk:asterisk /etc/asterisk 
    40   chmod -R g+w /etc/asterisk 
    41   chown -R asterisk:asterisk $ASTVARLIBDIR 
    42   chmod -R g+w $ASTVARLIBDIR 
    43   chown -R asterisk:asterisk $ASTLOGDIR 
    44   chmod -R g+w $ASTLOGDIR 
    45   chown -R asterisk:asterisk $ASTSPOOLDIR 
    46   chmod -R g+w $ASTSPOOLDIR 
    47   chown -R asterisk:asterisk $AMPWEBROOT/admin 
    48   chmod -R g+w $AMPWEBROOT/admin 
    49   chown -R asterisk:asterisk $FOPWEBROOT 
    50   chmod -R g+w $FOPWEBROOT 
    51   chown -R asterisk:asterisk $AMPWEBROOT/recordings 
    52   chmod -R g+w $AMPWEBROOT/recordings 
    53   chown -R asterisk:asterisk $AMPWEBROOT/_asterisk 
    54   chmod u+x,g+x $ASTVARLIBDIR/bin/* 
    55   chown -R asterisk:asterisk $ASTVARLIBDIR/bin/* 
    56   chown -R asterisk:asterisk $AMPBIN/* 
    57  
    58   if [ "$ASTAGIDIR" != "" ]; then 
    59     chmod u+x $ASTAGIDIR/* 
    60   else 
    61     chmod u+x $ASTVARLIBDIR/agi-bin/* 
    62   fi 
    63  
    64   chmod u+x,g+x $AMPBIN/bounce_op.sh 
    65   chmod u+x,g+x $FOPWEBROOT/*.pl 
    66   chmod u+x $FOPWEBROOT/safe_opserver 
    67   chown asterisk /dev/tty9 
    68   # Ensure that various hardware devices are owned correctly. 
    69   [ -e /dev/zap ] && chown -R asterisk:asterisk /dev/zap  
    70   [ -e /dev/capi20 ] && chown -R asterisk:asterisk /dev/capi20 
    71   [ -e /dev/misdn ] && chown -R asterisk:asterisk /dev/misdn 
    72   [ -e /dev/dsp ] && chown -R asterisk:asterisk /dev/dsp 
    73  
    74   echo Permissions OK 
    75 } 
    7614 
    7715check_asterisk() { 
     
    12361} 
    12462 
    125 check_fop() { 
    126 #check to see if FOP is running 
    127   pid_length=`pidof -x op_server.pl|awk '{print length($0)}'` 
    128   if [ "$pid_length" == "0" -a "$pid_length" != "" ] 
    129     then 
    130         ps -ef | grep safe_opserver | grep -v grep | awk '{print $2}' | xargs kill -9 
    131         echo 
    132         echo "-----------------------------------------------------" 
    133         echo "The FOP's server (op_server.pl) could not start!" 
    134         echo "Please correct this problem" 
    135         echo "-----------------------------------------------------" 
    136         exit 0 
    137     fi 
    138 } 
    139  
    140 run_fop() { 
    141 # check to see if FOP is running 
    142 echo 
    143 echo "STARTING FOP SERVER" 
    144 pid_length=`pidof -x op_server.pl|awk '{print length($0)}'` 
    145   if [ "$pid_length" != "0" -a "$pid_length" != "" ] 
    146     then 
    147       echo "FOP server is already running" 
    148     else 
    149       su - asterisk -c "cd $FOPWEBROOT && $FOPWEBROOT/safe_opserver &" 
    150       sleep 1 
    151       check_fop 
    152       echo "FOP Server Started" 
    153     fi 
    154 } 
    155  
    156 stop_fop() { 
    157   echo 
    158   echo "STOPPING FOP SERVER" 
    159   pid_length=`pidof -x op_server.pl|awk '{print length($0)}'` 
    160     if [ "$pid_length" != "0" -a "$pid_length" != "" ] 
    161       then 
    162         ps -ef | grep safe_opserver | grep -v grep | awk '{print $2}' | xargs kill 
    163         killall op_server.pl 
    164         echo "FOP Server Stopped" 
    165       fi 
    166 } 
    167  
    16863kill_amp() { 
    16964  echo 
     
    17873case "$1" in 
    17974  start) 
    180     chown_asterisk 
    18175    run_asterisk 
    182     if [ -z "$FOPRUN" -o "$FOPRUN" == "true" -o "$FOPRUN" == "TRUE" -o "$FOPRUN" == "True" -o "$FOPRUN" == "yes" -o "$FOPRUN" == "YES" -o "$FOPRUN" == "Yes" ] 
    183     then 
    184       run_fop 
    185     fi 
    18676  ;; 
    18777  stop) 
    18878    stop_asterisk 
    189     stop_fop 
    19079  ;; 
    19180  restart) 
    19281    stop_asterisk 
    193     stop_fop 
    19482    sleep 1 
    195     chown_asterisk 
    19683    run_asterisk 
    197     if [ -z "$FOPRUN" -o "$FOPRUN" == "true" -o "$FOPRUN" == "TRUE" -o "$FOPRUN" == "True" -o "$FOPRUN" == "yes" -o "$FOPRUN" == "YES" -o "$FOPRUN" == "Yes" ] 
    198     then 
    199       run_fop 
    200     fi 
    201   ;; 
    202   stop_fop) 
    203     stop_fop 
    204   ;; 
    205   start_fop) 
    206     run_asterisk 
    207     run_fop 
    208   ;; 
    209   restart_fop) 
    210     stop_fop 
    211     run_asterisk 
    212     run_fop 
    213   ;; 
    214   chown) 
    215     chown_asterisk 
    21684  ;; 
    21785  kill) 
     
    22694    echo "stop:        Gracefully stops Asterisk and the FOP server" 
    22795    echo "restart:     Stop and Starts" 
    228     echo "start_fop:   Starts FOP server and Asterisk if not running" 
    229     echo "stop_fop:    Stops FOP serverg" 
    230     echo "restart_fop: Stops FOP server and Starts it and Asterisk if not running" 
    23196    echo "kill:        Kills Asterisk and the FOP server" 
    232     echo "chown:       Sets appropriate permissions on files" 
    23397    echo 
    23498    exit 1