aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2023-03-06 11:04:33 +0100
committerPatrick Spek <p.spek@tyil.nl>2023-03-06 11:04:33 +0100
commite263f8606a9cbbe68595db68b4a56e34866a8d1d (patch)
tree1517a5a249d3a07881fea438f0c598ddb952d07d
parentf4ece68ecf8cfc855e54f2d5935ed2a2b8b0c4af (diff)
Various fixes to make the latest shellcheck pass
-rw-r--r--lib/main.bash1
-rw-r--r--lib/subcommands/add.bash2
-rw-r--r--lib/subcommands/backup.bash7
-rw-r--r--lib/subcommands/del.bash2
-rw-r--r--lib/subcommands/ssh.bash1
-rw-r--r--lib/subcommands/sync.bash8
-rw-r--r--lib/util/config.bash5
7 files changed, 17 insertions, 9 deletions
diff --git a/lib/main.bash b/lib/main.bash
index bbfd602..6a8d7e8 100644
--- a/lib/main.bash
+++ b/lib/main.bash
@@ -210,6 +210,7 @@ discover_system_init() {
discover_system_key() {
local key
+ # shellcheck disable=SC2031
key+="${BASHTARD_PLATFORM[os]}"
if [[ ${BASHTARD_PLATFORM[distro]} ]]
diff --git a/lib/subcommands/add.bash b/lib/subcommands/add.bash
index c72582b..2ae6a43 100644
--- a/lib/subcommands/add.bash
+++ b/lib/subcommands/add.bash
@@ -40,7 +40,7 @@ subcommand()
return 1
fi
- # shellcheck disable=SC1090
+ # shellcheck disable=SC1090,SC1091
. "$playbook_base/playbook.bash"
if ! playbook_add
diff --git a/lib/subcommands/backup.bash b/lib/subcommands/backup.bash
index 0d3f22d..8048053 100644
--- a/lib/subcommands/backup.bash
+++ b/lib/subcommands/backup.bash
@@ -53,7 +53,6 @@ backup_filesystem() {
local borg
local cmd_create
local cmd_prune
- local indexes
borg="$(config "bashtard.backup.borg.command" "borg")"
remote="$(config "bashtard.backup.borg.remote_paths.$index" "borg")"
@@ -79,6 +78,7 @@ backup_filesystem() {
)
notice "$BASHTARD_NAME/backup/$index" "> ${cmd_prune[*]}"
+ # shellcheck disable=SC2068
${cmd_prune[@]}
# Create new backups
@@ -97,6 +97,7 @@ backup_filesystem() {
done < <(config_subkeys "bashtard.backup.fs.paths")
notice "$BASHTARD_NAME/backup/$index" "> ${cmd_create[*]}"
+ # shellcheck disable=SC2068
${cmd_create[@]}
}
@@ -149,6 +150,7 @@ backup_database_postgresql() {
)
notice "$BASHTARD_NAME/backup/$index" "> ${cmd_prune[*]}"
+ # shellcheck disable=SC2068
${cmd_prune[@]}
# Create new backups
@@ -160,7 +162,8 @@ backup_database_postgresql() {
"-"
)
- notice "$BASHTARD_NAME/backup/$index" "> pg_dump "$database" | ${cmd_create[*]}"
+ notice "$BASHTARD_NAME/backup/$index" "> pg_dump $database | ${cmd_create[*]}"
+ # shellcheck disable=SC2068
pg_dump "$database" | ${cmd_create[@]}
done < <(psql -AXt -d template1 -c "SELECT datname FROM pg_database")
}
diff --git a/lib/subcommands/del.bash b/lib/subcommands/del.bash
index f5204d8..c09c501 100644
--- a/lib/subcommands/del.bash
+++ b/lib/subcommands/del.bash
@@ -40,7 +40,7 @@ subcommand()
return 1
fi
- # shellcheck disable=SC1090
+ # shellcheck disable=SC1090,SC1091
. "$playbook_base/playbook.bash"
if ! playbook_del
diff --git a/lib/subcommands/ssh.bash b/lib/subcommands/ssh.bash
index 563aa73..6c9a6be 100644
--- a/lib/subcommands/ssh.bash
+++ b/lib/subcommands/ssh.bash
@@ -30,6 +30,7 @@ subcommand()
notice "$BASHTARD_NAME/ssh" "$user@$node ($host) > $*"
+ # shellcheck disable=SC2029
ssh "$user@$host" "$@"
unset user
diff --git a/lib/subcommands/sync.bash b/lib/subcommands/sync.bash
index 9537922..e2eac77 100644
--- a/lib/subcommands/sync.bash
+++ b/lib/subcommands/sync.bash
@@ -16,9 +16,9 @@ subcommand()
fi
notice "bashtard/sync" "Syncing $BASHTARD_ETCDIR"
- pushd -- "$BASHTARD_ETCDIR" > /dev/null
+ pushd -- "$BASHTARD_ETCDIR" > /dev/null || return 4
git pull origin master || return 4
- popd > /dev/null
+ popd > /dev/null || return 4
# Otherwise, do a full sync
notice "bashtard/sync" "Syncing remote playbooks"
@@ -29,7 +29,7 @@ subcommand()
pushd -- "$BASHTARD_ETCDIR/playbooks.d/$playbook" > /dev/null \
|| return 2
git pull origin "$branch"
- popd > /dev/null
+ popd > /dev/null || return 2
done < "$BASHTARD_ETCDIR/playbooks.d/remotes"
# Run a sync for each registered playbook for this host
@@ -58,7 +58,7 @@ sync_playbook()
return 1
fi
- # shellcheck disable=SC1090
+ # shellcheck disable=SC1090,SC1091
. "$playbook_base/playbook.bash"
playbook_sync
diff --git a/lib/util/config.bash b/lib/util/config.bash
index 78841e1..ff8b66a 100644
--- a/lib/util/config.bash
+++ b/lib/util/config.bash
@@ -111,7 +111,10 @@ config_subkeys_for() {
while read -r result
do
- local subkey="$(awk -F. '{ print $1 }' <<< "${result#"$key."}")"
+ local subkey
+
+ subkey="$(awk -F. '{ print $1 }' <<< "${result#"$key."}")"
+
debug "bashtard/config_subkeys" "Found '$subkey' as subkey of '$key' through '$result'"
results+=("$subkey")
done < <(grep "^$key\." "$file" | awk -F= '{ print $1 }')