ソースを参照

feat(script): Add color to scripts

Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
Jeremy MAURO 2 年 前
コミット
75abdea86a
4 ファイル変更14 行追加2 行削除
  1. 2 0
      scripts/end_run.sh
  2. 5 2
      scripts/export_policy.sh
  3. 5 0
      scripts/run_policy.sh
  4. 2 0
      scripts/run_policy.sh.template

+ 2 - 0
scripts/end_run.sh

@@ -1,4 +1,6 @@
 #!/usr/bin/env bash
+
+echo -e "\n\e[33mSetting the right ownership to:\e[1mjeremy\e[39m"
 if [ $(id -g) -eq 0 ]; then
 	chown -Rh jeremy: policy-export nodes
 fi

+ 5 - 2
scripts/export_policy.sh

@@ -1,14 +1,17 @@
 #!/usr/bin/env bash
 
 set -e
+POLICY=${1:-"base"}
+echo -e "\n\e[4m\e[33mExporting policy:\e[0m \e[33m\e[1m${POLICY}\e[39m"
 ssh-ident -V
 # Ref:
 # 	https://medium.com/@emachnic/using-policyfiles-with-chef-client-local-mode-4f47477b24db
-POLICY=${1:-"base"}
 rm -rf policy-export/*
+echo -e "\e[32m"
+ln -svf "${POLICY}.rb" Policyfile.rb
+echo -en "\e[39m"
 bundle exec chef-cli update "${POLICY}.rb"
 bundle exec chef-cli export "${POLICY}.rb" -a policy-export
-ln -svf "${POLICY}.rb" Policyfile.rb
 pushd policy-export > /dev/null
 tar xfz *.tgz && rm -rf *.tgz
 popd > /dev/null

+ 5 - 0
scripts/run_policy.sh

@@ -1,5 +1,8 @@
 #!/usr/bin/env bash
 
+# To generate script:
+#	~/.local/bin/gengetoptions embed run_policy.sh.template > run_policy.sh
+
 # @getoptions
 parser_definition() {
 	setup	REST	help:usage	--			"Usage: run_policy [options]... [arguments]"	''
@@ -94,9 +97,11 @@ parse "$@"
 
 eval "set -- ${REST}"
 
+set -e
 # Ref:
 # 	https://medium.com/@emachnic/using-policyfiles-with-chef-client-local-mode-4f47477b24db
 ./scripts/export_policy.sh ${POLICY}
+echo -e "\n\e[4m\e[33mRunning:\e[0m \e[33m\e[1mchef-client -z\e[39m"
 pushd policy-export > /dev/null
 if [ ${DRY_RUN} -eq 1 ]; then
 	OPT="--why-run"

+ 2 - 0
scripts/run_policy.sh.template

@@ -23,9 +23,11 @@ parse "$@"
 
 eval "set -- ${REST}"
 
+set -e
 # Ref:
 # 	https://medium.com/@emachnic/using-policyfiles-with-chef-client-local-mode-4f47477b24db
 ./scripts/export_policy.sh ${POLICY}
+echo -e "\n\e[4m\e[33mRunning:\e[0m \e[33m\e[1mchef-client -z\e[39m"
 pushd policy-export > /dev/null
 if [ ${DRY_RUN} -eq 1 ]; then
 	OPT="--why-run"