jefflunt / glint-box

(retired) This was fun - but seriously, try Lakka instead (http://www.lakka.tv/)
MIT License
21 stars 5 forks source link

udev and autofs mount of usbdisks #5

Closed brandtdaniels closed 11 years ago

brandtdaniels commented 11 years ago

Create script to auto mount any inserted USB storage and search for any ".nes" files on that storage. Use the list of files found to generate a basic text menu that can be navigated using a nes controller. have the selected rom start up in the emulator.

jefflunt commented 11 years ago

I should have just put this in here instead of in an email:

I'd like to get a release out this week. Can we do the following with the auto-mount script?

brandtdaniels commented 11 years ago

Couple of things:

Copying files takes some time. Can we have ES first look in /root/roms then look in /mnt/usbdisk? I would rather have it just read my roms off the stick. This will avoid duplication or whatever other mess it could cause.

Second, logs should go in /var/log(s)/glint/gn.log

-Brandt

Sent from my iPhone

On Dec 16, 2012, at 12:55 PM, Jeff Lunt notifications@github.com wrote:

I should have just put this in here instead of in an email:

I'd like to get a release out this week. Can we do the following with the auto-mount script?

User inserts USB stick, which is auto mounted All .nes files are copied to /root/roms Launch executable /root/glint-es/glint-es &> /root/gn.log (this log file helps me troubleshoot problems with EmulationStation) — Reply to this email directly or view it on GitHub.

jefflunt commented 11 years ago

Yeah, I think that should be doable. Will the mount point always be called usbdisk or can it sometimes have a number after it or something else that prevents the name from being the same 100% of the time?

You have a good point about duplicatation, didn't think of that.

I'll start putting the log in the /var/log folder.

-Jeff

On Sun, Dec 16, 2012 at 3:41 PM, Brandt Daniels notifications@github.comwrote:

Couple of things:

Copying files takes some time. Can we have ES first look in /root/roms then look in /mnt/usbdisk? I would rather have it just read my roms off the stick. This will avoid duplication or whatever other mess it could cause.

Second, logs should go in /var/log(s)/glint/gn.log

-Brandt

Sent from my iPhone

On Dec 16, 2012, at 12:55 PM, Jeff Lunt notifications@github.com wrote:

I should have just put this in here instead of in an email:

I'd like to get a release out this week. Can we do the following with the auto-mount script?

User inserts USB stick, which is auto mounted All .nes files are copied to /root/roms Launch executable /root/glint-es/glint-es &> /root/gn.log (this log file helps me troubleshoot problems with EmulationStation) — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHubhttps://github.com/normalocity/glint-nes/issues/5#issuecomment-11423326.

brandtdaniels commented 11 years ago

It might need testing but I've set it up so udev changes sd?[1-9] to usbdisk%n and autofs mounts anyone of those to /mnt/usbdisk

-Brandt

Sent from my iPhone

On Dec 16, 2012, at 2:17 PM, Jeff Lunt notifications@github.com wrote:

Yeah, I think that should be doable. Will the mount point always be called usbdisk or can it sometimes have a number after it or something else that prevents the name from being the same 100% of the time?

You have a good point about duplicatation, didn't think of that.

I'll start putting the log in the /var/log folder.

-Jeff

On Sun, Dec 16, 2012 at 3:41 PM, Brandt Daniels notifications@github.comwrote:

Couple of things:

Copying files takes some time. Can we have ES first look in /root/roms then look in /mnt/usbdisk? I would rather have it just read my roms off the stick. This will avoid duplication or whatever other mess it could cause.

Second, logs should go in /var/log(s)/glint/gn.log

-Brandt

Sent from my iPhone

On Dec 16, 2012, at 12:55 PM, Jeff Lunt notifications@github.com wrote:

I should have just put this in here instead of in an email:

I'd like to get a release out this week. Can we do the following with the auto-mount script?

User inserts USB stick, which is auto mounted All .nes files are copied to /root/roms Launch executable /root/glint-es/glint-es &> /root/gn.log (this log file helps me troubleshoot problems with EmulationStation) — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHubhttps://github.com/normalocity/glint-nes/issues/5#issuecomment-11423326.

— Reply to this email directly or view it on GitHub.

jefflunt commented 11 years ago

Sounds pretty good. Can you commit it to a topic branch on the repo or send it to me?

On Sun, Dec 16, 2012 at 4:32 PM, Brandt Daniels notifications@github.comwrote:

It might need testing but I've set it up so udev changes sd?[1-9] to usbdisk%n and autofs mounts anyone of those to /mnt/usbdisk

-Brandt

Sent from my iPhone

On Dec 16, 2012, at 2:17 PM, Jeff Lunt notifications@github.com wrote:

Yeah, I think that should be doable. Will the mount point always be called usbdisk or can it sometimes have a number after it or something else that prevents the name from being the same 100% of the time?

You have a good point about duplicatation, didn't think of that.

I'll start putting the log in the /var/log folder.

-Jeff

On Sun, Dec 16, 2012 at 3:41 PM, Brandt Daniels < notifications@github.com>wrote:

Couple of things:

Copying files takes some time. Can we have ES first look in /root/roms then look in /mnt/usbdisk? I would rather have it just read my roms off the stick. This will avoid duplication or whatever other mess it could cause.

Second, logs should go in /var/log(s)/glint/gn.log

-Brandt

Sent from my iPhone

On Dec 16, 2012, at 12:55 PM, Jeff Lunt notifications@github.com wrote:

I should have just put this in here instead of in an email:

I'd like to get a release out this week. Can we do the following with the auto-mount script?

User inserts USB stick, which is auto mounted All .nes files are copied to /root/roms Launch executable /root/glint-es/glint-es &> /root/gn.log (this log file helps me troubleshoot problems with EmulationStation) — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub< https://github.com/normalocity/glint-nes/issues/5#issuecomment-11423326>.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHubhttps://github.com/normalocity/glint-nes/issues/5#issuecomment-11424015.

jefflunt commented 11 years ago

Unless you're still tweaking it, that is.

On Sun, Dec 16, 2012 at 5:19 PM, Jeff Lunt jefflunt@gmail.com wrote:

Sounds pretty good. Can you commit it to a topic branch on the repo or send it to me?

On Sun, Dec 16, 2012 at 4:32 PM, Brandt Daniels notifications@github.comwrote:

It might need testing but I've set it up so udev changes sd?[1-9] to usbdisk%n and autofs mounts anyone of those to /mnt/usbdisk

-Brandt

Sent from my iPhone

On Dec 16, 2012, at 2:17 PM, Jeff Lunt notifications@github.com wrote:

Yeah, I think that should be doable. Will the mount point always be called usbdisk or can it sometimes have a number after it or something else that prevents the name from being the same 100% of the time?

You have a good point about duplicatation, didn't think of that.

I'll start putting the log in the /var/log folder.

-Jeff

On Sun, Dec 16, 2012 at 3:41 PM, Brandt Daniels < notifications@github.com>wrote:

Couple of things:

Copying files takes some time. Can we have ES first look in /root/roms then look in /mnt/usbdisk? I would rather have it just read my roms off the stick. This will avoid duplication or whatever other mess it could cause.

Second, logs should go in /var/log(s)/glint/gn.log

-Brandt

Sent from my iPhone

On Dec 16, 2012, at 12:55 PM, Jeff Lunt notifications@github.com wrote:

I should have just put this in here instead of in an email:

I'd like to get a release out this week. Can we do the following with the auto-mount script?

User inserts USB stick, which is auto mounted All .nes files are copied to /root/roms Launch executable /root/glint-es/glint-es &> /root/gn.log (this log file helps me troubleshoot problems with EmulationStation) — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub< https://github.com/normalocity/glint-nes/issues/5#issuecomment-11423326>.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHubhttps://github.com/normalocity/glint-nes/issues/5#issuecomment-11424015.

brandtdaniels commented 11 years ago

the only thing that needs to be fleshed out more is the autofs file auto.ext-usb:

usbdisk -fstype=auto :/dev/usbdisk1

need to see if the 1 can be a matching statement such as [1-9]

brandtdaniels commented 11 years ago

Created a script for this if you want to integrate:

#!/usr/bin/env bash
#install autofs and udev
sudo apt-get -y install autofs udev
#create the mount point
sudo mkdir -p /mnt/usbdisk
#create a new udev rules file and add line
sudo echo -n 'ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd?[1-9]", SYMLINK+="usbdisk%n", RUN+="/usr/local/bin/copyroms.sh"' > /etc/udev/rules.d/80-usbdisk.rules
#restart udev
sudo /etc/init.d/udev restart
#add line to autofs file auto.master
sudo echo "/mnt /etc/auto.ext-usb --timeout=10,defaults,user,exec,uid=1000" >> /etc/auto.master
#create file and add line
sudo echo -n "usbdisk -fstype=auto :/dev/usbdisk1" > /etc/auto.ext-usb
#restart autofs
sudo /etc/init.d/autofs restart
jefflunt commented 11 years ago

Fucking awesome! I'll try it tonight - this is the big piece I'm really excited about.

-Jeff

On Sun, Dec 23, 2012 at 2:37 PM, Brandt Daniels notifications@github.comwrote:

Created a script for this if you want to integrate:

!/usr/bin/env bash

install autofs and udev

apt-get -y install autofs udev

create the mount point

mkdir -p /mnt/usbdisk

create a new udev rules file and add line

echo -n "SUBSYSTEMS=="usb", KERNEL=="sd?[1-9]", SYMLINK+="usbdisk%n"" > /etc/udev/rules.d/00-custom.rules

restart udev

/etc/init.d/udev restart

add line to autofs file auto.master

echo "/mnt /etc/auto.ext-usb --timeout=10,defaults,user,exec,uid=1000" >> /etc/auto.master

create file and add line

echo -n "usbdisk -fstype=auto :/dev/usbdisk1" > /etc/auto.ext-usb

restart autofs

/etc/init.d/autofs restart

— Reply to this email directly or view it on GitHubhttps://github.com/normalocity/glint-nes/issues/5#issuecomment-11650334.

brandtdaniels commented 11 years ago

created a script to copy the roms (/usr/local/bin/copyroms.sh):

#!/bin/bash
export HOME="/home/pi"
SOURCE="/mnt/usbdisk"
TARGET="/home/pi/roms"
if [ -d "$TARGET" ]; then
   rm -rf $TARGET/*
fi
if [ -d "$SOURCE" ]; then
   find $SOURCE -type f \( -name "*.nes" -o -name "*.NES" -o -name "*.Nes" \) -a \( ! -regex '.*/\..*' \) -exec cp {} $TARGET \; 
   echo "Copied ROMs to $TARGET" >> /var/log/syslog
   killall glint-es && /home/pi/glint-es/glint-es &
else
   echo "ERR: $SOURCE does not exist."   
   exit 1
fi
exit 0
brandtdaniels commented 11 years ago

updated both scripts above...tested and working well...

jefflunt commented 11 years ago

Got this stuff integrated into the wheezy-current branch. Working on getting some requite changes applied in glint-es as well, and then it's off to create a new release.

jefflunt commented 11 years ago

glint-es will now start with an empty game list and prompt the user to insert a USB stick to add games.

I'll close this case when I merge the changes to master.

brandtdaniels commented 11 years ago

Let's do an internal release first amongst all involved in this project before a public release.

jefflunt commented 11 years ago

This has been fully integrated into the latest release.

jefflunt commented 11 years ago

The feedback and other things that get fixed because other people are trying it is too valuable.

-Jeff

On Sun, Jan 6, 2013 at 12:51 AM, Brandt Daniels notifications@github.comwrote:

Let's do an internal release first amongst all involved in this project before a public release.

— Reply to this email directly or view it on GitHubhttps://github.com/normalocity/glint-nes/issues/5#issuecomment-11925221.