Skip to content

Instantly share code, notes, and snippets.

@louieli
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save louieli/9325613 to your computer and use it in GitHub Desktop.

Select an option

Save louieli/9325613 to your computer and use it in GitHub Desktop.
自安装脚本
# 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