11module_options+=(
2- [" module_duplicati,author" ]=" "
2+ [" module_duplicati,author" ]=" @armbian "
33 [" module_duplicati,maintainer" ]=" @igorpecovnik"
44 [" module_duplicati,feature" ]=" module_duplicati"
55 [" module_duplicati,example" ]=" install remove purge status help"
@@ -17,10 +17,9 @@ function module_duplicati () {
1717 local title=" duplicati"
1818 local condition=$( which " $title " 2> /dev/null)
1919
20- if pkg_installed docker-ce; then
21- local container=$( docker container ls -a | mawk ' /duplicati?( |$)/{print $1}' )
22- local image=$( docker image ls -a | mawk ' /duplicati?( |$)/{print $3}' )
23- fi
20+ pkg_installed docker.io || module_docker install
21+ local container=$( docker container ls -a --filter " name=duplicati" --format ' {{.ID}}' )
22+ local image=$( docker image ls -a --format ' {{.Repository}} {{.ID}}' | grep ' duplicati' | awk ' {print $2}' )
2423
2524 local commands
2625 IFS=' ' read -r -a commands <<< " ${module_options[" module_duplicati,example" ]}"
@@ -34,7 +33,6 @@ function module_duplicati () {
3433 local DUPLICATI_ENCRYPTION_KEY=" $1 "
3534 local DUPLICATI_WEBUI_PASSWORD=" $2 "
3635
37- pkg_installed docker-ce || module_docker install
3836 [[ -d " $DUPLICATI_BASE " ]] || mkdir -p " $DUPLICATI_BASE " || { echo " Couldn't create storage directory: $DUPLICATI_BASE " ; exit 1; }
3937
4038 # If no encryption key provided, prompt for it
@@ -60,8 +58,9 @@ function module_duplicati () {
6058 fi
6159
6260 docker run -d \
63- --name=duplicati \
6461 --net=lsio \
62+ --name duplicati \
63+ --restart=always \
6564 -e PUID=1000 \
6665 -e PGID=1000 \
6766 -e TZ=" $( cat /etc/timezone) " \
@@ -71,30 +70,30 @@ function module_duplicati () {
7170 -v " ${DUPLICATI_BASE} /config:/config" \
7271 -v " ${DUPLICATI_BASE} /backups:/backups" \
7372 -v /:/source:ro \
74- --restart unless-stopped \
7573 lscr.io/linuxserver/duplicati:latest
7674 for i in $( seq 1 20) ; do
77- if docker inspect -f ' {{ index .Config.Labels "build_version" }}' duplicati > /dev/null 2>&1 ; then
78- break
79- else
80- sleep 3
75+ state=" $( docker inspect -f ' {{.State.Status}}' duplicati 2> /dev/null || true) "
76+ if [[ " $state " == " running" ]]; then
77+ break
8178 fi
82- if [ $i -eq 20 ]; then
83- echo -e " \nTimed out waiting for ${title} to start, consult your container logs for more info (\` docker logs duplicati\` )"
79+ sleep 3
80+ if [[ $i -eq 20 ]]; then
81+ echo -e " \nTimed out waiting for ${title} to start, consult logs (\` docker logs duplicati\` )"
8482 exit 1
8583 fi
8684 done
8785 ;;
8886 " ${commands[1]} " )
89- if [[ -n " ${container} " ]]; then
90- docker container rm -f " ${container} " > /dev/null
91- fi
92-
93- if [[ -n " ${image} " ]]; then
94- docker image rm " ${image} " > /dev/null
87+ if [[ " ${container} " ]]; then
88+ echo " Removing container: $container "
89+ docker container rm -f " $container "
9590 fi
9691 ;;
9792 " ${commands[2]} " )
93+ ${module_options["module_duplicati,feature"]} ${commands[1]}
94+ if [[ " ${image} " ]]; then
95+ docker image rm " $image "
96+ fi
9897 ${module_options["module_duplicati,feature"]} ${commands[1]}
9998 if [[ -n " ${DUPLICATI_BASE} " && " ${DUPLICATI_BASE} " != " /" ]]; then
10099 rm -rf " ${DUPLICATI_BASE} "
0 commit comments