Skip to content

Commit d75e88e

Browse files
committed
feat: install udev rules
1 parent 8cbd9cf commit d75e88e

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

post_install.sh

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

0 commit comments

Comments
 (0)