Score:1

Firefox complaining about a running instance after crashing with umounts on Xubuntu

US flag
user126247

In order to run Firefox without allowing any changes to its configuration, I did setup a tmpfs and from it, create two overlays before launching the browser.
Script runs fine, creates and destroys the mounts as expected, but when booted into a launcher, some umounts apparently fail, and subsequent calls to Firefox complain about a running instance of themselves. I could verify, that some mounts remain only if the scripts gets executed from the launcher.

Here is the script:

#!/usr/bin/bash
# set variables
FOX="/usr/bin/firefox"
pkill `basename $FOX` || true

#find working directories:
#find ~ -type d -iname "*fox*"

function errout () {
zenity --info --text="$@"
exit 1
}

CACHE=~/.cache/mozilla/firefox
ZILLA=~/.mozilla/firefox
FREE=`free | awk 'NR==2 {print $4;}'`
TEMP=/mnt/tmp # this one gets built in fstab

if [[ "$FREE" -lt 200000 ]]
then
    errout "zu wenig Speicherplatz"
fi
if ! test -d "$CACHE"
then
    errout "$CACHE ist kein Verzeichnis"
fi
if ! test -d "$ZILLA"
then
    errout "$ZILLA ist kein Verzeichnis"
fi
if ! test -d "$TEMP"
then
    errout "$TEMP ist kein Verzeichnis"
fi
if [[ "$USER" == "uk" ]]
then
    PWD=SUDOPASSWORD # of course not :-)
fi
echo $PWD | sudo -S true >& /dev/null

if [[ `mount | awk /^tmpfs/ | grep -cw "$TEMP"` == "0" ]]
then
    sudo mount tmpfs -t tmpfs -o defaults,size=250m "$TEMP"
else
    : # es ist noch nicht sicher, dass der Platz reichen wird
fi

# setup overlays:
mkdir -p "$TEMP/helpfox/"{Clower,Cupper,Cwork,Zlower,Zupper,Zwork}
sudo mount --bind "$CACHE" "$TEMP/helpfox/Clower"
sudo mount --bind "$ZILLA" "$TEMP/helpfox/Zlower"
sudo mount -t overlay overlay -olowerdir="$TEMP/helpfox/Zlower",\
upperdir="$TEMP/helpfox/Zupper",workdir="$TEMP/helpfox/Zwork" "$ZILLA"
sudo mount -t overlay overlay -olowerdir="$TEMP/helpfox/Clower",\
upperdir="$TEMP/helpfox/Cupper",workdir="$TEMP/helpfox/Cwork" "$CACHE"
sudo -k

$FOX

# destroy overlays:
sleep 2
echo $PWD | sudo -S true >& /dev/null
mount | awk '$3 ~ /helpfox/ { print $3; }' | xargs -r -l sudo umount
sudo rm -rf $TEMP/helpfox 
zenity --info --text="Die Blase ist abgebaut" 
sudo -k

Score:1
US flag
user126247

I cannot access their laptop right now, thus not verify my theory, but ... I am pretty convinced, that the reasoon, why the script runs fine in terminal but not from the launcher might be the use of "~" in pathnames. "~" gets interpreted correctly when run by the user, but the launcher probably fails to decode that correctly. If that turns out to be true, the fix could be to replace

CACHE=~/.cache/mozilla/firefox

by

CACHE=`echo ~/.cache/mozilla/firefox`

and the same thing for ZILLA

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.