forked from dunwu/linux-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmongodb-install.sh
More file actions
36 lines (27 loc) · 937 Bytes
/
mongodb-install.sh
File metadata and controls
36 lines (27 loc) · 937 Bytes
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
#!/usr/bin/env bash
cat << EOF
###################################################################################
# 安装 mongodb 脚本
# @system: 适用于所有 linux 发行版本。
# @author: Zhang Peng
###################################################################################
EOF
if [[ $# -lt 1 ]] || [[ $# -lt 2 ]];then
echo "Usage: sh mongodb-install.sh [version] [path]"
echo -e "Example: sh mongodb-install.sh 4.0.9 /opt/mongodb\n"
fi
version=4.0.9
if [[ -n $1 ]]; then
version=$1
fi
root=/opt/mongodb
if [[ -n $2 ]]; then
root=$2
fi
echo "Current execution: install mongodb ${version} to ${root}"
echo -e "\n>>>>>>>>> download mongodb"
mkdir -p ${root}
wget -O ${root}/mongodb-linux-x86_64-${version}.tgz https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${version}.tgz
echo -e "\n>>>>>>>>> install mongodb"
tar zxf ${root}/mongodb-linux-x86_64-${version}.tgz -C ${root}
mkdir -p /data/db