The basic idea of creating a self-extracting installer in Bash is really straightforward. We just need to append the binary package, e.g. an archive file in our installer script.
Here's a simple example on how to do that.
- Create an installer script
#!/bin/bash
echo "Running self-extracting installer"
ARCHIVE=`awk '/^__START_HERE__/ {print NR + 1; exit 0; }' $0`
echo $ARCHIVE
tail -n+$ARCHIVE $0 | tar xzv
exit 0
__START_HERE__
- Append an archive file into an installer script
cat myproject.tar.gz >> installer
- Give an executable permission
chmod +x installer
- Execute the installer script
./installer
No comments:
Post a Comment