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 function show($text, $newLine = true) {
29 $hd = fopen ("/tmp/gforge-import.log", "a+");
30 fwrite($hd, "*** $text\n");
34 $text = GREEN.$text .NORMAL."\n";
36 fwrite($STDOUT, $text);
39 function run($command, $ignore = false) {
41 $hd = fopen ("/tmp/gforge-import.log", "a+");
42 fwrite($hd, "CMD ".$command."\n");
45 system($command, $ret);
54 echo RED.'An error ocurred running the last command... aborting.'.NORMAL."\n";
60 function validatePassword($password) {
61 if (strlen($password)<6) {
62 return 'Password is too short. Please try again.';
64 if (!preg_match('/[[:alnum:]]*/', $password)) {
65 return 'Password contains invalid characters. Please try again.';
70 function readMasked($prompt) {
72 if (strtolower(php_uname('s')) == 'sunos') {
74 $text_entered = fgets($STDIN);
77 $returned=popen("read $options \"".GREEN.$prompt.NORMAL."\n\"; echo \$REPLY", 'r');
78 $text_entered=fgets($returned, 100);
80 $text_entered=substr($text_entered, 0, strlen($text_entered));
84 return trim($text_entered);