Skip to content

Commit 427aad2

Browse files
committed
Improvements and linting
1 parent 96ccea3 commit 427aad2

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

bt-iso

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash -e
2-
# Copyright (c) 2011-2021 TurnKey GNU/Linux - http://www.turnkeylinux.org
2+
# Copyright (c) 2011-2025 TurnKey GNU/Linux - https://www.turnkeylinux.org
33
#
44
# This file is part of buildtasks.
55
#
@@ -55,26 +55,31 @@ EOF
5555

5656
clone_or_pull() {
5757
# If $dir doesn't exist, clone $repo. If it does, update from origin master
58-
dir=$1
59-
repo=$2
58+
local dir=$1
59+
local repo=$2
6060
if [[ -z "$dir" ]] || [[ -z "$repo" ]]; then
6161
fatal "One or more empty values passed to function: ${FUNCNAME[*]}."
6262
fi
6363
if [ ! -e "$dir" ]; then
64+
mkdir -p "$(dirname "$dir")"
6465
info "Attempting to clone repo $repo to $dir."
6566
cd "$(dirname "$dir")"
6667
git clone "https://github.com/$repo" "$dir"
6768
cd "$dir"
6869
else
69-
info "Repo $repo found, attempting to update"
70+
info "Directory $repo found, attempting to update"
71+
if [[ ! -d "$dir/.git" ]]; then
72+
check_debug "Does not appear to be a git repo (no .git)"
73+
fi
7074
cd "$dir"
7175
git pull origin master
7276
fi
7377
}
7478

7579
get_version() {
76-
pkg=$1
77-
sp="[[:space:]]"
80+
local pkg=$1
81+
local sp="[[:space:]]"
82+
local pkg_info
7883
pkg_info=$(dpkg -l \
7984
| sed -En "s|^ii.*($pkg)$sp*([0-9a-z\.-:]*)$sp*amd64$sp*.*|\1 \2|p")
8085
echo "$pkg_info" | cut -d' ' -f2
@@ -172,11 +177,11 @@ source "$BT_CONFIG/common.cfg"
172177
TKLDEV_DOCKER=${TKLDEV_DOCKER:-/turnkey/public/tkldev-docker}
173178
INIT_CONF="$TKLDEV_DOCKER/inithooks.conf"
174179

175-
if [[ ! -d "$TKLDEV_DOCKER" ]] && [[ "skip_setup" != "true" ]]; then
176-
warning "TKLDev-Docker repo not found ($TKLDEV_DOCKER); cloning"
177-
mkdir -p $(dirname "$TKLDEV_DOCKER")
178-
git clone https://github.com/turnkeylinux/tkldev-docker.git \
180+
if [[ "$skip_setup" != "true" ]]; then
181+
clone_or_pull https://github.com/turnkeylinux/tkldev-docker.git \
179182
"$TKLDEV_DOCKER"
183+
elif [[ ! -d "$TKLDEV_DOCKER" ]]; then
184+
check_debug "tkldev-docker repo not found: $TKLDEV_DOCKER"
180185
elif [[ ! -f "$INIT_CONF" ]]; then
181186
check_debug "Inithooks preseed file ($INIT_CONF) not found"
182187
else
@@ -227,7 +232,7 @@ if [[ -z "$skip_setup" ]]; then
227232
touch /root/clicksnap-setup.done
228233
fi
229234
fi
230-
if ! grep -q $appname <<<$(clicksnap list); then
235+
if ! grep -q "$appname" <<<"$(clicksnap list)"; then
231236
fatal "Clicksnap code for $appname not found"
232237
fi
233238
fi
@@ -378,7 +383,7 @@ if [[ -z "$no_screens" ]]; then
378383
sleep 1
379384
done
380385
info "container running - waiting for connection"
381-
for ping in {1..20}; do
386+
for _ in {1..20}; do # ping container to ensure it's available
382387
if ! curl localhost:7900 >/dev/null 2>&1; then
383388
sleep 1
384389
fi

0 commit comments

Comments
 (0)