|
1 | 1 | #!/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 |
3 | 3 | # |
4 | 4 | # This file is part of buildtasks. |
5 | 5 | # |
|
55 | 55 |
|
56 | 56 | clone_or_pull() { |
57 | 57 | # 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 |
60 | 60 | if [[ -z "$dir" ]] || [[ -z "$repo" ]]; then |
61 | 61 | fatal "One or more empty values passed to function: ${FUNCNAME[*]}." |
62 | 62 | fi |
63 | 63 | if [ ! -e "$dir" ]; then |
| 64 | + mkdir -p "$(dirname "$dir")" |
64 | 65 | info "Attempting to clone repo $repo to $dir." |
65 | 66 | cd "$(dirname "$dir")" |
66 | 67 | git clone "https://github.com/$repo" "$dir" |
67 | 68 | cd "$dir" |
68 | 69 | 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 |
70 | 74 | cd "$dir" |
71 | 75 | git pull origin master |
72 | 76 | fi |
73 | 77 | } |
74 | 78 |
|
75 | 79 | get_version() { |
76 | | - pkg=$1 |
77 | | - sp="[[:space:]]" |
| 80 | + local pkg=$1 |
| 81 | + local sp="[[:space:]]" |
| 82 | + local pkg_info |
78 | 83 | pkg_info=$(dpkg -l \ |
79 | 84 | | sed -En "s|^ii.*($pkg)$sp*([0-9a-z\.-:]*)$sp*amd64$sp*.*|\1 \2|p") |
80 | 85 | echo "$pkg_info" | cut -d' ' -f2 |
@@ -172,11 +177,11 @@ source "$BT_CONFIG/common.cfg" |
172 | 177 | TKLDEV_DOCKER=${TKLDEV_DOCKER:-/turnkey/public/tkldev-docker} |
173 | 178 | INIT_CONF="$TKLDEV_DOCKER/inithooks.conf" |
174 | 179 |
|
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 \ |
179 | 182 | "$TKLDEV_DOCKER" |
| 183 | +elif [[ ! -d "$TKLDEV_DOCKER" ]]; then |
| 184 | + check_debug "tkldev-docker repo not found: $TKLDEV_DOCKER" |
180 | 185 | elif [[ ! -f "$INIT_CONF" ]]; then |
181 | 186 | check_debug "Inithooks preseed file ($INIT_CONF) not found" |
182 | 187 | else |
@@ -227,7 +232,7 @@ if [[ -z "$skip_setup" ]]; then |
227 | 232 | touch /root/clicksnap-setup.done |
228 | 233 | fi |
229 | 234 | fi |
230 | | - if ! grep -q $appname <<<$(clicksnap list); then |
| 235 | + if ! grep -q "$appname" <<<"$(clicksnap list)"; then |
231 | 236 | fatal "Clicksnap code for $appname not found" |
232 | 237 | fi |
233 | 238 | fi |
@@ -378,7 +383,7 @@ if [[ -z "$no_screens" ]]; then |
378 | 383 | sleep 1 |
379 | 384 | done |
380 | 385 | 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 |
382 | 387 | if ! curl localhost:7900 >/dev/null 2>&1; then |
383 | 388 | sleep 1 |
384 | 389 | fi |
|
0 commit comments