#!/bin/sh -eu # Known good post-debootstrap values passwd_bootstrap="9ebb1c3da5b0ad8f1d366528b32c97cb" shadow_bootstrap="1c562aa2ed2f443b9151953e800eca16" group_bootstrap="60cd81599d39db5d624e63c8c18d4a5e" gshadow_bootstrap="3819432fb99fe6b8f38410c58d503de1" # Current post-debootstrap values passwd_hash=$(set -- $(md5sum /etc/passwd) && echo $1) shadow_hash=$(set -- $(cat /etc/shadow | sed "s/:.*:0:99999:/:0:99999:/g" | md5sum) && echo $1) group_hash=$(set -- $(md5sum /etc/group) && echo $1) gshadow_hash=$(set -- $(md5sum /etc/gshadow) && echo $1) # /etc/passwd if [ "$passwd_bootstrap" = "$passwd_hash" ]; then cat > /etc/passwd <&2 echo "The output below might help to resolve the issue" >&2 cat /etc/passwd exit 1 fi # /etc/shadow if [ "$shadow_bootstrap" = "$shadow_hash" ]; then cat > /etc/shadow <&2 echo "The output below might help to resolve the issue" >&2 cat /etc/shadow exit 1 fi # /etc/group if [ "$group_bootstrap" = "$group_hash" ]; then cat > /etc/group <&2 echo "The output below might help to resolve the issue" >&2 cat /etc/group exit 1 fi # /etc/gshadow if [ "$gshadow_bootstrap" = "$gshadow_hash" ]; then cat > /etc/gshadow <&2 echo "The output below might help to resolve the issue" >&2 cat /etc/gshadow exit 1 fi # Create some missing directories mkdir -p /var/lib/lightdm chown lightdm:lightdm /var/lib/lightdm chmod 750 /var/lib/lightdm mkdir -p /var/lib/usermetrics chown usermetrics:usermetrics /var/lib/usermetrics chmod 750 /var/lib/usermetrics # Record the current state for later comparison for file in /etc/passwd /etc/shadow /etc/group /etc/gshadow; do rm -f ${file}- cp ${file} ${file}.orig done