Last active
February 28, 2016 15:15
-
-
Save nonchip/ba7ef0222ec2ec08b49a to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# selfrun.sh <executable> | |
# creates "<executable>.standalone" containing "." and extracting&running itself. | |
export _ROOT="/tmp/.nc.selfrun.$(uuidgen)-$(uuidgen)" | |
cat > "${1}.standalone" <<END | |
#!/bin/bash | |
export self="\$(readlink -f "\$0")" | |
if test -e $_ROOT | |
then cd $_ROOT | |
else | |
mkdir $_ROOT | |
cd $_ROOT | |
tail -n +11 "\$self" | tar xj | |
fi | |
exec ./${1} "\$@" | |
END | |
tar cj * >> "${1}.standalone" | |
chmod +rx "${1}.standalone" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment