1 2 3 4 | #!/bin/bash
# 2012-09-17
# version 2.8.6
# todo Nirvanix storage
|
UPDATEUTILITY="/var/lib/ssl/BACKUP/PropertiesWriterCLI-0.22.jar" WEBAPPS="/var/lib/tomcat6/webapps" SOURCESTORAGEPROPERTIESFILE="$WEBAPPS/storagegateway/WEB-INF/app.properties" SOURCEAUTHENTICATIONPROPERTIESFILE="$WEBAPPS/authgateway/WEB-INF/app.properties" UPDATEDSOURCE="/var/lib/ssl/BACKUP" SAVEDSOURCE="/var/lib/ssl/SAVE"
function getCurrentVersion()
{
if [ -e "$SAVEDSOURCE/CONSOLEMENU.pl" ]; then
VERSIONFILE="$SAVEDSOURCE/CONSOLEMENU.pl"
VERSION=$( grep "use constant VERSION =" $VERSIONFILE | cut -f 2 -d "\"" )
fi
echo "$VERSION"
}
function readSavedAuthenticationSetting() { if [ "$#" -ne 1 ]; then echo "Cannot read as the setting parameter is missing" else java -jar "$UPDATEUTILITY" "$SAVEDSOURCE/authentication.app.properties" "$1" fi }
function writeAuthenticationSetting() { if [ "$#" -ne 2 ]; then echo "Cannot write as the identifier or new setting parameter is missing" else java -jar "$UPDATEUTILITY" "$SOURCEAUTHENTICATIONPROPERTIESFILE" "$1" "$2" fi }
function readSavedStorageSetting() { if [ "$#" -ne 1 ]; then echo "Cannot read as the setting parameter is missing" else java -jar "$UPDATEUTILITY" "$SAVEDSOURCE/storage.app.properties" "$1" fi }
function writeStorageSetting() { if [ "$#" -ne 2 ]; then echo "Cannot write as the identifier or new setting parameter is missing" else java -jar "$UPDATEUTILITY" "$SOURCESTORAGEPROPERTIESFILE" "$1" "$2" fi }
function saveStorageSettings() { if [ -e "$SAVEDSOURCE/storage.app.properties" ]; then echo "Saving storage settings..." SGWOID=$( readSavedStorageSetting storagegateway.storageGatewayOid ) SGWKEY=$( readSavedStorageSetting storagegateway.storageGatewaySignedHash ) SGWTYPE=$( readSavedStorageSetting storagegateway.storageGatewayType ) echo if [ "$VERSION" == "2.8.5" -o "$VERSION" == "2.8.5d" -o "$VERSION" == "2.8.5e" ]; then SGWDOWNLOADURL=$( readSavedStorageSetting storagegateway.downloadWeblinkPrefixUrl ) else SGWDOWNLOADURL=$( readSavedStorageSetting storagegateway.downloadWeblinkPrefixURL ) fi SGWUPLOADURL=$( readSavedStorageSetting storagegateway.directUploadPrefixUrl ) SGWPATH=$( readSavedStorageSetting storagegateway.storagePath )
echo "$SGWOID"
echo "$SGWKEY"
echo "$SGWTYPE"
echo "$SGWDOWNLOADURL"
echo "$SGWUPLOADURL"
echo "$SGWPATH"
# ATMOS STORAGE ##########
if [ "$SGWTYPE" == "EMCstorageAdaptor" ]; then
echo "Saving Atmos settings..."
if [ "$VERSION" == "2.8.1" -o "$VERSION" == "2.8.2" -o "$VERSION" == "2.8.3" -o "$VERSION" == "2.8.4" -o "$VERSION" == "2.8.5" -o "$VERSION" == "2.8.5d" -o "$VERSION" == "2.8.5e" ]; then
ATMOSIP=$( readSavedStorageSetting storagegateway.emcIpAddress )
ATMOSPORT=$( readSavedStorageSetting storagegateway.emcPortNumber )
ATMOSUID=$( readSavedStorageSetting storagegateway.emcUid )
ATMOSSHAREDSECRET=$( readSavedStorageSetting storagegateway.emcSharedSecret )
ATMOSSTORAGEFOLDER=$( readSavedStorageSetting storagegateway.emcStorageFolder )
else
ATMOSIP=$( readSavedStorageSetting storagegateway.emc.IpAddress )
ATMOSPORT=$( readSavedStorageSetting storagegateway.emc.portNumber )
ATMOSUID=$( readSavedStorageSetting storagegateway.emc.uid )
ATMOSSHAREDSECRET=$( readSavedStorageSetting storagegateway.emc.sharedSecret )
ATMOSSTORAGEFOLDER=$( readSavedStorageSetting storagegateway.emc.storageFolder )
fi
echo "$ATMOSIP"
echo "$ATMOSPORT"
echo "$ATMOSUID"
echo "$ATMOSSHAREDSECRET"
echo "$ATMOSSTORAGEFOLDER"
fi
fi
}
function restoreStorageSettings() { if [ -e "$SAVEDSOURCE/storage.app.properties" ]; then /etc/init.d/tomcat6 stop rm -rf "$WEBAPPS/storagegateway" rm -rf /var/cache/tomcat6/Catalina/localhost echo "Updating Storage Connector application..." cp -a "$UPDATEDSOURCE/storagegateway" "$WEBAPPS"
echo "Restoring storage settings..."
if [ -e "$SOURCESTORAGEPROPERTIESFILE" ]; then
writeStorageSetting storagegateway.storageGatewayOid $SGWOID
writeStorageSetting storagegateway.storageGatewaySignedHash $SGWKEY
writeStorageSetting storagegateway.storageGatewayType $SGWTYPE
writeStorageSetting storagegateway.downloadWeblinkPrefixURL $SGWDOWNLOADURL
writeStorageSetting storagegateway.directUploadPrefixUrl $SGWUPLOADURL
writeStorageSetting storagegateway.chunkFilesystem.storagePath $SGWPATH
if [ "$SGWTYPE" == "CIFSstorageAdaptor" ]; then
writeStorageSetting storagegateway.chunkFilesystem.isAvailable "true"
fi
if [ "$SGWTYPE" == "NFSstorageAdaptor" ]; then
writeStorageSetting storagegateway.chunkFilesystem.isAvailable "true"
fi
if [ "$SGWTYPE" == "EMCstorageAdaptor" ]; then
writeStorageSetting storagegateway.emc.isAvailable "true"
writeStorageSetting storagegateway.emc.IpAddress $ATMOSIP
writeStorageSetting storagegateway.emc.portNumber $ATMOSPORT
writeStorageSetting storagegateway.emc.uid $ATMOSUID
writeStorageSetting storagegateway.emc.sharedSecret $ATMOSSHAREDSECRET
writeStorageSetting storagegateway.emc.storageFolder $ATMOSSTORAGEFOLDER
fi
else
echo "Error updating the Storage application"
fi
echo "Storage settings restored successfully"
else
echo "Skipping restore as missing source $SOURCESTORAGEPROPERTIESFILE"
fi
}
function saveAuthenticationSettings() { if [ -e "$SAVEDSOURCE/authentication.app.properties" ]; then echo "Saving authentication settings..." AUTHSERVICE1ACTIVE=$( readSavedAuthenticationSetting authgateway.service1.active ) AUTHSERVICE1HOST=$( readSavedAuthenticationSetting authgateway.service1.ldapServerHost ) AUTHSERVICE1PORT=$( readSavedAuthenticationSetting authgateway.service1.ldapServerPort ) AUTHSERVICE1SSL=$( readSavedAuthenticationSetting authgateway.service1.ldapSSL ) AUTHSERVICE1BASEDN=$( readSavedAuthenticationSetting authgateway.service1.ldapBaseDn ) AUTHSERVICE1USERDN=$( readSavedAuthenticationSetting authgateway.service1.ldapManagerUserDn ) AUTHSERVICE1PASSWORD=$( readSavedAuthenticationSetting authgateway.service1.ldapManagerPassword ) AUTHSERVICE1SEARCHBASE=$( readSavedAuthenticationSetting authgateway.service1.ldapUserSearchBase ) AUTHSERVICE1USERATTRIBUTE=$( readSavedAuthenticationSetting authgateway.service1.ldapUserAttribute ) AUTHSERVICE1SEARCHSUBTREE=$( readSavedAuthenticationSetting authgateway.service1.ldapSearchSubtree ) AUTHSERVICE1SEARCHGROUPS=$( readSavedAuthenticationSetting authgateway.service1.ldapSearchGroups ) AUTHSERVICE1GROUPSEARCHBASE=$( readSavedAuthenticationSetting authgateway.service1.ldapGroupSearchBase ) AUTHSERVICE1GROUPROLEATTRIBUTE=$( readSavedAuthenticationSetting authgateway.service1.ldapGroupRoleAttributeName ) AUTHSERVICE1GROUPMEMBERATTRIBUTE=$( readSavedAuthenticationSetting authgateway.service1.ldapGroupMemberAttributeName )
echo ""
echo "service1 active: $AUTHSERVICE1ACTIVE"
echo "$AUTHSERVICE1HOST"
echo "$AUTHSERVICE1PORT"
echo "$AUTHSERVICE1SSL"
echo "$AUTHSERVICE1BASEDN"
echo "$AUTHSERVICE1USERDN"
echo "$AUTHSERVICE1PASSWORD"
echo "$AUTHSERVICE1SEARCHBASE"
echo "$AUTHSERVICE1USERATTRIBUTE"
echo "$AUTHSERVICE1SEARCHSUBTREE"
echo "$AUTHSERVICE1SEARCHGROUPS"
echo "$AUTHSERVICE1GROUPSEARCHBASE"
echo "$AUTHSERVICE1GROUPROLEATTRIBUTE"
echo "$AUTHSERVICE1GROUPMEMBERATTRIBUTE"
AUTHSERVICE2ACTIVE=$( readSavedAuthenticationSetting authgateway.service2.active )
AUTHSERVICE2HOST=$( readSavedAuthenticationSetting authgateway.service2.ldapServerHost )
AUTHSERVICE2PORT=$( readSavedAuthenticationSetting authgateway.service2.ldapServerPort )
AUTHSERVICE2SSL=$( readSavedAuthenticationSetting authgateway.service2.ldapSSL )
AUTHSERVICE2BASEDN=$( readSavedAuthenticationSetting authgateway.service2.ldapBaseDn )
AUTHSERVICE2USERDN=$( readSavedAuthenticationSetting authgateway.service2.ldapManagerUserDn )
AUTHSERVICE2PASSWORD=$( readSavedAuthenticationSetting authgateway.service2.ldapManagerPassword )
AUTHSERVICE2SEARCHBASE=$( readSavedAuthenticationSetting authgateway.service2.ldapUserSearchBase )
AUTHSERVICE2USERATTRIBUTE=$( readSavedAuthenticationSetting authgateway.service2.ldapUserAttribute )
AUTHSERVICE2SEARCHSUBTREE=$( readSavedAuthenticationSetting authgateway.service2.ldapSearchSubtree )
AUTHSERVICE2SEARCHGROUPS=$( readSavedAuthenticationSetting authgateway.service2.ldapSearchGroups )
AUTHSERVICE2GROUPSEARCHBASE=$( readSavedAuthenticationSetting authgateway.service2.ldapGroupSearchBase )
AUTHSERVICE2GROUPROLEATTRIBUTE=$( readSavedAuthenticationSetting authgateway.service2.ldapGroupRoleAttributeName )
AUTHSERVICE2GROUPMEMBERATTRIBUTE=$( readSavedAuthenticationSetting authgateway.service2.ldapGroupMemberAttributeName )
echo ""
echo "service2 active: $AUTHSERVICE2ACTIVE"
echo "$AUTHSERVICE2HOST"
echo "$AUTHSERVICE2PORT"
echo "$AUTHSERVICE2SSL"
echo "$AUTHSERVICE2BASEDN"
echo "$AUTHSERVICE2USERDN"
echo "$AUTHSERVICE2PASSWORD"
echo "$AUTHSERVICE2SEARCHBASE"
echo "$AUTHSERVICE2USERATTRIBUTE"
echo "$AUTHSERVICE2SEARCHSUBTREE"
echo "$AUTHSERVICE2SEARCHGROUPS"
echo "$AUTHSERVICE2GROUPSEARCHBASE"
echo "$AUTHSERVICE2GROUPROLEATTRIBUTE"
echo "$AUTHSERVICE2GROUPMEMBERATTRIBUTE"
AUTHSERVICE3ACTIVE=$( readSavedAuthenticationSetting authgateway.service3.active )
AUTHSERVICE3HOST=$( readSavedAuthenticationSetting authgateway.service3.ldapServerHost )
AUTHSERVICE3PORT=$( readSavedAuthenticationSetting authgateway.service3.ldapServerPort )
AUTHSERVICE3SSL=$( readSavedAuthenticationSetting authgateway.service3.ldapSSL )
AUTHSERVICE3BASEDN=$( readSavedAuthenticationSetting authgateway.service3.ldapBaseDn )
AUTHSERVICE3USERDN=$( readSavedAuthenticationSetting authgateway.service3.ldapManagerUserDn )
AUTHSERVICE3PASSWORD=$( readSavedAuthenticationSetting authgateway.service3.ldapManagerPassword )
AUTHSERVICE3SEARCHBASE=$( readSavedAuthenticationSetting authgateway.service3.ldapUserSearchBase )
AUTHSERVICE3USERATTRIBUTE=$( readSavedAuthenticationSetting authgateway.service3.ldapUserAttribute )
AUTHSERVICE3SEARCHSUBTREE=$( readSavedAuthenticationSetting authgateway.service3.ldapSearchSubtree )
AUTHSERVICE3SEARCHGROUPS=$( readSavedAuthenticationSetting authgateway.service3.ldapSearchGroups )
AUTHSERVICE3GROUPSEARCHBASE=$( readSavedAuthenticationSetting authgateway.service3.ldapGroupSearchBase )
AUTHSERVICE3GROUPROLEATTRIBUTE=$( readSavedAuthenticationSetting authgateway.service3.ldapGroupRoleAttributeName )
AUTHSERVICE3GROUPMEMBERATTRIBUTE=$( readSavedAuthenticationSetting authgateway.service3.ldapGroupMemberAttributeName )
echo ""
echo "service3 active: $AUTHSERVICE3ACTIVE"
echo "$AUTHSERVICE3HOST"
echo "$AUTHSERVICE3PORT"
echo "$AUTHSERVICE3SSL"
echo "$AUTHSERVICE3BASEDN"
echo "$AUTHSERVICE3USERDN"
echo "$AUTHSERVICE3PASSWORD"
echo "$AUTHSERVICE3SEARCHBASE"
echo "$AUTHSERVICE3USERATTRIBUTE"
echo "$AUTHSERVICE3SEARCHSUBTREE"
echo "$AUTHSERVICE3SEARCHGROUPS"
echo "$AUTHSERVICE3GROUPSEARCHBASE"
echo "$AUTHSERVICE3GROUPROLEATTRIBUTE"
echo "$AUTHSERVICE3GROUPMEMBERATTRIBUTE"
fi
}
function restoreAuthenticationSettings() { if [ -e "$SAVEDSOURCE/authentication.app.properties" ]; then echo "preparing to restore authentication configuration..." /etc/init.d/tomcat6 stop rm -rf "$WEBAPPS/authgateway" rm -rf /var/cache/tomcat6/Catalina/localhost echo "loading new authentication application code..." cp -a "$UPDATEDSOURCE/authgateway" "$WEBAPPS"
if [ -e "$SOURCEAUTHENTICATIONPROPERTIESFILE" ]; then
if [ "$AUTHSERVICE1ACTIVE" == "true" ]; then
echo "restoring authentication configuration settings..."
writeAuthenticationSetting authgateway.service1.active $AUTHSERVICE1ACTIVE
writeAuthenticationSetting authgateway.service1.ldapServerHost $AUTHSERVICE1HOST
writeAuthenticationSetting authgateway.service1.ldapServerPort $AUTHSERVICE1PORT
writeAuthenticationSetting authgateway.service1.ldapSSL $AUTHSERVICE1SSL
writeAuthenticationSetting authgateway.service1.ldapBaseDn $AUTHSERVICE1BASEDN
writeAuthenticationSetting authgateway.service1.ldapManagerUserDn $AUTHSERVICE1USERDN
writeAuthenticationSetting authgateway.service1.ldapManagerPassword $AUTHSERVICE1PASSWORD
writeAuthenticationSetting authgateway.service1.ldapUserSearchBase $AUTHSERVICE1SEARCHBASE
writeAuthenticationSetting authgateway.service1.ldapUserAttribute $AUTHSERVICE1USERATTRIBUTE
writeAuthenticationSetting authgateway.service1.ldapSearchSubtree $AUTHSERVICE1SEARCHSUBTREE
writeAuthenticationSetting authgateway.service1.ldapSearchGroups $AUTHSERVICE1SEARCHGROUPS
writeAuthenticationSetting authgateway.service1.ldapGroupSearchBase $AUTHSERVICE1GROUPSEARCHBASE
writeAuthenticationSetting authgateway.service1.ldapGroupRoleAttributeName $AUTHSERVICE1GROUPROLEATTRIBUTE
writeAuthenticationSetting authgateway.service1.ldapGroupMemberAttributeName $AUTHSERVICE1GROUPMEMBERATTRIBUTE
fi
if [ "$AUTHSERVICE2ACTIVE" == "true" ]; then
echo "restoring authentication configuration settings..."
writeAuthenticationSetting authgateway.service2.active $AUTHSERVICE2ACTIVE
writeAuthenticationSetting authgateway.service2.ldapServerHost $AUTHSERVICE2HOST
writeAuthenticationSetting authgateway.service2.ldapServerPort $AUTHSERVICE2PORT
writeAuthenticationSetting authgateway.service2.ldapSSL $AUTHSERVICE2SSL
writeAuthenticationSetting authgateway.service2.ldapBaseDn $AUTHSERVICE2BASEDN
writeAuthenticationSetting authgateway.service2.ldapManagerUserDn $AUTHSERVICE2USERDN
writeAuthenticationSetting authgateway.service2.ldapManagerPassword $AUTHSERVICE2PASSWORD
writeAuthenticationSetting authgateway.service2.ldapUserSearchBase $AUTHSERVICE2SEARCHBASE
writeAuthenticationSetting authgateway.service2.ldapUserAttribute $AUTHSERVICE2USERATTRIBUTE
writeAuthenticationSetting authgateway.service2.ldapSearchSubtree $AUTHSERVICE2SEARCHSUBTREE
writeAuthenticationSetting authgateway.service2.ldapSearchGroups $AUTHSERVICE2SEARCHGROUPS
writeAuthenticationSetting authgateway.service2.ldapGroupSearchBase $AUTHSERVICE2GROUPSEARCHBASE
writeAuthenticationSetting authgateway.service2.ldapGroupRoleAttributeName $AUTHSERVICE2GROUPROLEATTRIBUTE
writeAuthenticationSetting authgateway.service2.ldapGroupMemberAttributeName $AUTHSERVICE2GROUPMEMBERATTRIBUTE
fi
if [ "$AUTHSERVICE3ACTIVE" == "true" ]; then
echo "restoring authentication configuration settings..."
writeAuthenticationSetting authgateway.service3.active $AUTHSERVICE3ACTIVE
writeAuthenticationSetting authgateway.service3.ldapServerHost $AUTHSERVICE3HOST
writeAuthenticationSetting authgateway.service3.ldapServerPort $AUTHSERVICE3PORT
writeAuthenticationSetting authgateway.service3.ldapSSL $AUTHSERVICE3SSL
writeAuthenticationSetting authgateway.service3.ldapBaseDn $AUTHSERVICE3BASEDN
writeAuthenticationSetting authgateway.service3.ldapManagerUserDn $AUTHSERVICE3USERDN
writeAuthenticationSetting authgateway.service3.ldapManagerPassword $AUTHSERVICE3PASSWORD
writeAuthenticationSetting authgateway.service3.ldapUserSearchBase $AUTHSERVICE3SEARCHBASE
writeAuthenticationSetting authgateway.service3.ldapUserAttribute $AUTHSERVICE3USERATTRIBUTE
writeAuthenticationSetting authgateway.service3.ldapSearchSubtree $AUTHSERVICE3SEARCHSUBTREE
writeAuthenticationSetting authgateway.service3.ldapSearchGroups $AUTHSERVICE3SEARCHGROUPS
writeAuthenticationSetting authgateway.service3.ldapGroupSearchBase $AUTHSERVICE3GROUPSEARCHBASE
writeAuthenticationSetting authgateway.service3.ldapGroupRoleAttributeName $AUTHSERVICE3GROUPROLEATTRIBUTE
writeAuthenticationSetting authgateway.service3.ldapGroupMemberAttributeName $AUTHSERVICE3GROUPMEMBERATTRIBUTE
fi
else
echo "Error updating the Authentication application"
fi
else
echo "Skipping restore as missing source $SOURCEAUTHENTICATIONPROPERTIESFILE"
fi
}
function restoreVMSettings() { cp -a "$SAVEDSOURCE/interfaces" "/etc/network/" cp -a "$SAVEDSOURCE/resolv.conf" "/etc/" cp -a "$SAVEDSOURCE/ntp.conf" "/etc/" cp -a "$SAVEDSOURCE/hosts" "/etc/" cp -a "$SAVEDSOURCE/hostname" "/etc/" echo "Network settings restored"
if [ -f "$SAVEDSOURCE/cacerts" ]; then
cp -a "$SAVEDSOURCE/cacerts" "/etc/java-6-sun/security/cacerts"
fi
if [ -f "$SAVEDSOURCE/cert.crt" ]; then
cp -a "$SAVEDSOURCE/cert.crt" "/var/lib/ssl/"
fi
if [ -f "$SAVEDSOURCE/intermediate.crt" ]; then
cp -a "$SAVEDSOURCE/intermediate.crt" "/var/lib/ssl/"
fi
if [ -f "$SAVEDSOURCE/cert.key" ]; then
cp -a "$SAVEDSOURCE/cert.key" "/var/lib/ssl/"
fi
if [ -f "$SAVEDSOURCE/remotecert.crt" ]; then
cp -a "$SAVEDSOURCE/remotecert.crt" "/var/lib/ssl/"
fi
if [ -f "$SAVEDSOURCE/remotecacert.crt" ]; then
cp -a "$SAVEDSOURCE/remotecacert.crt" "/var/lib/ssl/"
fi
if [ -f "$SAVEDSOURCE/ldap.conf" ]; then
cp -a "$SAVEDSOURCE/ldap.conf" "/etc/ldap/"
fi
echo "SSL settings restored"
if [ -f "$SAVEDSOURCE/fstab" ]; then
cp -a "$SAVEDSOURCE/fstab" "/etc/"
fi
if [ -f "$SAVEDSOURCE/nfsserver" ]; then
cp -a "$SAVEDSOURCE/nfsserver" "/etc/"
fi
if [ -f "$SAVEDSOURCE/cifscredentials" ]; then
cp -a "$SAVEDSOURCE/cifscredentials" "/etc/"
fi
if [ -f "$SAVEDSOURCE/cifsserver" ]; then
cp -a "$SAVEDSOURCE/cifsserver" "/etc/"
fi
echo "Storage settings restored"
}
######### MAIN
/etc/init.d/tomcat6 stop sleep 10 VERSION=$( getCurrentVersion ) echo "Current Version: $VERSION"
restoreVMSettings
if [ -e "$UPDATEUTILITY" ]; then
cp -a "$UPDATEDSOURCE/tty1.conf" /etc/init/
if [ -e "/etc/init.d/CONSOLEMENU.pl" ]; then
rm /etc/init.d/CONSOLEMENU.pl
fi
rm /etc/init.d/FIREWALL-lockdown.sh
ln -s "$UPDATEDSOURCE/FIREWALL-lockdown.sh" /etc/init.d/FIREWALL-lockdown.sh
saveAuthenticationSettings
restoreAuthenticationSettings
saveStorageSettings
restoreStorageSettings
else echo "Unable to locate required dependency: $UPDATEUTILITY" fi