#! /bin/bash . /usr/src/k_framework/main.sh # ---- VARS ----- VERSION="1.2.3" SCRIPT_NAME="Corosync/Pacemaker/pcsd Install" TEST=0 # 1 - do not execute changes # ---- FUNCTIONS ----- # ---- MAIN ----- k_start k_detect_os # pcs need system ruby which will be installed as dependency # remove symlink to rvm ruby if such exists if [ -L /usr/bin/ruby ]; then rm -f /usr/bin/ruby fi if [[ $centos_version == 7 ]]; then yum -y install corosync pacemaker pcs systemctl enable pcsd systemctl enable corosync systemctl enable pacemaker elif [[ $ROCKY9 == 1 ]]; then dnf --enablerepo=highavailability -y install pacemaker pcs systemctl enable --now pcsd if ! grep -Fq 'alias pcs' /root/.bashrc; then echo "alias pcs='GEM_PATH=\"/usr/share/gems\" pcs'" >> /root/.bashrc report "run this command after scripts exit" 3 report " source /root/.bashrc" fix fi else report "Unssuported OS detected. Exiting" 6 fi systemctl start pcsd if [[ ! -e /root/hacluster_password ]]; then PSW=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c10) echo "$PSW" > /root/hacluster_password chmod 600 /root/hacluster_password cat /root/hacluster_password | passwd --stdin hacluster fi cp -f /usr/src/k_framework/helpers/corosync/resources/asterisk /usr/lib/ocf/resource.d/heartbeat chmod 755 /usr/lib/ocf/resource.d/heartbeat/asterisk cp -f /usr/src/k_framework/helpers/corosync/resources/opensips /usr/lib/ocf/resource.d/heartbeat chmod 755 /usr/lib/ocf/resource.d/heartbeat/opensips if ! grep -q "192.168.0.131" /etc/hosts; then # /etc/hosts has no nodes echo "192.168.0.131 node01 #This is example. Change to correct IP and hostname" >> /etc/hosts echo "192.168.0.132 node02 #Change to correct IP and hostname here as well" >> /etc/hosts fi k_exit $EXIT_CODE