Skip to content

Instantly share code, notes, and snippets.

@user890104
Last active December 21, 2016 19:29
Show Gist options
  • Save user890104/a8afb3d61cfeed451195ae50003099f1 to your computer and use it in GitHub Desktop.
Save user890104/a8afb3d61cfeed451195ae50003099f1 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
BIN_NAME=shairport-sync
BIN_SRC=/usr/bin
BINARY="${BIN_SRC}/${BIN_NAME}"
PATCH_DIR=/tmp/shairport-patch
PATCH_BIN="${PATCH_DIR}/${BIN_NAME}"
PATCH_NAME="${PATCH_DIR}/string"
if [ ! -f "${BINARY}" ]
then
echo binary not found
exit 1
fi
OFFSET=$(strings -t d /usr/bin/shairport-sync | grep -F 'AirPort4,107' | awk '{ print $1 }')
if [ -z "${OFFSET}" ]
then
echo substring not found
exit 1
fi
mkdir -p "${PATCH_DIR}"
echo -n ShairportSyn > "${PATCH_NAME}"
cp -p "${BINARY}" "${PATCH_BIN}"
dd if="${PATCH_NAME}" of="${PATCH_BIN}" obs=1 seek="$[${OFFSET} + 3]" conv=notrunc
mv "${BINARY}" "${BINARY}.bak"
mv "${PATCH_BIN}" "${BINARY}"
rm -rf "${PATCH_DIR}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment