Adding live-system script from live-tools.
[live-boot-grml.git] / bin / live-system
1 #!/bin/sh
2
3 # Redirect stdout to stderr
4 exec 1>&2
5
6 case "${1}" in
7         -h|--help|-u|--usage)
8                 echo "live-system - determine if running system is a live system"
9                 echo
10                 echo "Usage: ${0} [-v|--verbose]"
11
12                 exit 2
13                 ;;
14
15         -v|--verbose)
16                 _VERBOSE="true"
17                 ;;
18 esac
19
20 [ "${_VERBOSE}" ] && echo -n "Checking for live-system... "
21
22 if [ ! -e /proc/cmdline ]
23 then
24         echo "E: /proc/cmdline - No such file."
25         exit 2
26 fi
27
28 if grep -qs boot=live /proc/cmdline
29 then
30         [ "${_VERBOSE}" ] && echo -n " yes, this is a live system"
31
32         if [ -d /live/image/install ]
33         then
34                 if ls /live/image/install/pool/main/l/live-installer/live-installer_*.udeb > /dev/null 2>&1
35                 then
36                         [ "${_VERBOSE}" ] && echo " with live-installer support."
37                 else
38                         [ "${_VERBOSE}" ] && echo " without live-installer support."
39                 fi
40         else
41                 [ "${_VERBOSE}" ] && echo "without installer support."
42         fi
43
44         exit 0
45 else
46         [ "${_VERBOSE}" ] && echo " no, this is not a live system."
47
48         exit 1
49 fi