4 * FusionForge Installation
6 * Copyright 2010, Roland Mas
7 * http://fusionforge.org/
10 $fusionforge_etc_dir = getenv('FUSIONFORGE_ETC_DIR');
11 if (empty($fusionforge_etc_dir))
13 $fusionforge_etc_dir = '/etc/gforge';
15 $fusionforge_src_dir = getenv('FUSIONFORGE_SRC_DIR');
16 if (empty($fusionforge_src_dir))
18 $fusionforge_src_dir = '/opt/gforge';
20 $fusionforge_data_dir = getenv('FUSIONFORGE_DATA_DIR');
21 if (empty($fusionforge_data_dir))
23 $fusionforge_data_dir = '/var/lib/gforge';
26 $STDOUT = fopen('php://stdout','w');
27 $STDIN = fopen('php://stdin','r');
29 define ('GREEN', "\033[01;32m" );
30 define ('NORMAL', "\033[00m" );
31 define ('RED', "\033[01;31m" );
33 function show($text, $newLine = true) {
36 $hd = fopen ("/tmp/gforge-import.log", "a+");
37 fwrite($hd, "*** $text\n");
41 $text = GREEN.$text .NORMAL."\n";
43 fwrite($STDOUT, $text);
46 function run($command, $ignore = false) {
48 $hd = fopen ("/tmp/gforge-import.log", "a+");
49 fwrite($hd, "CMD ".$command."\n");
52 system($command, $ret);
61 echo RED.'An error ocurred running the last command... aborting.'.NORMAL."\n";
67 function validatePassword($password) {
68 if (strlen($password)<6) {
69 return 'Password is too short. Please try again.';
71 if (!preg_match('/[[:alnum:]]*/', $password)) {
72 return 'Password contains invalid characters. Please try again.';
77 function readMasked($prompt) {
79 if (strtolower(php_uname('s')) == 'sunos') {
81 $text_entered = fgets($STDIN);
84 $returned=popen("read $options \"".GREEN.$prompt.NORMAL."\n\"; echo \$REPLY", 'r');
85 $text_entered=fgets($returned, 100);
87 $text_entered=substr($text_entered, 0, strlen($text_entered));
91 return trim($text_entered);