From fed2ee644fe631ae52428ed016ddda62f64c1a41 Mon Sep 17 00:00:00 2001 From: Pig Monkey Date: Fri, 17 Oct 2014 14:21:25 -0700 Subject: [PATCH] Support FreeBSD date utility Both FreeBSD and OSX use the POSIX date utility. --- ec2-automate-backup/ec2-automate-backup-awscli.sh | 5 +++-- ec2-automate-backup/ec2-automate-backup.sh | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ec2-automate-backup/ec2-automate-backup-awscli.sh b/ec2-automate-backup/ec2-automate-backup-awscli.sh index f64f6e4..39cf94d 100755 --- a/ec2-automate-backup/ec2-automate-backup-awscli.sh +++ b/ec2-automate-backup/ec2-automate-backup-awscli.sh @@ -82,7 +82,8 @@ get_date_binary() { #$(uname) on OS X defaults to $(uname -s) and $(uname) on GNU/Linux defaults to $(uname -s) uname_result=$(uname) case $uname_result in - Darwin) date_binary="osx-posix" ;; + Darwin) date_binary="posix" ;; + FreeBSD) date_binary="posix" ;; Linux) date_binary="linux-gnu" ;; *) date_binary="unknown" ;; esac @@ -102,7 +103,7 @@ esac #based on the date_binary variable, the case statement below will determine the method to use to determine "purge_after_days" in the future case $date_binary in linux-gnu) echo $(date -d +${purge_after_value_seconds}sec -u +%s) ;; - osx-posix) echo $(date -v +${purge_after_value_seconds}S -u +%s) ;; + posix) echo $(date -v +${purge_after_value_seconds}S -u +%s) ;; *) echo $(date -d +${purge_after_value_seconds}sec -u +%s) ;; esac } diff --git a/ec2-automate-backup/ec2-automate-backup.sh b/ec2-automate-backup/ec2-automate-backup.sh index 5b1c0e7..bb88bed 100755 --- a/ec2-automate-backup/ec2-automate-backup.sh +++ b/ec2-automate-backup/ec2-automate-backup.sh @@ -83,7 +83,8 @@ get_date_binary() { #$(uname) on OS X defaults to $(uname -s) and $(uname) on GNU/Linux defaults to $(uname -s) uname_result=$(uname) case $uname_result in - Darwin) date_binary="osx-posix" ;; + Darwin) date_binary="posix" ;; + FreeBSD) date_binary="posix" ;; Linux) date_binary="linux-gnu" ;; *) date_binary="unknown" ;; esac @@ -103,7 +104,7 @@ esac #based on the date_binary variable, the case statement below will determine the method to use to determine "purge_after_days" in the future case $date_binary in linux-gnu) echo $(date -d +${purge_after_value_seconds}sec -u +%s) ;; - osx-posix) echo $(date -v +${purge_after_value_seconds}S -u +%s) ;; + posix) echo $(date -v +${purge_after_value_seconds}S -u +%s) ;; *) echo $(date -d +${purge_after_value_seconds}sec -u +%s) ;; esac }