#!/bin/sh -x # Automatic Green Bubble skin installer for NetScaler # See http://http://blogs.citrix.com/2012/04/19/green-bubble-theme-for-citrix-netscaler for complete details # # Description: # This script will automatically download and install the current GreenBubble NetScaler Theme for the Access Gateway Portal UI # from the Citrix CDN, extract all files to the /var/vpn/themes directory, automatically adjust referenced major and minor # build numbers in the static content, copy the content to flash, and finally put an entry in nsafter.sh to automatically run # the routine at each startup to check installation state and to copy the custom content to flash. This script assumes internet # connectivity from the NetScaler is available but will prompt the user for manual download if installing the skin out-of-band. # # To run simply enter ./GreenBubble#.sh: # GreenBubble1 = Base GreenBubble Skin # GreenBubble2 = Base GreenBubble Skin with addition of Domain Drop-down (Requires Additional configuration described in: http://support.citrix.com/article/CTX118657) # GreenBubble3 = Base GreenBubble Skin with ReCaptcha # GreenBubble4 = Base GreenBubble SKin with ReCaptcha and Domain Drop-down (Requires Additional configuration described in: http://support.citrix.com/article/CTX118657) # Variables SKINNAME=`basename $0 .sh` SKINARC="$SKINNAME.gz" SKINDIR="/var/vpn/themes" DL="/tmp" # Short names EPA="ns_gui/epa/epa.html" SKINURL="http://cdn.ws.citrix.com/wp-content/uploads/2012/04/$SKINARC" if ! [ -d $SKINDIR/$SKINNAME ] ; then if ! [ -s $DL/$SKINARC ] ; then # No wget on NS so use a bit of perl to download the skin echo "$0: Downloading skin archive '$SKINARC' to $DL" perl -e 'use LWP::Simple; $skin = get "'$SKINURL'"; open(F, ">'$DL/$SKINARC'"); print F $skin; close(F);' if [ $? -ne 0 ] ; then echo "$0: Failed to download skin archive '$SKINARC' to '$DL'. Please fetch '$SKINURL', copy '$SKINARC' to '$DL' and rerun this script." exit 1 fi fi echo "$0: Extracting skin archive '$DL/$SKINARC'" mkdir -p $SKINDIR cd $SKINDIR tar zxf $DL/$SKINARC || exit 1 rm $DL/$SKINARC fi # Find the skin version OLDCOMMAVER=`fgrep 'var nsversion=' $SKINDIR/$SKINNAME/$EPA | cut -d\" -f2` OLDDOTVER=`echo $OLDCOMMAVER | tr ',' '.'` # Find the running version DOTVER=`nsapimgr -d hwinfo | grep Version: | sed -e 's/Version: NetScaler NS//' -e 's/: Build /\./' -e 's/, Date.*//' | cut -d. -f1,2,3,4` COMMAVER=`echo $DOTVER | tr '.' ','` if [ $OLDDOTVER != $DOTVER ] ; then # Replace the version string in html files with the current version find $SKINDIR/$SKINNAME -type f -name \*.html -exec sed -e "s/$OLDDOTVER/$DOTVER/g" -e "s/$OLDCOMMAVER/$COMMAVER/g" -i '' {} \; fi # Install the skin cp -rf $SKINDIR/$SKINNAME/ /netscaler/ # Install the loader cp $0 $SKINDIR chmod 755 $SKINDIR/$SKINNAME.sh touch /nsconfig/nsafter.sh chmod 755 /nsconfig/nsafter.sh if ! fgrep -q $SKINDIR/$SKINNAME.sh /nsconfig/nsafter.sh ; then echo >>/nsconfig/nsafter.sh $SKINDIR/$SKINNAME.sh fi