-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildHosts.sh
More file actions
executable file
·35 lines (26 loc) · 827 Bytes
/
buildHosts.sh
File metadata and controls
executable file
·35 lines (26 loc) · 827 Bytes
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
#!/bin/bash
HOSTS="media@media-laptop pi@xbmc pi@rpi ltsp vserver001 vserver002"
MYIP=$(ipconfig | grep wlan0 | sed 's/ \+/ /g' | cut -f2 -d" " | sed 's/Addr://')
cd $HOME/bin
cat allhosts.master | sed "s/MYIP/$MYIP/" > /tmp/allhosts.txt
# me first!
echo Updating laptop
#cp allhosts.txt /tmp
cat /etc/hosts > /tmp/backup_hosts.txt;
head -3 /etc/hosts > /tmp/newhosts;
cat /tmp/allhosts.txt >> /tmp/newhosts;
sudo su -c "cat /tmp/newhosts > /etc/hosts"
for DEST in $HOSTS
do
echo Updating $DEST
scp /tmp/allhosts.txt $DEST:/tmp > /dev/null 2>&1
if [ $? -eq 0 ]
then
ssh $DEST "sudo cat /etc/hosts > /tmp/backup_hosts.txt;
head -2 /etc/hosts > /tmp/newhosts;
cat /tmp/allhosts.txt >> /tmp/newhosts;
sudo su -c \"cat /tmp/newhosts > /etc/hosts\""
else
echo "$DEST is unreachable"
fi
done