1+ #! /bin/bash
12echo " ----------------------------------------------"
2- echo " Running Phala Cloud Pre-Launch Script v0.0.14 "
3+ echo " Running Phala Cloud Pre-Launch Script v0.0.15 "
34echo " ----------------------------------------------"
45set -e
56
@@ -158,16 +159,13 @@ if [[ "$DOCKER_REGISTRY_TARGET" == "ghcr.io" && -n "$DSTACK_DOCKER_USERNAME" &&
158159 repo=" ${img# ghcr.io/ } " ; repo=" ${repo%%:* } "
159160 tag=" ${img##*: } " ; [[ " $tag " == " $img " || " $tag " == " $repo " ]] && tag=" latest"
160161 echo " Verifying GHCR pull access: $img "
161- token=$( curl -sf -u " $DSTACK_DOCKER_USERNAME :$DSTACK_DOCKER_PASSWORD " \
162- " https://ghcr.io/token?service=ghcr.io&scope=repository:${repo} :pull" | jq -r ' .token // empty' || true)
162+ token=$( curl -sf -u " $DSTACK_DOCKER_USERNAME :$DSTACK_DOCKER_PASSWORD " " https://ghcr.io/token?service=ghcr.io&scope=repository:${repo} :pull" | jq -r ' .token // empty' || true)
163163 if [[ -z " $token " ]]; then
164164 echo " ERROR: GHCR token exchange failed for $img "
165165 notify_host_hoot_error " GHCR token exchange failed: $img "
166166 exit 1
167167 fi
168- http_code=$( curl -s -o /dev/null -w " %{http_code}" -H " Authorization: Bearer $token " \
169- -H " Accept: application/vnd.oci.image.index.v1+json,application/vnd.oci.image.manifest.v1+json,application/vnd.docker.distribution.manifest.list.v2+json,application/vnd.docker.distribution.manifest.v2+json" \
170- " https://ghcr.io/v2/${repo} /manifests/${tag} " )
168+ http_code=$( curl -s -o /dev/null -w " %{http_code}" -H " Authorization: Bearer $token " -H " Accept: application/vnd.oci.image.index.v1+json,application/vnd.oci.image.manifest.v1+json,application/vnd.docker.distribution.manifest.list.v2+json,application/vnd.docker.distribution.manifest.v2+json" " https://ghcr.io/v2/${repo} /manifests/${tag} " )
171169 if [[ " $http_code " != " 200" ]]; then
172170 echo " ERROR: GHCR pull access denied for $img (HTTP $http_code )"
173171 notify_host_hoot_error " GHCR pull access denied: $img (HTTP $http_code )"
@@ -177,6 +175,26 @@ if [[ "$DOCKER_REGISTRY_TARGET" == "ghcr.io" && -n "$DSTACK_DOCKER_USERNAME" &&
177175 done
178176fi
179177
178+ #
179+ # Pull latest images from docker-compose.yaml so existing CVMs pick up new tags.
180+ # Pull is fail-soft: short-lived tokens may expire between login and pull, but
181+ # falling back to already-cached images is preferable to blocking boot.
182+ #
183+ echo " Images before pull:"
184+ docker images --format ' {{.Repository}}:{{.Tag}} {{.ID}} ({{.CreatedSince}})'
185+
186+ echo " Pulling latest images from /dstack/docker-compose.yaml..."
187+ if docker compose -f /dstack/docker-compose.yaml pull; then
188+ echo " docker compose pull completed"
189+ notify_host_hoot_info " docker compose pull completed"
190+ else
191+ echo " WARNING: docker compose pull failed; continuing with existing images"
192+ notify_host_hoot_info " docker compose pull failed; using existing images"
193+ fi
194+
195+ echo " Images after pull:"
196+ docker images --format ' {{.Repository}}:{{.Tag}} {{.ID}} ({{.CreatedSince}})'
197+
180198#
181199# Set root password.
182200#
@@ -221,17 +239,19 @@ else
221239
222240 if [ -n " $DSTACK_ROOT_PASSWORD " ]; then
223241 echo " Setting root password from user.."
224- echo " $DSTACK_ROOT_PASSWORD " | passwd --stdin root 2> /dev/null \
225- || printf ' %s\n%s\n' " $DSTACK_ROOT_PASSWORD " " $DSTACK_ROOT_PASSWORD " | passwd root
242+ echo " $DSTACK_ROOT_PASSWORD " | passwd --stdin root 2> /dev/null || printf ' %s
243+ %s
244+ ' " $DSTACK_ROOT_PASSWORD " " $DSTACK_ROOT_PASSWORD " | passwd root
226245 unset DSTACK_ROOT_PASSWORD
227246 echo " Root password set/updated from DSTACK_ROOT_PASSWORD"
228247 elif [ -z " $( grep ' ^root:' /etc/shadow 2> /dev/null | cut -d: -f2) " ]; then
229248 echo " Setting random root password.."
230249 DSTACK_ROOT_PASSWORD=$(
231250 LC_ALL=C tr -dc ' A-Za-z0-9' < /dev/urandom | dd bs=1 count=32 2> /dev/null
232251 )
233- echo " $DSTACK_ROOT_PASSWORD " | passwd --stdin root 2> /dev/null \
234- || printf ' %s\n%s\n' " $DSTACK_ROOT_PASSWORD " " $DSTACK_ROOT_PASSWORD " | passwd root
252+ echo " $DSTACK_ROOT_PASSWORD " | passwd --stdin root 2> /dev/null || printf ' %s
253+ %s
254+ ' " $DSTACK_ROOT_PASSWORD " " $DSTACK_ROOT_PASSWORD " | passwd root
235255 unset DSTACK_ROOT_PASSWORD
236256 echo " Root password set (random auto-init)"
237257 else
0 commit comments