4

I am working on a custom Ubuntu Installer image, and I'm in a bit over my head.

We have a custom seed file which is running this command:

d-i preseed/early_command string /cdrom/Snare/update_v5.sh

Within that script file I have added a check that throws an error if it cannot find a file on the existing system:

if [ ! -f /target/path/to/file.gz ]; then
   logger custom-partition error "File not found, upgrade aborted!"
   logger custom-partition error "Please run the Upgrade Preparation script first."
   exit 1
fi

When the check fails it throws a mostly useless error message and provides the option to continue on with the installation process.

preseed-failure

How can I make it throw a useful error message and block further installation steps?

Stephen RC
  • 4,920

1 Answers1

4

With helpful pointers from @CallmeV, I have found a solution.

Within the preseed/early_command script, you can setup a debconf error template and force an unlimited loop to prevent any further progress through the installer.

if [ ! -f /target/path/to/file.gz ]; then

   . /usr/share/debconf/confmodule

   cat > /tmp/Notification.template <<'!EOF!'
Template: snare-upgrade/notification
Type: error
Description: ERROR - Unable to upgrade!
 Unable to upgrade your existing system... blah blah blah...
!EOF!

   debconf-loadtemplate snare-upgrade /tmp/Notification.template

   while [ 1 ]; do
      db_input critical snare-upgrade/notification || true
      db_go
      db_get snare-upgrade/notification
   done
fi

As I said, big thanks to CallmeV, and these pages:

Stephen RC
  • 4,920