-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
135 lines (108 loc) · 3.62 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
[private]
default:
@just --list --unsorted
build target="humble":
#!/bin/bash
export SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1
if [ {{target}} == "humble" ]; then
export ROS_DISTRO=humble
export CORE_VERSION=core22
elif [ {{target}} == "jazzy" ]; then
export ROS_DISTRO=jazzy
export CORE_VERSION=core24
else
echo "Unknown target: $target"
exit 1
fi
./render_template.py ./snapcraft_template.yaml.jinja2 snap/snapcraft.yaml
snapcraft
install:
#!/bin/bash
unsquashfs husarion-depthai*.snap
sudo snap try squashfs-root/
sudo snap connect husarion-depthai:raw-usb
sudo snap connect husarion-depthai:c189-plug
sudo husarion-depthai.stop
remove:
#!/bin/bash
sudo snap remove husarion-depthai
sudo rm -rf squashfs-root/
clean:
#!/bin/bash
export SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1
snapcraft clean
iterate target="jazzy":
#!/bin/bash
start_time=$(date +%s)
echo "Starting script..."
sudo snap remove husarion-depthai
sudo rm -rf squashfs-root/
sudo rm -rf husarion-depthai*.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
snapcraft clean
sudo rm -rf snap/snapcraft.yaml
./render_template.py ./snapcraft_template.yaml.jinja2 snap/snapcraft.yaml
chmod 444 snap/snapcraft.yaml
snapcraft
unsquashfs husarion-depthai*.snap
sudo snap try squashfs-root/
sudo snap connect husarion-depthai:raw-usb
sudo snap connect husarion-depthai:shm-plug husarion-depthai:shm-slot
sudo husarion-depthai.stop
# sudo snap connect husarion-depthai:c189-plug rosbot:c189-slot
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
swap-enable:
#!/bin/bash
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
# Make the swap file permanent:
sudo bash -c "echo '/swapfile swap swap defaults 0 0' >> /etc/fstab"
# Adjust swappiness:
sudo sysctl vm.swappiness=10
sudo bash -c "echo 'vm.swappiness=10' >> /etc/sysctl.conf"
swap-disable:
#!/bin/bash
sudo swapoff /swapfile
sudo rm /swapfile
sudo sed -i '/\/swapfile swap swap defaults 0 0/d' /etc/fstab # Remove the swap file entry
sudo sed -i '/vm.swappiness=10/d' /etc/sysctl.conf # Remove or comment out the swappiness setting
sudo sysctl -p # Reload sysctl configuration
prepare-store-credentials:
#!/bin/bash
snapcraft export-login --snaps=husarion-depthai \
--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 husarion-depthai*.snap
list-lxd-cache:
#!/bin/bash
sudo du -h --max-depth=1 /var/snap/lxd/common/lxd/storage-pools/default/containers/ | sort -h
remove-lxd-cache:
#!/bin/bash
lxc project switch snapcraft
for container in $(lxc list --format csv -c n); do
lxc delete $container --force
done
echo "verify:"
sudo du -h --max-depth=1 /var/snap/lxd/common/lxd/storage-pools/default/containers/
df -h
lxc project switch default