Linux Installation Scripts

Source: Internet
Author: User

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 66676869707172737475767778798081828384858687888990919293949596979899100101102103104105 #!/bin/bash# user can config the following configs, then package.install=/usr/Local/cusflo-serverok_msg () {Echo- e "${1}${pos}${black}[${green} OK ${black}]" }failed_msg () {Echo- e "${1}${pos}${black}[${red}failed${black}]" }# Discover the current work Dir, the log and access.echo "argv[0]=" if [[! - F + ]]; Thenecho "directly execute the scripts on shell."; Work_dir= 'pwd 'Elseecho "Execute scripts in file: $ "; Work_dir= ' DirName$ '; work_dir= ' (cd ${work_dir} && pwd) ' fiProduct_dir=$work _dir# User must stop service first.Ok_msg"Check previous install"if [[ -f/etc/init.d/cusflo-server-moon]]; Then/etc/init.d/cusflo-server-moon Status >/dev/null 2>&1ret=$?;if [[0 -eq ${ret}]; ThenFailed_msg"You must stop the service First:sudo/etc/init.d/cusflo-server-moon stop";exit 1;fifiOk_msg"Previous install checked"# Backup Old SRSOk_msg"Backup Old Cusflo-server-moon"install_root=$INSTALLinstall_bin=$install _root/if [[- D $install _root]]; ThenBackup_dir=${install_root}. ' Date ' +%y-%m-%d_%h-%m-%s "' Ok_msg"Backup installed dir"Ok_msg"to=$backup _dir" Mv$install _root $backup _dir 2>&1 Ret=$?;if [[0 -ne ${ret}]; Then failed_msg "Backup installed dir failed"; exit $ret; fi Ok_msg"Backup installed dir success"fiOk_msg"Old SRS backuped"# copy core filesOk_msg"Copy core components"(mkdir-p$install _rootCp-r$work _dir/conf $install _root && Cp-r$work _dir/dog $install _root && Cp-r$work _dir/log $install _root && Cp-r$work _dir/moon $install _root && Cp-r$work _dir/scripts $install _root ) 2>&1ret=$?;if [[0 -ne ${ret}]; Then failed_msg, "Copy core components failed"; exit $ret; fi Ok_msg"Copy Core components Success" # Install INIT.D scriptsOk_msg"Install INIT.D scripts"(Rm-rf/etc/init.d/cusflo-server-moon &&LN-SF$install _root/scripts/cusflo-server-moon/etc/init.d/cusflo-server-moon) 2>&1ret=$?;if [[0 -ne ${ret}]; Then failed_msg "Install INIT.D scripts failed"; exit $ret; fi Ok_msg"Install INIT.D scripts Success"# Install system serviceLsb_release--id|grep"CentOS" >/dev/null 2>&1; os_id_centos=$?Lsb_release--id|grep"Ubuntu" >/dev/null 2>&1; os_id_ubuntu=$?Lsb_release--id|grep"Debian" >/dev/null 2>&1; os_id_debian=$?Lsb_release--id|grep"Raspbian" >/dev/null 2>&1; os_id_rasabian=$?if [[0 -eq $os _id_centos]]; ThenOk_msg"Install system service for CentOS"/sbin/chkconfig--add cusflo-server-moon &&/sbin/chkconfig cusflo-server-moon onret=$?;if [[0 -ne ${ret}]; Then failed_msg "Install system service failed"; exit $ret; fi Ok_msg"Install system service Success"elif [[0 -eq $os _id_ubuntu]]; ThenOk_msg"Install system service for Ubuntu"Update-rc.d Cusflo-server-moon defaultsret=$?;if [[0 -ne ${ret}]; Then failed_msg "Install system service failed"; exit $ret; fi Ok_msg"Install system service Success"elif [[0 -eq $os _id_debian]]; ThenOk_msg"Install system service for Debian"Update-rc.d Cusflo-server-moon defaultsret=$?;if [[0 -ne ${ret}]; Then failed_msg "Install system service failed"; exit $ret; fi Ok_msg"Install system service Success"elif [[0 -eq $os _id_rasabian]]; ThenOk_msg"Install system service for Raspberrypi"Update-rc.d Cusflo-server-moon defaultsret=$?;if [[0 -ne ${ret}]; Then failed_msg "Install system service failed"; exit $ret; fi Ok_msg"Install system service Success"ElseWarn_msg"Ignore and donot install system service for ' Lsb_release--id|awk ' {print $ } '." fiecho "" echo "Install success, you can:" echo -E "${green} sudo./moon/scripts/cusflo-server-moon start${black}" echo "Cusflo-server-moon root is ${install}" Exit 0
http://daodaoliang.com/linux%E5%AD%A6%E4%B9%A0/2015/02/05/linux%E5%AD%A6%E4%B9%A0-2015-02-05-%E5%AE%89%E8%A3% 85%e8%84%9a%e6%9c%ac%e7%bc%96%e5%86%99/

Linux Installation Scripts

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.