Skip to content

Instantly share code, notes, and snippets.

@UtahDave
Created August 17, 2015 20:31
Show Gist options
  • Select an option

  • Save UtahDave/4378b1018cf07be963be to your computer and use it in GitHub Desktop.

Select an option

Save UtahDave/4378b1018cf07be963be to your computer and use it in GitHub Desktop.
RPM self installer using rpm -Uvh
#!/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
rpm -Uvh $TMPDIR/*rpm
return $?
}
main "$@"
exit $?
__ARCHIVE_BELOW__
@whiteinge

Copy link
Copy Markdown

This has trailing whitespace that breaks the script. Use this version instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment