-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env bash | ||
|
||
# DEFINE ERROR HANDLERS. | ||
set -e | ||
# Since we have set -e, any errors will cause the script to exit immediately, | ||
# so we must trap EXIT instead. | ||
trap cleanup EXIT | ||
cleanup() { | ||
echo -e "\nAttempting to clean up mount points and attached disks..." | ||
# We don't want to show any more errors. | ||
umount "$mount_point" | ||
rmdir "$mount_point" | ||
diskutil eject "$disk_identifier" | ||
} | ||
|
||
# TODO: Verify the command line arguments and provide usage. | ||
|
||
# STORE THE PATHS. | ||
iso_path="$1" | ||
mount_point="$(mktemp -d)" | ||
cwd="$(pwd)" | ||
|
||
# ATTACH THE DISK IMAGE. | ||
# When a disk image contains an HFS volume, the disk must | ||
# be attached and THEN mounted, which is just a fluke of | ||
# newer Macs I guess. | ||
# | ||
# When a partition is successfully attached, | ||
# `hdiutil` returns output like the following: | ||
# /dev/disk4 Apple_partition_scheme | ||
# /dev/disk4s1 Apple_partition_map | ||
# /dev/disk4s2 ISO | ||
# /dev/disk4s3 Apple_HFS | ||
# | ||
# The "ISO" line corresponds to the PC filesystem, and the | ||
# Apple_HFS corresponds (of course) to the HFS volume. | ||
partitions_on_attached_iso=$(hdiutil attach -nomount "$iso_path") | ||
echo $partitions_on_attached_iso | ||
|
||
# MOUNT THE WINDOWS (CD9660) PORTION. | ||
disk_identifier=$(echo "$partitions_on_attached_iso" | awk '{print $1}' | head -n 1) | ||
echo "CD9660 Portion: $mount_point" | ||
mount -t cd9660 "$disk_identifier" "$mount_point" | ||
|
||
# PRINT THE HASHES OF EACH FILE IN THE WINDODWS PORTION. | ||
# This gets the hashes of all files in the root directory. | ||
for file in "$mount_point"/*; do | ||
md5sum "$file" 2> /dev/null | ||
done | grep -v "Not a regular file" | sed "s|$mount_point/||" | awk '{ print $2, $1 }' | ||
# This gets the hashes of all files in subdirectories. | ||
for file in "$mount_point"/**/**; do | ||
md5sum "$file" 2> /dev/null | ||
done | grep -v "Not a regular file" | sed "s|$mount_point/||" | awk '{ print $2, $1 }' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# READ THE COMMAND-LINE ARGUMENTS. | ||
cdrom_device=$1 | ||
index=$2 | ||
|
||
# READ THE CD TOC | ||
cdrdao read-toc --device "$cdrom_device" "$index.toc" | ||
|
||
# CREATE AN ISO IMAGE. | ||
ddrescue -b 2048 -r1 -v "$cdrom_device" "$index.iso" "$index.log" | ||
|
||
# MOUNT THE PC PART OF THE ISO. | ||
echo "*** WINDOWS PARTITION ***" | ||
mount_point=$(mktemp -d) | ||
sudo mount "$index.iso" "$mount_point" | ||
ls -la "$mount_point" | ||
sudo umount "$mount_point" | ||
rmdir "$mount_point" | ||
|
||
echo | ||
echo "*** MAC PARTITION ***" | ||
hmount "$index.iso" | ||
hls | ||
humount |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This folder holds scripts that are useful for developing and debugging Media Station, | ||
but are not related to the main asset extraction. |