-
Notifications
You must be signed in to change notification settings - Fork 0
/
valheim-update.sh
44 lines (40 loc) · 1.33 KB
/
valheim-update.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
#!/usr/bin/env bash
source "Defaults" || exit 1
# Container Engine Binary - You will need
# to change this if using something other
# than podman (podman is recommended,
# specifically Oracle Cloud Infrastructure's
# version as these scripts were designed to use
# advanced features possibly not available yet
# for other versions).
CE_EXEC=$(which podman)
if [[ ! -f "${CE_EXEC}" ]]; then
echo "Container Engine Binary not found."
exit 1
fi
podWaitInterval=15
function inspectPod() {
local podStatus
podStatus=$(sudo "${CE_EXEC}" inspect --format '{{.State.Status}}' "${CONTAINER_NAME}")
if [[ "${podStatus}" == "running" ]]; then
echo "${CONTAINER_NAME} is running."
return 0
else
echo "${CONTAINER_NAME} failed to run."
echo "Check ${CONTAINER_NAME}.json for more information."
return 1
fi
}
echo "Updating entrypoint script..."
if [ -f "./${CONTAINER_NAME}-entrypoint.sh" ]; then
sudo "${CE_EXEC}" cp "${CONTAINER_NAME}-entrypoint.sh" "${CONTAINER_NAME}:${ENTRYPOINT}/${CONTAINER_NAME}-entrypoint.sh"
sudo "${CE_EXEC}" exec -it -u 0 "${CONTAINER_NAME}" chmod +x "${ENTRYPOINT}/${CONTAINER_NAME}-entrypoint.sh"
else
echo "./${CONTAINER_NAME}-entrypoint.sh file not found."
exit 1
fi
echo "Restarting ${CONTAINER_NAME}."
sudo "${CE_EXEC}" restart "${CONTAINER_NAME}"
sleep "${podWaitInterval}"
inspectPod
exit $?