Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report