added "clean" target
[rrq/overlay-boot.git] / overlay-go
1 #!/bin/sh
2
3 [ $(id -u) = 0 ] || exec sudo $0 $@
4 . $(dirname $(realpath $0))/functions XXX
5
6 NAME="$1"
7
8 if [ -z "$NAME" ] ; then
9     echo "Select subhost: $(list_running)"
10     exit 0
11 fi
12
13 read USPID RSPID <<EOF
14 $(is_live $NAME)
15 EOF
16
17 [ -z "$USPID" ] && echo "$NAME is not running" >&2 && exit 1
18
19 if [ -z "$RSPID" ] ; then
20     cat <<EOF >&2
21 ***  $NAME is started (pid $USPID) but doesn't seem to be running
22 *** /.reaper and might need manual fixing.
23 EOF
24     exit 1
25 fi
26
27 sudo nsenter -t "$RSPID" -n -m -p -r -w -u -C /bin/bash
28 if [ $? = 137 ] ; then
29     echo "######### please 'fg' this again (if stopped)" >&2
30     stty sane # a killed bash might leave the tty insane and stty
31               # typically gets stopped trying to correct it
32 fi
33 echo "done"