Skip to content

Instantly share code, notes, and snippets.

@mhewedy
Last active October 28, 2022 08:20
Show Gist options
  • Save mhewedy/fea40df9071a505e1217927a8bcb6d6b to your computer and use it in GitHub Desktop.
Save mhewedy/fea40df9071a505e1217927a8bcb6d6b to your computer and use it in GitHub Desktop.
Install RPM package (from the internet or from local filesystem) to a remote Linux machine (with no internet access)
#!/bin/bash
set -e
#set -x
if [ "$#" -ne 2 ];
then
echo "Usage: $0 <user@ip> [rpm url|file]"
exit
fi
userip=$1
url=$2
file=$(basename $2)
if [[ $url == http* ]] ;
then
echo "downloading from url"
wget $url -O /tmp/$file
scp /tmp/$file $userip:/tmp
else
echo "using local file"
scp $url $userip:/tmp
fi
ssh $userip "sudo yum install -y /tmp/$file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment