Skip to content

Commit e73f35e

Browse files
authored
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
1 parent eb53af4 commit e73f35e

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

misc/build.func

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,15 +2954,14 @@ fix_gpu_gids() {
29542954

29552955
# For privileged containers: also fix permissions inside container
29562956
if [[ "$CT_TYPE" == "0" ]]; then
2957-
pct exec "$CTID" -- bash -c "
2957+
pct exec "$CTID" -- sh -c "
29582958
if [ -d /dev/dri ]; then
29592959
for dev in /dev/dri/*; do
29602960
if [ -e \"\$dev\" ]; then
2961-
if [[ \"\$dev\" =~ renderD ]]; then
2962-
chgrp ${render_gid} \"\$dev\" 2>/dev/null || true
2963-
else
2964-
chgrp ${video_gid} \"\$dev\" 2>/dev/null || true
2965-
fi
2961+
case \"\$dev\" in
2962+
*renderD*) chgrp ${render_gid} \"\$dev\" 2>/dev/null || true ;;
2963+
*) chgrp ${video_gid} \"\$dev\" 2>/dev/null || true ;;
2964+
esac
29662965
chmod 660 \"\$dev\" 2>/dev/null || true
29672966
fi
29682967
done

misc/tools.func

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ install_packages_with_retry() {
192192
if [[ $retry -le $max_retries ]]; then
193193
msg_warn "Package installation failed, retrying ($retry/$max_retries)..."
194194
sleep 2
195+
# Fix any interrupted dpkg operations before retry
196+
$STD dpkg --configure -a 2>/dev/null || true
195197
$STD apt update 2>/dev/null || true
196198
fi
197199
done
@@ -217,6 +219,8 @@ upgrade_packages_with_retry() {
217219
if [[ $retry -le $max_retries ]]; then
218220
msg_warn "Package upgrade failed, retrying ($retry/$max_retries)..."
219221
sleep 2
222+
# Fix any interrupted dpkg operations before retry
223+
$STD dpkg --configure -a 2>/dev/null || true
220224
$STD apt update 2>/dev/null || true
221225
fi
222226
done
@@ -1182,6 +1186,12 @@ cleanup_orphaned_sources() {
11821186
# This should be called at the start of any setup function
11831187
# ------------------------------------------------------------------------------
11841188
ensure_apt_working() {
1189+
# Fix interrupted dpkg operations first
1190+
# This can happen if a previous installation was interrupted (e.g., by script error)
1191+
if [[ -f /var/lib/dpkg/lock-frontend ]] || dpkg --audit 2>&1 | grep -q "interrupted"; then
1192+
$STD dpkg --configure -a 2>/dev/null || true
1193+
fi
1194+
11851195
# Clean up orphaned sources first
11861196
cleanup_orphaned_sources
11871197

0 commit comments

Comments
 (0)