Skip to content

Instantly share code, notes, and snippets.

@UtahDave
Forked from whiteinge/selfinstaller.bzx
Last active August 29, 2015 14:18
Show Gist options
  • Save UtahDave/cc267232084b4678f5d6 to your computer and use it in GitHub Desktop.
Save UtahDave/cc267232084b4678f5d6 to your computer and use it in GitHub Desktop.
#!/bin/sh
# A self-extracting installer for RPMs
#
# To create: make a gzip-compressed tarball of RPMs (with no subdirectory),
# convert to base64, then concatenate onto the end of this file::
#
# cd /some/directory/of/rpm/files
# tar -cz *.rpm | base64 -w0 >> selfinstaller.bzx
main() {
echo -e "\nSelf Extracting Installer\n"
TMPDIR=`mktemp -d /tmp/selfextract.XXXXXX`
trap 'rm -rf '$TMPDIR SIGINT SIGTERM EXIT
ARCHIVE=`awk '/^__ARCHIVE_BELOW__/ { print NR + 1; exit 0; }' $0`
tail -n+$ARCHIVE $0 | base64 -d | tar -C $TMPDIR -xz || \
{ echo "Bad archive. Exiting."; return 1; }
echo "Installing:"
find $TMPDIR -name '*rpm' -print | awk -F/ '{ print $NF } END { print }'
yum localinstall --nogpgcheck -q -y $TMPDIR/*rpm
return $?
}
main "$@"
exit $?
__ARCHIVE_BELOW__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment