@@ -17,10 +17,9 @@ function module_uptimekuma () {
1717 local title=" uptimekuma"
1818 local condition=$( which " $title " 2> /dev/null)
1919
20- if pkg_installed docker-ce; then
21- local container=$( docker container ls -a | mawk ' /uptime-kuma?( |$)/{print $1}' )
22- local image=$( docker image ls -a | mawk ' /uptime-kuma?( |$)/{print $3}' )
23- fi
20+ pkg_installed docker.io || module_docker install
21+ local container=$( docker container ls -a --filter " name=uptime-kuma" --format ' {{.ID}}' )
22+ local image=$( docker image ls -a --format ' {{.Repository}} {{.ID}}' | grep ' uptime-kuma ' | awk ' {print $2}' )
2423
2524 local commands
2625 IFS=' ' read -r -a commands <<< " ${module_options[" module_uptimekuma,example" ]}"
@@ -29,7 +28,6 @@ function module_uptimekuma () {
2928
3029 case " $1 " in
3130 " ${commands[0]} " )
32- pkg_installed docker-ce || module_docker install
3331 [[ -d " $UPTIMEKUMA_BASE " ]] || mkdir -p " $UPTIMEKUMA_BASE " || { echo " Couldn't create storage directory: $UPTIMEKUMA_BASE " ; exit 1; }
3432 docker run -d \
3533 --net=lsio \
@@ -39,26 +37,28 @@ function module_uptimekuma () {
3937 -v " ${UPTIMEKUMA_BASE} :/app/data" \
4038 louislam/uptime-kuma:1
4139 for i in $( seq 1 20) ; do
42- if docker inspect -f ' {{ index .Config.Labels "build_version" }}' uptime-kuma > /dev/null 2>&1 ; then
43- break
44- else
45- sleep 3
40+ state=" $( docker inspect -f ' {{.State.Status}}' uptime-kuma 2> /dev/null || true) "
41+ if [[ " $state " == " running" ]]; then
42+ break
4643 fi
47- if [ $i -eq 20 ] ; then
48- echo -e " \nTimed out waiting for ${title} to start, consult your container logs for more info (\` docker logs uptimekuma\` )"
44+ sleep 3
45+ if [[ $i -eq 20 ]]; then
46+ echo -e " \nTimed out waiting for ${title} to start, consult logs (\` docker logs uptime-kuma\` )"
4947 exit 1
5048 fi
5149 done
5250 ;;
5351 " ${commands[1]} " )
5452 if [[ " ${container} " ]]; then
55- docker container rm -f " $container " > /dev/null
56- fi
57- if [[ " ${image} " ]]; then
58- docker image rm " $image " > /dev/null
53+ echo " Removing container: $container "
54+ docker container rm -f " $container "
5955 fi
6056 ;;
6157 " ${commands[2]} " )
58+ ${module_options["module_uptimekuma,feature"]} ${commands[1]}
59+ if [[ " ${image} " ]]; then
60+ docker image rm " $image "
61+ fi
6262 ${module_options["module_uptimekuma,feature"]} ${commands[1]}
6363 if [[ -n " ${UPTIMEKUMA_BASE} " && " ${UPTIMEKUMA_BASE} " != " /" ]]; then
6464 rm -rf " ${UPTIMEKUMA_BASE} "
0 commit comments