Skip to content

Instantly share code, notes, and snippets.

@raykao
Created February 10, 2017 19:58
Show Gist options
  • Save raykao/9580c944c0df846fd9b6ff357bb1dabe to your computer and use it in GitHub Desktop.
Save raykao/9580c944c0df846fd9b6ff357bb1dabe to your computer and use it in GitHub Desktop.
Downloads the galera.cnf config file to the MariaDB config.d path, then replaces values with the current machine's info.
#!/usr/bin/env bash
sudo -i
cd /etc/mysql/conf.d
wget https://gist.githubusercontent.com/raykao/027e42847392a0eafb6c7b51c3291191/raw/a328e20eb13e2e129101dea460e1bd592d7f1c3b/galera.cnf
sed -i "s/first_ip/$(ip -4 addr ls eth0 | awk '/inet / {print $2}' | cut -d"/" -f1)/g" galera.cnf
sed -i "s/this_node_ip/$(ip -4 addr ls eth0 | awk '/inet / {print $2}' | cut -d"/" -f1)/g" galera.cnf
sed -i "s/this_node_name/$(hostname)/g" galera.cnf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment