-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathinstall
executable file
·35 lines (26 loc) · 1.13 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
if ! type git >/dev/null 2>&1; then
printf "\nNot found git, run command\n\n"
printf " \033[36mbrew install git\033[0m\n"
exit 1
fi
set -eux
REPO_NAME=${1:-terraform-provider-name}
git clone --depth 1 https://github.com/tmknom/template-terraform-module.git "${REPO_NAME}"
cd "${REPO_NAME}"
rm -rf Makefile.terraform install .github/workflows/shellscript.yml .git
REGISTRY_PATH=$(echo "${REPO_NAME}" | awk -F- '{print substr($0, index($0, $3))"/"$2}')
sed -i "" -e "s#name/provider#${REGISTRY_PATH}#g" README.md
sed -i "" -e "s/template-terraform-module/${REPO_NAME}/g" README.md
sed -i "" -e "s/include Makefile.terraform/include .Makefile.terraform/g" Makefile
sed -i "" -e "s/$(cat VERSION)/0.0.1/g" VERSION
# File creation of a new line only
find . -type f -name '*.tf' -path "./*" -not -path "**/.terraform/*" -print0 | xargs -0 -I {} sh -c 'echo > {}'
git init
git add .
git commit -m "Initial commit" -m "Based on https://github.com/tmknom/template-terraform-module"
# Download .Makefile.terraform
make
set +x
printf "\nInstall success, run command\n\n"
printf " \033[36mcd %s && make install\033[0m\n" "${REPO_NAME}"