Created
July 9, 2014 02:14
-
-
Save sstelfox/6087d2108ba97bf2161a to your computer and use it in GitHub Desktop.
Override the linux library responsible for the host file too allow for alternate locations
This file contains hidden or 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
| #!/bin/bash | |
| OVERRIDE_PATH="./lib_overrides" | |
| COMMAND="${1}"; shift | |
| ARGUMENTS="$@" | |
| mkdir -p ${OVERRIDE_PATH} | |
| # Ensure the host file exists at our new location | |
| if [ ! -f /tmp/hosts ]; then | |
| cp /etc/hosts /tmp/hosts | |
| fi | |
| for LIB in $(find / -name libnss_files.so.2 -print 2> /dev/null); do | |
| # Generally there is both a 32bit and 64bit version, differentiate them with | |
| # their parent dir. | |
| DIR=$(basename $(dirname ${LIB})); | |
| NEW_LIB_PATH="${OVERRIDE_PATH}/${DIR}/$(basename ${LIB})" | |
| if [ ! -f ${NEW_LIB_PATH} ]; then | |
| mkdir -p $(dirname ${NEW_LIB_PATH}) | |
| cp ${LIB} ${NEW_LIB_PATH} | |
| sed -ie 's:/etc/hosts:/tmp/hosts:g' ${NEW_LIB_PATH} | |
| fi | |
| LD_LIBRARY_PATH="${OVERRIDE_PATH}/${DIR}:${LD_LIBRARY_PATH}" | |
| done | |
| echo ${LD_LIBRARY_PATH} | |
| export LD_LIBRARY_PATH | |
| ${COMMAND} ${ARGUMENTS} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment