-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaufs-exec
More file actions
executable file
·69 lines (51 loc) · 1.35 KB
/
aufs-exec
File metadata and controls
executable file
·69 lines (51 loc) · 1.35 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
ME=${0##*/}
LIVE_X64_LD_PATH="/lib64:/lib:/lib/x86_64-linux-gnu:/usr/lib"
LIVE_386_LD_PATH="/lib:/lib/i386-linux-gnu:/usr/lib"
LIVE_PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin"
usage() {
local ret=${1:-0}
cat <<Usage
Usage: $ME command [options]
Execute <command> from under the $dir directory, including
any libraries dependenices.
Usage
exit $ret
}
main() {
prep
[ $# -lt 1 ] && usage
local xdir found prog=$1
[ -n "${prog##/*}" ] && prog=$(ld_path_which $prog)
if [ -z "$prog" ]; then
printf "Program %s not found under $LD_DIR\n" "$1" >&2
return 1
fi
shift
LD_LIBRARY_PATH=$LD_PATH $LD_DIR$prog "$@"
}
prep() {
case $ME in
aufs-*) dir=/live/aufs ;;
linux-*) dir=/live/linux ;;
esac
LD_DIR=$dir
arch=$(uname -m)
case $arch in
x86_64) ld_path=$LIVE_X64_LD_PATH ;;
i[3-8]86) ld_path=$LIVE_386_LD_PATH ;;
*) printf 'unknown architecture "%s". Assuming "%s"\n' $arch i686 >&2
ld_path=$LIVE_386_LD_PATH;;
esac
LD_PATH=$(echo $ld_path | sed -r "s=(^|:)=\\1$dir=g")
}
ld_path_which() {
local xdir prog=$1
for xdir in $(echo $LIVE_PATH | tr ':' ' '); do
[ -x $LD_DIR$xdir/$prog ] || continue
echo $xdir/$prog
return 0
done
return 1
}
main "$@"