-
Notifications
You must be signed in to change notification settings - Fork 0
/
ros-master.sh
executable file
·59 lines (50 loc) · 1.27 KB
/
ros-master.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
#!/usr/bin/env bash
script_name=$0
option_name=$2
if [ -n "`$SHELL -c 'echo $ZSH_VERSION'`" ]; then
# assume Zsh
file=zshenv;
elif [ -n "`$SHELL -c 'echo $BASH_VERSION'`" ]; then
# assume Bash
file=bashrc;
else
echo "Shell currently unsupported.";
exit 1;
fi
function usage () {
echo "ROS_MASTER_URI: $ROS_MASTER_URI"
echo "usage : "
echo "$(basename ${script_name}) { -l | -j | -m | --local | --jetson | --manual }"
echo ""
}
function local-master () {
printf %s\\n '/ROS_MASTER_URI=/s_//.*:_//localhost:_' w q | ed -s ~/.${file}; }
function jetson-master () {
printf %s\\n '/ROS_MASTER_URI=/s_//.*:_//robot:_' w q | ed -s ~/.${file}; }
function manual-master () {
printf %s\\n "/ROS_MASTER_URI=/s_//.*:_//$option_name:_" w q | ed -s ~/.${file};}
# check arguments
if [[ $# < 1 || $# > 2 || ( "$1" != "-l" && "$1" != "-j" && "$1" != "-m" && "$1" != "--local" && "$1" != "--jetson" && "$1" != "--manual" ) ]]; then
usage;
exit 1;
fi
case $1 in
"-l" )
local-master;
;;
"--local" )
local-master;
;;
"-j" )
jetson-master;
;;
"--jetson" )
jetson-master;
;;
"-m" )
manual-master;
;;
"--manual" )
manual-master;
esac
exec $SHELL