#!/bin/bash ## script: ./upd-ezfit-latest.sh # #------------------------------------------------------------------------------ # Description: Update latest ezFIT installer # Usage: # Format: # Current date: % ./upd-ezfit-latest.sh # Arbitrary date: % ./upd-ezfit-latest.sh [YYYY-MMDD] # YYYY - Year (4 digits). # MM - Month (always 2 digits, including leading zero if necessary). # DD - Day of month (always 2 digitis, including leading zero if necessary). # Example: % ./publish-ezfit-latest.sh 2014-0422 #------------------------------------------------------------------------------ #----------------------------- # User Defined Variables #----------------------------- # Define Target Organizations TARGETORG=( "Audina" "Auditiva" "iEar" "MDHearingAid" "Acme" ) # Define Target Directory TARGETDIR="/var/www/downloads/prototypes" # Time Stamp (formatted as SYSDATESTAMP="2013-0117") SYSDATESTAMP=$(date +%Y-%m%d) SYSDATEYEAR=$(date +%Y) #----------------------------- # Use command line argument to override variables if [ -n "$1" ] then echo "Current version $SYSDATESTAMP will be ovewritten with $1" SYSDATESTAMP="$1" SYSDATEYEAR=${SYSDATESTAMP:0:4} fi # Try to create TargetDir if it does not exist if ! cd $TARGETDIR; then mkdir $TARGETDIR fi totalOrg=${#TARGETORG[*]} idx=0 while [ $idx -lt $totalOrg ]; do ORG=${TARGETORG[$idx]} #echo "Processing company $ORG" # Perform operations if TargetDir exists if cd $TARGETDIR; then #----------------------------- # Link current ezfit installer to ezfit-latest.exe #----------------------------- rm ezfit-$ORG-$SYSDATEYEAR-latest.exe ln -s ezfit-setup-$ORG-$SYSDATESTAMP.exe ezfit-$ORG-$SYSDATEYEAR-latest.exe echo "Success linking version $SYSDATESTAMP to ezfit-setup-$ORG-$SYSDATEYEAR-latest.exe" else echo "Failed to link version $SYSDATESTAMP to ezfit-ORG-$SYSDATEYEAR-latest.exe" fi let idx=idx+1 done #------------------------------------------------ # GetDate #------------------------------------------------ function GetDate() { SYSDATE=$(date +%Y%m%d) } #------------------------------------------------ # GetDateTime #------------------------------------------------ function GetDateTime() { SYSDATETIME=$(date +%Y%m%d-%H%M) } #------------------------------------------------ # GetDateStamp #------------------------------------------------ function GetDateStamp() { SYSDATESTAMP=$(date +%Y-%m%d) } #------------------------------------------------ # GetDate #------------------------------------------------ function GetYear() { SYSDATEYEAR=$(date +%Y) } #------------------------------------------------ # DisplayDate #------------------------------------------------ function DisplayDate() { if [ ! -z $SYSDATE ]; then echo $SYSDATE else echo "SYSDATE not defined. Define using GetDate()" fi }