-
Notifications
You must be signed in to change notification settings - Fork 1
/
justfile
205 lines (168 loc) · 6.34 KB
/
justfile
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
build:
#!/bin/bash
export SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1
sudo /bin/bash -c "echo "net.ipv4.conf.all.forwarding=1" > /etc/sysctl.d/99-forwarding.conf"
sudo systemctl stop docker.service
sudo systemctl stop docker.socket
sudo systemctl restart systemd-sysctl
sudo iptables -I DOCKER-USER -i lxdbr0 -j ACCEPT
sudo iptables -I DOCKER-USER -o lxdbr0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
# sudo lxd init --minimal
# sudo usermod -aG lxd $USER
# newgrp lxd
# snapcraft --debug
snapcraft
dev-clean:
#!/bin/bash
export SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1
snapcraft clean
_install-rsync:
#!/bin/bash
if ! command -v rsync &> /dev/null; then
if [ "$EUID" -ne 0 ]; then
echo "Please run as root to install dependencies"
exit 1
fi
sudo apt update && sudo apt install -y rsync
fi
dev-install:
#!/bin/bash
if ls rosbot-xl_*.snap 1> /dev/null 2>&1; then
sudo snap remove --purge rosbot-xl
sudo rm -rf ./squashfs-root
unsquashfs ./rosbot-xl_*.snap
sudo snap try squashfs-root
else
echo "No snap found in current directory. Build it at first (run: just build)"
exit 1
fi
install:
#!/bin/bash
if ls rosbot-xl_*.snap 1> /dev/null 2>&1; then
sudo snap remove --purge rosbot-xl
sudo snap install ./rosbot-xl_*.snap --dangerous
else
echo "No snap found in current directory. Build it at first (run: just build)"
exit 1
fi
dev-launch:
#!/bin/bash
export SERIAL_PORT=/dev/ttyUSBDB
# export SERIAL_PORT_SLOT=$(snap interface serial-port | yq .slots[0] | sed 's/^\([^ ]*\) .*/\1/')
export SERIAL_PORT_SLOT="snapd:ft230xbasicuart"
sudo snap set rosbot-xl serial-port=$SERIAL_PORT
sudo snap connect rosbot-xl:serial-port $SERIAL_PORT_SLOT
sudo snap connect rosbot:ros-humble ros-humble-ros-base
sudo snap start --enable rosbot-xl # with --enable it will start after reboot
# sudo snap logs rosbot-xl
# sudo snap stop rosbot-xl
# sudo snap restart rosbot-xl
stop:
#!/bin/bash
sudo snap disconnect rosbot-xl:ros-humble
info:
#!/bin/bash
sudo snap get rosbot-xl
sudo snap connections rosbot-xl
logs:
sudo snap logs rosbot-xl -n 20
journalctl -t rosbot-xl
# copy repo content to remote host with 'rsync' and watch for changes
sync hostname password="husarion": _install-rsync
#!/bin/bash
sshpass -p "husarion" rsync -vRr ./ husarion@{{hostname}}:/home/husarion/${PWD##*/}
while inotifywait -r -e modify,create,delete,move ./ ; do
sshpass -p "{{password}}" rsync -vRr ./ husarion@{{hostname}}:/home/husarion/${PWD##*/}
done
# sshpass -p "husarion" rsync -vRr --delete ./ husarion@{{hostname}}:/home/husarion/${PWD##*/}
# while inotifywait -r -e modify,create,delete,move ./ ; do
# sshpass -p "{{password}}" rsync -vRr --delete ./ husarion@{{hostname}}:/home/husarion/${PWD##*/}
# done
install-snap:
#!/bin/bash
sudo apt install snapd
sudo systemctl unmask snapd.service
sudo systemctl unmask snapd.socket
sudo systemctl unmask snapd.seeded.service
sudo systemctl enable snapd.service
sudo systemctl enable snapd.socket
sudo systemctl enable snapd.seeded.service
sudo systemctl start snapd.service
sudo systemctl start snapd.socket
sudo systemctl start snapd.seeded.service
install-snapcraft:
#!/bin/bash
# fixing issues with networking (https://documentation.ubuntu.com/lxd/en/latest/howto/network_bridge_firewalld/?_ga=2.178752743.25601779.1705486119-1059592906.1705486119#prevent-connectivity-issues-with-lxd-and-docker)
sudo bash -c 'echo "net.ipv4.conf.all.forwarding=1" > /etc/sysctl.d/99-forwarding.conf'
sudo systemctl stop docker.service
sudo systemctl stop docker.socket
sudo systemctl restart systemd-sysctl
# now you may need to reboot (after reboot docker will not work until you run `sudo systemctl start docker.service`)
sudo snap install lxd
sudo lxd init --minimal
sudo snap install snapcraft --classic
# Enable the hotplug feature and restart the `snapd` daemon (for serial interface):
sudo snap set core experimental.hotplug=true
sudo systemctl restart snapd
sudo usermod -aG lxd $USER
newgrp lxd
enable-docker:
#!/bin/bash
sudo systemctl start docker.service
sudo systemctl start docker.socket
sudo systemctl restart systemd-sysctl
# run teleop_twist_keybaord (host)
teleop:
#!/bin/bash
# export FASTRTPS_DEFAULT_PROFILES_FILE=$(pwd)/shm-only.xml
ros2 run teleop_twist_keyboard teleop_twist_keyboard # --ros-args -r __ns:=/robot
iterate target="jazzy":
#!/bin/bash
start_time=$(date +%s)
echo "Starting script..."
sudo snap remove rosbot-xl
sudo rm -rf squashfs-root/
sudo rm -rf rosbot-xl*.snap
export SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1
if [ {{target}} == "humble" ]; then
export ROS_DISTRO=humble
elif [ {{target}} == "jazzy" ]; then
export ROS_DISTRO=jazzy
else
echo "Unknown target: {{target}}"
exit 1
fi
if [ -f snap/snapcraft.yaml ]; then
snapcraft clean
sudo rm -rf snap/snapcraft.yaml
fi
./render_template.py ./snapcraft_template.yaml.jinja2 snap/snapcraft.yaml
chmod 444 snap/snapcraft.yaml
snapcraft
unsquashfs rosbot-xl*.snap
sudo snap try squashfs-root/
sudo snap connect rosbot-xl:raw-usb
sudo snap connect rosbot-xl:shm-plug rosbot-xl:shm-slot
sudo snap connect rosbot-xl:shutdown
sudo snap connect rosbot-xl:hardware-observe
sudo snap connect rosbot-xl:joystick
end_time=$(date +%s)
duration=$(( end_time - start_time ))
hours=$(( duration / 3600 ))
minutes=$(( (duration % 3600) / 60 ))
seconds=$(( duration % 60 ))
printf "Script completed in %02d:%02d:%02d (hh:mm:ss)\n" $hours $minutes $seconds
remove-logs:
#!/bin/bash
sudo rm -rf /var/log/journal/*
sudo systemctl restart systemd-journald
prepare-store-credentials:
#!/bin/bash
snapcraft export-login --snaps=rosbot-xl \
--acls package_access,package_push,package_update,package_release \
exported.txt
publish:
#!/bin/bash
export SNAPCRAFT_STORE_CREDENTIALS=$(cat exported.txt)
snapcraft login
snapcraft upload --release edge rosbot-xl*.snap