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

Example Analysis of web Page Update script

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

Share

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

Editor to share with you the example analysis of the web page update script, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

#! / bin/bash

# version 0.1

# Last revision by: xxx

# whoever in the company modifies this script file, please write your name on it

Clear

Echo 'Note: in order to ensure security, you need to enter the production password during synchronization!'

Echo-e'\ e [32m1. Local specified file (directory)-> > production server specified file (directory)\ e [m'

Echo-e'\ e [32m2. Local web root directory-> > production server web and directory\ e [m'

Echo-e'\ e [35m3. Exit'

While:

Do

Read-p 'Select your action:' num

If [$num-eq 1]; then

Read-p "input local file absolute path:" src

Read-p "which machine do you want to synchronize files to? (web1/web2/web3):" web

Read-p "input remote file absolute path:" dst

Read-p "are you sure you want to synchronize files? (yes/no):" ack

If ["$ack" = = "yes"]; then

Rsync-arvlSH $src $web:$dst 2 > / dev/null

[$?-eq 0] & & echo "synchronization succeeded! please go to production service to check" | | echo "synchronization failed, please check it yourself or contact the operation and maintenance personnel"

Elif ["$ack" = = "no"]; then

:

Else

Echo 'input error!'

Fi

Elif [$num-eq 2]; then

Echo 'you can't do that yet!'

Elif [$num-eq 3]; then

Exit

Fi

Done

The execution results are as follows:

Background: generally speaking, the web online update of the production server in the company is completed by the operation and maintenance personnel, but it does not rule out that some companies have chaotic management and developers upload files to the server by themselves. For example, the company where I worked before has such a strange thing. There are many ways to update. Automatic operation and maintenance tools, such as ansible, can be used for more services, and svn or git can be used directly. But if there are few servers, using tools like ansible always feels like killing a chicken, so write the following script for new developers to upload new files to the web server.

Note: this script is not used for production, but only a small part of it is used for beginners' reference exercises.

#! / bin/bash

# version 0.1

# Last revision by: xxx

# whoever in the company modifies this script file, please write your name on it

Clear

Echo 'Note: in order to ensure security, you need to enter the production password during synchronization!'

Echo-e'\ e [32m1. Local specified file (directory)-> > production server specified file (directory)\ e [m'

Echo-e'\ e [32m2. Local web root directory-> > production server web and directory\ e [m'

Echo-e'\ e [35m3. Exit'

While:

Do

Read-p 'Select your action:' num

If [$num-eq 1]; then

Read-p "input local file absolute path:" src

Read-p "which machine do you want to synchronize files to? (web1/web2/web3):" web

Read-p "input remote file absolute path:" dst

Read-p "are you sure you want to synchronize files? (yes/no):" ack

If ["$ack" = = "yes"]; then

Rsync-arvlSH $src $web:$dst 2 > / dev/null

[$?-eq 0] & & echo "synchronization succeeded! please go to production service to check" | | echo "synchronization failed, please check it yourself or contact the operation and maintenance personnel"

Elif ["$ack" = = "no"]; then

:

Else

Echo 'input error!'

Fi

Elif [$num-eq 2]; then

Echo 'you can't do that yet!'

Elif [$num-eq 3]; then

Exit

Fi

Done

The execution results are as follows:

The above is all the content of the article "sample Analysis of web Page Update script". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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