Skip to content

Commit 8cd1256

Browse files
committed
Added support for parallel disc ripping.
1 parent 145ad5b commit 8cd1256

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

rootfs/etc/services.d/autodiscripper/run rootfs/defaults/autodiscripper.run

+19-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ if [ ! -L "$0" ]; then
1010
exec ./"$SV_NAME" "$@"
1111
fi
1212

13+
# Name of the service.
14+
SV_NAME="$(basename "$0")"
15+
16+
# Set the prefix of makemkvcon log messages.
17+
MAKEMKVCON_LOG_PREFIX="[makemkvcon]"
18+
if echo "$SV_NAME" | grep -q '^autodiscripper-[0-9]\+$'; then
19+
MAKEMKVCON_LOG_PREFIX="[makemkvcon-$(echo "$SV_NAME" | cut -d'-' -f2)]"
20+
fi
21+
1322
# Set umask.
1423
if [ "${UMASK:-UNSET}" != "UNSET" ]; then
1524
umask "$UMASK"
@@ -21,7 +30,7 @@ log() {
2130

2231
log_makemkvcon() {
2332
if [ "${LAST_MSG:-UNSET}" != "$*" ]; then
24-
echo "[makemkvcon] $*"
33+
echo "$MAKEMKVCON_LOG_PREFIX $*"
2534
LAST_MSG="$*"
2635
fi
2736
}
@@ -124,7 +133,15 @@ FIRST_RUN=1
124133
while true; do
125134
# Fetch information about optical drives.
126135
DRIVES_INFO="$(mktemp)"
127-
$MAKEMKV_CLI -r --cache=1 info disc:9999 | grep "^DRV:" > "$DRIVES_INFO" 2>&1
136+
137+
# Based on the service name, determine if we need to handle all drives or a
138+
# single one.
139+
if echo "$SV_NAME" | grep -q '^autodiscripper-[0-9]\+$'; then
140+
ID="$(echo "$SV_NAME" | cut -d'-' -f2)"
141+
$MAKEMKV_CLI -r --cache=1 info disc:9999 | grep "^DRV:$ID," > "$DRIVES_INFO" 2>&1
142+
else
143+
$MAKEMKV_CLI -r --cache=1 info disc:9999 | grep "^DRV:" > "$DRIVES_INFO" 2>&1
144+
fi
128145

129146
# Loop through all drives.
130147
while read -r DRV; do
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/with-contenv sh
2+
3+
set -e # Exit immediately if a command exits with a non-zero status.
4+
set -u # Treat unset variables as an error.
5+
6+
log() {
7+
echo "[cont-init.d] $(basename $0): $*"
8+
}
9+
10+
MAKEMKV_CLI="env HOME=/config LD_PRELOAD=/opt/makemkv/lib/umask_wrapper.so /opt/makemkv/bin/makemkvcon"
11+
12+
# Clear actual services, if any.
13+
rm -rf /etc/services.d/autodiscripper*
14+
15+
if [ "${AUTO_DISC_RIPPER:-0}" -eq 0 ]; then
16+
log "automatic disc ripper disabled."
17+
exit 0
18+
fi
19+
20+
if [ "${MAKEMKV_OPTICAL_DRIVE_PRESENT:-0}" -eq 0 ]; then
21+
log "no usable optical drive available."
22+
exit 0
23+
fi
24+
25+
if [ "${AUTO_DISC_RIPPER_PARALLEL_RIP:-0}" -eq 0 ]; then
26+
log "installing automatic disc ripper service..."
27+
mkdir /etc/services.d/autodiscripper
28+
cp /defaults/autodiscripper.run /etc/services.d/autodiscripper/run
29+
else
30+
$MAKEMKV_CLI -r --cache=1 info disc:9999 | grep "^DRV:[0-9]\+,[1|2]," | while read DRV_INFO
31+
do
32+
DRV_ID="$(echo "$DRV_INFO" | cut -d',' -f1 | cut -d':' -f2)"
33+
DRV_NAME="$(echo "$DRV_INFO" | cut -d',' -f5 | tr -d '"')"
34+
35+
log "installing automatic disc ripper for drive $DRV_ID ($DRV_NAME)..."
36+
mkdir /etc/services.d/autodiscripper-$DRV_ID
37+
cp /defaults/autodiscripper.run /etc/services.d/autodiscripper-$DRV_ID/run
38+
done
39+
fi
40+
41+
# vim: set ft=sh :

0 commit comments

Comments
 (0)