mirror of https://github.com/veops/cmdb.git
doc: add install.sh method in readme, change install.sh for macos support
This commit is contained in:
parent
8f0107b46c
commit
89548336f3
|
@ -74,15 +74,18 @@
|
|||
|
||||
### Docker 一键快速构建
|
||||
> 方法一
|
||||
- 第一步: 拷贝项目
|
||||
- 第一步: 先安装 docker 环境, 以及docker-compose
|
||||
- 第二步: 拷贝项目
|
||||
```shell
|
||||
git clone https://github.com/veops/cmdb.git
|
||||
```
|
||||
- 第二步:进入主目录(先安装 docker 环境, 以及docker-compose)
|
||||
- 第三步:进入主目录,执行:
|
||||
```
|
||||
docker-compose up -d
|
||||
```
|
||||
> 方法二, 该方法适用于linux系统
|
||||
> 方法二, 该方法适用于linux系统, 即
|
||||
- 第一步: 先安装 docker 环境, 以及docker-compose
|
||||
- 第二步: 直接使用项目根目录下的install.sh 文件进行 `安装`、`启动`、`暂停`、`查状态`、`删除`、`卸载`,对于类linux系统有用。
|
||||
```shell
|
||||
curl -ssL https://raw.githubusercontent.com/veops/cmdb/dev_install/install.sh -o install.sh
|
||||
sh istall.sh install
|
||||
|
|
|
@ -80,7 +80,7 @@ docker-compose up -d
|
|||
```
|
||||
> Method 2
|
||||
- step 1: **Prepare: install docker and docker-compose**
|
||||
- step 2:
|
||||
- step 2: directly use the install.sh file in the project's root directory to `install`, `start`, `pause`, `status`, `delete`, and `uninstall` the application. only usefull for linux os.
|
||||
```shell
|
||||
curl -ssL https://raw.githubusercontent.com/veops/cmdb/master/install.sh -o install.sh
|
||||
sh istall.sh install
|
||||
|
@ -92,7 +92,6 @@ sh istall.sh install
|
|||
```
|
||||
|
||||
|
||||
|
||||
### [Local Setup](local_en.md)
|
||||
|
||||
### [Installation with Makefile](makefile_en.md)
|
||||
|
|
63
install.sh
63
install.sh
|
@ -1,25 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
cmdb_dir="~/apps"
|
||||
current_path=$(pwd)
|
||||
cmdb_dir=$(cd ~ && pwd)/apps
|
||||
|
||||
check_docker() {
|
||||
if [ -x "$(command -v docker)" ]; then
|
||||
if pgrep "dockerd" >/dev/null; then
|
||||
:
|
||||
else
|
||||
echo "error: please install docker firstly"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "error: please install docker firstly"
|
||||
docker info >/dev/null 2>&1
|
||||
if ! [ $? -eq 0 ]; then
|
||||
echo "error: please install and start docker firstly"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_docker_compose() {
|
||||
if [ -x "$(command -v docker-compose)" ]; then
|
||||
:
|
||||
else
|
||||
docker-compose --version >/dev/null 2>&1
|
||||
if ! [ $? -eq 0 ]; then
|
||||
echo "error: please install docker-compose firstly"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -43,12 +37,8 @@ change_directory() {
|
|||
}
|
||||
|
||||
install_service() {
|
||||
check_docker
|
||||
check_docker_compose
|
||||
|
||||
echo ""
|
||||
echo "Installing the service $1..."
|
||||
current_path=$(pwd)
|
||||
change_directory "$cmdb_dir"
|
||||
|
||||
if [ -d "${cmdb_dir}/cmdb" ]; then
|
||||
|
@ -66,26 +56,17 @@ install_service() {
|
|||
}
|
||||
|
||||
start_service() {
|
||||
check_docker
|
||||
check_docker_compose
|
||||
|
||||
echo "Starting the service $1..."
|
||||
current_path=$(pwd)
|
||||
cd ${cmdb_dir}/cmdb
|
||||
docker-compose up -d
|
||||
cd $current_path
|
||||
}
|
||||
|
||||
pause_service() {
|
||||
check_docker
|
||||
check_docker_compose
|
||||
|
||||
case $2 in
|
||||
"" | cmdb-api | cmdb-ui | cmdb-db | cmdb-cache)
|
||||
echo "Pausing the service ..."
|
||||
|
||||
current_path=$(pwd)
|
||||
|
||||
cd ${cmdb_dir}/cmdb || exit 1
|
||||
docker-compose stop $2
|
||||
|
||||
|
@ -98,21 +79,13 @@ pause_service() {
|
|||
}
|
||||
|
||||
delete_service() {
|
||||
check_docker
|
||||
check_docker_compose
|
||||
|
||||
echo "Deleting the service ..."
|
||||
current_path=$(pwd)
|
||||
cd ${cmdb_dir}/cmdb || exit 1
|
||||
docker-compose down
|
||||
cd $current_path || exit 1
|
||||
}
|
||||
|
||||
status_service() {
|
||||
check_docker
|
||||
check_docker_compose
|
||||
|
||||
current_path=$(pwd)
|
||||
cd ${cmdb_dir}/cmdb || exit 1
|
||||
docker-compose ps
|
||||
cd $current_path || exit 1
|
||||
|
@ -120,18 +93,21 @@ status_service() {
|
|||
}
|
||||
|
||||
uninstall_service() {
|
||||
check_docker
|
||||
check_docker_compose
|
||||
if ! [ -d "${cmdb_dir}/cmdb" ]; then
|
||||
echo "directory ${cmdb_dir}/cmdb already not exist"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
read -p "Are you sure to uninstall the all the application and data? y/n:" input
|
||||
if [ $input = "y" ]; then
|
||||
echo "Uninstalling the service $1..."
|
||||
current_path=$(pwd)
|
||||
echo "Uninstalling the service ..."
|
||||
|
||||
cd ${cmdb_dir}/cmdb || exit 1
|
||||
docker-compose down -v
|
||||
if [ $? -eq 0 ]; then
|
||||
rm -fr ${cmdb_dir}/cmdb
|
||||
fi
|
||||
|
||||
cd $current_path || exit 1
|
||||
fi
|
||||
}
|
||||
|
@ -139,23 +115,34 @@ uninstall_service() {
|
|||
echo "Welcome to the CMDB service management script!"
|
||||
echo ""
|
||||
|
||||
check_depend() {
|
||||
check_docker
|
||||
check_docker_compose
|
||||
}
|
||||
|
||||
case $1 in
|
||||
install)
|
||||
check_depend
|
||||
install_service $2
|
||||
;;
|
||||
start)
|
||||
check_depend
|
||||
start_service $2
|
||||
;;
|
||||
status)
|
||||
check_depend
|
||||
status_service $2
|
||||
;;
|
||||
pause)
|
||||
check_depend
|
||||
pause_service $2
|
||||
;;
|
||||
delete)
|
||||
check_depend
|
||||
delete_service $2
|
||||
;;
|
||||
uninstall)
|
||||
check_depend
|
||||
uninstall_service $2
|
||||
;;
|
||||
*)
|
||||
|
|
Loading…
Reference in New Issue