首页 > 代码库 > linux安装脚本
linux安装脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | # user can config the following configs, then package. INSTALL=/usr/local/cusflo-server ok_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]=$0" if [[ ! -f $0 ]]; then echo "directly execute the scripts on shell."; work_dir=`pwd` else echo "execute scripts in file: $0"; work_dir=`dirname $0`; work_dir=`(cd ${work_dir} && pwd)` fi product_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>&1 ret=$?; if [[ 0 -eq ${ret} ]]; then failed_msg "you must stop the service first: sudo /etc/init.d/cusflo-server-moon stop"; exit 1; fi fi ok_msg "previous install checked" # backup old srs ok_msg "backup old cusflo-server-moon" install_root=$INSTALL install_bin=$install_root/ if [[ -d $install_root ]]; then backup_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" fi ok_msg "old srs backuped" # copy core files ok_msg "copy core components" ( mkdir -p $install_root cp -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>&1 ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "copy core components failed"; exit $ret; fi ok_msg "copy core components success" # install init.d scripts ok_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>&1 ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "install init.d scripts failed"; exit $ret; fi ok_msg "install init.d scripts success" # install system service lsb_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 ]]; then ok_msg "install system service for CentOS" /sbin/chkconfig --add cusflo-server-moon && /sbin/chkconfig cusflo-server-moon on ret=$?; 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 ]]; then ok_msg "install system service for Ubuntu" update-rc.d cusflo-server-moon defaults ret=$?; 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 ]]; then ok_msg "install system service for Debian" update-rc.d cusflo-server-moon defaults ret=$?; 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 ]]; then ok_msg "install system service for RaspberryPi" update-rc.d cusflo-server-moon defaults ret=$?; if [[ 0 -ne ${ret} ]]; then failed_msg "install system service failed"; exit $ret; fi ok_msg "install system service success" else warn_msg "ignore and donot install system service for `lsb_release --id|awk ‘{print $3}‘`." fi echo "" 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安装脚本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。