Last active
August 29, 2015 13:56
-
-
Save louieli/9325613 to your computer and use it in GitHub Desktop.
自安装脚本
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
| # tar cjf hello.tar.bz2 hello | |
| # cat install.sh | |
| #!/bin/bash | |
| install_dir=/tmp/hello | |
| if [[ -e $install_dir ]];then | |
| rm -rf $install_dir && make $install_dir | |
| else | |
| mkdir $install_dir | |
| fi | |
| sed -n '1,/^exit 0$/!p' $0 >$install_dir/hello.tar.bz2 | |
| cd $install_dir && tar xf hello.tar.bz2 && cp hello /bin && chmod +x /bin/hello | |
| exit 0 | |
| cat install.sh hello.tar.bz2 >myinstall.bin | |
| #!/bin/bash | |
| INSTDIR=/default/install/path/ | |
| ARCHIVE=`awk '/^__ARCHIVE_BELOW__/ {print NR + 1; exit 0; }' $0` | |
| tail -n+$ARCHIVE $0 | tar xzv -C $TMPDIR | |
| CDIR=`pwd` | |
| cd $TMPDIR | |
| ./install $INSTDIR | |
| cd $CDIR | |
| rm -rf $TMPDIR | |
| exit 0 | |
| __ARCHIVE_BELOW__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment