Get the App
SLTechnology News&Howtos  ›  Servers  › 

Making if conditional statements by the lottery sharing program of Shell script

Shulou Source: shulou.com Published: 2022-06-02 07:27:51 10月03日 Update

Master server configuration

#! / bin/bash

# production of lottery sharing program Q

# DNS master-slave synchronization-master server

Rpm-Q bind

If [$?-ne 0]; then

Yum install bind-y

Systemctl start named

Fi

# determine whether the DNS service is installed

Read-p "Please enter the primary server address:" zhu

Read-p "Please enter slave server address:" cong

Read-p "domain name (please suffix):" yu

Quanju= "/ etc/named.conf"

Quyu= "/ etc/named.rfc1912.zones"

[!-e $quanju.bak] & & cp $quanju $quanju.bak

Sed-I-e "13s/127.0.0.1/$zhu/"-e '21s any quanju

[!-e $quyu.bak] & & cp $quyu $quyu.bak

# backup global and regional configuration files

Grep "$yu" $quyu & > / dev/null

While [$?-ne 0]; do

Sed-I "18azone\" $yu\ "IN {\ n type master\;\ nfile\" $yu.dns\ "\;\ nallow- transfer {$cong\;}\;\ n}\;\ n" $quyu

Peizhi= "/ var/named/$yu.dns"

Cp-p / var/named/named.localhost $peizhi

Done

# determine whether the domain name exists, and add it if it does not exist

Sed-I-e '2d'-e "1a @ IN SOA" $yu "\ .admin\." $yu "\. (" / var/named/$yu.dns

Sed-I '8d' / var/named/$yu.dns

Sed-I'$d' / var/named/$yu.dns

Sed-I-e "7a\ NS $yu."-e "/ A/s/127.0.0.1/$zhu/" / var/named/$yu.dns

# modify the zone file

While [1-ge 0]; do

Read-p "Please enter a custom pointer (example: www IN A 8.8.8.8)" zhen

Echo $zhen > > / var/named/$yu.dns

Read-p "whether to continue to add (yPao)" a

If [$a! = "y"]; then

Break

Fi

Done

# Loop

Systemctl stop firewalld.service

Setenforce 0

Systemctl restart named

Jieguo= `systemctl status named | grep "active" & > / dev/ null`

If [$?-eq 0]; then

Echo "Service start"

Else

Echo "Startup failed"

Fi

# determine whether the service can be started normally

Sed-I-e '3d'-e "2anameserver $zhu" / etc/resolv.conf

# for self-test

Configure from the server

#! / bin/bash

# DNS master-slave synchronization-slave server

Rpm-Q bind

If [$?-ne 0]; then

Yum install bind-y

Fi

# determine whether the DNS service is installed

Read-p "Please enter the primary server address:" zhu

Read-p "Please enter slave server address:" cong

Read-p "domain name (please suffix):" yu

Quanju= "/ etc/named.conf"

Quyu= "/ etc/named.rfc1912.zones"

[!-e $quanju.bak] & & cp $quanju $quanju.bak

Sed-I-e "13s/127.0.0.1/$cong/"-e '21s any quanju

[!-e $quyu.bak] & & cp $quyu $quyu.bak

# backup global and regional configuration files

Grep "$yu" $quyu & > / dev/null

While [$?-ne 0]; do

Sed-I "18azone\" $yu\ "IN {\ n type slave\;\ nfile\" slaves\ / $yu.dns\ "\;\ nmasters {$zhu\;}\;\ n}\;\ n" $quyu

Done

# determine whether the domain name exists, and add it if it does not exist

Systemctl restart named

Systemctl stop firewalld.service

Setenforce 0

Jieguo= `systemctl status named | grep "active" & > / dev/ null`

If [$?-eq 0]; then

Echo "Service start"

Else

Echo "Startup failed"

Fi

# determine whether the service can be started normally

Tags: Service server input address domain name configuration zone file master-slave global suffix backup synchronization program production pointer loop condition script statement Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Apple Shulou Information MySQL Xiaomi