This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgendocs.sh
119 lines (95 loc) · 3.92 KB
/
gendocs.sh
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
scriptDir="$(dirname "$(realpath "$0")")"
configDir="${scriptDir}/data/config"
genDocsDir="${configDir}/cubeengine/modules/docs"
docsDir="${scriptDir}/../docs"
GIT_USER_NAME="CubeEngine Bot"
GIT_USER_EMAIL="[email protected]"
# docker settings
NETWORK_NAME="forge_network"
MYSQL_CONTAINER_NAME="docgen_mysql"
MYSQL_ROOT_PASSWORD="<db-root-pw>"
MYSQL_DATABASE="minecraft"
MYSQL_USER="minecraft"
MYSQL_PASSWORD="<db-user-pw>"
MONGODB_CONTAINER_NAME="docgen_mongodb"
MONGODB_DBNAME="cubeengine"
MONGODB_USERNAME="minecraft"
MONGODB_PASSWORD="<mongo-db-user-pw>"
FORGE_CONTAINER_NAME="docgen_forge"
FORGE_JAVA_VM_ARGS="-Xmx1536M"
FORGE_MODS_DIR="${scriptDir}/data/mods"
FORGE_WORLD_DIR="${scriptDir}/data/world"
generate_docs() {
pushd "${scriptDir}"
echo "Creates volume directories (so that they have the correct access rights)..."
mkdir -vp "${configDir}"
echo "Creates a docker network..."
docker network create -d bridge "${NETWORK_NAME}"
echo "Creates and starts the MySQL container..."
docker run --name "${MYSQL_CONTAINER_NAME}" -d --rm \
--network="${NETWORK_NAME}" \
--env MYSQL_ROOT_PASSWORD="${MYSQL_ROOT_PASSWORD}" \
--env MYSQL_DATABASE="${MYSQL_DATABASE}" \
--env MYSQL_USER="${MYSQL_USER}" \
--env MYSQL_PASSWORD="${MYSQL_PASSWORD}" \
mysql:5.7
echo "Creates and starts the MongoDB container..."
docker run --name "${MONGODB_CONTAINER_NAME}" -d --rm \
--network="${NETWORK_NAME}" \
--env MONGODB_DBNAME="${MONGODB_DBNAME}" \
--env MONGODB_USERNAME="${MONGODB_USERNAME}" \
--env MONGODB_PASSWORD="${MONGODB_PASSWORD}" \
frodenas/mongodb:3.0
echo "Updates the cubeengine/forge image..."
docker pull cubeengine/forge:1.12.2
echo "Deletes dangling cubeengine/forge images..."
docker rmi $(docker images --filter "reference=cubeengine/forge" --filter "dangling=true" -q)
echo "Creates and starts the Forge container in foreground..."
docker run --name "${FORGE_CONTAINER_NAME}" --rm \
--user="$(id -u):$(id -g)" \
--network="${NETWORK_NAME}" \
--env DB_HOST="${MYSQL_CONTAINER_NAME}" \
--env DB_NAME="${MYSQL_DATABASE}" \
--env DB_USER="${MYSQL_USER}" \
--env DB_PASSWORD="${MYSQL_PASSWORD}" \
--env MONGO_DB_HOST="${MONGODB_CONTAINER_NAME}" \
--env MONGO_DB_NAME="${MONGODB_DBNAME}" \
--env MONGO_DB_USER="${MONGODB_USERNAME}" \
--env MONGO_DB_PASSWORD="${MONGODB_PASSWORD}" \
--env JAVA_VM_ARGS="${FORGE_JAVA_VM_ARGS}" \
--env CUBEENGINE_DOCS_SHUTDOWN="true" \
--volume="${configDir}:/home/minecraft/server/config" \
--volume="${FORGE_MODS_DIR}:/home/minecraft/server/mods" \
--volume="${FORGE_WORLD_DIR}:/home/minecraft/server/world" \
cubeengine/forge:1.12.2
echo "Stops background docker containers..."
docker stop "${MONGODB_CONTAINER_NAME}" "${MYSQL_CONTAINER_NAME}"
echo "Removes the docker network..."
docker network rm "${NETWORK_NAME}"
if [ ! -f "${genDocsDir}/README.md" ]
then
echo "The docs couldn't be created!"
exit 1
fi
popd
}
push_changes() {
echo "Removes all .md files from the docs repo..."
rm -v "${docsDir}"/*.md
rm -v "${docsDir}"/modules/*.md
echo "Moves all generated doc files to the docs repo directory..."
cp -Rv "${genDocsDir}"/* "${docsDir}"
pushd "${docsDir}"
git add .
git status
git config user.name "${GIT_USER_NAME}"
git config user.email "${GIT_USER_EMAIL}"
git commit -m "docs were updated automatically"
git push origin master
popd
}
echo "Generate Docs..."
generate_docs
echo "Push doc changes to git repo..."
push_changes