Last active
February 14, 2016 14:41
-
-
Save phaus/344ae00a3a714765f5d8 to your computer and use it in GitHub Desktop.
DVD Indexer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file maintains persistent names for CD/DVD reader and writer devices. | |
# See udev(7) for syntax. | |
# | |
# Entries are automatically added by the 75-cd-aliases-generator.rules | |
# file; however you are also free to add your own entries provided you | |
# add the ENV{GENERATED}=1 flag to your own rules as well. | |
# VBOX_CD-ROM (pci-0000:00:01.1-scsi-0:0:1:0) | |
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-0:0:1:0", SYMLINK+="cdrom", ENV{GENERATED}="1" | |
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-0:0:1:0", SYMLINK+="dvd", ENV{GENERATED}="1" | |
# VBOX_CD-ROM (pci-0000:00:01.1-scsi-0:0:0:0) | |
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-0:0:0:0", SYMLINK+="cdrom1", ENV{GENERATED}="1" | |
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-0:0:0:0", SYMLINK+="dvd1", ENV{GENERATED}="1" | |
# VBOX_CD-ROM (pci-0000:00:01.1-scsi-0:0:0:0) | |
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-0:0:0:0", SYMLINK+="cdrom2", ENV{GENERATED}="1" | |
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-0:0:0:0", SYMLINK+="dvd2", ENV{GENERATED}="1" | |
# VBOX_CD-ROM (pci-0000:00:01.1-scsi-0:0:1:0) | |
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-0:0:1:0", SYMLINK+="cdrom3", ENV{GENERATED}="1" | |
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-0:0:1:0", SYMLINK+="dvd3", ENV{GENERATED}="1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# VBOX_CD-ROM (pci-0000:00:01.1-scsi-0:0:0:0) | |
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-0:0:0:0", RUN+="/usr/local/bin/autodvd", ENV{GENERATED}="1" | |
# VBOX_CD-ROM (pci-0000:00:01.1-scsi-1:0:1:0) | |
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-1:0:1:0", RUN+="/usr/local/bin/autodvd", ENV{GENERATED}="1" | |
# VBOX_CD-ROM (pci-0000:00:01.1-scsi-0:0:1:0) | |
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-0:0:1:0", RUN+="/usr/local/bin/autodvd", ENV{GENERATED}="1" | |
# VBOX_CD-ROM (pci-0000:00:01.1-scsi-1:0:0:0) | |
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-1:0:0:0", RUN+="/usr/local/bin/autodvd", ENV{GENERATED}="1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
{ | |
env | |
if [ $ID_CDROM_MEDIA -eq 1 ]; then | |
mkdir -p /vagrant/dvdindex/dev | |
dev=`echo $DEVLINKS | cut -d ' ' -f 1` | |
devlock=/vagrant/dvdindex$DEVNAME.lock | |
if [ ! -f $devlock ]; then | |
touch $devlock | |
mkdir -p /var/run/usbmount$DEVNAME | |
mount -t $ID_FS_TYPE -o ro $dev /var/run/usbmount$DEVNAME | |
sum=`find /var/run/usbmount$DEVNAME -type f -print0 | sort -z | xargs -0 sha1sum | sha1sum | cut -d ' ' -f 1` | |
logfile=/vagrant/dvdindex/$sum.nfo | |
isofile=/vagrant/dvdindex/$sum.iso | |
lockfile=/vagrant/dvdindex/$sum.lock | |
touch $lockfile | |
echo "label $ID_FS_LABEL_ENC" > $logfile | |
echo "" >> $logfile | |
echo "folder $sum" >> $logfile | |
echo "" >> $logfile | |
ls -alR /var/run/usbmount$DEVNAME >> $logfile | |
umount -l /var/run/usbmount$DEVNAME | |
dd if=$dev of=$isofile bs=4194304 | |
sum=`sha1sum $isofile | cut -d ' ' -f 1` | |
echo "iso $sum" >> $logfile | |
rm $lockfile | |
rm $devlock | |
eject | |
fi | |
else | |
umount -l /var/run/usbmount$DEVNAME | |
rm -rf /var/run/usbmount$DEVNAME | |
fi | |
} &>> "/var/log/autodvd.log" & |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.hostname = "dvdindex" | |
# Every Vagrant virtual environment requires a box to build off of. | |
config.vm.box = "dvdindex" | |
config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box" | |
config.vm.provider "virtualbox" do |vb| | |
vb.name = "dvdindex" | |
vb.memory = 1024 | |
vb.cpus = 1 | |
vb.customize ["storagectl", :id, "--name", "IDE Controller", "--add", "ide"] | |
vb.customize ["storageattach", :id, "--storagectl", "IDE Controller", "--port", "0", "--device", "0", "--type", "dvddrive", "--medium", "emptydrive"] | |
# optional for HW DVD - comment above line then. | |
# vb.customize ["storageattach", :id, "--storagectl", "IDE Controller", "--port", "0", "--device", "0", "--type", "dvddrive", "--medium", "host:00445644-4152-204d-4748-32324c533730"] | |
vb.customize ["storageattach", :id, "--storagectl", "IDE Controller", "--port", "0", "--device", "1", "--type", "dvddrive", "--medium", "emptydrive"] | |
vb.customize ["storageattach", :id, "--storagectl", "IDE Controller", "--port", "1", "--device", "0", "--type", "dvddrive", "--medium", "emptydrive"] | |
vb.customize ["storageattach", :id, "--storagectl", "IDE Controller", "--port", "1", "--device", "1", "--type", "dvddrive", "--medium", "emptydrive"] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment