Last active
October 28, 2022 08:20
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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