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. [Grid Layout] Describe a grid layout using named grid lines

    We can use named grid lines to describe our grid layout. Let’s see how to apply this to our grid-tem ...

  2. 【u026】房间最短路问题

    描述 在一个长宽均为10,入口出口分别为(0,5).(10,5)的房间里,有几堵墙,每堵墙上有两个缺口,求入口到出口的最短路经. 格式 输入格式 第一排为n(n<=20),墙的数目. 接下来n排 ...

  3. 【hdu 2486】A simple stone game

    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s) ...

  4. 【t040】SETI任务

    Time Limit: 1 second Memory Limit: 128 MB [问题描述] Sqybi的电脑在做一个任务,就是SETI@home,据说这个任务在全世界有500 多万台电脑在同时做 ...

  5. Oracle数据库零散知识05 -- 表创建,修改

    1.表的创建 Create table student02(sno number); 2.表的删除 Drop table student02; 3.表的重命名 Rename student02 to ...

  6. 【 D3.js 高级系列 — 2.0 】 机械图 + 人物关系图

    机械图(力路线图)结合老百姓的关系图中的生活,这是更有趣. 本文将以此为证据,所列的如何图插入外部的图像和文字的力学. 在[第 9.2 章]中制作了一个最简单的力学图.其后有非常多朋友有疑问,基本的问 ...

  7. Spire.Doc组件

    使用Spire.Doc组件利用模板导出Word文档 以前一直是用Office的组件实现Word文档导出,但是让客户在服务器安装Office,涉及到版权:而且Office安装,包括权限配置也是比较麻烦. ...

  8. Crystal Report - 利用后台代码设计或实现水晶报表工具栏相关功能

    水晶报表工具栏分页按钮响应事件: 水晶报表中有自带的分页功能,在设置好每页显示的记录后会自动分页,并自动记录总页数和保存当前页,在工具栏可以通过“首页”“尾页”“下一页”“上一页”和“跳页”进行页面跳 ...

  9. jquery即点击改

    $(document).on("click",".sp",function(){    var brand_id=$(this).attr("valu ...

  10. 3 Task中的一些枚举 创建时候的、continue时候的

    创建时常用的枚举: None.PreferFairness.LongRunning.AttacthedToParent.DenyChildAttach.HideScheduler AttacthedT ...