Skip to content

Commit f0569fa

Browse files
authored
Merge pull request #10 from sourcebots/fixes
Fix issues from testing
2 parents b52c4cf + e0df6f5 commit f0569fa

File tree

6 files changed

+53
-4
lines changed

6 files changed

+53
-4
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[udisks1]
2+
Identity=unix-group:storage
3+
Action=org.freedesktop.udisks.filesystem-mount;org.freedesktop.udisks.luks-unlock;org.freedesktop.udisks.drive-eject;org.freedesktop.udisks.drive-detach
4+
ResultAny=yes
5+
6+
[udisks2]
7+
Identity=unix-group:storage
8+
Action=org.freedesktop.udisks2.filesystem-mount;org.freedesktop.udisks2.filesystem-mount-system;org.freedesktop.udisks2.encrypted-unlock;org.freedesktop.udisks2.eject-media;org.freedesktop.udisks2.power-off-drive
9+
ResultAny=yes
10+
11+
[udisks2-other-seat]
12+
Identity=unix-group:storage
13+
Action=org.freedesktop.udisks2.filesystem-mount-other-seat;org.freedesktop.udisks2.filesystem-unmount-others;org.freedesktop.udisks2.encrypted-unlock-other-seat;org.freedesktop.udisks2.eject-media-other-seat;org.freedesktop.udisks2.power-off-drive-other-seat
14+
ResultAny=yes
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
polkit.addRule(function(action, subject) {
2+
var YES = polkit.Result.YES;
3+
var permission = {
4+
// required for udisks1:
5+
"org.freedesktop.udisks.filesystem-mount": YES,
6+
"org.freedesktop.udisks.luks-unlock": YES,
7+
"org.freedesktop.udisks.drive-eject": YES,
8+
"org.freedesktop.udisks.drive-detach": YES,
9+
// required for udisks2:
10+
"org.freedesktop.udisks2.filesystem-mount": YES,
11+
"org.freedesktop.udisks2.encrypted-unlock": YES,
12+
"org.freedesktop.udisks2.eject-media": YES,
13+
"org.freedesktop.udisks2.power-off-drive": YES,
14+
// required for udisks2 if using udiskie from another seat (e.g. systemd):
15+
"org.freedesktop.udisks2.filesystem-mount-other-seat": YES,
16+
"org.freedesktop.udisks2.filesystem-unmount-others": YES,
17+
"org.freedesktop.udisks2.encrypted-unlock-other-seat": YES,
18+
"org.freedesktop.udisks2.encrypted-unlock-system": YES,
19+
"org.freedesktop.udisks2.eject-media-other-seat": YES,
20+
"org.freedesktop.udisks2.power-off-drive-other-seat": YES
21+
};
22+
if (subject.isInGroup("storage")) {
23+
return permission[action.id];
24+
}
25+
});

parts/files/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
sbot[vision]==1.0.0rc2
1+
sbot[vision]==1.0.0
22
numpy==1.25.0
3-
runusb==2023.0.0rc2
3+
runusb==2023.0.0

parts/files/runusb.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Description=Automatic running of USB devices
55
Type=simple
66
User=robot
77
Environment="RUNUSB_MOUNTPOINT_DIR=/media/robot"
8-
ExecStart=/usr/bin/runusb
8+
ExecStart=/usr/local/bin/runusb
99
Restart=on-failure
1010
RestartSec=5s
1111

parts/robot.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ cp /tmp/packer-files/udiskie/udiskie.yml /etc/
99
cp /tmp/packer-files/udiskie/udiskie.service /lib/systemd/system/
1010
systemctl enable udiskie.service
1111

12+
# Add polkit rules for udiskie
13+
mkdir -p /etc/polkit-1/rules.d
14+
mkdir -p /etc/polkit-1/localauthority/50-local.d
15+
cp /tmp/packer-files/polkit/rules.d/50-udiskie.rules /etc/polkit-1/rules.d/50-udiskie.rules
16+
cp /tmp/packer-files/polkit/localauthority/10-udisks.pkla /etc/polkit-1/localauthority/50-local.d/10-udisks.pkla
17+
18+
# Create a group that can use udisks and add the default user to it.
19+
groupadd --force storage
20+
usermod -a -G storage robot
21+
1222
# Install core components
1323
pip install --no-cache -r /tmp/packer-files/requirements.txt
1424

parts/user.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ useradd \
1111
--create-home \
1212
-s /bin/bash \
1313
-u 1000 \
14-
-G sudo,video,dialout,adm \
14+
-G sudo,video,dialout,adm,gpio \
1515
-p "$password" \
1616
$user
1717

0 commit comments

Comments
 (0)