garr/shib2idp/lib/puppet/type/shibboleth_install.rb
####	ensure property is not necessary, because it is not used.
#			newproperty(:ensure) do
#			desc "Whether the resource is in sync or not."
#
#			defaultto :insync
#
#			def retrieve
#				# Returns always notrun to permit re-installations if something was changed or updated in the source folder.
#				:insync
#			end
#
#			newvalue :outofsync
#			newvalue :insync do
#				# Do nothing only execute install when refreshed
#			end
####	end
ensure property is not necessary, because it is not used.
newproperty(:ensure) do
desc "Whether the resource is in sync or not."

defaultto :insync

def retrieve
Returns always notrun to permit re-installations if something was changed or updated in the source folder.
:insync
end

newvalue :outofsync
newvalue :insync do
Do nothing only execute install when refreshed
end
end
ensure property is not necessary because it is not used . newproperty ( : ensure ) do desc " Whether the resource is in sync or not . " defaultto : insync def retrieve Returns always notrun to permit re - installations if something was changed or updated in the source folder . : insync end newvalue : outofsync newvalue : insync do Do nothing only execute install when refreshed end end
def refresh
			debug("Shibboleth_install[name] = " + @parameters[:name].value + ".")
			debug("Shibboleth_install[sourcedir] = " + @parameters[:sourcedir].value + ".")
			debug("Shibboleth_install[idpfqdn] = " + @parameters[:idpfqdn].value + ".")
			debug("Shibboleth_install[keystorepassword] = " + @parameters[:keystorepassword].value + ".")
			debug("Shibboleth_install[installdir] = " + @parameters[:installdir].value + ".")
			debug("Shibboleth_install[javahome] = " + @parameters[:javahome].value + ".")
			debug("Shibboleth_install[tomcathome] = " + @parameters[:tomcathome].value + ".")
			debug("Shibboleth_install[curtomcat] = " + @parameters[:curtomcat].value + ".")
			debug("Shibboleth_install[idpscope] = " + @parameters[:idpscope].value + ".")
			filename = @parameters[:sourcedir].value + "/autoinstall.properties"  
			File.open(filename, "w") do |saved_file|  
				saved_file.write("idp.src.dir = " + @parameters[:sourcedir].value + "\n")
				saved_file.write("idp.target.dir = " + @parameters[:installdir].value + "\n")
				saved_file.write("idp.host.name = " + @parameters[:idpfqdn].value + "\n")
				saved_file.write("idp.sealer.password = " + @parameters[:keystorepassword].value + "\n")
				saved_file.write("idp.keystore.password = " + @parameters[:keystorepassword].value + "\n")
				saved_file.write("idp.merge.properties = autoinstall-merge.properties\n")
				saved_file.write("idp.noprompt = true\n")
			end
			system("/bin/rm -f " + @parameters[:installdir].value + "/edit-webapp/css/*")
			filename = @parameters[:sourcedir].value + "/autoinstall-merge.properties"  
			File.open(filename, "w") do |saved_file|  
				saved_file.write("idp.entityID = https://" + @parameters[:idpfqdn].value + "/idp/shibboleth" + "\n")
				saved_file.write("idp.scope = " + @parameters[:idpscope].value + "\n")
			end
			filename = "/tmp/autoinstall.sh"  
			File.open(filename, "w") do |saved_file|  
				saved_file.write("#!/bin/bash\n")
				saved_file.write(". /etc/environment\n")
				saved_file.write("export JAVA_HOME\n")
				saved_file.write("\n")
				saved_file.write("cd " + @parameters[:sourcedir].value + "\n")
				saved_file.write("/bin/bash bin/install.sh -Didp.property.file=autoinstall.properties\n") 
			end
			debug("Executing install script.")
			system("/bin/bash " + filename) or raise Puppet::Error, "Error while installing Shibboleth IdP." 
            debug("Create link to idp.crt and idp.key if not already present.")
            if not File.exists?(@parameters[:installdir].value + "/credentials/idp.crt")
                system("/bin/ln -s " + @parameters[:installdir].value + "/credentials/idp-signing.crt " + @parameters[:installdir].value + "/credentials/idp.crt")
            else
                system("/bin/ln -s " + @parameters[:installdir].value + "/credentials/idp.crt " + @parameters[:installdir].value + "/credentials/idp-signing.crt")
                system("/bin/ln -s " + @parameters[:installdir].value + "/credentials/idp.crt " + @parameters[:installdir].value + "/credentials/idp-encryption.crt")
            end
            if not File.exists?(@parameters[:installdir].value + "/credentials/idp.key")
                system("/bin/ln -s " + @parameters[:installdir].value + "/credentials/idp-signing.key " + @parameters[:installdir].value + "/credentials/idp.key")
            else
                system("/bin/ln -s " + @parameters[:installdir].value + "/credentials/idp.key " + @parameters[:installdir].value + "/credentials/idp-signing.key")
                system("/bin/ln -s " + @parameters[:installdir].value + "/credentials/idp.key " + @parameters[:installdir].value + "/credentials/idp-encryption.key")
            end
			debug("Copying file for velocity templates and messages")
			system("/bin/cp -f " + @parameters[:sourcedir].value + "/views/*.vm " + @parameters[:installdir].value + "/views/") or raise Puppet::Error, "Error while copying velocity templates."
			system("/bin/cp -f " + @parameters[:sourcedir].value + "/messages/*.properties " + @parameters[:installdir].value + "/messages/") or raise Puppet::Error, "Error while copying messages files."
			system("/bin/chown -R " + @parameters[:curtomcat].value + ":" + @parameters[:curtomcat].value + " " + @parameters[:installdir].value + "/logs/ " + @parameters[:installdir].value + "/metadata/ " + @parameters[:installdir].value) or raise Puppet::Error, "Error while setting credentials."
			debug("Deleting file " + filename + ".")
			File.delete(filename)
		end
def refresh debug ( "Shibboleth_install[name] = " + @parameters [ :name ] . value + "." ) debug ( "Shibboleth_install[sourcedir] = " + @parameters [ :sourcedir ] . value + "." ) debug ( "Shibboleth_install[idpfqdn] = " + @parameters [ :idpfqdn ] . value + "." ) debug ( "Shibboleth_install[keystorepassword] = " + @parameters [ :keystorepassword ] . value + "." ) debug ( "Shibboleth_install[installdir] = " + @parameters [ :installdir ] . value + "." ) debug ( "Shibboleth_install[javahome] = " + @parameters [ :javahome ] . value + "." ) debug ( "Shibboleth_install[tomcathome] = " + @parameters [ :tomcathome ] . value + "." ) debug ( "Shibboleth_install[curtomcat] = " + @parameters [ :curtomcat ] . value + "." ) debug ( "Shibboleth_install[idpscope] = " + @parameters [ :idpscope ] . value + "." ) filename = @parameters [ :sourcedir ] . value + "/autoinstall.properties" File . open ( filename , "w" ) do | saved_file | saved_file . write ( "idp.src.dir = " + @parameters [ :sourcedir ] . value + "\n" ) saved_file . write ( "idp.target.dir = " + @parameters [ :installdir ] . value + "\n" ) saved_file . write ( "idp.host.name = " + @parameters [ :idpfqdn ] . value + "\n" ) saved_file . write ( "idp.sealer.password = " + @parameters [ :keystorepassword ] . value + "\n" ) saved_file . write ( "idp.keystore.password = " + @parameters [ :keystorepassword ] . value + "\n" ) saved_file . write ( "idp.merge.properties = autoinstall-merge.properties\n" ) saved_file . write ( "idp.noprompt = true\n" ) end system ( "/bin/rm -f " + @parameters [ :installdir ] . value + "/edit-webapp/css/*" ) filename = @parameters [ :sourcedir ] . value + "/autoinstall-merge.properties" File . open ( filename , "w" ) do | saved_file | saved_file . write ( "idp.entityID = https://" + @parameters [ :idpfqdn ] . value + "/idp/shibboleth" + "\n" ) saved_file . write ( "idp.scope = " + @parameters [ :idpscope ] . value + "\n" ) end filename = "/tmp/autoinstall.sh" File . open ( filename , "w" ) do | saved_file | saved_file . write ( "#!/bin/bash\n" ) saved_file . write ( ". /etc/environment\n" ) saved_file . write ( "export JAVA_HOME\n" ) saved_file . write ( "\n" ) saved_file . write ( "cd " + @parameters [ :sourcedir ] . value + "\n" ) saved_file . write ( "/bin/bash bin/install.sh -Didp.property.file=autoinstall.properties\n" ) end debug ( "Executing install script." ) system ( "/bin/bash " + filename ) or raise Puppet :: Error , "Error while installing Shibboleth IdP." debug ( "Create link to idp.crt and idp.key if not already present." ) if not File . exists? ( @parameters [ :installdir ] . value + "/credentials/idp.crt" ) system ( "/bin/ln -s " + @parameters [ :installdir ] . value + "/credentials/idp-signing.crt " + @parameters [ :installdir ] . value + "/credentials/idp.crt" ) else system ( "/bin/ln -s " + @parameters [ :installdir ] . value + "/credentials/idp.crt " + @parameters [ :installdir ] . value + "/credentials/idp-signing.crt" ) system ( "/bin/ln -s " + @parameters [ :installdir ] . value + "/credentials/idp.crt " + @parameters [ :installdir ] . value + "/credentials/idp-encryption.crt" ) end if not File . exists? ( @parameters [ :installdir ] . value + "/credentials/idp.key" ) system ( "/bin/ln -s " + @parameters [ :installdir ] . value + "/credentials/idp-signing.key " + @parameters [ :installdir ] . value + "/credentials/idp.key" ) else system ( "/bin/ln -s " + @parameters [ :installdir ] . value + "/credentials/idp.key " + @parameters [ :installdir ] . value + "/credentials/idp-signing.key" ) system ( "/bin/ln -s " + @parameters [ :installdir ] . value + "/credentials/idp.key " + @parameters [ :installdir ] . value + "/credentials/idp-encryption.key" ) end debug ( "Copying file for velocity templates and messages" ) system ( "/bin/cp -f " + @parameters [ :sourcedir ] . value + "/views/*.vm " + @parameters [ :installdir ] . value + "/views/" ) or raise Puppet :: Error , "Error while copying velocity templates." system ( "/bin/cp -f " + @parameters [ :sourcedir ] . value + "/messages/*.properties " + @parameters [ :installdir ] . value + "/messages/" ) or raise Puppet :: Error , "Error while copying messages files." system ( "/bin/chown -R " + @parameters [ :curtomcat ] . value + ":" + @parameters [ :curtomcat ] . value + " " + @parameters [ :installdir ] . value + "/logs/ " + @parameters [ :installdir ] . value + "/metadata/ " + @parameters [ :installdir ] . value ) or raise Puppet :: Error , "Error while setting credentials." debug ( "Deleting file " + filename + "." ) File . delete ( filename ) end
ensure property is not necessary, because it is not used.
ensure property is not necessary because it is not used .
# Creates a new property file to be used for input parameters of Shibboleth IdP installation. # Open it and complete it line by line # Creates a new property file to be used for input parameters of Shibboleth IdP installation. # Open it and complete it line by line # Creates a new bash script who adds JAVA_HOME environment variable to the underlying system and calls the "install.sh" to install the Shibboleth IdP. # Open it and complete it line by line # If the system() return 'false' reise up the message "Error while..."