Raspberry Pi - DigitalSky Kensington Remotes

Part 1: General setup

  • run raspbian-ua-netinst on SD card (default install - server packages of debian jessie)
    • Note that wheezy doesn't work because systemd/udev are too old… and there's no backports repo for Raspbian
  • before you SSH in as root, you have to run sed -i -e 's/^PermitRootLogin without-password$/#PermitRootLogin without-password/g' /etc/ssh/sshd_config
  • SSH in as root…
> /etc/motd
echo rpi-ds-remote > /etc/hostname
sed -i s/pi/rpi-ds-remote/g /etc/hosts
echo "America/Chicago" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
sed -i -e 's/^# en_US.UTF-8/en_US.UTF-8/' /etc/locale.gen
dpkg-reconfigure -f noninteractive locales
sed -i $'s|deb http://archive.raspberrypi.org/debian jessie main|# Foundation does not yet provide a jessie repo\\\ndeb http://archive.raspberrypi.org/debian wheezy main|g' /etc/apt/sources.list
apt-get update
apt-get --no-install-recommends install aptitude
#aptitude install linux-image-rpi-rpfv raspberrypi-bootloader-nokernel
#cp /boot/vmlinuz-* /boot/kernel.img
# the rpi foundation version is less buggy, although distributed in a more annoying way:
aptitude install raspberrypi-bootloader
echo 'blacklist spi-bcm2708' > /etc/modprobe.d/raspi-blacklist.conf
echo 'blacklist i2c-bcm2708' >> /etc/modprobe.d/raspi-blacklist.conf
echo 'blacklist snd-soc-bcm2708-i2s' >> /etc/modprobe.d/raspi-blacklist.conf
sed -i -e 's/^snd-bcm2835/#snd-bcm2835/g' /etc/modules
echo 'vm.min_free_kbytes = 4096' > /etc/sysctl.d/raspi-eth0_fix.conf # see http://wiki.gentoo.org/wiki/Raspberry_Pi#Troubleshooting
aptitude install raspi-copies-and-fills
aptitude install libraspberrypi-bin fbset
# this is a default config.txt file - just comments, no settings:
wget -O /boot/config.txt https://raw.githubusercontent.com/Evilpaul/RPi-config/master/config.txt
sed -i 's/#boot_delay=0/boot_delay=0/g' /boot/config.txt
aptitude install netcat-traditional screen rsync psmisc file patch ethtool strace tcpdump vim
aptitude --without-recommends install dnsutils
aptitude install dosfstools
aptitude install watchdog
sed -i -e 's/^watchdog_module="none"/watchdog_module="bcm2708_wdog"/g' /etc/default/watchdog
sed -i -e 's/^#watchdog-device/watchdog-device/g' /etc/watchdog.conf
sed -i -e 's/^#max-load-1\t/max-load-1\t/g' /etc/watchdog.conf
echo "# Raspberry Pi doesn't work with the default timeout of 60; set it to 10 instead" >> /etc/watchdog.conf
echo $'watchdog-timeout\t= 10' >> /etc/watchdog.conf

aptitude --without-recommends install kbd

adduser tdobes
adduser tdobes adm

Part 2: Wireless

aptitude --without-recommends install ifplugd wpasupplicant
aptitude install ifmetric iw wireless-tools
sed -i -e 's/raspbian jessie main firmware$/raspbian jessie main firmware non-free/g' /etc/apt/sources.list
aptitude update
aptitude forget-new
aptitude install firmware-ralink firmware-atheros
sed -i -e 's/^REGDOMAIN=$/REGDOMAIN=US/g' /etc/default/crda
sed -i -e 's/^INTERFACES=""/INTERFACES="eth0"/g' /etc/default/ifplugd
#we don't set HOTPLUG_INTERFACES because wireless interfaces are already handled by udev
#sed -i -e 's/^HOTPLUG_INTERFACES=""/HOTPLUG_INTERFACES="all"/g' /etc/default/ifplugd
sed -i -e 's/^auto eth0/#allow-hotplug eth0/g' /etc/network/interfaces
# this is needed so that we don't run an ifplugd for the lo interface while using HOTPLUG_INTERFACES:
echo 'SUBSYSTEM=="net", KERNEL!="lo", RUN+="ifplugd.agent"' > /etc/udev/rules.d/60-ifplugd.rules
/etc/init.d/ifplugd restart

echo 'allow-hotplug wlan0' >> /etc/network/interfaces
echo 'iface wlan0 inet manual' >> /etc/network/interfaces
echo 'wpa-driver nl80211,wext' >> /etc/network/interfaces
echo 'wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf' >> /etc/network/interfaces
echo '# not supported on realtek dongle:' >> /etc/network/interfaces
echo '#pre-up iwconfig $IFACE power off' >> /etc/network/interfaces
echo 'iface mcp inet dhcp' >> /etc/network/interfaces
echo 'metric 1' >> /etc/network/interfaces
cat > /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev



Part 3: General systemd + Wheezy hacks

aptitude install systemd-sysv dbus
** it'll ask about removing sysvinit-core, which is fine

## NOTE:  These hacks might not be needed as systemd support in Jessie improves.

echo '[Unit]' > /etc/systemd/system/cron.service
echo 'Description=Regular background program processing daemon' >> /etc/systemd/system/cron.service
echo >> /etc/systemd/system/cron.service
echo '[Service]' >> /etc/systemd/system/cron.service
echo 'ExecStart=/usr/sbin/cron -f' >> /etc/systemd/system/cron.service
echo >> /etc/systemd/system/cron.service
echo '[Install]' >> /etc/systemd/system/cron.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/cron.service
echo '[Unit]' > /etc/systemd/system/ntp.service
echo 'Description=Network Time Protocol daemon' >> /etc/systemd/system/ntp.service
echo 'After=network.target' >> /etc/systemd/system/ntp.service
echo >> /etc/systemd/system/ntp.service
echo '[Service]' >> /etc/systemd/system/ntp.service
echo 'ExecStart=/usr/sbin/ntpd -n -g -u ntp:ntp' >> /etc/systemd/system/ntp.service
echo >> /etc/systemd/system/ntp.service
echo '[Install]' >> /etc/systemd/system/ntp.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/ntp.service

systemctl enable cron.service
systemctl enable ntp.service
systemctl disable ssh.service
systemctl enable ssh.socket

systemctl mask rc.local.service # buggy on wheezy, untested on jessie - replace with custom service files
systemctl disable rsyslog.service # disable to reduce writes to sd card
systemctl disable wpa_supplicant.service # unnecessary; started automatically
systemctl mask wd_keepalive.service # apparently conflicts with startup of watchdog because watchdog init script doesn't stop it successfully

systemctl stop rsyslog.service
rm /var/log/auth.log* /var/log/daemon.log* /var/log/debug /var/log/kern.log* /var/log/messages /var/log/user.log*

# ifplugd should start up / shut down interfaces using systemd, not calling ifupdown directly
# ideally, this would work... but we have to comment out allow-hotplug in /etc/network/interfaces to prevent udev from ifup'ing eth0... and ifup@.service passes --allow=hotplug to ifup, which prevents this from working
# ...so I gave up and just let ifup run in the ifplugd service instead
#echo '--- /etc/ifplugd/action.d/ifupdown' > /tmp/ifplugd_systemd.patch
#echo '+++ /etc/ifplugd/action.d/ifupdown.new' >> /tmp/ifplugd_systemd.patch
#echo '@@ -3,9 +3,17 @@' >> /tmp/ifplugd_systemd.patch
#echo ' ' >> /tmp/ifplugd_systemd.patch
#echo ' case "$2" in' >> /tmp/ifplugd_systemd.patch
#echo ' up)' >> /tmp/ifplugd_systemd.patch
#echo $'-\t/sbin/ifup $1' >> /tmp/ifplugd_systemd.patch
#echo $'+\tif [ -e /sys/fs/cgroup/systemd ]; then' >> /tmp/ifplugd_systemd.patch
#echo $'+\t\t/bin/systemctl start ifup@$1.service' >> /tmp/ifplugd_systemd.patch
#echo $'+\telse' >> /tmp/ifplugd_systemd.patch
#echo $'+\t\t/sbin/ifup $1' >> /tmp/ifplugd_systemd.patch
#echo $'+\tfi' >> /tmp/ifplugd_systemd.patch
#echo $' \t;;' >> /tmp/ifplugd_systemd.patch
#echo ' down)' >> /tmp/ifplugd_systemd.patch
#echo $'-\t/sbin/ifdown $1' >> /tmp/ifplugd_systemd.patch
#echo $'+\tif [ -e /sys/fs/cgroup/systemd ]; then' >> /tmp/ifplugd_systemd.patch
#echo $'+\t\t/bin/systemctl stop ifup@$1.service' >> /tmp/ifplugd_systemd.patch
#echo $'+\telse' >> /tmp/ifplugd_systemd.patch
#echo $'+\t\t/sbin/ifdown $1' >> /tmp/ifplugd_systemd.patch
#echo $'+\tfi' >> /tmp/ifplugd_systemd.patch
#echo $' \t;;' >> /tmp/ifplugd_systemd.patch
#echo ' esac' >> /tmp/ifplugd_systemd.patch
#patch -p0 < /tmp/ifplugd_systemd.patch && rm /tmp/ifplugd_systemd.patch

mkdir -p /etc/systemd/system/getty\@tty1.service.d
echo '[Service]' > /etc/systemd/system/getty\@tty1.service.d/noclear.conf
echo 'TTYVTDisallocate=no' >> /etc/systemd/system/getty\@tty1.service.d/noclear.conf

systemctl mask networking.service # we use ifplugd instead
systemctl mask kbd.service # this doesn't seem to work anyway
echo 'D /run/network 0755 root root' > /etc/tmpfiles.d/debian-networking.conf
echo 'F /run/network/ifstate 0644 root root - lo=lo' >> /etc/tmpfiles.d/debian-networking.conf

See also: http://blog.higgsboson.tk/2012/09/19/systemd-on-raspbian/

Part 4: DS Remote

aptitude install python2.7 usbutils

adduser remote
** press ctrl+d for password (don't set a password)
** Full name: MCP DS-Remote
** (all other values empty)
chsh -s /bin/false remote

# for debugging
adduser tdobes remote

echo 'KERNEL=="event*", SUBSYSTEM=="input", SUBSYSTEMS=="usb", ATTRS{idVendor}=="047d", ATTRS{idProduct}=="2012", TAG+="systemd", ENV{SYSTEMD_WANTS}="mcp-remote-kensington@$env{DEVNAME}.service", ENV{SYSTEMD_ALIAS}="/mcp$env{DEVNAME}", GROUP="remote", MODE="0660"' > /etc/udev/rules.d/mcp-remotes.rules
echo 'KERNEL=="event*", SUBSYSTEM=="input", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c538", TAG+="systemd", ENV{SYSTEMD_WANTS}="mcp-remote-logitech@$env{DEVNAME}.service", ENV{SYSTEMD_ALIAS}="/mcp$env{DEVNAME}", GROUP="remote", MODE="0660"' >> /etc/udev/rules.d/mcp-remotes.rules

echo '[Unit]' > /etc/systemd/system/mcp-remote-kensington\@.service
echo 'Description=MCP - Listen for commands from Kensington remote' >> /etc/systemd/system/mcp-remote-kensington\@.service
echo 'BindsTo=mcp%i.device' >> /etc/systemd/system/mcp-remote-kensington\@.service
echo 'After=mcp%i.device' >> /etc/systemd/system/mcp-remote-kensington\@.service
echo >> /etc/systemd/system/mcp-remote-kensington\@.service
echo '[Service]' >> /etc/systemd/system/mcp-remote-kensington\@.service
echo 'ExecStart=/opt/remote/kensington.py %I' >> /etc/systemd/system/mcp-remote-kensington\@.service
echo 'Type=simple' >> /etc/systemd/system/mcp-remote-kensington\@.service
echo 'User=remote' >> /etc/systemd/system/mcp-remote-kensington\@.service
echo 'Restart=always' >> /etc/systemd/system/mcp-remote-kensington\@.service
echo 'RestartSec=1' >> /etc/systemd/system/mcp-remote-kensington\@.service

echo '[Unit]' > /etc/systemd/system/mcp-remote-logitech\@.service
echo 'Description=MCP - Listen for commands from Logitech remote' >> /etc/systemd/system/mcp-remote-logitech\@.service
echo 'BindsTo=mcp%i.device' >> /etc/systemd/system/mcp-remote-logitech\@.service
echo 'After=mcp%i.device' >> /etc/systemd/system/mcp-remote-logitech\@.service
echo >> /etc/systemd/system/mcp-remote-logitech\@.service
echo '[Service]' >> /etc/systemd/system/mcp-remote-logitech\@.service
echo 'ExecStart=/opt/remote/logitech.py %I' >> /etc/systemd/system/mcp-remote-logitech\@.service
echo 'Type=simple' >> /etc/systemd/system/mcp-remote-logitech\@.service
echo 'User=remote' >> /etc/systemd/system/mcp-remote-logitech\@.service
echo 'Restart=always' >> /etc/systemd/system/mcp-remote-logitech\@.service
echo 'RestartSec=1' >> /etc/systemd/system/mcp-remote-logitech\@.service

# MCP Apt Proxy
echo 'Acquire::http { Proxy "http://apt.mcp.lcl:3142"; };' > /etc/apt/apt.conf.d/mcp-proxy

** Copy software into /opt/remote

** add quiet to the end of /boot/cmdline.txt
computer/raspberry_pi_ds-remote.txt · Last modified: 2015/03/07 19:34 by tdobes
Recent changes RSS feed Driven by DokuWiki Valid XHTML 1.0 Valid CSS