Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- GREP_STR="Copyright Veritone Corporation 2018. All rights reserved."
- LICENSE_HASH="# Copyright Veritone Corporation 2018. All rights reserved.
- # See LICENSE for more information.
- "
- LICENSE_SLASH="// Copyright Veritone Corporation 2018. All rights reserved.
- // See LICENSE for more information.
- "
- dir=$1
- if [[ ${dir// } = "" ]]; then
- echo "ERROR: No directory to scan"
- exit 1
- fi
- # Handle files: .go
- while read -r file; do
- if grep "$GREP_STR" "$file" &> /dev/null; then
- continue
- fi
- echo "Updating: $file"
- echo "$LICENSE_SLASH" | cat - "$file" > _- && mv _- "$file"
- done <<< "$(find "$dir" -type f -name '*.go')"
- # Handle files: .yml .yaml
- while read -r file; do
- if grep "$GREP_STR" "$file" &> /dev/null; then
- continue
- fi
- echo "Updating: $file"
- echo "$LICENSE_HASH" | cat - "$file" > _- && mv _- "$file"
- done <<< "$(find "$dir" -type f -name '*.yml' -or -name '*.yaml')"
- # Handle files: .sh .bash
- while read -r file; do
- if grep "$GREP_STR" "$file" &> /dev/null; then
- continue
- fi
- echo "Updating: $file"
- shebang=""
- firstLine=$(head -n 1 "$file")
- if echo "$firstLine" | grep '#!' &> /dev/null; then
- shebang=$firstLine
- sed '1d' < "$file" > _- && mv _- "$file"
- fi
- printf "$shebang\\n$LICENSE_HASH" | cat - "$file" > _- && mv _- "$file"
- done <<< "$(find "$dir" -type f -name '*.sh' -or -name '*.bash')"
Add Comment
Please, Sign In to add comment