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,712
  • 7
  • 39
  • 47
  • Hey (Valorin..if that is your real name..heh,heh,heh) A preseed script is an auto-answer script, and yours is failing. Wish I had better news.. perhaps more info will get added?!? – Scott Goodgame Apr 12 '13 at 01:38
  • @ScottGoodgame I need it to fail gracefully and **prevent** the installer from continuing. At the moment it fails with a useless error and lets the user continue as if nothing happened. I am happy to use direct `d-i` commands if it will help, I just used the script because it was already there... – Stephen RC Apr 12 '13 at 01:43
  • Also @ScottGoodgame, nice last name :P If you want my real name click on *Valorin*, it's listed on my profile under `real name`... :) – Stephen RC Apr 12 '13 at 01:44
  • 1
    Instead of throwing an error, you could launch an additional script or blob that presents an "Installation cannot complete, select OK to exit" with only one menu option. That menu option runs init 6. This post should get you over the hump. http://stackoverflow.com/questions/11718329/bash-scripting-on-debian-installer-not-accepting-user-input-on-preseeding – RobotHumans Apr 15 '13 at 14:31
  • 1
    Thanks, @CallmeV, that was really helpful and I now have a working solution :) – Stephen RC Apr 16 '13 at 03:24

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,712
  • 7
  • 39
  • 47