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
|
#!/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
|
linux安装脚本的更多相关文章
- Linux安装脚本需要交互之如何实现自动安装
Linux中shell脚本运行时经常需要进行交互,比如安装软件的过程中对license声明的确认,需要输入yes,回车之类的确认信息.这个在自动化安装的时候就会是个问题. 通常对于这个问题比较灵活的解 ...
- Linux环境下JDK/Eclipse一键安装脚本
-------------------------------------------------------------------- author:jiangxin Email:jiangxinn ...
- Odoo Linux服务器一键安装脚本使用指南
Odoo安装脚本介绍 为了帮助更多Linux服务器维护人员快速部署Odoo,为此开源智造(OSCG)基于André Schenkels曾经开放的openerp-install-scripts所构建的基 ...
- 树莓派进阶之路 (035) - 基于linux的zsh安装脚本
基于linux的zsh安装脚本: Ubuntu版本: #!/bin/sh cd #安装zsh sudo apt-get install zsh #查看zsh cat /etc/shells #更改zs ...
- MySQL For Linux(CentOS/Ubuntu/Debian/Fedora/Arch)一键安装脚本(5.1-8.0)
简介 很多童鞋不懂这么在Linux系统安装MySQL,网上大多数教程较复杂,不太适合小白安装,本教程提供一键安装脚本供大家使用,教大家怎么在Linux操作系统( 支持CentOS/Ubuntu/Deb ...
- jdk1.8一键安装脚本(linux环境)
1.下载jdk安装包和安装脚本 下载地址:https://pan.baidu.com/s/1bo6ADQ3 其中包括: jdk安装包:jdk-8u151-linux-x64.tar.gz jdk一键安 ...
- linux 安装配置kafka脚本
安装脚本 #!/bin/bash # auto install kafka echo "========= Start to install kafka ==============&quo ...
- [linux] shell脚本编程-xunsearch安装脚本学习
安装脚本setup.sh #!/bin/sh # FULL fast install/upgrade script # See help message via `--help' # $Id$ # s ...
- 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' ...
随机推荐
- NSstring封装
来自http://devtang.com/blog/2012/02/14/nsstring-java-like-wrapper/ NSStringWrapper.h #import <Found ...
- oracle的number的浅析
author:skate time:2011-02-14 oracle的number的浅析 从例如以下几个方面来认识number 1.表示的数值范围 2.占用的存储空间 3.number的性能 ...
- WPF去除边框的方法
原文:WPF去除边框的方法 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/yangsen600/article/details/81978125 W ...
- WPF自定义TextBox及ScrollViewer
原文:WPF自定义TextBox及ScrollViewer 寒假过完,在家真心什么都做不了,可能年龄大了,再想以前那样能专心坐下来已经不行了.回来第一件事就是改了项目的一个bug,最近又新增了一个新的 ...
- java中的switch结构
switchkeyword的中文意思是开关.转换的意思,switch语句在条件语句中特别适合做一组变量相等的推断,在结构上比if语句要清晰非常多.switch语句的语法格式为:switch(表达式) ...
- QT 内存文件映射就是如此简单!
QFile file(fileName); file.open(QIODevice::ReadWrite ); uchar* fpr = file.map(0, file.size());//映射文件 ...
- Some Very Good VC++/MFC Resources Besides Codeproject.com
Some Very Good VC++/MFC Resources Besides Codeproject.com http://www.naughter.com/ (VC++/MFC huge co ...
- React路由配置
React路由简单配置 //入口文件index.js import React from 'react'; import ReactDom from 'react-dom'; import { Rou ...
- python短信轰炸机版本smsbomb----------部分(post)
用一些用手机号注冊且须要发送验证码的站点的漏洞.能够向不论什么人的手机号发送短信,当然短信内容,我们无法控制.所以主要工作还是寻找这种站点.然后利用Fiddler或者HttpWatch分析请求.使用p ...
- VC++中的C运行时库浅析(控制台程序默认使用单线程的静态链接库,而MFC中的CFile类已暗藏了多线程)
1.概论 运行时库是程序在运行时所需要的库文件,通常运行时库是以LIB或DLL形式提供的.C运行时库诞生于20世纪70年代,当时的程序世界还很单纯,应用程序都是单线程的,多任务或多线程机制在此时还属于 ...