var. core fixes (bash to sh in fix_gpu_gids ...) (#9666)
* Switch container exec from bash to sh in fix_gpu_gids Replaces bash with sh for container execution in fix_gpu_gids and updates device matching logic to use a POSIX-compliant case statement. This improves compatibility with containers that may not have bash installed. * fix(apt): auto-recover from interrupted dpkg operations When a previous installation is interrupted (e.g., by script error or user cancellation), dpkg can be left in an inconsistent state requiring 'dpkg --configure -a' to fix. This change: - Adds dpkg --configure -a check to ensure_apt_working() - Adds dpkg --configure -a to retry logic in install_packages_with_retry() - Adds dpkg --configure -a to retry logic in upgrade_packages_with_retry() Fixes: Omada Controller update failing after interrupted installation Reported-in: #9663
This commit is contained in:
parent
eb53af44c9
commit
e73f35e2c8
@ -2954,15 +2954,14 @@ fix_gpu_gids() {
|
||||
|
||||
# For privileged containers: also fix permissions inside container
|
||||
if [[ "$CT_TYPE" == "0" ]]; then
|
||||
pct exec "$CTID" -- bash -c "
|
||||
pct exec "$CTID" -- sh -c "
|
||||
if [ -d /dev/dri ]; then
|
||||
for dev in /dev/dri/*; do
|
||||
if [ -e \"\$dev\" ]; then
|
||||
if [[ \"\$dev\" =~ renderD ]]; then
|
||||
chgrp ${render_gid} \"\$dev\" 2>/dev/null || true
|
||||
else
|
||||
chgrp ${video_gid} \"\$dev\" 2>/dev/null || true
|
||||
fi
|
||||
case \"\$dev\" in
|
||||
*renderD*) chgrp ${render_gid} \"\$dev\" 2>/dev/null || true ;;
|
||||
*) chgrp ${video_gid} \"\$dev\" 2>/dev/null || true ;;
|
||||
esac
|
||||
chmod 660 \"\$dev\" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
|
||||
@ -192,6 +192,8 @@ install_packages_with_retry() {
|
||||
if [[ $retry -le $max_retries ]]; then
|
||||
msg_warn "Package installation failed, retrying ($retry/$max_retries)..."
|
||||
sleep 2
|
||||
# Fix any interrupted dpkg operations before retry
|
||||
$STD dpkg --configure -a 2>/dev/null || true
|
||||
$STD apt update 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
@ -217,6 +219,8 @@ upgrade_packages_with_retry() {
|
||||
if [[ $retry -le $max_retries ]]; then
|
||||
msg_warn "Package upgrade failed, retrying ($retry/$max_retries)..."
|
||||
sleep 2
|
||||
# Fix any interrupted dpkg operations before retry
|
||||
$STD dpkg --configure -a 2>/dev/null || true
|
||||
$STD apt update 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
@ -1182,6 +1186,12 @@ cleanup_orphaned_sources() {
|
||||
# This should be called at the start of any setup function
|
||||
# ------------------------------------------------------------------------------
|
||||
ensure_apt_working() {
|
||||
# Fix interrupted dpkg operations first
|
||||
# This can happen if a previous installation was interrupted (e.g., by script error)
|
||||
if [[ -f /var/lib/dpkg/lock-frontend ]] || dpkg --audit 2>&1 | grep -q "interrupted"; then
|
||||
$STD dpkg --configure -a 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Clean up orphaned sources first
|
||||
cleanup_orphaned_sources
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user