Skip to content

Commit 7a91204

Browse files
committed
feat: install udev rules
1 parent 61293ec commit 7a91204

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

post_install.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
3+
arduino_zephyr_rules () {
4+
cat <<EOF
5+
# Arduino Zephyr rules
6+
7+
# Arduino UNO Q
8+
# Operating mode
9+
SUBSYSTEM=="usb", ATTR{idVendor}=="2341", ATTR{idProduct}=="0078", MODE="0666"
10+
# EDL mode
11+
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", ATTR{idProduct}=="9008", MODE="0666"
12+
13+
EOF
14+
}
15+
16+
OS="$(uname -s)"
17+
case "$OS" in
18+
Linux*)
19+
if [ "$EUID" -ne 0 ]; then
20+
if [ -e "${PWD}/post_install.sh" ]; then
21+
if command -v pkexec > /dev/null 2>&1; then
22+
echo "Requesting root privileges..."
23+
pkexec "${PWD}/post_install.sh"
24+
else
25+
echo
26+
echo "You might need to configure permissions for uploading."
27+
echo "To do so, run the following command from the terminal:"
28+
echo "sudo \"${PWD}/post_install.sh\""
29+
echo
30+
exit
31+
fi
32+
else
33+
# Script was executed from another path. It is assumed this will only occur when user is executing script directly.
34+
# So it is not necessary to provide the command line.
35+
echo "Please run as root"
36+
fi
37+
38+
exit
39+
fi
40+
41+
arduino_zephyr_rules > /etc/udev/rules.d/60-arduino-zephyr.rules
42+
43+
# reload udev rules
44+
echo "Reload rules..."
45+
udevadm trigger
46+
udevadm control --reload-rules
47+
48+
;;
49+
esac

0 commit comments

Comments
 (0)