Skip to content

Instantly share code, notes, and snippets.

@whiteinge
Last active August 29, 2015 13:56
Show Gist options
  • Save whiteinge/8851059 to your computer and use it in GitHub Desktop.
Save whiteinge/8851059 to your computer and use it in GitHub Desktop.
Self-extracting RPM installer
#!/bin/sh
# A self-extracting installer for RPMs
#
# Requires: POSIX env, base64, and mktemp.
#
# 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() {
printf '\nSelf Extracting Installer\n'
local TMPDIR=$(mktemp -d /tmp/selfextract.XXXXXX)
trap 'rm -rf '"$TMPDIR" SIGINT SIGTERM EXIT
local ARCHIVE=$(awk '/^__ARCHIVE_BELOW__/ { print NR + 1; exit 0; }' $0)
tail -n+"$ARCHIVE" "$0" | base64 -d | tar -C "$TMPDIR" -xz || \
{ printf 'Bad archive. Exiting.\n'; return 1; }
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