Created
April 22, 2016 14:34
-
-
Save mandarjog/834259245f5558503225b6f146a29266 to your computer and use it in GitHub Desktop.
After a 1.7+ opsmanager restarts with a new ip address, this script will update it in the database
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 | |
# After a 1.7+ opsmanager restarts with a new ip address | |
# ssh into the opsmanager as 'ubuntu' and | |
# Run this file from the opsmanager as follows | |
# sudo su -l postgres < thisfile.sh > | |
# Get the current public ip or hostname from aws metadata | |
HN=$(curl http://169.254.169.254/latest/meta-data/public-hostname) | |
if [[ -z ${HN} ]];then | |
HN=$(curl http://169.254.169.254/latest/meta-data/public-ipv4) | |
fi | |
# get the current hostname | |
psql -d tempest_production -c "SELECT id, hostname from uaa_configs" | |
# update to hn | |
psql -d tempest_production -c "UPDATE uaa_configs set hostname='${HN}' where id=1" | |
# show the updated hostname | |
psql -d tempest_production -c "SELECT id, hostname from uaa_configs" | |
# A typical session | |
# ubuntu@ip-10-0-0-108:~$ sudo su -l postgres /home/ubuntu/hn.sh | |
# % Total % Received % Xferd Average Speed Time Time Time Current | |
# Dload Upload Total Spent Left Speed | |
# 100 40 100 40 0 0 3579 0 --:--:-- --:--:-- --:--:-- 4000 | |
# id | hostname | |
# ----+------------------------------------------ | |
# 1 | ec2-52-91-240-11.compute-1.amazonaws.com | |
# (1 row) | |
# | |
# UPDATE 1 | |
# id | hostname | |
# ----+------------------------------------------ | |
# 1 | ec2-52-90-243-58.compute-1.amazonaws.com | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This needs to add:
sudo service tempest-web stop
sudo service tempest-web start