#!/bin/bash
#
# sed command to remove malware scriptNode from Maya ascii files
#
# Usage cleanScriptNode fileName
#
# future work:
#   check on status
#   
# were we passed any parameters
if [ $# -gt 0 ]; then

  grep -q MayaMelUIConfigurationFile  "$1"
  if [ $? -eq 0 ]; then
    echo "processing file: ["$1"] ..."
    sed -i.bak '/createNode script -n "MayaMelUIConfigurationFile/,/setAttr ".st" 1;/d' "$1"
  fi

  grep -q vaccine_gene "$1"
  if [ $? -eq 0 ]; then
    echo "processing file: ["$1"] ..."
    sed -i.bak '/createNode script -n "vaccine_gene";/,/leukocyte.antivirus()/d' "$1"
    sed -i.bak '/createNode script -n "breed_gene";/,/setAttr ".stp" 1;/d' "$1"
  fi

else
  echo "Usage: cleanScriptNode filePattern"
fi

