diff options
author | Brian Dolbec <dolsen@gentoo.org> | 2018-07-04 16:49:47 -0700 |
---|---|---|
committer | Brian Dolbec <dolsen@gentoo.org> | 2018-07-06 22:22:14 -0700 |
commit | 0cef7485299fc61aea928eeb669fcfb7cbaa55fb (patch) | |
tree | 11423a64f18981cfc11591e58f88631d0c3c3691 | |
parent | gkeys-ldap updateseeds.sh: Add a force override option (diff) | |
download | gentoo-keys-0cef7485299fc61aea928eeb669fcfb7cbaa55fb.tar.gz gentoo-keys-0cef7485299fc61aea928eeb669fcfb7cbaa55fb.tar.bz2 gentoo-keys-0cef7485299fc61aea928eeb669fcfb7cbaa55fb.zip |
gkeys-ldap updateseeds.sh: Shellcheck cleanup
Signed-off-by: Brian Dolbec <dolsen@gentoo.org>
-rwxr-xr-x | gkeys-ldap/bin/update-seeds.sh | 52 |
1 files 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" |