Skip to content

Instantly share code, notes, and snippets.

@elieux
Created June 15, 2016 19:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elieux/93962c687650b60df7c8ac0b71ed06bf to your computer and use it in GitHub Desktop.
Save elieux/93962c687650b60df7c8ac0b71ed06bf to your computer and use it in GitHub Desktop.
Alternative Midipix startup script
#!/bin/sh
prepend_path() {
local _pname _pname_prepend="${1}" IFS=":"
for _pname in ${PATH}; do
if [ "${_pname}" = "${_pname_prepend}" ]; then
return
fi
done
export PATH="${_pname_prepend}${PATH:+:${PATH}}"
}
prepend_path "/bin"
export MSYS2_ARG_CONV_EXCL="*"
if [ "${1}" = -h ]; then
echo "Usage: $0 [path_to_native]"
exit 0
elif [ ${#} -eq 0 ]; then
PWD_ABSOLUTE="$(cygpath -am native)" || exit 1
MIDIPIX_PATH="${PWD_ABSOLUTE%%:*}${PWD_ABSOLUTE#*:}"
unset PWD_ABSOLUTE
elif [ ${#} -eq 1 ]; then
MIDIPIX_PATH="${1}"
else
echo "Usage: $0 [path_to_native]"
exit 6
fi
if [ "${MIDIPIX_PATH#*[ ]*}" != "${MIDIPIX_PATH}" ]; then
echo "Error: path_to_native must not contain spaces nor tabs."
exit 3
fi
MIDIPIX_PATH=${MIDIPIX_PATH#/}
MIDIPIX_PATH=${MIDIPIX_PATH%/}
if [ ! -f "/proc/cygdrive/${MIDIPIX_PATH}/bin/ntctty.exe" ]; then
echo "Error: Midipix path invalid. Could not find '/${MIDIPIX_PATH}/bin/ntctty.exe'."
exit 4
else
if [ -f "/proc/cygdrive/${MIDIPIX_PATH}/bin/libpsxscl.log" ]; then
echo "Found libpsxscl.log, copying to /${MIDIPIX_PATH}/libpsxscl.last."
mv "/proc/cygdrive/${MIDIPIX_PATH}/bin/libpsxscl.log" "/proc/cygdrive/${MIDIPIX_PATH}/libpsxscl.last" || exit 5
fi
echo "Midipix native root: /${MIDIPIX_PATH}"
mintty -h always -e /bin/sh -c "
set -o errexit
stty raw -echo
cd /proc/cygdrive/${MIDIPIX_PATH}/bin
export PATH=/proc/cygdrive/${MIDIPIX_PATH}/bin:/proc/cygdrive/${MIDIPIX_PATH}/lib
./ntctty.exe -e chroot //${MIDIPIX_PATH} /bin/bash" &
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment