Changeset 12357

Show
Ignore:
Timestamp:
08/04/11 17:30:20 (2 years ago)
Author:
xrobau
Message:

Minor fixes for installer, and add the ability to symlink any asterisk path to elsewhere, and it'll still work.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.9/amp_conf/bin/freepbx_engine

    r12230 r12357  
    160160  chmod 640 /etc/amportal.conf 
    161161  chmod 640 $FREEPBX_CONF 
    162   chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $ASTRUNDIR 
    163   chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $ASTETCDIR 
    164   chmod -R g+w $ASTETCDIR 
    165   chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $ASTVARLIBDIR 
    166   chmod g+w $ASTVARLIBDIR 
    167   chmod -R g+w $ASTVARLIBDIR/* 
    168   chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $ASTLOGDIR 
    169   chmod -R g+w $ASTLOGDIR 
    170   chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $ASTSPOOLDIR 
    171   chmod -R g+w $ASTSPOOLDIR 
    172   chown -R $AMPASTERISKWEBUSER:$AMPASTERISKWEBGROUP $AMPWEBROOT/admin 
    173   chmod -R g+w $AMPWEBROOT/admin 
    174   chown -R $AMPASTERISKWEBUSER:$AMPASTERISKWEBGROUP $FOPWEBROOT 
    175   chmod -R g+w $FOPWEBROOT 
    176   chown -R $AMPASTERISKWEBUSER:$AMPASTERISKWEBGROUP $AMPWEBROOT/recordings 
    177   chmod -R g+w $AMPWEBROOT/recordings 
    178   chown -R $AMPASTERISKWEBUSER:$AAMPASTERISKWEBGROUP $AMPWEBROOT/_asterisk 
    179   chmod u+x,g+x $AMPBIN/* 
    180   chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $AMPBIN/* 
     162  chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $(readlink -f $ASTRUNDIR) 
     163  chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $(readlink -f $ASTETCDIR) 
     164  chmod -R g+w $(readlink -f $ASTETCDIR) 
     165  chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $(readlink -f $ASTVARLIBDIR) 
     166  chmod -R g+w $(readlink -f $ASTVARLIBDIR) 
     167  chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $(readlink -f $ASTLOGDIR) 
     168  chmod -R g+w $(readlink -f $ASTLOGDIR) 
     169  chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $(readlink -f $ASTSPOOLDIR) 
     170  chmod -R g+w $(readlink -f $ASTSPOOLDIR) 
     171  chown -R $AMPASTERISKWEBUSER:$AMPASTERISKWEBGROUP $(readlink -f $AMPWEBROOT/admin) 
     172  chmod -R g+w $(readlink -f $AMPWEBROOT/admin) 
     173  chown -R $AMPASTERISKWEBUSER:$AMPASTERISKWEBGROUP $(readlink -f $FOPWEBROOT) 
     174  chmod -R g+w $(readlink -f $FOPWEBROOT) 
     175  chown -R $AMPASTERISKWEBUSER:$AMPASTERISKWEBGROUP $(readlink -f $AMPWEBROOT/recordings) 
     176  chmod -R g+w $(readlink -f $AMPWEBROOT/recordings) 
     177  chown -R $AMPASTERISKWEBUSER:$AAMPASTERISKWEBGROUP $(readlink -f $AMPWEBROOT/_asterisk) 
     178  chmod u+x,g+x $(readlink -f $AMPBIN)/* 
     179  chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $(readlink -f $AMPBIN) 
    181180 
    182181  if [ "$FPBXDBUGFILE" != "" -a -e "$FPBXDBUGFILE" ]; then 
    183     chown $AMPASTERISKWEBUSER:$AMPASTERISKWEBGROUP $FPBXDBUGFILE 
     182    chown $AMPASTERISKWEBUSER:$AMPASTERISKWEBGROUP $(readlink -f $FPBXDBUGFILE) 
    184183  fi 
    185184 
    186185  if [ "$FPBX_LOG_FILE" != "" -a -e "$FPBX_LOG_FILE" ]; then 
    187     chown $AMPASTERISKWEBUSER:$AMPASTERISKWEBGROUP $FPBX_LOG_FILE 
     186    chown $AMPASTERISKWEBUSER:$AMPASTERISKWEBGROUP $(readlink -f $FPBX_LOG_FILE) 
    188187  fi 
    189188     
    190189  if [ "$ASTAGIDIR" != "" ]; then 
    191190    chmod u+x $ASTAGIDIR/* 
    192     chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $ASTAGIDIR 
     191    chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $(readlink -f $ASTAGIDIR) 
    193192  else 
    194     chmod u+x $ASTVARLIBDIR/agi-bin/* 
     193    chmod u+x $(readlink -f $ASTVARLIBDIR/agi-bin) 
    195194  fi 
    196195 
  • freepbx/branches/2.9/amp_conf/bin/freepbx_setting

    r11535 r12357  
    4747$user = trim(`whoami`); 
    4848$sudo_command = trim(getenv('SUDO_COMMAND')); 
    49 if ($user == 'root' && $sudo_command == '') { 
    50   $web_user = $freepbx_conf->get_conf_setting('AMPASTERISKWEBUSER'); 
     49$web_user = $freepbx_conf->get_conf_setting('AMPASTERISKWEBUSER'); 
     50exec("id $web_user 2>&1", $null, $retvar); 
     51if ($web_user != "" && $retvar == 0 && $user == 'root' && $sudo_command == '') { 
    5152  out(sprintf(_("trying to run as user %s:"),$web_user)); 
    5253  out(''); 
  • freepbx/branches/2.9/install_amp

    r12250 r12357  
    5454  out("  --asteriskuser <user>    Asterisk Manager username",false); 
    5555  out("  --asteriskpass <pass>    Asterisk Manager password",false); 
    56   out("  --systemconfig <path>    System config files",false); 
    5756  out("  --debug                  Enable debug output",false); 
    5857  out("  --dry-run                Don't actually do anything",false); 
     
    6968  out("  --my-svn-is-correct      Ignore Asterisk version, assume it is correct",false); 
    7069  out("  --engine <name>          Use the specified PBX Engine ('asterisk')",false); 
     70  out("  --uid <user>             Set ownership of files to user",false); 
     71  out("  --gid <group>            Set ownership of files to group",false); 
     72  out("  --scripted               Scripted install. Do not ask any questions.",false); 
     73  out("                           (Intended for unattended installers only)",false); 
    7174} 
    7275 
     
    225228  global $asterisk_user; 
    226229  global $asterisk_pass; 
     230  global $scripted; 
     231  global $freepbxip; 
     232  global $runas_uid; 
     233  global $runas_gid; 
    227234 
    228235  out("Creating new $filename"); 
    229236   
     237  if ($scripted == true) { 
     238    # Scripted install. Everything should have been set for us, don't ask questions. 
     239    out("Scripted install. Accepting command line params."); 
     240    $amp_conf["AMPDBUSER"] = $dbuser; 
     241    $amp_conf["AMPDBPASS"] = $dbpass; 
     242    $amp_conf["AMPDBHOST"] = $dbhost; 
     243    $amp_conf["AMPDBNAME"] = $dbname; 
     244    $amp_conf["AMPMGRUSER"] = "admin"; 
     245    $amp_conf["AMPMGRPASS"] = "unset"; 
     246    $amp_conf["AMPWEBROOT"] = $webroot; 
     247    $amp_conf["FOPWEBROOT"] = ($fopwebroot ? $fopwebroot : $webroot."/panel"); 
     248    $amp_conf["AMPWEBADDRESS"] = $freepbxip; 
     249    $amp_conf["FOPPASSWORD"] = "passw0rd"; 
     250    $amp_conf["AMPEXTENSIONS"] = "extensions"; 
     251    $amp_conf["AMPBIN"] = $ampbin_dir; 
     252    $amp_conf["AMPSBIN"] = "$ampsbin_dir"; 
     253    $amp_conf["AMPASTERISKWEBUSER"] = $runas_uid; 
     254    $amp_conf["AMPASTERISKWEBGROUP"] = $runas_gid; 
     255    $amp_conf["AMPASTERISKUSER"] = $runas_uid; 
     256    $amp_conf["AMPASTERISKGROUP"] = $runas_gid; 
     257    $amp_conf["AMPDEVUSER"] = $runas_uid; 
     258    $amp_conf["AMPDEVGROUP"] = $runas_gid; 
     259    write_amportal_conf($filename, $amp_conf); 
     260    outn(AMP_CONF." written"); 
     261    return; 
     262  } 
     263     
    230264  outn("Enter your USERNAME to connect to the '$dbname' database:\n [".($dbuser ? $dbuser : $asterisk_user) . "] "); 
    231265  $key = trim(fgets(STDIN,1024)); 
     
    283317    $amp_conf["FOPWEBROOT"] = $fopwebroot; 
    284318   
    285   outn("Enter the IP ADDRESS or hostname used to access the AMP web-admin:\n [xx.xx.xx.xx] "); 
     319  outn("Enter the IP ADDRESS or hostname used to access the AMP web-admin:\n [$freepbxip] "); 
    286320  $key = trim(fgets(STDIN,1024)); 
    287   if (preg_match('/^$/',$key)) $amp_conf["AMPWEBADDRESS"] = "xx.xx.xx.xx"
     321  if (preg_match('/^$/',$key)) $amp_conf["AMPWEBADDRESS"] = $freepbxip
    288322  else $amp_conf["AMPWEBADDRESS"] = $key; 
    289323   
     
    542576// **** Parse out command-line options 
    543577$shortopts = "h?u:p:"; 
    544 $longopts = array("help","debug","dry-run","username=","password=","force-version=","dbhost=","no-files","force-overwrite","dbname=","my-svn-is-correct","engine=","webroot=","install-moh","install-fop=","make-links-devel","dev-links","skip-module-install"); 
     578$longopts = array("help","debug","dry-run","username=","password=","force-version=","dbhost=","no-files","force-overwrite","dbname=","my-svn-is-correct","engine=","webroot=","install-moh","install-fop=","make-links-devel","dev-links","skip-module-install","uid=","gid=","scripted","freepbxip="); 
    545579 
    546580$args = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), $shortopts, $longopts); 
     
    555589$install_files = true; 
    556590$override_astvers = false; 
     591$scripted = false; 
    557592 
    558593$install_moh = false; 
     
    563598//initialize variables to avoid php notices 
    564599$dbhost = null;  
    565 $dbname = null;  
     600$dbname = 'asterisk';  
    566601$new_username = null; 
    567602$new_password = null; 
     603 
     604$runas_uid = "asterisk"; 
     605$runas_gid = "asterisk"; 
     606$freepbxip = "192.168.1.1"; 
    568607 
    569608foreach ($args[0] as $arg) { 
     
    654693    case "--sbin": 
    655694      $ampsbin_dir = $arg[1]; 
    656       out("Using sbin ar ".$ampsbin_dir); 
     695      out("Using sbin at ".$ampsbin_dir); 
    657696    break; 
    658697    case "--asteriskuser": 
     
    664703      out("Using asteriskpass ".str_repeat("*",strlen($arg[1]))); 
    665704    break; 
    666  
    667 /*    do we need this ? 
    668     case "--systemconfig": 
    669       $systemconfig = $arg[1]; 
    670       out("Using system config at ". $systemconfig); 
    671     break;  
    672 */ 
     705    case "--uid": 
     706      $runas_uid = $arg[1]; 
     707      out("Setting ownership (user) to ".$runas_uid); 
     708    break; 
     709    case "--gid": 
     710      $runas_gid = $arg[1]; 
     711      out("Setting ownership (group) to ".$runas_gid); 
     712    break; 
     713    case "--scripted": 
     714      $scripted = true; 
     715      out("Unattended installation. No questions will be asked"); 
     716    break; 
     717    case "--freepbxip": 
     718      $freepbxip = $arg[1];  
     719      out("Setting IP address of web interface to $freepbxip"); 
     720    break; 
    673721 
    674722  } 
     
    710758  // this file contains password and should not be a+r 
    711759  // this addresses http://freepbx.org/trac/ticket/1878 
    712   chown(AMP_CONF, "asterisk");  
    713   chgrp(AMP_CONF, "asterisk");  
     760  chown(AMP_CONF, $runas_uid);  
     761  chgrp(AMP_CONF, $runas_gid);  
    714762  chmod(AMP_CONF, 0640);  
    715763 
    716   collect_settings(AMP_CONF, $dbhost, $new_username, $new_password, 'asterisk'); 
     764  collect_settings(AMP_CONF, $dbhost, $new_username, $new_password, $dbname); 
    717765 
    718766  out("Assuming new install, --install-moh added to command line"); 
     
    10361084} 
    10371085 
     1086// Ensure executables are executable 
     1087chmod($amp_conf["AMPBIN"]."/freepbx_setting", 0755); 
    10381088outn("Configuring install for your environment.."); 
     1089exec($amp_conf["AMPBIN"]."/freepbx_setting AMPASTERISKWEBGROUP $runas_gid"); 
     1090exec($amp_conf["AMPBIN"]."/freepbx_setting AMPASTERISKWEBUSER $runas_uid"); 
     1091exec($amp_conf["AMPBIN"]."/freepbx_setting AMPASTERISKGROUP $runas_gid"); 
     1092exec($amp_conf["AMPBIN"]."/freepbx_setting AMPASTERISKUSER $runas_uid"); 
     1093exec($amp_conf["AMPBIN"]."/freepbx_setting AMPDEVGROUP $runas_gid"); 
     1094exec($amp_conf["AMPBIN"]."/freepbx_setting AMPDEVUSER $runas_uid"); 
    10391095if (!$dryrun) { 
    10401096  $asteriskuser = isset($amp_conf['AMPASTERISKUSER']) && $amp_conf['AMPASTERISKUSER'] ? $amp_conf['AMPASTERISKUSER'] : 'asterisk';