]> git.ozlabs.org Git - petitboot/blob - utils/pb-exec
discover/grub2: Allow to separate the --id argument using a space char
[petitboot] / utils / pb-exec
1 #!/bin/sh
2
3 PREFIX=""
4
5 # Check if root required
6 if [[ "$(id -u)" != "0" ]]; then
7         read -n 1 -r -p "Running as user $(id -un), run as root? (y/N)" key
8         if [ "$key" == "y" ]; then
9                 PREFIX="sudo"
10         fi
11         printf "\n"
12 fi
13
14 # Run a program specified by Petitboot.
15 $PREFIX $@
16 echo "$0 ran '$@'"
17
18 # Wait for the user to exit back to Petitboot.
19 read -n 1 -r -p "Press ENTER to return to Petitboot or any other key to drop to a shell" key
20
21 if [ "$key" == "" ]; then
22         echo "Returning to Petitboot.."
23         exit 0
24 fi
25
26 printf "\nLaunching shell. Type 'exit' to return\n"
27 /bin/sh