ROS/build_ros/entrypoint.sh
2022-11-14 15:47:49 +01:00

41 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
if [ ! -f /home/ros/docker_image_version ]; then
echo "0" > /home/ros/docker_image_version
fi
chsh -s /usr/bin/bash ros
if [ "0" == "$(cat /home/ros/docker_image_version)" ]; then
echo "Performing initial setup..."
cp /etc/skel/.* /home/ros
chown -R ros:ros /home/ros
su ros -c "echo 'source ~/.rosrc' >> ~/.bashrc"
echo "Modified .bashrc"
su ros -c "mkdir -p /home/ros/workspace/src"
echo "Created workspace"
su ros -c "cd /home/ros/workspace; colcon build --event-handlers console_cohesion+ --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja"
echo "Built workspace"
printf "1" > /home/ros/docker_image_version
fi
if [ ! -f /home/ros/.ssh/id_rsa ]; then
su ros -c "ssh-keygen -N '' -f /home/ros/.ssh/id_rsa"
echo "Generated SSH Keys."
fi
echo "ros:ros" | chpasswd
su ros -c "printf 'source /opt/ros/$ROS_DISTRO/setup.bash\nsource /home/ros/workspace/install/setup.bash' > ~/.rosrc"
printf "export DISPLAY=$DISPLAY" > /etc/profile.d/display.sh
printf "export XAUTHORITY=$XAUTHORITY" > /etc/profile.d/xauth.sh
chmod +x /etc/profile.d/display.sh
chmod +x /etc/profile.d/xauth.sh
echo "Ready to connect."
/usr/sbin/sshd -p 2222 -D