-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_robot_configuration
executable file
·95 lines (79 loc) · 2.76 KB
/
setup_robot_configuration
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
#!/bin/bash
# Check if running with root privileges
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# resize fs
echo "Resizing the file system"
root_device=/dev/$(lsblk -no PKNAME,MOUNTPOINT | awk '$2 == "/" {print $1}')
partition_suffix=$(lsblk -no KNAME,MOUNTPOINT | awk '$2 == "/" {gsub(/.*[^0-9]/, "", $1); print $1}')
if [[ $root_device == /dev/sd* ]]; then
partition_number="${partition_suffix}"
else
partition_number="p${partition_suffix}"
fi
sudo growpart ${root_device} ${partition_suffix}
sudo resize2fs ${root_device}${partition_number}
# Parse command line arguments
if [[ $# -gt 2 ]]; then
echo "Usage: $(basename "$0") ROBOT_MODEL ROS_VERSION"
exit 0
fi
if [ -z "$2" ]; then
if [ "$IMAGE_TYPE" == "VULCANEXUS_HUMBLE" ]; then
ros_version="vulcanexus_humble"
elif [ "$IMAGE_TYPE" == "ROS2_JAZZY" ]; then
ros_version="ros2_jazzy"
elif [ "$IMAGE_TYPE" == "ROS2_HUMBLE" ]; then
ros_version="ros2_humble"
elif [ "$IMAGE_TYPE" == "ROS2_FOXY" ]; then
ros_version="ros2_humble"
elif [ "$IMAGE_TYPE" == "ROS_NOETIC" ]; then
ros_version="ros_noetic"
else
echo "Error: No ROS version specified"
exit 1
fi
else
if [ "$2" == "vulcanexus_humble" ] || [ "$2" == "ros2_jazzy" ] || [ "$2" == "ros2_humble" ] || [ "$2" == "ros_noetic" ]; then
ros_version="$2"
else
echo "Error: Invalid ROS version specified: $2"
echo "Usage: $(basename "$0") ROBOT_MODEL ROS_VERSION"
exit 1
fi
fi
echo "ROS version: ${ros_version}"
if [ -z "$1" ]; then
echo ""
echo "Using default configuration"
exit 0
else
if [ "$1" == "rosbot_xl" ] || [ "$1" == "rosbot_3" ] || [ "$1" == "rosbot_2r" ] || [ "$1" == "rosbot_2_pro" ] || [ "$1" == "panther" ]; then
robot_model="$1"
else
echo "Error: Invalid robot model: $1"
echo "Usage: $(basename "$0") ROBOT_MODEL ROS_VERSION"
exit 1
fi
echo "Robot model: ${robot_model}"
cp -rp /etc/husarion/robot_configs/${robot_model}/${ros_version}/* /home/husarion
dpkg -i /etc/husarion/robot_configs/${robot_model}/motd_$(uname -m).deb
cp /etc/husarion/robot_configs/${robot_model}/netplan.yaml /etc/netplan/01-network-manager-all.yaml
bash /usr/lib/husarion/custom_config_${robot_model}.sh
fi
mkdir /home/husarion/.ros
chown husarion:husarion /home/husarion/.ros
sudo chmod 600 /etc/netplan/01-network-manager-all.yaml
# Generating new SSH credentials
sudo echo "" > /root/.ssh/authorized_keys
sudo echo "" > /root/.ssh/known_hosts
sudo echo "" > /home/husarion/.ssh/authorized_keys
sudo echo "" > /home/husarion/.ssh/known_hosts
sudo rm -rf /etc/ssh/ssh_host_*
ssh-keygen -A
# systemctl restart ssh.service
# Print success message
echo ""
echo "Configuration files copied successfully for robot model \"$robot_model\" and ROS version \"$ros_version\""