Created
February 25, 2014 14:22
-
-
Save mstaflex/9209710 to your computer and use it in GitHub Desktop.
Script that distributes all the ROS files from the central control station to the TWISTbots
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
stations="tbot_unit01 tbot_unit02 tbot_unit03 tbot_unit04 tbot_unit05" | |
excluds="distribute build msg_gen srv_gen log packs" | |
# Author Jasper Buesch | |
#################################################################################### | |
############# DO NOT CHANGE BELOW THIS ############################################# | |
#################################################################################### | |
if [ "$1" == "-h" ]; then | |
echo "" | |
echo "This is a command line tool to distribute ROS (~/ros) code onto the tbot_units" | |
echo "Usage:" | |
echo " distribute [ all | <list of bot names> ]" | |
echo | |
exit | |
fi | |
if [ "$#" -ne 0 ]; then | |
if [ "$1" == "all" ]; then | |
stations=$stations | |
else | |
stations=$@ | |
fi | |
fi | |
echo $stations | |
return="" | |
station="" | |
active_stations="" | |
running="False" | |
exclude_param="" | |
for i in $excluds | |
do | |
exclude_param="$exclude_param --exclude=$i" | |
done | |
echo "" | |
echo "Pinging for active stations..." | |
echo "" | |
check_if_station_is_there () | |
{ | |
result="$(ping -w 1 -c 1 $station | grep '1 received' | awk -F ' ' '{print $1}')" | |
if [ "$result" == "" ]; then | |
echo "$station not present" | |
return | |
elif [ $result -ne 1 ]; then | |
return | |
else | |
return='True' | |
fi | |
} | |
for i in $stations | |
do | |
station=$i | |
return='False' | |
check_if_station_is_there | |
if [ $return == 'True' ]; then | |
running="True" | |
echo "$station PRESENT!" | |
$(rsync -a -z $exclude_param /home/tbot/cps_ros/ $i:/home/tbot/ros/ ) & | |
fi | |
done | |
printf "\nSynching clients." | |
while [ "$running" != "" ]; do | |
sleep 1 | |
printf "." | |
running="$(ps aux | grep rsync | grep ssh | awk -F ' ' '{print $12}')" | |
done | |
printf "\n" | |
echo "Synching to all clients finished!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment