| 1 | #!/bin/sh |
| 2 | |
| 3 | # live-tools(7) - System Support Scripts |
| 4 | # Copyright (C) 2016-2020 The Debian Live team |
| 5 | # Copyright (C) 2006-2015 Daniel Baumann <[email protected]> |
| 6 | # |
| 7 | # This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING. |
| 8 | # This is free software, and you are welcome to redistribute it |
| 9 | # under certain conditions; see COPYING for details. |
| 10 | |
| 11 | # Redirect stdout to stderr |
| 12 | exec 1>&2 |
| 13 | |
| 14 | case "${1}" in |
| 15 | -h|--help|-u|--usage) |
| 16 | echo "live-system - determine if running system is a live system" |
| 17 | echo |
| 18 | echo "Usage: ${0} [-v|--verbose]" |
| 19 | |
| 20 | exit 2 |
| 21 | ;; |
| 22 | |
| 23 | -v|--verbose) |
| 24 | _VERBOSE="true" |
| 25 | ;; |
| 26 | esac |
| 27 | |
| 28 | [ "${_VERBOSE}" ] && echo -n "Checking for live system..." |
| 29 | |
| 30 | if [ ! -e /proc/cmdline ] |
| 31 | then |
| 32 | [ "${_VERBOSE}" ] && echo |
| 33 | echo "E: /proc/cmdline - No such file." |
| 34 | |
| 35 | exit 2 |
| 36 | fi |
| 37 | |
| 38 | if grep -qs "boot=live" /proc/cmdline |
| 39 | then |
| 40 | [ "${_VERBOSE}" ] && echo -n " yes, this is a live system" |
| 41 | |
| 42 | if [ -d /run/live/medium/install ] |
| 43 | then |
| 44 | if ls /run/live/medium/install/pool/main/l/live-installer/live-installer_*.udeb > /dev/null 2>&1 |
| 45 | then |
| 46 | [ "${_VERBOSE}" ] && echo " with debian-installer (live) support." |
| 47 | else |
| 48 | [ "${_VERBOSE}" ] && echo " with debian-installer (normal) support." |
| 49 | fi |
| 50 | else |
| 51 | [ "${_VERBOSE}" ] && echo "without debian-installer support." |
| 52 | fi |
| 53 | |
| 54 | exit 0 |
| 55 | else |
| 56 | [ "${_VERBOSE}" ] && echo " no, this is not a live system." |
| 57 | |
| 58 | exit 1 |
| 59 | fi |