-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathip-address
More file actions
executable file
·35 lines (34 loc) · 1.34 KB
/
ip-address
File metadata and controls
executable file
·35 lines (34 loc) · 1.34 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
#!/bin/bash
# | perl -p -e 'chomp'
# Look for a file identifying the host
# This is necessary b/c DHCP sometimes gives the computer a
# different hostname
if [ -f ~/.hostname ]; then
if ( grep --silent clio ~/.hostname || grep --silent thalia ~/.hostname || grep --silent euterpe ~/.hostname || grep --silent jen ~/.hostname || grep --silent stitchfix ~/.hostname); then
# Mac systems, some laptops, may or may not actually be connected.
# Prefer wired connections
if ( /sbin/ifconfig en0 | grep --silent inet ); then
/sbin/ifconfig en0 | grep inet | grep netmask | \
sed 's/.*inet //g' | sed 's/ .*//'
exit
fi
# Then wireless connections
if ( /sbin/ifconfig en1 | grep --silent inet ); then
/sbin/ifconfig en1 | grep inet | grep netmask | \
sed 's/.*inet //g' | sed 's/ .*//'
exit
fi
elif ( grep --silent lerma90 ~/.hostname || grep --silent aramis ~/.hostname || grep --silent sesame ~/.hostname ); then
# Linux machines with more or less permanent wired connections
/sbin/ifconfig eth0 | grep inet | grep Masque | \
sed 's/.*adr://g' | sed 's/ .*//'
elif ( grep --silent dionysus ~/.hostname ); then
echo Not implemented
else
echo "Host Unknown!"
exit
fi
else
echo "Can't find .hostname file!"
exit
fi