-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbash-recreate_subscriptions.sh
More file actions
20 lines (17 loc) · 1010 Bytes
/
bash-recreate_subscriptions.sh
File metadata and controls
20 lines (17 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
# Resubscription from .csv file generated by Ansible
INVFILE="$1"
SATHOST="$2"
ORGNAME="$3"
LOGFILE="${HOME}/content_host_resubscription.log"
rm -f ${LOGFILE}
touch ${LOGFILE}
while read line; do
NAME=`echo "${line}" | awk -F"," '{ print $1 }'`
HOST=`echo "${line}" | awk -F"," '{ print $2 }'`
ACTKEY=`echo "${line}" | awk -F"," '{ print $4 }'`
SSHKEY=`echo "${line}" | awk -F"," '{ print $12 }'`.pem
echo "Resubscribing ${NAME}:"
echo "ssh -t -t -i ${HOME}/.ssh/${SSHKEY} ${HOST} \"sudo /bin/subscription-manager unregister; sudo /bin/yum -y erase katello-ca-consumer-satellite*; sudo /bin/subscription-manager clean; sudo /bin/curl --insecure --remote-name https://${SATHOST}/pub/katello-ca-consumer-latest.noarch.rpm; sudo /bin/rpm -Uvh katello-ca-consumer-latest.noarch.rpm; sudo /bin/subscription-manager register --org ${ORGNAME} --activationkey ${ACTKEY}; sudo /bin/yum clean all; sudo systemctl restart goferd\"" | sh
echo
done < $INVFILE | tee -a ${LOGFILE}