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
#!/bin/bash
 
# 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安装脚本的更多相关文章

  1. Linux安装脚本需要交互之如何实现自动安装

    Linux中shell脚本运行时经常需要进行交互,比如安装软件的过程中对license声明的确认,需要输入yes,回车之类的确认信息.这个在自动化安装的时候就会是个问题. 通常对于这个问题比较灵活的解 ...

  2. Linux环境下JDK/Eclipse一键安装脚本

    -------------------------------------------------------------------- author:jiangxin Email:jiangxinn ...

  3. Odoo Linux服务器一键安装脚本使用指南

    Odoo安装脚本介绍 为了帮助更多Linux服务器维护人员快速部署Odoo,为此开源智造(OSCG)基于André Schenkels曾经开放的openerp-install-scripts所构建的基 ...

  4. 树莓派进阶之路 (035) - 基于linux的zsh安装脚本

    基于linux的zsh安装脚本: Ubuntu版本: #!/bin/sh cd #安装zsh sudo apt-get install zsh #查看zsh cat /etc/shells #更改zs ...

  5. MySQL For Linux(CentOS/Ubuntu/Debian/Fedora/Arch)一键安装脚本(5.1-8.0)

    简介 很多童鞋不懂这么在Linux系统安装MySQL,网上大多数教程较复杂,不太适合小白安装,本教程提供一键安装脚本供大家使用,教大家怎么在Linux操作系统( 支持CentOS/Ubuntu/Deb ...

  6. jdk1.8一键安装脚本(linux环境)

    1.下载jdk安装包和安装脚本 下载地址:https://pan.baidu.com/s/1bo6ADQ3 其中包括: jdk安装包:jdk-8u151-linux-x64.tar.gz jdk一键安 ...

  7. linux 安装配置kafka脚本

    安装脚本 #!/bin/bash # auto install kafka echo "========= Start to install kafka ==============&quo ...

  8. [linux] shell脚本编程-xunsearch安装脚本学习

    安装脚本setup.sh #!/bin/sh # FULL fast install/upgrade script # See help message via `--help' # $Id$ # s ...

  9. centos7 lvm合并分区脚本初探-linux性能测试 -centos7修改网卡名字-jdk环境安装脚本-关键字查询文件-批量添加用户

    1.#!/bin/bash lvmdiskscan | grep centos > /root/a.txt a=`sed -n '1p' /root/a.txt` b=`sed -n '2p' ...

随机推荐

  1. [React] Modify file structure

    In React app, you might create lots of components. We can use index.js to do both 'import' & 'ex ...

  2. 【翻译自mos文章】当使用原地升级的方法将db升级到11.2.0.4之后,windows注冊表丢失autostart属性

    来源于: Windows Registry Missing Autostart Attribute after In-Place Upgrade of Oracle Database from 11. ...

  3. RequiredFieldValidator----验证控件不起作用

    验证码对于网络时代的我们来说实在是太熟悉了.登陆一个站点.注冊一个账户或是各种聊天工具登陆都须要来输入验证码.     为什么要使用验证码呢?     验证码通常是防止有人利用机器人自己主动批量注冊. ...

  4. 64位Oracle11g自带的sqldevelper无法启动

    原因:选择的jdk有问题 解决方法:由于Oracle自带的Sqldeveloper只支持32位的java运行环境,如果本机安装64位jdk,需要手动更改SqlDeveloper路径到32位的jdk即可 ...

  5. 选课 - 树型DP(孩子兄弟建树法)

    题目描述 学校实行学分制.每门的必修课都有固定的学分,同时还必须获得相应的选修课程学分.学校开设了 N(N<300)门的选修课程,每个学生可选课程的数量 M 是给定的.学生选修了这M门课并考核通 ...

  6. [GeekBand] 设计模式之观察者模式学习笔记

    本文参考文献::GeekBand课堂内容,授课老师:李建忠 :网络资料: http://blog.csdn.net/hguisu/article/details/7556625 本文仅作为自己的学习笔 ...

  7. springboot启动tomcat报错java.lang.NoClassDefFoundError: javax/el/ELManager仅记录

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'o ...

  8. Centos root权限的变化

    方法一:更改 /etc/sudoers 文件, 找到以下一行,把前面的凝视(#)去掉 ## Allows people in group wheel to run all commands %whee ...

  9. SpringBoot项目优化和Jvm调优(楼主亲测,真实有效)

    项目调优 作为一名工程师,项目调优这事,是必须得熟练掌握的事情. 在SpringBoot项目中,调优主要通过配置文件和配置JVM的参数的方式进行. 在这边有一篇比较好的文章,推荐给大家! Spring ...

  10. 自己动手编写一个VS插件(五)

    作者:朱金灿 来源:http://blog.csdn.net/clever101 继续编写VisualStudio插件.这次我编写的插件叫DevAssist(意思是开发助手).在看了前面的文章之后你知 ...