Created
October 20, 2011 12:09
-
-
Save ClausPolanka/1300992 to your computer and use it in GitHub Desktop.
CPB Software AG Script to manag WebSphere profiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/qsh | |
EXIT_SUCCESS=0 | |
EXIT_FAILURE=1 | |
EXIT_ERROR=2 | |
USERNAME="" | |
PASSWORD="" | |
INSTALL="n" | |
CREATE="n" | |
DELETE="n" | |
installApplications() { | |
installPropertyFile $ARG | |
replacePropertiesInPropertyLoader | |
replaceScriptHomeInPyhtonScripts | |
executeInstallationProcess | |
} | |
installPropertyFile() { | |
if [ -f $ARG.properties ] | |
then | |
. $ARG.properties | |
else | |
echo " Error: Please be sure that $ARG.properties exist." | |
exit 1 | |
fi | |
} | |
replacePropertiesInPropertyLoader() { | |
cat $(pwd)/wsadmin/PropertyLoaderClass.py | \ | |
sed -e "s%TODO%$(pwd)%" -e "s%PROFILE%$ARG%" \ | |
> $(pwd)/wsadmin/PropertyLoaderClass.py | |
} | |
executeInstallationProcess() { | |
echo "Install Applications ..." | |
/QIBM/UserData/WebSphere/AppServer/V7/Express/profiles/$ARG/bin/wsadmin \ | |
-username $USERNAME -password $PASSWORD \ | |
-lang jython -f $(pwd)/wsadmin/installEARs.py | |
} | |
createProfile() { | |
installPropertyFile $ARG | |
replacePropertiesInPropertyLoader | |
executeProfileCreation $ARG | |
startServer $ARG | |
replaceScriptHomeInPyhtonScripts | |
configureServer $ARG | |
# stopServer $ARG | |
} | |
executeProfileCreation() { | |
echo "Create profile: $ARG ..." | |
/QIBM/ProdData/WebSphere/AppServer/V7/Express/bin/manageprofiles \ | |
-create \ | |
-profileName $ARG \ | |
-profilePath /QIBM/UserData/WebSphere/AppServer/V7/Express/profiles/$ARG \ | |
-hostName $host.cpbs.at \ | |
-nodeName $host_$ARG \ | |
-enableAdminSecurity true \ | |
-startingPort $startingPort \ | |
-adminUserName $USERNAME \ | |
-adminPassword $PASSWORD | |
echo "Successfully created profile!" | |
} | |
startServer() { | |
echo "Starting server of $ARG-profile ..." | |
/QIBM/UserData/WebSphere/AppServer/V7/Express/profiles/$ARG/bin/startServer | |
} | |
replaceScriptHomeInPyhtonScripts() { | |
cat $(pwd)/wsadmin/configSetup.py | sed -e "s%TODO%$(pwd)%" > $(pwd)/wsadmin/configSetup.py | |
cat $(pwd)/wsadmin/configureJVMLogs.py | sed -e "s%TODO%$(pwd)%" > $(pwd)/wsadmin/configureJVMLogs.py | |
cat $(pwd)/wsadmin/datasources.py | sed -e "s%TODO%$(pwd)%" > $(pwd)/wsadmin/datasources.py | |
cat $(pwd)/wsadmin/datasourcesCustomProperties.py | sed -e "s%TODO%$(pwd)%" > $(pwd)/wsadmin/datasourcesCustomProperties.py | |
cat $(pwd)/wsadmin/installEARs.py | sed -e "s%TODO%$(pwd)%" > $(pwd)/wsadmin/installEARs.py | |
cat $(pwd)/wsadmin/jdbcProvider.py | sed -e "s%TODO%$(pwd)%" > $(pwd)/wsadmin/jdbcProvider.py | |
cat $(pwd)/wsadmin/security.py | sed -e "s%TODO%$(pwd)%" > $(pwd)/wsadmin/security.py | |
cat $(pwd)/wsadmin/serverConfig.py | sed -e "s%TODO%$(pwd)%" > $(pwd)/wsadmin/serverConfig.py | |
cat $(pwd)/wsadmin/sharedLibs.py | sed -e "s%TODO%$(pwd)%" > $(pwd)/wsadmin/sharedLibs.py | |
cat $(pwd)/wsadmin/urls.py | sed -e "s%TODO%$(pwd)%" > $(pwd)/wsadmin/urls.py | |
cat $(pwd)/wsadmin/was_variablen.py | sed -e "s%TODO%$(pwd)%" > $(pwd)/wsadmin/was_variablen.py | |
cat $(pwd)/wsadmin/messaging.py | sed -e "s%TODO%$(pwd)%" > $(pwd)/wsadmin/messaging.py | |
} | |
configureServer() { | |
echo "Configure server of $ARG-profile ..." | |
/QIBM/UserData/WebSphere/AppServer/V7/Express/profiles/$ARG/bin/wsadmin -username $USERNAME -password $PASSWORD -lang jython \ | |
-f $(pwd)/wsadmin/configSetup.py | |
} | |
stopServer() { | |
echo "Stopping server of $ARG-profile ..." | |
/QIBM/UserData/WebSphere/AppServer/V7/Express/profiles/$ARG/bin/stopServer -username $USERNAME -password $PASSWORD | |
} | |
deleteProfile() { | |
echo "Delete Profile $ARG ..." | |
/QIBM/ProdData/WebSphere/AppServer/V7/Express/bin/manageprofiles -delete -profileName $ARG | |
} | |
function usage { | |
echo "Usage: $SCRIPTNAME [-h] [-u username] [-p password] [[-i] | [-c] | [-d]] profileName ..." >&2 | |
[[ $# -eq 1 ]] && exit $1 || exit $EXIT_FAILURE | |
} | |
while getopts ":u:p:hcdi" opt; do | |
case $opt in | |
u) USERNAME="$OPTARG" ;; | |
p) PASSWORD="$OPTARG" ;; | |
i) INSTALL="y" ;; | |
c) CREATE="y" ;; | |
d) DELETE="y" ;; | |
h) usage ;; | |
\?) | |
echo "Invalid option: -$OPTARG" >&2 | |
exit EXIT_FAILURE | |
;; | |
:) | |
echo "Option -$OPTARG requires an argument." >&2 | |
exit EXIT_FAILURE | |
;; | |
esac | |
done | |
# Shift already used arguments. | |
shift $(( OPTIND - 1 )) | |
if [ $# -lt 1 ]; then | |
usage $EXIT_ERROR | |
fi | |
if [ $OPTIND -ne 6 ]; then | |
usage $EXIT_ERROR | |
fi | |
for ARG; do | |
if [[ $INSTALL = "y" ]]; then | |
installApplications $* | |
elif [[ $CREATE = "y" ]]; then | |
createProfile $* | |
elif [[ $DELETE = "y" ]]; then | |
deleteProfile $* | |
fi | |
done | |
exit $EXIT_SUCCESS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment