forked from ros-industrial/industrial_training
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.check_training_config.bash
executable file
·133 lines (114 loc) · 4.06 KB
/
.check_training_config.bash
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
TARGET_BRANCH=foxy # industrial_training git branch
ROS_RELEASE=noetic # ROS1 release version
ROS2_RELEASE=foxy # ROS2 release version
#=======================================================================
# verify that PC configuration matches requirements for training class
#=======================================================================
function print_result() {
if [ $? -eq 0 ]; then # check command result
echo -e "\e[00;32m[OK]\e[00m"
else
echo -e "\e[00;31m[FAIL]\e[00m"
fi
}
# replace print_result() call with print_disabled() call to temporarily disable a test
function print_disabled() {
echo -e "\e[00;30m[DISABLED]\e[00m"
}
function check_internet() {
echo "Checking internet connection... "
printf " - %-30s" "google.com:"
print_result $(ping -q -c1 google.com &> /dev/null)
printf " - %-30s" "training wiki:"
print_result $(/usr/bin/wget -q -O /dev/null https://github.com/ros-industrial/industrial_training/wiki)
} #end check_internet()
function check_repo() {
echo "Checking git repo status... "
DIR=$(dirname "${BASH_SOURCE[0]}")
printf " - %-30s" "git repo exists:"
print_result $(cd $DIR && git status &> /dev/null)
printf " - %-30s" "active branch:"
ACTIVE_BRANCH=$(cd $DIR && git rev-parse --abbrev-ref HEAD)
print_result $([ "$ACTIVE_BRANCH" == "$TARGET_BRANCH" ])
# attempt to checkout correct branch, if needed
if [ "$ACTIVE_BRANCH" != "$TARGET_BRANCH" ]; then
printf " %-28s" "attempting to fix branch:"
print_result $(cd $DIR && git checkout -q $TARGET_BRANCH)
fi
printf " - %-30s" "repo version:"
REMOTE_URL=https://github.com/ros-industrial/industrial_training.git
REMOTE_GIT=$(git ls-remote -q $REMOTE_URL $TARGET_BRANCH 2> /dev/null | cut -c1-6)
LOCAL_GIT=$(cd $DIR && git rev-parse HEAD | cut -c1-6)
print_result $([ "$REMOTE_GIT" == "$LOCAL_GIT" ])
# attempt to update repo, if needed
if [ "$REMOTE_GIT" != "$LOCAL_GIT" ]; then
printf " %-28s" "attempting to update repo:"
print_result $(cd $DIR && git pull -q $REMOTE_URL)
printf " %-28s" "re-check repo version:"
LOCAL_GIT=$(cd $DIR && git rev-parse HEAD | cut -c1-6)
print_result $([ "$REMOTE_GIT" == "$LOCAL_GIT" ])
[ "$REMOTE_GIT" != "$LOCAL_GIT" ] && printf " remote: %s local: %s\n" "$REMOTE_GIT" "$LOCAL_GIT"
fi
} #end check_repo()
function check_deb() {
printf " - %-30s" "$1:"
print_result $(dpkg-query -s $1 &> /dev/null)
}
function disable_deb() {
printf " - %-30s" "$1:"
print_disabled $(dpkg-query -s $1 &> /dev/null)
}
function check_debs() {
echo "Checking debian packages... "
check_deb git
check_deb meld
check_deb build-essential
check_deb libfontconfig1
check_deb mesa-common-dev
check_deb libglu1-mesa-dev
check_deb pcl-tools
echo "Checking ROS1 packages:"
check_deb python3-catkin-tools
check_deb ros-$ROS_RELEASE-desktop
check_deb ros-$ROS_RELEASE-perception
check_deb ros-$ROS_RELEASE-moveit
disable_deb ros-$ROS_RELEASE-industrial-core
disable_deb ros-$ROS_RELEASE-openni-launch
disable_deb ros-$ROS_RELEASE-openni-camera
disable_deb ros-$ROS_RELEASE-openni2-launch
disable_deb ros-$ROS_RELEASE-openni2-launch
echo "Checking ROS2 packages:"
check_deb python3-colcon-bash
check_deb python3-colcon-core
check_deb python3-colcon-ros
check_deb ros-$ROS2_RELEASE-desktop
}
function check_bashrc() {
echo "Checking .bashrc... "
printf " - %-30s" "\$ROS_VERSION:"
if [ -z ${ROS_VERSION+x} ]; then
print_disabled $(false)
else
print_result $([ $ROS_VERSION == "2" ])
fi
printf " - %-30s" "\$ROS_DISTRO:"
if [ -z ${ROS_DISTRO+x} ]; then
print_disabled $(false)
else
print_result $([ $ROS_DISTRO == "$ROS2_RELEASE" ])
fi
}
function check_qtc() {
echo "Checking for QTCreator w/ ROS plugin... "
printf " - %-30s" "qtcreator-ros:"
print_result $( [ `which qtcreator-ros` ] || [ -f "$HOME/QtCreator/latest/bin/qtcreator-ros" ] )
}
#---------------------------------------
# run the actual tests
#---------------------------------------
check_internet
check_repo
check_debs
check_qtc
check_bashrc