You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.3 KiB
Bash
54 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
# vim:ts=4:sts=4:sw=4:et
|
|
#
|
|
# Author: Hari Sekhon
|
|
# Date: 2020-02-13 15:36:35 +0000 (Thu, 13 Feb 2020)
|
|
#
|
|
# https://github.com/harisekhon/bash-tools
|
|
#
|
|
# License: see accompanying Hari Sekhon LICENSE file
|
|
#
|
|
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
|
#
|
|
# https://www.linkedin.com/in/harisekhon
|
|
#
|
|
|
|
set -euo pipefail
|
|
[ -n "${DEBUG:-}" ] && set -x
|
|
srcdir="$(dirname "$0")"
|
|
|
|
cd "$srcdir"
|
|
|
|
if [ $# -eq 0 ];then
|
|
echo "usage: <file1> <file2> ..."
|
|
exit 1
|
|
fi
|
|
|
|
sync_file(){
|
|
local filename="$1"
|
|
local repo="$2"
|
|
local dir="${3:-}"
|
|
if [ -z "$dir" ]; then
|
|
dir="$repo"
|
|
fi
|
|
dir="$(tr '[:upper:]' '[:lower:]' <<< "$dir")"
|
|
if ! [ -d "../../$dir" ]; then
|
|
echo "WARNING: repo dir $dir not found, skipping..."
|
|
return 0
|
|
fi
|
|
target="../../$dir/.github/$filename"
|
|
targetdir="${target%/*}"
|
|
mkdir -p -v "$targetdir"
|
|
echo "syncing $filename -> $target"
|
|
perl -p -e "s/(DevOps-)?Bash-tools/$repo/i" "$filename" > "$target"
|
|
}
|
|
|
|
sed 's/#.*//; s/:/ /' ../setup/repos.txt |
|
|
grep -v -e bash-tools \
|
|
-e '^[[:space:]]*$' |
|
|
while read -r repo dir; do
|
|
for filename in "$@"; do
|
|
sync_file "$filename" "$repo" "$dir"
|
|
done
|
|
done
|