-
Notifications
You must be signed in to change notification settings - Fork 0
/
XbOSX.sh
executable file
·55 lines (47 loc) · 1.52 KB
/
XbOSX.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
PCBYTES="55AA"
XBOXBYTES="99CC"
STARTINGBYTES="0x1FE"
BYTELENGTH="0x02"
DISKLOCATION="$2"
FLAG="$1"
# Check if disk is mounted
if [ -z "$DISKLOCATION" ]; then
echo "No disk location specified"
exit 1
fi
#check if flag is set
if [ -z "$FLAG" ]; then
echo "No flag specified"
exit 1
fi
if [[ "${FLAG}" == "check" ]]; then
sudo xxd -u -ps -s "${STARTINGBYTES}" -l "${BYTELENGTH}" "${DISKLOCATION}"
else
if [[ "${FLAG}" == "pc" ]]; then
echo "Are you sure you want to write to ${DISKLOCATION}? (y/n)"
read -r -n 1 -s
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Writing PC boot sector to ${DISKLOCATION}"
echo "${PCBYTES}" | sudo xxd -u -ps -s "${STARTINGBYTES}" -l "${BYTELENGTH}" -r - "${DISKLOCATION}"
echo -e "Done \a"
else
echo "Exiting"
exit 1
fi
elif [[ "${FLAG}" == "xbox" ]]; then
echo "Are you sure you want to write to ${DISKLOCATION}? (y/n)"
read -r -n 1 -s
if [[ $REPLY =~ ^[Yy]$ ]]; then
diskutil unmountDisk "${DISKLOCATION}" && echo "Writing Xbox boot sector to ${DISKLOCATION}"; \
echo "${XBOXBYTES}" | sudo xxd -u -ps -s "${STARTINGBYTES}" -l "${BYTELENGTH}" -r - "${DISKLOCATION}"
echo -e "Done \a"
else
echo "Exiting"
exit 1
fi
else
echo "Invalid flag"
exit 1
fi
fi