From 7bb8ee6fefb794c68cf9f6b2f5561c8f8a56c57e Mon Sep 17 00:00:00 2001 From: Rick Elrod Date: Sun, 14 Jun 2020 01:44:35 -0500 Subject: [PATCH] Fix bugs due to no variable-quoting in meetbot scripts, and fix shellcheck warnings on them Signed-off-by: Rick Elrod --- roles/supybot/files/archive.sh | 8 ++++---- roles/supybot/files/meetings_by_team.sh | 12 +++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/roles/supybot/files/archive.sh b/roles/supybot/files/archive.sh index 9d22aaab45..91dd12d926 100644 --- a/roles/supybot/files/archive.sh +++ b/roles/supybot/files/archive.sh @@ -1,8 +1,8 @@ #!/bin/bash -cd /srv/web/meetbot/teams +cd /srv/web/meetbot/teams || exit for team in *; do - pushd $team >/dev/null 2>&1 - tar -cphf /srv/web/meetbot/archives/$team.tgz *.log.txt - popd >/dev/null 2>&1 + pushd "$team" >/dev/null 2>&1 || { echo "Refusing to process non-directory: /srv/web/meetbot/teams/$team"; continue; } + tar -cphf "/srv/web/meetbot/archives/$team.tgz" ./*.log.txt + popd >/dev/null 2>&1 || { echo "Something really weird happened and popd failed. Aborting."; continue; } done diff --git a/roles/supybot/files/meetings_by_team.sh b/roles/supybot/files/meetings_by_team.sh index c746f6e4ed..1063de680d 100755 --- a/roles/supybot/files/meetings_by_team.sh +++ b/roles/supybot/files/meetings_by_team.sh @@ -1,13 +1,11 @@ #!/bin/bash BASELOCATION=/srv/web/meetbot/teams -cd $BASELOCATION -cd .. +cd "$BASELOCATION/.." || exit -for f in `find -type f -mtime -30 | grep -v "fedora-meeting\."` +for f in $(find . -type f -mtime -30 | grep -v "fedora-meeting\.") do - teamname=$(basename $f | awk -F. '{ print $1 }' ) - mkdir -p $BASELOCATION/$teamname - ln -f -s $PWD/$f $BASELOCATION/$teamname/ + teamname="$(basename "$f" | awk -F. '{ print $1 }' )" + mkdir -p "$BASELOCATION/$teamname" + ln -f -s "$PWD/$f" "$BASELOCATION/$teamname/" done -