]> git.donarmstrong.com Git - dsa-puppet.git/commitdiff
static-update-component: support a -f to override host/srcdir checks
authorPeter Palfrader <peter@palfrader.org>
Sun, 7 Apr 2013 18:26:25 +0000 (20:26 +0200)
committerPeter Palfrader <peter@palfrader.org>
Sun, 7 Apr 2013 18:26:25 +0000 (20:26 +0200)
modules/roles/templates/static-mirroring/static-update-component.erb

index 7dbad820aea4e71ecbc1a746d503693f5cca1f31..ed214e58fda570587558a460cbeb6a8ec9e48308 100755 (executable)
 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
+usage() {
+  echo >&2 "Usage: $0 [-f] <component>"
+  exit 1
+}
+
 componentlist=/etc/static-components.conf
 
-if [ "$#" != 1 ]; then
-  echo >&2 "Usage: $0 <component>"
-  exit 1
+if [ "$#" = 1 ]; then
+  component="$1"
+elif [ "$#" = 2 ]; then
+  if [ "$1" = "-f" ]; then force=1
+  else usage; fi
+  component="$2"
+else
+  usage
 fi
 
-component="$1"
 
 if [ "${component%/*}" != "$component" ] ; then
   echo >&2 "$0: Invalid component: $component";
@@ -42,18 +51,18 @@ if [ -z "$srchost" ] || [ -z "$srcdir" ]; then
   exit 1
 fi
 
-if ! [ "$srchost" = "`hostname -f`" ]; then
+if ! [ "$srchost" = "`hostname -f`" ] && ! [ "$force" = 1 ]; then
   echo >&2 "Component $component is sourced from $srchost, not this host."
   exit 1
 fi
 
-if ! [ -d "$srcdir" ]; then
+if ! [ -d "$srcdir" ] && ! [ "$force" = 1 ]; then
   echo >&2 "Component source directory $srcdir does not exist or is not a directory, or is not accessible."
   exit 1
 fi
 
 if [ "`id -nu`" != "staticsync" ]; then
-  sudo -u staticsync static-update-component "$component"
+  sudo -u staticsync static-update-component "$@"
 else
   masters=()
 <%=