Changeset 7760d8e


Ignore:
Timestamp:
08/07/14 12:30:19 (5 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0.3, releng/10.1
Children:
07ff5b1
Parents:
577fa72 (diff), d4c98327 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of github.com:pcbsd/pcbsd

Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • src-sh/pc-updatemanager/pc-updatemanager

    r22bfc1e rd4c98327  
    11481148  # Update the repo DB 
    11491149  rc_halt "${PKG_CMD} update" 
     1150 
     1151  # Make sure we always have an updated pkgng before attempting to 
     1152  # check for updates 
     1153  ${PKG_CMD} ${PKG_FLAG} upgrade -y pkg 
     1154  if [ $? -ne 0 ] ; then 
     1155     echo "Warning: Failed to upgrade pkgng.." 
     1156  fi 
    11501157 
    11511158  ${PKG_CMD} ${PKG_FLAG} upgrade -n >/tmp/.pkgData.$$ 
  • src-webui/appweb/dispatcher

    r3da6dccc r36f3620  
    55# Dispatch script, run as root, allows www process to run  
    66# specific commands with priv 
     7# 
     8# Also runs as a daemon to process the said commands that appweb 
     9# wants to have run 
     10 
     11# queue commands 
     12# <app> <origin> <flag> <target> 
     13# app = pbi / pkg 
     14# origin = www/firefox or other PBI/PKG origin 
     15# flag = install/delete/info 
     16# target = system / <jailname> 
    717 
    818PATH="$PATH:/usr/local/bin:/usr/local/sbin" 
    919export PATH 
    1020 
     21# QUEUE File 
     22QTMPDIR="/var/tmp/appweb"  
     23QLOGDIR="${QTMPDIR}/logs" 
     24QLIST="${QTMPDIR}/dispatch-queue" 
     25QWRK="${QLIST}.working" 
     26QLOG="${QLIST}.log" 
     27QRESULTS="${QLIST}.results" 
     28 
     29init_daemon() 
     30{ 
     31  # Appweb tmp dir 
     32  if [ ! -d "$QTMPDIR" ] ; then 
     33     mkdir ${QTMPDIR} 
     34  fi 
     35  if [ ! -d "$QLOGDIR" ] ; then 
     36     mkdir ${QLOGDIR} 
     37  fi 
     38 
     39  chmod 600 ${QTMPDIR} 
     40  chmod 600 ${QLOGDIR} 
     41 
     42  # Cleanup old daemon runtime 
     43  rm /var/tmp/appweb/* 2>/dev/null >/dev/null 
     44  rm /var/tmp/appweb/logs/* 2>/dev/null >/dev/null 
     45 
     46  for i in $QWRK $QRESULTS 
     47  do 
     48    if [ ! -e "$i" ] ; then 
     49      touch $i 
     50      chmod 600 $i 
     51    fi 
     52  done 
     53} 
     54 
     55run_queue_cmd() 
     56{ 
     57  # Breakdown the line into individual flags 
     58  app=`echo $1 | cut -d " " -f 1` 
     59  origin=`echo $1 | cut -d " " -f 2` 
     60  flag=`echo $1 | cut -d " " -f 3` 
     61  target=`echo $1 | cut -d " " -f 4` 
     62 
     63  # Get the uniq identifier for this cmd 
     64  local ident="`echo $1 | sha256 -q`" 
     65 
     66  # Sanity check some of the given options 
     67  case $app in 
     68   pkg|pbi) ;; 
     69         *) echo "Unauthorized command specified: $1" >> ${QLOG} 
     70            echo "FAILED $ident $@" >> $QRESULTS 
     71            return 1 
     72            ;; 
     73  esac 
     74 
     75  case $flag in 
     76 install|delete|info) ;; 
     77         *) echo "Unauthorized command specified: $1" >> ${QLOG} 
     78            echo "FAILED $ident $@" >> $QRESULTS 
     79            return 1 
     80            ;; 
     81  esac 
     82   
     83  # Now build the command 
     84  if [ "$app" == "pbi" ];then 
     85     cmd="pbi" 
     86     if [ "$target" != "system" ] ; then 
     87       cmd="$cmd -j $target" 
     88     fi 
     89     cmd="$cmd $flag $origin" 
     90  elif [ "$app" == "pkg" ];then 
     91     cmd="pkg" 
     92     if [ "$target" != "system" ] ; then 
     93       cmd="$cmd -j $target" 
     94     fi 
     95     cmd="$cmd $flag -y $origin" 
     96  fi 
     97 
     98  # Remove any old ident lines from results 
     99  sed -i '' "/ $ident /d" ${QRESULTS} 
     100 
     101  # Lets run the command now 
     102  $cmd >$QLOG 2>$QLOG 
     103  err=$? 
     104  if [ $err -ne 0 ] ; then 
     105     echo "FAILED $ident $@" >> $QRESULTS 
     106  else 
     107     echo "SUCCESS $ident $@" >> $QRESULTS 
     108  fi 
     109 
     110  # Save the log file for later diagnostics 
     111  mv ${QLOG} ${QLOGDIR}/${ident}.log 
     112  chmod 644 ${QLOGDIR}/${ident}.log 
     113 
     114  return $err 
     115} 
     116 
     117run_daemon() 
     118{ 
     119  pid="/var/run/appweb-dispatcher.pid" 
     120 
     121  # Check if we have another copy of the daemon running 
     122  if [ -e "${pid}" ] ; then 
     123     pgrep -F ${pid} >/dev/null 2>/dev/null 
     124     if [ $? -eq 0 ] ; then return 0; fi 
     125  fi 
     126  echo "$$" > ${pid} 
     127 
     128  # Setup the daemon files 
     129  init_daemon 
     130 
     131  # Run the main loop 
     132  while : 
     133  do 
     134    # Check if we have anything to do? 
     135    if [ ! -e "$QLIST" ] ; then 
     136       sleep 8 
     137       continue 
     138    fi 
     139 
     140    # Move the queue over and run it 
     141    mv $QLIST ${QLIST}.tmp 
     142    while read line 
     143    do 
     144       echo "$line" > $QWRK 
     145       run_queue_cmd "$line" 
     146       echo "" > $QWRK 
     147    done < ${QLIST}.tmp 
     148    rm ${QLIST}.tmp 
     149  done 
     150 
     151  rm $pid 
     152} 
     153 
     154list_status() 
     155{ 
     156  if [ -e "$QWRK" ] ; then 
     157     cat ${QWRK} 
     158  else 
     159     echo "Idle" 
     160  fi 
     161} 
     162 
     163list_results() 
     164{ 
     165  if [ -e "$QRESULTS" ] ; then 
     166    cat ${QRESULTS}  
     167  else 
     168    echo "" 
     169  fi 
     170} 
     171 
     172display_log() 
     173{ 
     174  if [ -e "${QLOGDIR}/${1}.log" ] ; then 
     175    cat ${QLOGDIR}/${1}.log 
     176  else 
     177    echo "" 
     178  fi 
     179} 
     180 
     181run_warden_cmd() 
     182{ 
     183  case $2 in 
     184      start) warden start $3;; 
     185       stop) warden stop $3;; 
     186       auto) warden auto $3;; 
     187          *) echo "Non-dispatch-approved warden command: $2" ;; 
     188  esac 
     189} 
     190 
     191print_usage() 
     192{ 
     193  echo "Dispatcher usage: 
     194-------------------------------- 
     195   warden {start|stop} {jail} 
     196   queue {pkg|pbi} {origin} {install/delete/info} {system|<jailname>} 
     197   daemon 
     198   status 
     199   results  
     200   log {hash} 
     201"  
     202} 
     203 
    11204case $1 in 
    12     warden) $@;; 
    13     pbi) $@;; 
    14          *) echo "Invalid command run!" ; exit 1 ;; 
     205    # We can passthru some warden commands immediately 
     206    warden) run_warden_cmd $@ ;; 
     207    # These commands interact with the dispatcher daemon 
     208     queue) echo "$@" | cut -d ' ' -f 2- >>${QLIST} ;; 
     209    daemon) run_daemon ;; 
     210       log) display_log "$2" ;; 
     211    status) list_status ;; 
     212   results) list_results ;; 
     213         *) print_usage ; exit 1 ;; 
    15214esac 
     215 
     216exit 0 
  • src-webui/appweb/rc.d/appweb

    rc1b354e r36f3620  
    2222pidfile="${_pidprefix}/${name}.pid" 
    2323_tmpprefix="/var/tmp/nginx" 
    24 required_files=/usr/local/share/appweb/nginx.conf 
     24appweb_dir="/usr/local/share/appweb" 
     25required_files="/usr/local/share/appweb/nginx.conf" 
    2526 
    2627[ -z "$appweb_enable" ]         && appweb_enable="NO" 
     
    4647 
    4748  $command -c /usr/local/share/appweb/nginx.conf -g "pid /var/run/appweb.pid;" 
     49 
     50  # Start the dispatcher also 
     51  ( ${appweb_dir}/dispatcher daemon )& 
    4852} 
    4953 
     
    5155{ 
    5256  kill -QUIT $(cat /var/run/appweb.pid) 
     57  kill -9 $(cat /var/run/appweb-dispatcher.pid) 
    5358} 
    5459 
  • src-webui/appweb/share/html/include/functions.php

    r1dc56a0 r36f3620  
    3838} 
    3939 
     40function queueInstallApp() 
     41{ 
     42   $app = $_GET['installApp']; 
     43   $type = $_GET['installAppCmd']; 
     44   $target = $_GET['installAppTarget']; 
     45   if ( ! empty($app) and ! empty($type) and ! empty($target) ) 
     46      run_cmd("queue $type $app install $target"); 
     47 
     48   // Now we can remove those values from the URL 
     49   $newUrl=http_build_query($_GET); 
     50   $app=str_replace("/", "%2F", $app); 
     51   $newUrl=str_replace("&installApp=$app", "", $newUrl); 
     52   $newUrl=str_replace("installApp=$app", "", $newUrl); 
     53   $newUrl=str_replace("&installAppCmd=$type", "", $newUrl); 
     54   $newUrl=str_replace("installAppCmd=$type", "", $newUrl); 
     55   $newUrl=str_replace("&installAppTarget=$target", "", $newUrl); 
     56   $newUrl=str_replace("installAppTarget=$target", "", $newUrl); 
     57   hideurl("?".$newUrl); 
     58} 
     59 
     60function queueDeleteApp() 
     61{ 
     62   $app = $_GET['deleteApp']; 
     63   $type = $_GET['deleteAppCmd']; 
     64   $target = $_GET['deleteAppTarget']; 
     65   if ( ! empty($app) and ! empty($type) and ! empty($target) ) 
     66      run_cmd("queue $type $app delete $target"); 
     67 
     68   // Now we can remove those values from the URL 
     69   $newUrl=http_build_query($_GET); 
     70   $app=str_replace("/", "%2F", $app); 
     71   $newUrl=str_replace("&deleteApp=$app", "", $newUrl); 
     72   $newUrl=str_replace("deleteApp=$app", "", $newUrl); 
     73   $newUrl=str_replace("&deleteAppCmd=$type", "", $newUrl); 
     74   $newUrl=str_replace("deleteAppCmd=$type", "", $newUrl); 
     75   $newUrl=str_replace("&deleteAppTarget=$target", "", $newUrl); 
     76   $newUrl=str_replace("deleteAppTarget=$target", "", $newUrl); 
     77   hideurl("?".$newUrl); 
     78} 
     79 
    4080?> 
  • src-webui/appweb/share/html/include/leftmenu.php

    r6394b4b r36f3620  
    33  // Will need a major visual upgrade 
    44 
    5   if ( $page == "appcafe" or $page == "sysapp" or $page == "appinfo" ) { 
     5  if ( $page == "appcafe" or $page == "sysapp" or $page == "appinfo" or $page == "dispatcher" ) { 
    66?> 
    77 
  • src-webui/appweb/share/html/include/nav-computer.php

    r6394b4b r36f3620  
    2222</div> 
    2323 
    24 <div id="notifer" style="height:25px;width:100%;position:absolute;margin-top:3.80em;margin-left:12.50em;"> 
    25   <iframe src="pages/notifier.php" height="30px" width="100%" seamless></iframe> 
     24<div id="notifer" style="height:35px;width:600px;position:absolute;margin-top:3.80em;margin-left:12.50em;"> 
     25  <iframe src="pages/notifier.php" height="35" width="565" seamless></iframe><a href="?p=dispatcher" title="View recent actions and results"><img style="vertical-align:top" height=34 width=34 src="images/notifier.png" border=0></a> 
    2626</div> 
    2727 
    28 <div id="body" style="height:100%;width:100%;position:absolute;margin-top:6.50em;margin-left:12.50em;"> 
     28<div id="body" style="height:100%;width:700px;position:absolute;margin-top:6.50em;margin-left:12.50em;"> 
  • src-webui/appweb/share/html/include/nav-phone.php

    r6394b4b r36f3620  
    2525<body> 
    2626 
    27 <div id="notifer" style="height:30px;width:100%;position:absolute;margin-top:0em;margin-left:0em;"> 
    28   <iframe src="pages/notifier.php" height="30px" width="100%" seamless></iframe> 
     27<div id="notifer" style="height:35px;width:300px;position:absolute;margin-top:0em;margin-left:0em;"> 
     28  <iframe src="pages/notifier.php" height="35px" width="264" seamless></iframe><a href="?p=dispatcher"><img style="vertical-align:top" height=35 width=35 src="images/notifier.png" border=0></a> 
    2929</div> 
    3030 
  • src-webui/appweb/share/html/index.php

    r6394b4b r36f3620  
    44  require("include/functions.php"); 
    55 
     6  // Do any install / delete requests 
     7  if ( ! empty($_GET["deleteApp"]) ) 
     8     queueDeleteApp(); 
     9  if ( ! empty($_GET["installApp"]) ) 
     10     queueInstallApp(); 
     11 
    612  // Figure out what page is being requested 
    713  if ( empty($_GET["p"])) 
    8      $page = "main"; 
     14     $page = "appcafe"; 
    915  else 
    1016     $page = $_GET["p"]; 
  • src-webui/appweb/share/html/js/appcafe.js

    r6394b4b r36f3620  
    1 function delConfirm(appname) { 
     1function delConfirm(appname, origin, cmd, target) { 
    22    if (confirm("Are you sure you want to delete " + appname + "?") == true) { 
    3         window.location.href = ""; 
     3        var newURL = window.location.href; 
     4        window.location.href = newURL + "&deleteApp=" + origin + "&deleteAppCmd=" + cmd + "&deleteAppTarget=" + target; 
    45    } 
    56} 
    67 
    7 function addConfirm(appname) { 
     8function addConfirm(appname, origin, cmd, target) { 
    89    if (confirm("Are you sure you want to install " + appname + "?") == true) { 
    9         window.location.href = ""; 
     10        var newURL = window.location.href; 
     11        window.location.href = newURL + "&installApp=" + origin + "&installAppCmd=" + cmd + "&installAppTarget=" + target; 
    1012    } 
    1113} 
  • src-webui/appweb/share/html/pages/appcafe.php

    r6394b4b r36f3620  
    1 <script> 
    2 function delConfirm() { 
    3     if (confirm("Are you sure you want to delete this application?") == true) { 
    4         window.location.href = ""; ?>"; 
    5     } 
    6 } 
    7 </script> 
    8  
    91<? 
    102function parse_details($pbiorigin, $jail, $col)  
     
    4133 
    4234  if ( array_search($pbiorigin, $inslist) !== false) 
    43     print("    <button onclick=\"delConfirm('" . $pbiname . "')\">-Remove</button>"); 
     35    print("    <button onclick=\"delConfirm('" . $pbiname ."','".$pbiorigin."','pbi','system')\">-Remove</button>"); 
    4436  else 
    45     print("    <button onclick=\"addConfirm('" . $pbiname ."')\">+Install</button>"); 
     37    print("    <button onclick=\"addConfirm('" . $pbiname ."','".$pbiorigin."','pbi','system')\">+Install</button>"); 
    4638 
    4739  print("\n  </td>"); 
     
    5749<h2>Recommended Applications</h2> 
    5850<? 
     51 
    5952  if ( $deviceType == "computer" ) {  
    6053    $totalCols = 4; 
  • src-webui/appweb/share/html/pages/appinfo.php

    r6394b4b r36f3620  
    44 
    55   $pbiorigin = $_GET['app']; 
    6  
    7    if ( ! empty($_GET['delete']) ) 
    8    { 
    9         print "<h2>DELETED -$pbiorigin<br></h2>"; 
    10         hideurl("?p=sysappinfo&app=$pbiorigin"); 
    11    } 
    126 
    137   // Load the PBI details page 
     
    4236    <td align=center> 
    4337      <img align="center" height=64 width=64 src="images/pbiicon.php?i=<? echo "$pbicdir"; ?>/icon.png"><br><br> 
    44       <button onclick="delConfirm('<? echo $pbiname; ?>')">Delete App</button> 
     38      <? 
     39         print("    <button onclick=\"delConfirm('" . $pbiname ."','".$pbiorigin."','pbi','system')\">-Remove</button>"); 
     40      ?> 
    4541    </td> 
    4642    <td> 
  • src-webui/appweb/share/html/pages/notifier.php

    r9203a2f r36f3620  
     1<? 
     2  require("../include/functions.php"); 
     3 
     4  // Command to prod dispatcher for current status 
     5  // Eventually we will pep this up with extra parsing about 
     6  // the status 
     7  $narray = run_cmd("status"); 
     8  if ( $narray[0] == "Idle" or empty($narray[0]) ) { 
     9    $rarray = run_cmd("results"); 
     10    $lastElement=count($rarray); 
     11    $lastElement--; 
     12    if ( ! empty($rarray[$lastElement]) ) { 
     13      $results = explode(" ", $rarray[$lastElement]); 
     14      $result=$results[0] . " ". $results[4] . " " . $results[3]; 
     15    } else { 
     16      $result="$cmd"; 
     17    } 
     18 
     19    $output="$result"; 
     20 
     21  } else { 
     22    $output="$narray[0]"; 
     23  } 
     24?> 
    125<html> 
     26<META HTTP-EQUIV="refresh" CONTENT="6"> 
    227<body style="background-color:yellow;"> 
    3 <? 
    4    echo "idle"; 
    5 ?> 
     28<? echo "$output"; ?> 
    629</body> 
    730</html> 
  • src-webui/appweb/share/html/pages/sysapp.php

    r6394b4b r36f3620  
    3131  print("    <a href=\"/?p=appinfo&app=$pbiorigin\" title=\"$pbicomment\"><img border=0 align=\"center\" height=48 width=48 src=\"images/pbiicon.php?i=$pbicdir/icon.png\" style=\"float:left;\"></a>\n"); 
    3232  print("    <a href=\"/?p=appinfo&app=$pbiorigin\">$pbiname</a><br>$pbiver<br>\n"); 
     33  print("    <button onclick=\"delConfirm('" . $pbiname ."','".$pbiorigin."','pbi','system')\">-Remove</button>"); 
    3334  print("  </td>"); 
    3435 
     
    4344<? 
    4445  if ( $deviceType == "computer" ) {  
    45     $totalCols = 4; 
     46    $totalCols = 3; 
    4647?> 
    4748<table class="jaillist" style="width:768px"> 
    4849<tr> 
    49    <th></th> 
    5050   <th></th> 
    5151   <th></th> 
  • src-webui/port-files/pkg-plist

    rd5cff0a r36f3620  
    77share/appweb/html/css/_reset.css 
    88share/appweb/html/css/main.css 
     9share/appweb/html/images/notifier.png 
    910share/appweb/html/images/pbiicon.php 
    1011share/appweb/html/include/Mobile_Detect.php 
     
    2021share/appweb/html/pages/appcafe.php 
    2122share/appweb/html/pages/appinfo.php 
     23share/appweb/html/pages/dispatcher.php 
    2224share/appweb/html/pages/error.php 
    2325share/appweb/html/pages/jails.php 
  • src-sh/syscache/client/syscache-client.cpp

    r55a92d4 r577fa72  
    55  curSock = new QLocalSocket(this); 
    66    connect(curSock, SIGNAL(connected()), this, SLOT(startRequest())); 
     7    connect(curSock, SIGNAL(disconnected()), this, SLOT(requestFinished()) ); 
    78    connect(curSock, SIGNAL(error(QLocalSocket::LocalSocketError)), this, SLOT(connectionError())); 
    89} 
     
    3031  QTextStream out(curSock); 
    3132  out << servRequest.join("\n"); 
     33  out << "\n[FINISHED]"; 
    3234  connect(curSock, SIGNAL(readyRead()), this, SLOT(requestFinished()) ); 
    3335} 
     
    6971    qDebug() << "[ERROR]" << curSock->errorString(); 
    7072    qDebug() << " - Is the syscache daemon running?"; 
    71     exit(1); 
    7273  } 
     74  exit(1); 
    7375} 
  • src-sh/syscache/daemon/syscache-daemon.cpp

    r63c42b5 r577fa72  
    3333//Server/Client connections 
    3434void SysCacheDaemon::checkForConnections(){ 
     35  //qDebug() << "Check for Connections..." << curSock; 
     36  static bool checking = false; 
     37  if(checking){ return; } 
     38  checking = true; 
    3539  //Check if we are ready for the next request 
    3640  bool getnext = (curSock==0); 
    37   if(!getnext){ getnext = !curSock->isValid(); } 
     41  if(!getnext){  
     42    getnext = !curSock->isValid();  
     43    if(!getnext){ QTimer::singleShot(0, this, SLOT(answerRequest())); } 
     44  } 
    3845  if(getnext){ getnext = server->hasPendingConnections(); } 
    3946   
     
    4148  if(getnext){ 
    4249    curSock = server->nextPendingConnection(); 
     50    //qDebug() << " - Found connection:" << curSock; 
    4351    connect(curSock, SIGNAL(disconnected()), this, SLOT(requestFinished()) ); 
    44     QTimer::singleShot(0,this, SLOT(answerRequest())); 
     52    connect(curSock, SIGNAL(readyRead()), this, SLOT(answerRequest()) ); 
     53    QTimer::singleShot(0,this, SLOT(answerRequest()) ); 
    4554  } 
     55  checking = false; 
    4656} 
    4757 
    4858void SysCacheDaemon::answerRequest(){ 
    49   curSock->waitForReadyRead(1000); //wait max 1 second for the request from the client 
     59  //curSock->waitForReadyRead(1000); //wait max 1 second for the request from the client 
     60  static bool working = false; 
     61  if(working || curSock==0){ return; } 
     62  working = true; 
    5063  QStringList req, out; 
    5164  bool stopdaemon=false; 
    5265  QTextStream stream(curSock); 
     66  bool done = false; 
    5367  while(!stream.atEnd()){ 
    5468    req = QString(stream.readLine()).split(" "); 
     69    //qDebug() << " - Request:" << req; 
    5570    //qDebug() << "Request Received:" << req; 
    56     if(req.join("")=="shutdowndaemon"){ stopdaemon=true; break; } 
     71    if(req.join("")=="shutdowndaemon"){ stopdaemon=true; done=true; break; } 
     72    if(req.join("")=="[FINISHED]"){ done = true; break; } 
    5773    else{  
     74         
    5875      QString res = DATA->fetchInfo(req); 
    5976      //For info not available, try once more time as it can error unexpectedly if it was  
     
    6481  } 
    6582  //Now write the output to the socket and disconnect it 
     83  //qDebug() << " - Request replied:" << done; 
    6684  stream << out.join("\n"); 
    6785  //curSock->disconnectFromServer(); 
    68   stream << "\n[FINISHED]"; 
     86  working = false; 
     87  if(done){ stream << "\n[FINISHED]"; } 
     88  else{ QTimer::singleShot(0,this, SLOT(answerRequest()) ); } 
    6989  if(stopdaemon){ QTimer::singleShot(10, this, SLOT(stopServer())); } 
    7090} 
    7191 
    7292void SysCacheDaemon::requestFinished(){ 
     93  //qDebug() << " - Request Finished"; 
    7394  curSock=0; //reset the internal pointer 
    7495  //Now look for the next request 
Note: See TracChangeset for help on using the changeset viewer.