From 0cef7485299fc61aea928eeb669fcfb7cbaa55fb Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Wed, 4 Jul 2018 16:49:47 -0700 Subject: gkeys-ldap updateseeds.sh: Shellcheck cleanup Signed-off-by: Brian Dolbec --- gkeys-ldap/bin/update-seeds.sh | 52 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/gkeys-ldap/bin/update-seeds.sh b/gkeys-ldap/bin/update-seeds.sh index a2e0f87..a29de66 100755 --- a/gkeys-ldap/bin/update-seeds.sh +++ b/gkeys-ldap/bin/update-seeds.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # $Id: update-seeds.sh,v 0.2.1 2014/10/12 dolsen Exp $ FORCE=${1} @@ -6,22 +6,22 @@ HAS_UPDATES=false # configuration to run from a checkout with a custom config cwd=$(pwd) -source ${cwd}/update-seeds.conf -source ${cwd}/testpath +source "${cwd}/update-seeds.conf" +source "${cwd}/testpath" die(){ echo "$@" 1>&2; exit 1; } success(){ echo "$@"; exit 0; } clone_api(){ - local target=dirname ${API_DIR} - cd target - git clone ${API_URL} + local target=dirname "${API_DIR}" + cd target || die " *** Failed to change directory... exiting" + git clone "${API_URL}" } clone_gkey_seeds(){ - local target=dirname ${GKEY_SEEDS_DIR} - cd target - git clone ${GKEY_SEEDS_URL} + local target=dirname "${GKEY_SEEDS_DIR}" + cd target || die " *** Failed to change directory... exiting" + git clone "${GKEY_SEEDS_URL}" } # start update process @@ -29,56 +29,56 @@ echo "Beginning seed file update" echo " *** updating gkey-seeds repo" # update api checkout -if [[ ! -d ${GKEY_SEEDS_DIR} ]]; then +if [[ ! -d "${GKEY_SEEDS_DIR}" ]]; then clone_gkey_seeds else - cd ${GKEY_SEEDS_DIR} && git pull + cd "${GKEY_SEEDS_DIR}" && git pull fi echo " *** updating api.gentoo.org repo" # update api checkout -if [[ ! -d ${API_DIR} ]]; then +if [[ ! -d "${API_DIR}" ]]; then clone_api else - cd ${API_DIR} && git pull + cd "${API_DIR}" && git pull fi echo " *** Fetching new seeds from LDAP" -cd ${GKEYS_DIR} +cd "${GKEYS_DIR}" || die " *** Failed to change directory... exiting" gkeys-ldap update-seeds -C gentoo-devs || die "Seed file generation failed... aborting" echo " *** Checking if seed files are up-to-date" -if ! diff -q ${GKEYS_DIR}/${GKEYS_SEEDS} ${GKEY_SEEDS_DIR}/${GKEY_SEEDS} > /dev/null ;then +if ! diff -q "${GKEYS_DIR}/${GKEYS_SEEDS}" "${GKEY_SEEDS_DIR}/${GKEY_SEEDS}" > /dev/null ;then HAS_UPDATES=true fi -if [[ "${FORCE}" == "force" || ${HAS_UPDATES} ]] ; then +if [[ "${FORCE}" == "force" || "${HAS_UPDATES}" ]] ; then echo " *** Spotted differences" echo " *** Updating old seeds with a new one" # copy seeds to gkey-seeds echo " ... cp ${GKEYS_SEEDS} ${API_DIR}/${API_SEEDS}" - cp ${GKEYS_SEEDS} ${GKEY_SEEDS_DIR}/${GKEY_SEEDS} + cp "${GKEYS_SEEDS}" "${GKEY_SEEDS_DIR}/${GKEY_SEEDS}" else success " *** No changes detected" exit 0 fi echo "Signing new developers.seeds file" -gkeys sign -n ${GKEYS_SIGN} -F ${GKEY_SEEDS_DIR}/${GKEY_SEEDS} || die " *** Signing failed... exiting" +gkeys sign -n "${GKEYS_SIGN}" -F "${GKEY_SEEDS_DIR}/${GKEY_SEEDS}" || die " *** Signing failed... exiting" echo "Committing changes to gkey-seeds repo..." -cd ${GKEY_SEEDS_DIR} -git add ${GKEY_SEEDS} || die " *** Failed to add modified ${GKEYS_SEEDS} file" -git add ${GKEY_SEEDS}.${GKEYS_SIG} || die " *** Failed to add ${GKEYS_SEEDS}.sig file" +cd "${GKEY_SEEDS_DIR}" || die " *** Failed to change directory... exiting" +git add "${GKEY_SEEDS}" || die " *** Failed to add modified ${GKEYS_SEEDS} file" +git add "${GKEY_SEEDS}.${GKEYS_SIG}" || die " *** Failed to add ${GKEYS_SEEDS}.sig file" git commit -S -m"${GKEYS_COMMIT_MSG}" || die " *** Failed to commit updates" git push --signed origin master || die " *** git push failed" cd .. echo "Committing changes to api repo..." -cp ${GKEY_SEEDS_DIR}/${GKEY_SEEDS} ${API_DIR}/${API_SEEDS} || die " *** Failed to copy modified ${GKEYS_SEEDS} file" -cp ${GKEY_SEEDS_DIR}/${GKEY_SEEDS}.${GKEYS_SIG} ${API_DIR}/${API_SEEDS}.${GKEYS_SIG} || die " *** Failed to copy modified ${GKEYS_SEEDS}.${GKEYS_SIG} file" -cd ${API_DIR} -git add ${API_SEEDS} || die " *** Failed to add modified ${GKEYS_SEEDS} file" -git add ${API_SEEDS}.${GKEYS_SIG} || die " *** Failed to add ${GKEYS_SEEDS}.sig file" +cp "${GKEY_SEEDS_DIR}/${GKEY_SEEDS}" "${API_DIR}/${API_SEEDS}" || die " *** Failed to copy modified ${GKEYS_SEEDS} file" +cp "${GKEY_SEEDS_DIR}/${GKEY_SEEDS}.${GKEYS_SIG}" "${API_DIR}/${API_SEEDS}.${GKEYS_SIG}" || die " *** Failed to copy modified ${GKEYS_SEEDS}.${GKEYS_SIG} file" +cd "${API_DIR}" || die " *** Failed to change directory... exiting" +git add "${API_SEEDS}" || die " *** Failed to add modified ${GKEYS_SEEDS} file" +git add "${API_SEEDS}.${GKEYS_SIG}" || die " *** Failed to add ${GKEYS_SEEDS}.sig file" git commit -S -m "${GKEYS_COMMIT_MSG}" || die " *** Failed to commit updates" git push --signed origin master || die " *** git push failed" -- cgit v1.2.3-65-gdbad