Changeset 1021
- Timestamp:
- 05/22/05 21:55:04 (3 years ago)
- Files:
-
- trunk/support/autoconf.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/support/autoconf.php
r1015 r1021 9 9 * be found. 10 10 * 11 * If no argument is present, the detmined configuration is only written to stdout after the 12 * debugging messages. Otherwise, the filename specified on the command line will be replaced 13 * with the autodetected configuration. 14 * 11 15 * @package midcom 12 16 * @author The Midgard Project, http://www.midgard-project.org … … 17 21 18 22 $GLOBALS['configfile'] = ''; 23 24 if ($argc == 1) 25 { 26 $GLOBALS['outfile'] = null; 27 } 28 else if ($argc == 2) 29 { 30 $GLOBALS['outfile'] = $argv[1]; 31 } 32 else 33 { 34 ?> 35 Usage: php autoconf.php [ output_filename ] 36 <?php 37 exit(); 38 } 19 39 20 40 function add_option_to_configfile($option, $value) … … 59 79 die("The 'which' utility cannot be found. It is required for auto-configuration. Aborting."); 60 80 } 61 62 // Todo:63 // - Detect external utilities64 // - Verify all required external utilities65 // - Check PHP / PEAR dependencies66 // - Collect midcom.conf lines.67 81 68 82 echo "Detecting Cache Handlers... "; … … 145 159 146 160 161 // Check Memory Limit 162 echo "Checking Memory Limit... "; 163 $cur_limit = ini_get('memory_limit'); 164 $last_char = substr($cur_limit, -1); 165 if ($last_char == 'M') 166 { 167 $cur_limit = substr($cur_limit, 0, -1) * 1024 * 1024; 168 } 169 else if ($last_char == 'K') 170 { 171 $cur_limit = substr($cur_limit, 0, -1) * 1024; 172 } 173 else if ($last_char == 'G') 174 { 175 $cur_limit = substr($cur_limit, 0, -1) * 1024 * 1024 * 1024; 176 } 177 if ($cur_limit >= (20 * 1024 * 1024)) 178 { 179 echo "{$cur_limit} Bytes... OK\n"; 180 } 181 else 182 { 183 echo "{$cur_limit} Bytes... Memory Limit is below 20 MB, it is recommeded to set this in the php.ini file."; 184 $GLOBALS['configfile'] .= "ini_set('memory_limit', '20M');\n"; 185 } 186 187 // - Check PHP / PEAR dependencies 188 147 189 ?> 148 190 … … 157 199 ?> 158 200 ---------------------------------------------------------------------------- 201 <?php 202 203 if (! is_null($GLOBALS['outfile'])) 204 { 205 $handle = fopen($GLOBALS['outfile'], 'w'); 206 if ($handle === false) 207 { 208 die ("Could not open output file {$GLOBALS['outfile']} for writing.\n"); 209 } 210 fwrite ($handle, "<?php\n"); 211 fwrite ($handle, $GLOBALS['configfile']); 212 fwrite ($handle, "?>\n"); 213 fclose($handle); 214 215 echo("\nConfiguration written to {$GLOBALS['outfile']}\n"); 216 } 217 218 ?>
