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