Changeset 6804749


Ignore:
Timestamp:
09/17/14 10:03:16 (10 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, enter/10, releng/10.1, releng/10.1.1, releng/10.1.2
Children:
9053202
Parents:
e5bac4a
Message:

Add initial support for reading configfile data with PBI modules using
the service-configfile include.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • pbi-modules/irc/bitlbee/service-configfile

    r1a8ed30 r6804749  
    1818  $appConfig[1]['delim'] = " = "; 
    1919  $appConfig[1]['default'] = "6667"; 
     20  $appConfig[1]['min'] = "1024"; 
     21  $appConfig[1]['max'] = "65535"; 
    2022   
    2123  $appConfig[2]['cfgfile'] = "/usr/local/etc/bitlbee/bitlbee.conf"; 
     
    3032  $appConfig[3]['type'] = "COMBOBOX"; 
    3133  $appConfig[3]['desc'] = "Auth Mode"; 
    32   $appConfig[3]['longdesc'] = "Open - Accept connections from anyone<br> Closed - Require auth using the Password specified below<br> Registered - Only allow registered users to use the server"; 
     34  $appConfig[3]['longdesc'] = "Open - Accept connections from anyone<br>Closed - Require auth using the Password specified below<br>Registered - Only allow registered users to use the server"; 
    3335  $appConfig[3]['key'] = "AuthMode"; 
    3436  $appConfig[3]['delim'] = " = "; 
  • src-webui/appweb/dispatcher

    r5fb7b91 r6804749  
    264264} 
    265265 
     266# Get value from config file 
     267getcfg() 
     268{ 
     269   if [ ! -e "$cfile" ] ; then exit 0; fi 
     270 
     271   value=`grep "^${key}${delim}" $cfile 2>/dev/null | head -n 1 | sed "s|${key}${delim}||g"` 
     272 
     273   # See if we have quotes to remove 
     274   if [ "`echo $value | cut -c 1`" = '"' ] ; then 
     275      value="`echo $value | sed 's|"||g'`" 
     276   fi 
     277 
     278   echo "$value" 
     279   exit 0 
     280} 
     281 
    266282print_usage() 
    267283{ 
     
    272288   pkgupdate {__system__|<jailname>} 
    273289   service {start|stop|restart} {servicetag} {servicerc} {__system__|<jid>} 
     290   getcfg {file} {key} {delim} 
    274291   daemon 
    275292   status 
     
    278295"  
    279296} 
     297 
     298if [ "`/usr/bin/id -u`" != "0" ] ; then 
     299   echo "Must be run as root!" 
     300   exit 1 
     301fi 
    280302 
    281303case $1 in 
     
    298320    status) list_status ;; 
    299321   results) list_results ;; 
     322    getcfg) cfile="$2" ; key="$3" ; delim="$4"  
     323            getcfg ;; 
    300324         *) print_usage ; exit 1 ;; 
    301325esac 
  • src-webui/appweb/share/html/css/main.css

    r544a716 r6804749  
    246246} 
    247247 
     248.btn-style{ 
     249        border : solid 2px #c7c7c7; 
     250        border-radius : 5px 5px 20px 20px ; 
     251        moz-border-radius : 5px 5px 20px 20px ; 
     252        -webkit-box-shadow : 0px 1px 5px rgba(0,0,0,1.0); 
     253        -moz-box-shadow : 0px 1px 5px rgba(0,0,0,1.0); 
     254        box-shadow : 0px 1px 5px rgba(0,0,0,1.0); 
     255        font-size : 15px; 
     256        color : #ff8400; 
     257        padding : 2px 15px; 
     258        background : #ffffff; 
     259        background : -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#e6e6e6)); 
     260        background : -moz-linear-gradient(top, #ffffff 0%, #e6e6e6 100%); 
     261        background : -webkit-linear-gradient(top, #ffffff 0%, #e6e6e6 100%); 
     262        background : -o-linear-gradient(top, #ffffff 0%, #e6e6e6 100%); 
     263        background : -ms-linear-gradient(top, #ffffff 0%, #e6e6e6 100%); 
     264        background : linear-gradient(top, #ffffff 0%, #e6e6e6 100%); 
     265        filter : progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#e6e6e6',GradientType=0 ); 
     266 
     267} 
  • src-webui/appweb/share/html/pages/appinfo.php

    r539a6be r6804749  
    140140} 
    141141 
     142// Get the current value for a config file setting 
     143function get_cfg_value($cfg) 
     144{ 
     145  global $jail; 
     146  global $jailUrl; 
     147  global $jailPath; 
     148 
     149  $cfgFile = $cfg['cfgfile']; 
     150  $key = $cfg['key']; 
     151  $delim = $cfg['delim']; 
     152  $default = $cfg['default']; 
     153 
     154  // If working on a jail, get correct path to config 
     155  if ( $jail != "#system" ) 
     156     $cfgFile = $jailPath . $cfgFile; 
     157   
     158  // Talk to dispatcher to get config value 
     159  $output = run_cmd("getcfg ". escapeshellarg("$cfgFile") . " " . escapeshellarg($key) . " " . escapeshellarg($delim) ); 
     160  if ( ! empty($output[0]) ) 
     161     return $output[0]; 
     162 
     163  return $default;  
     164} 
     165 
     166// Display a input = number type box 
     167function display_number_box($cfg) 
     168{ 
     169  $current = get_cfg_value($cfg); 
     170  $desc = $cfg['desc']; 
     171  $longdesc = str_replace("<br>", "\n", $cfg['longdesc']); 
     172  $default = $cfg['default']; 
     173  $min = $cfg['min']; 
     174  $max = $cfg['max']; 
     175  echo "  <tr>\n"; 
     176  echo "    <td><input type=\"number\" title=\"$longdesc\" name=\"$desc\" min=\"$min\" max=\"$max\" value=\"$current\"></td>\n"; 
     177  echo "    <td title=\"$longdesc\">$desc</td>\n"; 
     178  echo "  </tr>\n"; 
     179} 
     180 
     181// Display a option box 
     182function display_combo_box($cfg) 
     183{ 
     184  $current = get_cfg_value($cfg); 
     185  $desc = $cfg['desc']; 
     186  $longdesc = str_replace("<br>", "\n", $cfg['longdesc']); 
     187  $default = $cfg['default']; 
     188  echo "  <tr>\n"; 
     189  echo "    <td><select title=\"$longdesc\" name=\"$desc\">"; 
     190  $i=1; 
     191  for ( ;; ) { 
     192    $akey = "option" . $i; 
     193    if ( empty($cfg[$akey]) ) 
     194       break; 
     195    unset($ops); 
     196    $ops = explode("::::", $cfg[$akey]); 
     197    $option = $ops[0]; 
     198    $disp = $ops[1]; 
     199    $selected=""; 
     200    if ( $option == $current ) 
     201      $selected="selected"; 
     202    echo "      <option value=\"$option\" $selected>$disp</option>\n"; 
     203    $i++; 
     204  } 
     205  echo "    </select></td>\n"; 
     206  echo "    <td title=\"$longdesc\">$desc</td>\n"; 
     207  echo "  </tr>\n"; 
     208} 
     209 
     210// Display a string/password input box 
     211function display_string_box($cfg) 
     212{ 
     213  $current = get_cfg_value($cfg); 
     214  $desc = $cfg['desc']; 
     215  $longdesc = str_replace("<br>", "\n", $cfg['longdesc']); 
     216  $default = $cfg['default']; 
     217 
     218  $type = "text"; 
     219  if ( $cfg['type'] == "PASSWORDBOX" ) 
     220     $type = "password"; 
     221 
     222  echo "  <tr>\n"; 
     223  echo "    <td><input type=\"$type\" title=\"$longdesc\" name=\"$desc\" value=\"$current\"></td>\n"; 
     224  echo "    <td title=\"$longdesc\">$desc</td>\n"; 
     225  echo "  </tr>\n"; 
     226} 
     227 
    142228// Display the configuration widget 
    143229function display_config_details() 
    144230{ 
    145  
     231  global $pbicdir; 
     232  global $pbiorigin; 
     233  global $jail; 
     234  global $jailUrl; 
     235  global $jailPath; 
     236  global $sc; 
     237 
     238  // Get the jail path 
     239  exec("$sc ". escapeshellarg("jail $jail path"), $jArray); 
     240  $jailPath=$jArray[0]; 
     241   
     242  // Init the array to load in config data 
     243  unset($appConfig); 
     244  $appConfig = array(); 
     245 
     246  // Load the config file 
     247  require($pbicdir . "/service-configfile"); 
     248 
     249  // Start the form 
     250  echo "<form method=\"post\" action=\"?p=appinfo&app=".rawurlencode($pbiorigin)."&jail=$jailUrl\">\n"; 
     251  echo " <table class=\"jaillist\" style=\"width:100%\">"; 
     252  echo "  <tr>\n"; 
     253  echo "   <th></th>\n"; 
     254  echo "   <th width=99%></th>\n"; 
     255  echo "  </tr>"; 
     256 
     257  // Now loop through the array and build the form 
     258  foreach ($appConfig as $cfgWidget) { 
     259    // Skip any array missing the type 
     260    if ( empty($cfgWidget['type']) ) 
     261       continue; 
     262 
     263    switch ($cfgWidget['type']) { 
     264        case "COMBOBOX": 
     265            display_combo_box($cfgWidget); 
     266            break; 
     267        case "NUMBERBOX": 
     268            display_number_box($cfgWidget); 
     269            break; 
     270        case "STRINGBOX": 
     271        case "PASSWORDBOX": 
     272            display_string_box($cfgWidget); 
     273            break; 
     274    } 
     275    
     276  } 
     277 
     278  // All done, finish the form 
     279  echo "  <tr><td colspan=2 align=center><input type=\"submit\" value=\"Save Config\" class=\"btn-style\"></td></tr>\n"; 
     280  echo " </table>\n"; 
     281  echo "<form>\n"; 
    146282 
    147283} 
  • src-webui/appweb/share/html/pages/jailcreate.php

    rf27cd24 r6804749  
    6161</tr> 
    6262<tr> 
    63   <td colspan="2"><input name="submit" type="submit" value="createjail" /></td> 
     63  <td colspan="2"><input name="submit" type="submit" value="createjail" class="btn-style" /></td> 
    6464</tr> 
    6565 
  • src-webui/appweb/share/html/pages/jailinfo.php

    r5fb7b91 r6804749  
    8181</tr> 
    8282<tr> 
    83   <td colspan="2"><input name="submit" type="submit" value="Save" /></td> 
     83  <td colspan="2"><input name="submit" type="submit" value="Save" class="btn-style" /></td> 
    8484</tr> 
    8585 
Note: See TracChangeset for help on using the changeset viewer.