Using packages, to manage code between your IDM environments, allows for consistent transfer of code and easy management.

Sharing packages between multiple team members can become cumbersome, unless you setup your own repository.

The below Linux script can move built packages from an FTP directory (specified by the variable ${FTPSRCDIR}) to a web directory (under ${STARTDIR}/plugins/) and generate the necessary feature file (under ${STARTDIR}/features/) and site.xml.

The script just requires the Java JDK to execute jar commands in the PATH environment.

#!/bin/sh

export FTPSRCDIR=/srv/ftp/packages
export STARTDIR=/path/to/designer/packages/updatesite2_0_0
export PKGURL=http://mysite.com/designer/packages/updatesite2_0_0/
export CHOWNER=wwwrun:www
export MANIFEST=feature.MF
export BUILDDIR=jar-build
export EXTRACTDIR=jar-extract
export FEATURE=feature.xml
export SITE=site.xml

#####################################
# Copy FTP Packages                 #
#####################################
if ls ${FTPSRCDIR}/*_*.*.*.*.jar 1> /dev/null 2>&1
 then
	mv ${FTPSRCDIR}/*_*.*.*.*.jar ${STARTDIR}/plugins/
	chown ${CHOWNER} ${STARTDIR}/plugins/*.jar
	chmod 644 ${STARTDIR}/plugins/*.jar
else
	echo -e "No file at ${FTPSRCDIR}/*_*.*.*.*.jar"
fi

#####################################
# Cleanup                           #
#####################################
rm -f ${STARTDIR}/${MANIFEST}

#####################################
# Site Header                       #
#####################################
echo -e "<?xml version=\"1.0\" encoding=\"UTF-8\"?>">${STARTDIR}/${SITE}.new
echo -e "<site>">>${STARTDIR}/${SITE}.new
echo -e "\t<description url=\"${PKGURL}\">This site contains released packages(4.6) for Micro Focus Identity Manager.</description>">>${STARTDIR}/${SITE}.new

#####################################
# Loop through files                #
#####################################
cd ${STARTDIR}/plugins
for plugin in $(ls -1 *.jar)
 do
	#####################################
	# Get Plugin Details                #
	#####################################
	idm_shortname=${plugin%_*}
	idm_buildtime=${plugin#*_}
	idm_buildtime=${idm_buildtime%.*}
	#####################################
	# Only bother with missing features #
	#####################################
	if [ ! -f "${STARTDIR}/features/${idm_shortname}.feature_${idm_buildtime}.jar" ]
	 then
		echo -e "Building ${idm_shortname}.feature_${idm_buildtime}.jar from ${plugin}"
		mkdir -p ${STARTDIR}/${EXTRACTDIR}
		cd ${STARTDIR}/${EXTRACTDIR}
		jar -xf ../plugins/${plugin}
		headers=$(grep -n "<license>" package_import.xml | grep -Eo '^[^:]+')
		head -${headers} package_import.xml>package_output.xml
		echo "</package>">>package_output.xml
		symbolic_name=$(echo 'cat //package/@symbolic-name' | xmllint --shell package_output.xml --noout | awk -F'[="]' '!/>/{print $(NF-1)}')
		symbolic_name=$(echo "${symbolic_name}" | sed 's/[[:space:]]-------//')
		symbolic_name=$(echo "${symbolic_name}" | tr -d '\n')
		description=$(echo 'cat //package/description/text()' | xmllint --shell package_output.xml --noout | awk -F'[="]' '!/>/{print $(NF-1)}')
		description=$(echo "${description}" | sed 's/[[:space:]]-------//')
		description=$(echo "${description}" | tr -d '\n')
		idm_vendorname=$(echo 'cat //package/idm-vendorname/text()' | xmllint --shell package_output.xml | awk -F'[="]' '!/>/{print $(NF-1)}')
		idm_vendorname=$(echo "${idm_vendorname}" | sed 's/[[:space:]]-------//')
		idm_vendorname=$(echo "${idm_vendorname}" | tr -d '\n')
		idm_internalversion=$(echo 'cat //package/idm-internalversion/text()' | xmllint --shell package_output.xml | awk -F'[="]' '!/>/{print $(NF-1)}')
		idm_internalversion=$(echo "${idm_internalversion}" | sed 's/[[:space:]]-------//')
		idm_internalversion=$(echo "${idm_internalversion}" | tr -d '\n')
		cd ${STARTDIR}
		rm -fr ${STARTDIR}/${EXTRACTDIR}
		#####################################
		# Build Manifest                    #
		#####################################
		mkdir -p ${STARTDIR}/${BUILDDIR}
		rm -f ${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "Manifest-Version: 1.0">${STARTDIR}/${MANIFEST}
		echo "Require-Bundle: com.novell.idm.packagemanager">>${STARTDIR}/${MANIFEST}
		echo "Bundle-Vendor: ${idm_vendorname}">>${STARTDIR}/${MANIFEST}
		echo "Internal-Version: ${idm_internalversion}">>${STARTDIR}/${MANIFEST}
		echo "Bundle-Version: ${idm_buildtime}">>${STARTDIR}/${MANIFEST}
		echo "Bundle-Name: ${description}">>${STARTDIR}/${MANIFEST}
		echo "Bundle-ManifestVersion: 2">>${STARTDIR}/${MANIFEST}
		echo "Bundle-SymbolicName: ${symbolic_name}; singleton:=true">>${STARTDIR}/${MANIFEST}
		#####################################
		# Build Feature XML                 #
		#####################################
		echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>">${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "<feature">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "    id=\"${idm_shortname}.feature\"">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "    label=\"${description}\"">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "    version=\"${idm_buildtime}\"">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "    provider-name=\"${idm_vendorname}\">">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "    <description>">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "        ${description}">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "    </description>">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "    <plugin">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "        id=\"${idm_shortname}\"">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "        download-size=\"0\"">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "        install-size=\"0\"">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "        version=\"${idm_buildtime}\"">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "        fragment=\"true\"">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "        unpack=\"false\"/>">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		echo "</feature>">>${STARTDIR}/${BUILDDIR}/${FEATURE}
		cd ${STARTDIR}/${BUILDDIR}
		#####################################
		# Build Feature                     #
		#####################################
		jar -cfm ${STARTDIR}/features/${idm_shortname}.feature_${idm_buildtime}.jar ${STARTDIR}/${MANIFEST} *
		cd ${STARTDIR}
		rm -fr ${STARTDIR}/${BUILDDIR}
		rm -f ${STARTDIR}/${MANIFEST}
	fi
	#####################################
	# Echo site.xml                     #
	#####################################
	echo -e "\t<feature id=\"${idm_shortname}.feature\" url=\"features/${idm_shortname}.feature_${idm_buildtime}.jar\" version=\"${idm_buildtime}\"/>">>${STARTDIR}/${SITE}.new
done

chown ${CHOWNER} ${STARTDIR}/features/*.jar
chmod 644 ${STARTDIR}/features/*.jar

#####################################
# Site Footer                       #
#####################################
echo -e "</site>">>${STARTDIR}/${SITE}.new
echo -e "<!-- Generated on: `date` -->">>${STARTDIR}/${SITE}.new
rm -f ${STARTDIR}/${SITE}
mv ${STARTDIR}/${SITE}.new ${STARTDIR}/${SITE}
chown ${CHOWNER} ${STARTDIR}/${SITE}
chmod 644 ${STARTDIR}/${SITE}

More articles on my Website.

2 votes, average: 5.00 out of 52 votes, average: 5.00 out of 52 votes, average: 5.00 out of 52 votes, average: 5.00 out of 52 votes, average: 5.00 out of 5 (2 votes, average: 5.00 out of 5)
You need to be a registered member to rate this post.
Loading...

Disclaimer: As with everything else at NetIQ Cool Solutions, this content is definitely not supported by NetIQ, so Customer Support will not be able to help you if it has any adverse effect on your environment.  It just worked for at least one person, and perhaps it will be useful for you too.  Be sure to test in a non-production environment.

Leave a Reply

No Comments
ScorpionSting
Mar 6, 2017
11:55 am
Reads:
1,110
Score:
5
Active Directory Authentication Automation Cloud Computing Cloud Security Configuration Customizing Data Breach DirXML Drivers End User Management Identity Manager Importing-Exporting / ICE/ LDIF Intelligent Workload Management IT Security Knowledge Depot LDAP Monitoring Open Enterprise Server Passwords Reporting Secure Access Supported Troubleshooting Workflow