#!/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