Skip to content

Commit 0cc3fc7

Browse files
committed
core: 避免有时 modloop 下载不完整导致报错
fixes #308 #370 #376
1 parent 6a35bf6 commit 0cc3fc7

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

trans.sh

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -414,22 +414,30 @@ extract_env_from_cmdline() {
414414
}
415415

416416
ensure_service_started() {
417-
service=$1
418-
419-
if ! rc-service -q $service status; then
420-
if ! retry 5 rc-service -q $service start; then
421-
error_and_exit "Failed to start $service."
422-
fi
417+
local service=$1
418+
419+
if ! rc-service -q "$service" start; then
420+
for i in $(seq 10); do
421+
if [ "$service" = modloop ]; then
422+
# 避免有时 modloop 下载不完整导致报错
423+
# * Failed to verify signature of !
424+
# mount: mounting /dev/loop0 on /.modloop failed: Invalid argument
425+
rm -f /lib/modloop-lts /lib/modloop-virt
426+
fi
427+
if rc-service -q "$service" start; then
428+
return
429+
fi
430+
sleep 5
431+
done
432+
error_and_exit "Failed to start $service."
423433
fi
424434
}
425435

426436
ensure_service_stopped() {
427-
service=$1
437+
local service=$1
428438

429-
if rc-service -q $service status; then
430-
if ! retry 5 rc-service -q $service stop; then
431-
error_and_exit "Failed to stop $service."
432-
fi
439+
if ! retry 10 5 rc-service -q "$service" stop; then
440+
error_and_exit "Failed to stop $service."
433441
fi
434442
}
435443

0 commit comments

Comments
 (0)