selftest: Add helper scripts for accessing the testenv namespace
[samba.git] / selftest / ns / nsenter-helper.sh
1 #!/bin/sh
2 #
3 # Helper script that gets run with nsenter to manually setup a secondary shell
4 # session to a given namespace testenv. This basically just sets up the same
5 # environment variables as you normally get with selftest, for convenience.
6
7 if [ $# -lt 1 ] ; then
8     echo "Usage: $0 <exports-file>"
9     exit 1
10 fi
11
12 # we get passed a exports file with all the environment variables defined
13 exports_file=$1
14
15 # read the exports file so the new shell has appropriate variables setup
16 # (we export rather than sourcing here so they get inherited by the subshell)
17 while read -r line ; do
18     export $line
19     # dump them for the user too
20     echo $line
21 done < $exports_file
22
23 echo ""
24 echo "Entered $NETBIOSNAME namespace, with above variables defined."
25 echo "Use CTRL+D or exit to leave the namespace."
26 echo ""
27
28 # start a shell session in the new namespace
29 $SHELL
30
31