pre-start script # Check time stamps of custom and rootfs parts of the system # and adjust system clock if it is behind, to ensure apparmor cache # validation logic can validate precompiled profiles TIME_CUSTOM=$(cat /custom/build_id) TIME_ROOTFS=$(cat /etc/media-info | awk '{print $8}' | sed 's/\(-..\)\(..\)/\1:\2:/g;s/:$//;s/-/ /g;s/[)(]//g') TIME_ROOTFS=$(date --date="$TIME_ROOTFS" +%s) if [ $TIME_CUSTOM -ge $TIME_ROOTFS ]; then TIME_ROM=$TIME_CUSTOM else TIME_ROM=$TIME_ROOTFS fi TIME_NOW=$(date -d now +%s) if [ $TIME_ROM -ge $TIME_NOW ]; then echo "Current time is behind build stamp of customisation -> booting first time after factory, adjust time" date +%s -s @$TIME_ROM hwclock --set --date @$TIME_ROM fi end script