Nominal Animal
Well-known member
If the installation of udev rules causes trouble for developers new to Linux, it might make sense to create an installer for it.
As an example, I saved the following Bash script at http://www.nominal-animal.net/answers/install-teensy-rules:
The part between cat >"$TEMPRULE" <<ENDRULE and ENDRULE should be exactly the latest version of the 49-teensy.rules file.
The idea is that to install the udev rule safely (that is, if you trust the script -- I have not ponied up the money to secure my web host), you only need to run
or, if you want to examine the script first, then
Similarly, you could install all three Linux teensy binaries as /usr/lib/teensy/i686/teensy, /usr/lib/teensy/x86_64/teensy, and /usr/lib/teensy/armv6l/teensy (for Raspberry Pi), and use a startup script /usr/bin/teensy to launch the correct one:
As an example, I saved the following Bash script at http://www.nominal-animal.net/answers/install-teensy-rules:
Code:
#!/bin/bash
RULENAME=49-teensy.rules
RULEDIRS=( /lib/udev/rules.d \
/etc/udev/rules.d )
if [ -z "$RULES" ]; then
for ruledir in $RULEDIRS ; do
if [ -d "$ruledir" ]; then
RULES="$ruledir"
fi
done
if [ -z "$RULES" ]; then
printf '\n'
printf 'Cannot locate the udev rules directory on your system.\n'
printf '\n'
printf 'If you know where it should be, run this script using\n'
printf ' RULES=/etc/udev/rules.d bash %s\n' "$0"
printf '\n'
exit 1
fi
fi
if [ ! -d "$RULES" ]; then
printf '\n'
printf 'udev rules directory %s does not exist.\n' "$RULES"
printf '\n'
exit 1
fi
TEMPRULE=$(mktemp) || exit 1
trap "rm -f '$TEMPRULE'" EXIT
cat >"$TEMPRULE" <<ENDRULE
# UDEV Rules for Teensy boards, http://www.pjrc.com/teensy/
#
# The latest version of this file may be found at:
# http://www.pjrc.com/teensy/49-teensy.rules
#
# This file must be placed at:
#
# /etc/udev/rules.d/49-teensy.rules (preferred location)
# or
# /lib/udev/rules.d/49-teensy.rules (req'd on some broken systems)
#
# To install, type this command in a terminal:
# sudo cp 49-teensy.rules /etc/udev/rules.d/49-teensy.rules
#
# After this file is installed, physically unplug and reconnect Teensy.
#
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789B]?", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789A]?", ENV{MTP_NO_PROBE}="1"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789ABCD]?", MODE:="0666"
KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789B]?", MODE:="0666"
#
# If you share your linux system with other users, or just don't like the
# idea of write permission for everybody, you can replace MODE:="0666" with
# OWNER:="yourusername" to create the device owned by you, or with
# GROUP:="somegroupname" and mange access using standard unix groups.
#
#
# If using USB Serial you get a new device each time (Ubuntu 9.10)
# eg: /dev/ttyACM0, ttyACM1, ttyACM2, ttyACM3, ttyACM4, etc
# apt-get remove --purge modemmanager (reboot may be necessary)
#
# Older modem proding (eg, Ubuntu 9.04) caused very slow serial device detection.
# To fix, add this near top of /lib/udev/rules.d/77-nm-probe-modem-capabilities.rules
# SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", GOTO="nm_modem_probe_end"
#
ENDRULE
printf '\n'
printf 'To install the udev rules file, superuser privileges are needed.\n'
printf 'To cancel the installation, just press Ctrl+C here.\n'
printf '\n'
sudo true || exit 0
sudo rm -f "$RULES/$RULENAME"
sudo install -o 0 -g 0 -m 0664 "$TEMPRULE" "$RULES/$RULENAME" || exit 1
sudo udevadm control --reload-rules || exit 1
sudo udevadm trigger || exit 1
printf '\n'
printf 'udev rule file successfully installed to\n'
printf ' %s\n' "$RULES/$RULENAME"
printf 'and activated.\n'
printf '\n'
exit 0
The idea is that to install the udev rule safely (that is, if you trust the script -- I have not ponied up the money to secure my web host), you only need to run
Code:
wget -O - http://www.nominal-animal.net/answers/install-teensy-rules | bash --
Code:
rm -f install-teensy-rules
wget http://www.nominal-animal.net/answers/install-teensy-rules
# Examine install-teensy-rules
bash install-teensy-rules
rm -f install-teensy-rules
Similarly, you could install all three Linux teensy binaries as /usr/lib/teensy/i686/teensy, /usr/lib/teensy/x86_64/teensy, and /usr/lib/teensy/armv6l/teensy (for Raspberry Pi), and use a startup script /usr/bin/teensy to launch the correct one:
Code:
#!/bin/bash
case "$(uname -m)" in
i386|i486|i586|i686)
cd /usr/lib/teensy/i686/ && exec teensy "$@" || exit 1
;;
x86_64)
cd /usr/lib/teensy/x86_64/ && exec teensy "$@" || exit 1
;;
armv6l)
cd /usr/lib/teensy/armv6l/ && exec teensy "$@" || exit 1
;;
esac
printf '\n'
printf 'Unsupported hardware architecture; sorry.\n'
printf '\n'
exit 1