anchor.diff:              do
                   if [ $count -eq 30 ]
                   then
  -                  echo "Tried 30 times, giving up..."
  -	          exit 1
  -                 fi
  +                    echo "Tried 30 times, giving up..."
  +	            exit 1
  +                fi
   
  -                 echo "MySQL daemon not yet started. Waiting for 1 second..."
  -                 count=$((count++))
  -                 sleep 1
  +                echo "MySQL daemon not yet started. Waiting for 1 second..."
  +                count=$((count++))
  +                sleep 1
               done
   
  -            # Create initial databases
  +	    if [ -f /tmp/mysql_init ]
  +	    then
  +	        # Create initial databases
   
  -            ${concatMapStrings (database: 
  -              ''
  -                if ! test -e "${cfg.dataDir}/${database.name}"; then
  -                    echo "Creating initial database: ${database.name}"
  -                    ( echo "create database ${database.name};"
  -                      echo "use ${database.name};"
  -		      if [ -f "${database.schema}" ]
  -		      then
  -                          cat ${database.schema}
  -		      elif [ -d "${database.schema}" ]
  -		      then
  -		          cat ${database.schema}/mysql-databases/*.sql
  -		      fi
  +                ${concatMapStrings (database: 
  +                  ''
  +                    if ! test -e "${cfg.dataDir}/${database.name}"; then
  +                        echo "Creating initial database: ${database.name}"
  +                        ( echo "create database ${database.name};"
  +                          echo "use ${database.name};"
  +		          if [ -f "${database.schema}" ]
  +		          then
  +                              cat ${database.schema}
  +		          elif [ -d "${database.schema}" ]
  +		          then
  +		              cat ${database.schema}/mysql-databases/*.sql
  +		          fi
  +		        ) | ${mysql}/bin/mysql -u root -N
  +                    fi
  +                  '') cfg.initialDatabases}            
  +	
  +	        # Execute initial script
  +		
  +		${optionalString (cfg.initialScript != null)
  +		  ''
  +		    cat ${cfg.initialScript} | ${mysql}/bin/mysql -u root -N
  +		  ''}
  +		
  +	        # Change root password
  +		
  +		${optionalString (cfg.rootPassword != null)
  +		  ''
  +		    ( echo "use mysql;"
  +		      echo "update user set Password=password('$(cat ${cfg.rootPassword})') where User='root';"
  +		      echo "flush privileges;"
   		    ) | ${mysql}/bin/mysql -u root -N
  -                fi
  -              '') cfg.initialDatabases}            
  +		  ''}
  +		  
  +	      rm /tmp/mysql_init
  +	    fi
   	  '';
  -
  +	  	  
           # !!! Need a postStart script to wait until mysqld is ready to
           # accept connections.
   
  
positive.code: 	  { name = "foodatabase"; schema = ./foodatabase.sql; }
  	  { name = "bardatabase"; schema = ./bardatabase.sql; }
  	];
        };
      };
      
  
negative.code:                 mkdir -m 0700 -p ${cfg.dataDir}
                  chown -R ${cfg.user} ${cfg.dataDir}
                  ${mysql}/bin/mysql_install_db ${mysqldOptions}
  		touch /tmp/mysql_init
              fi
  
              mkdir -m 0700 -p ${cfg.pidDir}
  