Headless Internet Radio

Created by Pete Nesbitt pete@linux1.ca
October 2014

Build a headless system to automatically play Internet radio.

Agtigo (PICO ITX)

-auto login of user at boot
-auto run inet-radio script
-since no keyboard, insert a USB thumb drive to trigger power off
-for emergency shutdown (if you don't have a usd-drive), plug in usb keyboard and hit ctl-alt-del (set to shudown not reboot)
-this is not a security minded setup. It's intended for a dedicated box on a private network.

-no volume control so not great with headphones, but using computer speakers is fine (they all have Volume controls.


  -I used Fedora 19 "minimal install" from a thumbdrive
        -creat a single regular user to run everything under

  -post install, after a regular system update, install:
        alsa: alsa-lib alsa-firmware alsa-utils alsa-tools-firmware

        mplayer (comes from rpmfusion repo)

        Optionally pulse and alsa-pulse-plugin but no value here
        rpmfusion.org repo

  Radio Script:
        -download inet-radio.sh from linux1.ca
        -put it in /usr/local/bin (or whereever you like)
        -make it executable  'chmod 755 inet-radio.sh'

        -modify users profile to run script on login
          edit ~/.bash_profile

          add a single line to the end:

# test mplayer with 
 mplayer -playlist http://cp.usa7.fastcast4u.com:2199/tunein/alcann00.asx
 mplayer -playlist http://playerservices.streamtheworld.com/pls/CBC_R2_VCR_H.pls

if no sound, try amixer (cmd) or alsamixer (curses) to check master and line volumes etc


 Auto Login:
  -create getty@1.service within systemd services
        cp /usr/lib/systemd/system/getty@.service \

        ln -sf /etc/systemd/system/autologin@.service \

  *this symlink may not be 100% correct, need to review default settings. I made my notes post install :(

   edit:  /etc/systemd/system/autologin@.service

         ExecStart=  line to read: (change USERNAME to the user created at install)
           ExecStart=-/sbin/mingetty --autologin USERNAME %I
          OR (I had some issues with this on one instance, so I used:
           ExecStart=-/sbin/agetty --noclear --autologin USERNAME %I 38400 linux

         Alias=  line to read:

    activate it all by running: 'systemctl daemon-reload'


 Auto Shutdown:
    -we have a standard and a backup method.

    Primary Method:
        -inserting a thumbdrive triggers a system power off.
        -we use a UDEV rule to call the systemd poweroff.target

        1) create a file for your rules. I used /etc/udev/rules.d/10-local.rules
           add a single line:

                KERNEL=="sdb", ENV{SYSTEMD_WANTS}="poweroff.target"

                -note that since my system has only one scsi disk (sda), the first inserted thumbdrive will be given sdb.
                -I tried with ACTION=="add" ACTION=="remove" and ACTION=="change" but only works for insert :[

        2) after editing the rules, run 'udevadm control --reload-rules' (or reboot)

          Now inserting a USB Thumb Drive will power everything off.

    Secondary/Emergency Method:
        shutdown via /usr/lib/systemd/system/
                -force a symlink of ctrl-alt-del to poweroff:

                ln -sf /lib/systemd/system/poweroff.target /lib/systemd/system/ctrl-alt-del.target

                -now pressing Ctrl-Alt-Del keys at once will power everything off.

That's it. If all went well, you can power it off, then hook up speakers and a network cable and nothing else.
Fire it up and after about 30 to 60 seconds (boot up + cache filling time) you should hear music.
When you're done, just insert a USB Drive and it will shut itself off.
Remove the USB drive to prevent a boot time loop.