Bash scripting/BACULA CLIENT INSTALL SCRIPT

From Mana zināšanu grāmata
 
#!/bin/bash
if [ -f /etc/redhat-release ]
    then
        yum install -y wget
        wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-6.noarch.rpm
        rpm -ivh epel-release-7-6.noarch.rpm
        yum update -y
        echo -e "[epel-bacula7]\n
        name=Bacula backports from rawhide\n
        baseurl=http://repos.fedorapeople.org/repos/slaanesh/bacula7/epel-\$releasever/\$basearch/
        \n
        enable=1\n
        skip_if_unavailable=1\n
        gpgkey=http://repos.fedorapeople.org/repos/slaanesh/bacula7/RPM-GPG-KEY-slaanesh\n
        gpgcheck=1\n
        [epel-bacula7-source]\n
        name=Bacula backports from rawhide — Source\n
        baseurl=http://repos.fedorapeople.org/repos/slaanesh/bacula7/epel-\$releasever/SRPMS\n
        enabled=0\n
        skip_if_unavailable=1\n
        gpgkey=http://repos.fedorapeople.org/repos/slaanesh/bacula7/RPM-GPG-KEY-slaanesh\n
        gpgcheck=1" >> /etc/yum.repos.d/epel-bacula7.repo
        yum install bacula-client -y
if 'firewall-cmd --state' = running
    then
        firewall-cmd --permanent --zone=public --add-port=9102/tcp
        firewall-cmd --reload
fi
elif [ -f /etc/lsb-release ]
    then
    apt update
    apt install bacula-client -y
else
    exit
fi
if [ -f /etc/bacula/bacula-fd.conf ]
    then
    read -p "Your srv IP: " ip
    sed -i '/Password = /c\  Password = QWE123qwe' /etc/bacula/bacula-fd.conf
    sed -i "/FDAddress /c\  FDAddress = ${ip}" /etc/bacula/bacula-fd.conf
    sed -i '/Password = /c\  Password = QWE123qwe' /etc/bacula/bconsole.conf
    systemctl restart bacula-fd
    systemctl status bacula-fd
else
    exit
fi