[Fusionforge-commits] r12406 - trunk/src

Christian Bayle cbayle at fusionforge.org
Sun Feb 27 21:32:50 CET 2011


Author: cbayle
Date: 2011-02-27 21:32:49 +0100 (Sun, 27 Feb 2011)
New Revision: 12406

Modified:
   trunk/src/fusionforge-install-3-db.php
   trunk/src/fusionforge.spec
Log:
Move generation of config file from src/fusionforge.spec to src/fusionforge-install-3-db.php


Modified: trunk/src/fusionforge-install-3-db.php
===================================================================
--- trunk/src/fusionforge-install-3-db.php	2011-02-27 18:43:56 UTC (rev 12405)
+++ trunk/src/fusionforge-install-3-db.php	2011-02-27 20:32:49 UTC (rev 12406)
@@ -315,9 +315,40 @@
 	if (!is_dir($fusionforge_etc_dir)) {
 		mkdir($fusionforge_etc_dir);
 	}
+	if (!is_dir($fusionforge_etc_dir.'/config.ini.d')) {
+		mkdir($fusionforge_etc_dir.'/config.ini.d');
+	}
 
+	show(' * Saving database configuration in FForge config file');
+	if (!is_file("$fusionforge_etc_dir/config.ini.d/rpm-install.ini")){
+		if ($fp = fopen("$fusionforge_etc_dir/config.ini.d/rpm-install.ini", "w")) {
+			$config='; This file was generated by the RPM installation system.
+; You can edit the values here or move them to other files.
+[core]
+forge_name=FusionForge
+web_host='.system("hostname -f").'
+';
+			fwrite ($fp, $config);
+			fclose($fp);	
+		}
+	}
+	if (!is_file("$fusionforge_etc_dir/config.ini.d/rpm-install-secrets.ini")){
+		if ($fp = fopen("$fusionforge_etc_dir/config.ini.d/rpm-install-secrets.ini", "w")) {
+			$config='; This file was generated by the RPM installation system.
+; You can edit the values here or move them to other files.
+; These values should not go into world-readable files!
 
-	show(' * Saving database configuration in FForge config file');
+[core]
+database_host=""
+database_name='.$gforge_db.'
+database_user='.$gforge_user.'
+database_port=5432
+#database_password=$pw
+';
+			fwrite ($fp, $config);
+			fclose($fp);	
+		}
+	}
 	#$data = file_get_contents("$fusionforge_etc_dir/local.inc");
 	#$lines = explode("\n",$data);
 	#$config = '';

Modified: trunk/src/fusionforge.spec
===================================================================
--- trunk/src/fusionforge.spec	2011-02-27 18:43:56 UTC (rev 12405)
+++ trunk/src/fusionforge.spec	2011-02-27 20:32:49 UTC (rev 12406)
@@ -586,47 +586,6 @@
 	[ -d %{FORGE_VAR_LIB}/etc ] || mkdir %{FORGE_VAR_LIB}/etc
 	touch %{FORGE_VAR_LIB}/etc/httpd.vhosts
 
-# ====================
-	# Installation from scratch, let's generate initial config files
-	if [ ! -e %{FORGE_CONF_DIR}/config.ini.d ] ; then 
-		mkdir -p %{FORGE_CONF_DIR}/config.ini.d
-	fi
-	if [ ! -e %{FORGE_CONF_DIR}/config.ini.d/rpm-install.ini ] ; then
-		cat > %{FORGE_CONF_DIR}/config.ini.d/rpm-install.ini <<EOF
-; This file was generated by the RPM installation system.
-; You can edit the values here or move them to other files.
-
-[core]
-forge_name=FusionForge
-web_host=$HOSTNAME
-EOF
-	fi
-	if [ ! -e %{FORGE_CONF_DIR}/config.ini.d/rpm-install-secrets.ini ] ; then
-		t=$(mktemp %{FORGE_CONF_DIR}/config.ini.d/rpm-install-secrets.ini.XXXXXX)
-		if [ "$pw" = "" ] ; then
-		    if [ -c /dev/urandom ]; then  # ...using /dev/urandom when possible
-			pw=$(dd if=/dev/urandom count=1 bs=16 2> /dev/null | md5sum | cut -c-32)
-		    else		# ...or something else if need be.
-			pw=$(date +"%s:%N" | md5sum | cut -c-32)
-		    fi
-	fi
-
-	cat > $t <<EOF
-; This file was generated by the RPM installation system.
-; You can edit the values here or move them to other files.
-; These values should not go into world-readable files!
-
-[core]
-database_host=""
-database_name=%{dbname}
-database_user=%{dbuser}
-database_port=5432
-#database_password=$pw
-EOF
-		mv $t %{FORGE_CONF_DIR}/config.ini.d/rpm-install-secrets.ini
-	fi
-# ====================
-
 	/usr/bin/php %{FORGE_DIR}/fusionforge-install-4-config.php >>/var/log/%{name}-install.log 2>&1
 
 	/etc/init.d/httpd restart >/dev/null 2>&1




More information about the Fusionforge-commits mailing list