2 # The purpose of this script is to encapsulate the calls
3 # made to the rip_dvd script. This is done to help distribute
4 # the resulting ripped files to the proper folders. This
5 # script is called from the mythtv menus for example with a
6 # smaller set of options.
8 ##############################################
9 # Don't run if a previous rip attempt is still running
10 SCRIPT_NAME1="rip_dvd.wrap"
11 SCRIPT_NAME2="xterm -T Ripping"
14 GRAND_PID=$(ps -ef | grep "^[a-zA-Z]* [ ]* $PARENT_PID " | awk '{print $3}')
15 GREAT_GRAND_PID=$(ps -ef | grep "^[a-zA-Z]* [ ]* $GRAND_PID " | awk '{print $3}')
16 ps -ef | grep -e "$SCRIPT_NAME1" -e "$SCRIPT_NAME2" | grep -v grep | grep -v $MY_PID | grep -v $PARENT_PID | grep -v $GRAND_PID | grep -v $GREAT_GRAND_PID
17 if [[ $? == 0 ]]; then
18 echo -e "-E- Found an instance of this script already running. Aborting this additional attempt to rip..."
19 echo -e " my_pid=$MY_PID parent_pid=$PARENT_PID grand_pid=$GRAND_PID great_grand_pid=$GREAT_GRAND_PID\n"
20 CALLER=$(ps -ef | grep "^[a-zA-Z]* [ ]* $PPID " | awk '{print $3}')
21 CALLER_CALLER=$(ps -ef | grep "^[a-zA-Z]* [ ]* $CALLER " | awk '{print $3}')
22 echo I was called from $CALLER who was called by $CALLER_CALLER
23 ps -ef | grep $MY_PID | grep -v grep
24 ps -ef | grep $PARENT_PID | grep -v grep
28 ##############################################
29 # COMMAND LINE PROCESSING
31 # get the dvdtype from the command line
34 # remove the dvdtype from the args, and interpret the rest
35 # of the args to be passed directly to the rip_dvd script.
38 ##############################################
39 if [ -z "$dvdtype" ]; then
40 echo "-E- $0 <dvdtype>' is a required option"
44 mydir=$(cd $(dirname $0) && pwd)
47 if [ -x "$mydir/rip_dvd" ]
49 ripcmd="$mydir/rip_dvd"
51 echo >&2 "Cannot find your rip_dvd command!"
56 ##############################################################################
57 # Local Machine Settings:
58 # Sources both the "default" conf file tracked by GIT (rip_dvd.conf.dist)
59 # and the local conf file created by each local machine (rip_dvd.conf)
60 # Copy the rip_dvd.conf.dist file to rip_dvd.conf and edit the later.
61 # This will allow you to override all the default values to meet your needs
62 # in a way that won't get clobbered when you pull updates from my GIT repo.
63 ##############################################################################
64 config="${0%/*}/rip_dvd.conf"
66 # The config file will be searched for in the following location order:
69 # 1) /path/to/rip_dvd/script/rip_dvd.conf.dist
70 [ -e "${config}.dist" ] && found_config=1 && . "${config}.dist"
72 # 2) /path/to/rip_dvd/script/rip_dvd.conf
73 [ -e "${config}" ] && found_config=1 && . "${config}"
75 # 3) /etc/rip_dvd.conf
76 [ -e "/etc/rip_dvd.conf" ] && found_config=1 && . "/etc/rip_dvd.conf"
78 # 4) $PWD/rip_dvd.conf
79 [ -e "$PWD/rip_dvd.conf" ] && found_config=1 && . "$PWD/rip_dvd.conf"
81 # Check to make sure we found the config file
82 if [ $found_config -eq 0 ]; then
83 echo "-E- Unable to find the rip_dvd.conf file: $config"
87 ##############################################
88 # get the name of the DVD from the DVD disk
89 dvdname=`volname $dev | awk '{ print $1 }'`
90 dvdname=${dvdname%.} # remove trailing '.' character
92 ##############################################
93 # Find out what type of DVD we are ripping
94 # And set our destination directory appropriately
96 # - netflix = DVD ripped as an entire ISO image
97 # since these are only kept around until we watch them,
98 # there is no need to do anything less than full iso.
99 # - collection = Only DVD main feature is ripped
100 # - childrens = Only DVD main feature is ripped
101 # - church = Only DVD main feature is ripped
103 if [ "$dvdtype" == "netflix" ]; then
104 echo "-> Ripping Netflix DVD"
105 dest=/myth/video/DVDs/Netflix
107 elif [ "$dvdtype" == "collection" ]; then
108 echo "-> Ripping Personal Collection DVD"
109 dest=/myth/video/DVDs/Collection
111 elif [ "$dvdtype" == "childrens" ]; then
112 echo "-> Ripping Children's DVD"
113 dest=/myth/video/DVDs/Childrens
115 elif [ "$dvdtype" == "church" ]; then
116 echo "-> Ripping Church DVD"
117 dest=/myth/video/DVDs/Church
120 echo '-E- Must specify dvdtype as "netflix" or "collection" or "childrens" or "church"'
124 ##############################################
125 # Display progress window
127 # Pop up an xterm window and run the script inside of it
128 echo "xterm -T \"Ripping->$dvdname\" -geometry 72x15+20+10 -bg black -fg white -e \"/bin/bash\" -c \"$ripcmd -d $dest $rip_opts\" &"
129 xterm -T "Ripping->$dvdname" -geometry 72x15+20+10 -bg black -fg white -e "/bin/bash" -c "$ripcmd -d $dest $rip_opts" &
131 ##############################################
132 # OR display the script output directly in the terminal it's called from
133 #$ripcmd -d $dest $rip_opts
135 ##############################################