summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt-docker/data/etc/X11/Xreset.d/cleanup-container-session
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/run-virt-docker/data/etc/X11/Xreset.d/cleanup-container-session')
-rw-r--r--core/modules/run-virt-docker/data/etc/X11/Xreset.d/cleanup-container-session32
1 files changed, 32 insertions, 0 deletions
diff --git a/core/modules/run-virt-docker/data/etc/X11/Xreset.d/cleanup-container-session b/core/modules/run-virt-docker/data/etc/X11/Xreset.d/cleanup-container-session
new file mode 100644
index 00000000..07da7b37
--- /dev/null
+++ b/core/modules/run-virt-docker/data/etc/X11/Xreset.d/cleanup-container-session
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+#exec &> /tmp/cleanup-container-session.log
+#set -x
+
+# remove scripts and autostart from $HOME
+USER_CONTAINER_CONTEXT="$HOME/.local/docker"
+USER_CONTAINER_AUTOSTART="$HOME/.config/autostart/docker-init.desktop"
+[ -f "$USER_CONTAINER_AUTOSTART" ] && rm -- "$USER_CONTAINER_AUTOSTART"
+[ -d "$USER_CONTAINER_CONTEXT" ] && rm -rf -- "$USER_CONTAINER_CONTEXT"
+
+# remove running containers
+[ -n "$(docker ps -aq)" ] && docker rm -f $(docker ps -aq) > /dev/null
+
+
+## CLEANUP GVFS RELATED STUFF
+#
+
+# TODO: i don't know how to properly unmount a users gvfs locations under GVFS_MOUNTDIR.
+# Either root can't do that for him nor root can't su into user and do it. (because of dbus thing)
+# Maybe one simple solution could be that root kills the gvfsd-smb process ?
+GVFS_MOUNTDIR="/run/user/$( id -u "$USER" )/gvfs"
+#for location in "$GVFS_MOUNTDIR"/*; do
+# [ -d "$location" ] && gio mount -u "$location"
+#done
+
+# Look for soft link in HOME and HOME/Desktop whith point into GVFS_MOUNTDIR and delete them
+FIND_OPT="-maxdepth 1 -type l"
+DEAD_LINKS=$(find $HOME $FIND_OPT && find ${HOME}/Desktop/ $FIND_OPT )
+for dead_link in $DEAD_LINKS; do
+ [ "$GVFS_MOUNTDIR" = "$(dirname $(readlink $dead_link))" ] && rm -f -- "$dead_link";
+done