Print Selection menu, one-click Install Web Service

Source: Internet
Author: User

Print the Select menu and install the Web service one-click:

[Email protected]]# sh menu.sh 1.    [Install lamp] 2.[install LNMP] 3.    [Install MySQL] 4.[install PHP] 5. [Exit] pls input the num you want:

Requirements:

1, when the user input 1 , the output "startinstallinglamp." "then execute /server/scripts/lamp.sh, script content output " Lampis installed " after exiting the script;

2, when the user input 2 , the output "startinstallinglnmp." "then execute /server/scripts/lnmp.sh output " Lnmpis installed " after exiting the script ;

3, when the user input 2 , the output "startinstallingmysql." "then execute /server/scripts/mysql.sh output " MySQL installed " after exiting the script ;

4, when the user input 2 , the output "startinstallingphp." "then execute /server/scripts/php.sh output " PHP installed " after exiting the script ;

5, when input 3 , exit the current menu and script;

6.When you enter any other characters, give the prompt "input error" and exit the script.

7, to the execution of the script to determine the relevant conditions, such as: whether the script exists, whether it can be executed, etc.

Answer:

#!/bin/bashred_color= ' \e[1;31m ' green_color= ' \e[1;32m ' yellow_color= ' \e[1;33m ' blue_color= ' \E[1;34m ' PINK_COLOR= ' e[1;35m ' res= ' \e[0m ' cat <<eof    the menu to print 1.[ Install lamp]2. [INSTALL&NBSP;LNMP] 3.[install mysql]4. [install php] 5.[exit]eofread -p "Pls input the num you want:"  a    Please enter a parameter case$ain1)   echo -e  "$BLUE _color startinstalling lamp  $RES"       add color to the content of the output   lampScripts=/server/scripts/lamp.sh [-f$lampScripts] & & sh  $lampScripts | |  exit1    determine if the lamp file to be executed exists  ;; &NBSP;2)   echo -e  "$PINK _color startinstalling lnmp  $RES"    lnmpscripts=/server/scripts/lnmp.sh  [-f$lnmpscripts] && sh  $lnmpScripts | |  exit2 ;;  3)   echo -e  "$GREEN _color startinstalling mysql  $RES"   mysqlscripts=/server/scripts/mysql.sh  [-f$mysqlscripts] && sh  $mysqlScripts | |  exit3 ;;  4)  echo-e  "$PINK _color startinstalling php  $RES"  phpscripts=/server/ scripts/mysql.sh  [-f$phpscripts] && sh  $phpScripts | |  exit4  ;;  *)   echo -e  "$RED _color input error  $RES" Esac




This article is from the "one small step per day" blog, so be sure to keep this source http://fenyuer.blog.51cto.com/11265169/1944999

Print Selection menu, one-click Install Web Service

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.