-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuname.sh
executable file
·101 lines (95 loc) · 2.09 KB
/
uname.sh
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
#run with --install to install fake uname
which uname.orig &> /dev/null
if [ $? -ne 0 ]; then
if [ $# -gt 0 ] && [ $1 == '--install' ]; then
if [ $# -ne 2 ]; then
echo "Usage: $0 --install <desired fake uname -r output>"
exit 1
fi
set -e
KERNEL_VER=$2
echo "Installing fake uname to $(which uname) for uname -r = $KERNEL_VER"
cp $(which uname) $(which uname).orig
echo "#!$(which bash)" > $(which uname).fake
echo "KERNEL_VER=$KERNEL_VER" >> $(which uname).fake
grep -v '#!/' $0 >> $(which uname).fake
cp $(which uname).fake $(which uname)
echo "Installed successfully! Run $(which uname) --uninstall to remove"
exit 0
fi
UNAME='uname'
PROG=$0
KERNEL_VER="fake_uname-r_here"
else
if [ $# -eq 1 ] && [ "$1" == '--uninstall' ]; then
set -e
echo "Uninstalling fake uname..."
mv $(which uname.orig) $(which uname)
echo "Uninstalled successfully! $(which uname).fake remains"
exit 0
fi
UNAME='uname.orig'
PROG=$0
fi
US=''
UN=''
UR=''
UV=''
UM=''
UP=''
UI=''
UO=''
if [ $# -eq 0 ]; then
$UNAME; exit
fi
while [ $# -gt 0 ]; do
ARG=$1
case $ARG in
-a)
$PROG -s -n -r -v -m -p -i -o
exit
;;
-s)
US=$($UNAME -s)
shift
;;
-n)
UN=$($UNAME -n)
shift
;;
-r)
UR=$KERNEL_VER
shift
;;
-v)
UV=$($UNAME -v)
shift
;;
-m)
UM=$($UNAME -m)
shift
;;
-p)
UP=$($UNAME -p)
shift
;;
-i)
UI=$($UNAME -i)
shift
;;
-o)
UO=$($UNAME -o)
shift
;;
--version)
$UNAME --version
exit
;;
*)
$UNAME --help
exit
;;
esac
done
echo $US $UN $UR $UV $UM $UP $UI $UO