summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt-docker/data/etc/X11/Xreset.d/cleanup-container-session
blob: 07da7b37864af372846a604d6a9d70cda4baed28 (plain) (blame)
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
#!/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