summaryrefslogtreecommitdiffstats
path: root/utils/pb-exec
blob: d672ec11683779f7dd37d6246ebbff80db7f0ada (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh

PREFIX=""

# Check if root required
if [[ "$(id -u)" != "0" ]]; then
	read -n 1 -r -p "Running as user $(id -un), run as root? (y/N)" key
	if [ "$key" == "y" ]; then
		PREFIX="sudo"
	fi
	printf "\n"
fi

# Run a program specified by Petitboot.
$PREFIX $@
echo "$0 ran '$@'"

# Wait for the user to exit back to Petitboot.
read -n 1 -r -p "Press ENTER to return to Petitboot or any other key to drop to a shell" key

if [ "$key" == "" ]; then
	echo "Returning to Petitboot.."
	exit 0
fi

printf "\nLaunching shell. Type 'exit' to return\n"
/bin/sh
OpenPOWER on IntegriCloud