-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathentrypoint.sh
82 lines (73 loc) · 2.94 KB
/
entrypoint.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
configure_vnc() {
# Create Openbox application configuration
mkdir -p /etc/xdg/openbox
cat >/etc/xdg/openbox/rc.xml <<'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<openbox_config xmlns="http://openbox.org/3.4/rc"
xmlns:xi="http://www.w3.org/2001/XInclude">
<applications>
<application name="rviz2">
<maximized>yes</maximized>
<position force="yes">
<x>center</x>
<y>center</y>
</position>
<focus>yes</focus>
<desktop>1</desktop>
</application>
</applications>
</openbox_config>
EOF
# Create rviz2 start script
cat >/usr/local/bin/start-rviz2.sh <<'EOF'
#!/bin/bash
source /opt/ros/humble/setup.bash
source /opt/autoware/setup.bash
if [ -n "$RVIZ_CONFIG" ]; then
exec rviz2 -d "$RVIZ_CONFIG"
else
exec rviz2
fi
EOF
chmod +x /usr/local/bin/start-rviz2.sh
echo "echo 'Autostart executed at $(date)' >> /tmp/autostart.log" >>/etc/xdg/openbox/autostart
echo "/usr/local/bin/start-rviz2.sh" >>/etc/xdg/openbox/autostart
# Start VNC server with Openbox
echo "Starting VNC server with Openbox..."
vncserver :99 -geometry 1024x768 -depth 16 -pixelformat rgb565
VNC_RESULT=$?
if [ $VNC_RESULT -ne 0 ]; then
echo "Failed to start VNC server (exit code: $VNC_RESULT)"
exit $VNC_RESULT
fi
# Set the DISPLAY variable to match VNC server
echo "Setting DISPLAY to :99"
echo "export DISPLAY=:99" >>~/.bashrc
sleep 2
# Start NoVNC
echo "Starting NoVNC..."
websockify --daemon --web=/usr/share/novnc/ --cert=/etc/ssl/certs/novnc.crt --key=/etc/ssl/private/novnc.key 6080 localhost:5999
# Configure ngrok if set
if [ -n "$NGROK_AUTHTOKEN" ]; then
ngrok config add-authtoken "$NGROK_AUTHTOKEN"
if [ -n "$NGROK_URL" ]; then
ngrok http --url="$NGROK_URL" 6080 --log=stdout >ngrok.log &
else
ngrok http 6080 --log=stdout >ngrok.log &
sleep 2
NGROK_URL=$(grep -oP 'url=\K[^\s]+' ngrok.log)
fi
fi
# Print info
echo -e "\033[32m-------------------------------------------------------------------------\033[0m"
echo -e "\033[32mBrowser interface available at local address http://$(hostname -I | cut -d' ' -f1):6080/vnc.html?resize=scale&password=openadkit&autoconnect=true\033[0m"
[ -z "$NGROK_AUTHTOKEN" ] && echo -e "\033[32mIf you have a static public ip you can access it on WEB at http://$(curl -s ifconfig.me):6080/vnc.html?resize=scale&password=openadkit&autoconnect=true\033[0m"
[ -n "$NGROK_AUTHTOKEN" ] && echo -e "\033[32mBrowser interface available at WEB address $NGROK_URL/vnc.html?resize=scale&password=openadkit&autoconnect=true\033[0m"
echo -e "\033[32m-------------------------------------------------------------------------\033[0m"
}
# shellcheck disable=SC1090
[ "$VNC_ENABLED" == "true" ] && configure_vnc
source "/opt/ros/$ROS_DISTRO/setup.bash"
source "/opt/autoware/setup.bash"
exec "$@"