0

How can I determine within a shell script if the script is running:

  • On a Ubuntu LiveOS (not necessarily version dependant) -- (already answered here)
  • Within a chroot on an Ubuntu LiveOS (already addressed here)
  • On a locally installed system (no LiveOS) -- (already answered here)

As all three points seem to be addressed elsewhere, I'm going to vote to close this question. Pointed out in the only answer here, a combination of tests can be used to determine chroot on LiveOS.

b_laoshi
  • 4,660
  • 4
  • 25
  • 46

1 Answers1

2

Consider combining these checks to determine a live sessions:

Look for live file system being mounted somewhere:

losetup -l | grep /cdrom/casper/filesystem.squashfs

If you find something there is a high chance that it's a live session.

Check root file system:

df /

Or look for existence of special files (ex: ubiquity: Ubuntu installer)

which ubiquity

also check it's shortcut at ~/Desktop

Check currently logged in users: users you should get: ubuntu.

And they can all be set up to look like a live session to trick you ...

For chroot, I'm not sure how it's possible... I'll check it out.

Ravexina
  • 55,668
  • 25
  • 164
  • 183