File: //var/packages/ContainerManager/scripts/postuninst
#!/bin/sh
# Copyright (c) 2000-2020 Synology Inc. All rights reserved.
if [ "$SYNOPKG_PKG_STATUS" != UPGRADE -a "$pkgwizard_remove_additional" = true ]; then
# remove docker log
rm -rf /var/packages/ContainerManager/var/log/synodockerwebapi.log
# remove docker aufs mounts and btrfs subvolumes
NATIVE_DOCKER_PATH="/${SYNOPKG_PKGDEST_VOL}/@docker"
for i in $(grep aufs/mnt /proc/mounts | sed 's@.*aufs/mnt/\(\w*\).*@\1@'); do
umount "$NATIVE_DOCKER_PATH/aufs/mnt/$i"
done
if [ -d "$NATIVE_DOCKER_PATH/btrfs" ]; then
/usr/sbin/btrfs subvolume delete $NATIVE_DOCKER_PATH/btrfs/subvolumes/*
umount $NATIVE_DOCKER_PATH/btrfs
fi
ETC_PATH="$(readlink /var/packages/ContainerManager/etc)"
rm -fR "$NATIVE_DOCKER_PATH" "$ETC_PATH" /usr/local/etc/services.d/docker_*.sc
fi
# Because package which version < 1020 won't "overwrite" currently existing "data-root" in
# docker config (/var/packages/ContainerManager/etc/dockerd.json).
# Here's a workaround for the downgrading problem, installing package which version < 1020 with
# preserved docker data which originally belongs to package which version >= 1020.
# Because package which version < 1020 and the one >= 1020 have different "data-root" config,
# "data-root" config won't be update after package installation finishes.
# Therefore, it'll cause docker daemon initialized by the wrong root data path.
# So the workaround here is removing "data-root" config whenever doing package uninstallation,
# and "data-root" config will be added correctly next time of installation.
DOCKERD_CONFIG=/var/packages/ContainerManager/etc/dockerd.json
if [ -f ${DOCKERD_CONFIG} ]; then
DOCKERD_CONFIG_TMP=${DOCKERD_CONFIG}.tmp
jq 'del(.["data-root"])' $DOCKERD_CONFIG > $DOCKERD_CONFIG_TMP
mv $DOCKERD_CONFIG_TMP $DOCKERD_CONFIG
fi
# NATIVE_DOCKER_DATA_LINK is a link to NATIVE_DOCKER_PATH
NATIVE_DOCKER_DATA_LINK="/var/packages/ContainerManager/var/docker"
rm -f "$NATIVE_DOCKER_DATA_LINK"
rm -f \
/usr/local/bin/docker \
/usr/syno/bin/synosystemctl reload syslog-ng
exit 0