>>108004564
>>108004571
I'm also tmpfstacked
#
# on startup
#
user=$(basename $path)
grep -q $user /etc/passwd || break
uid=$(id -u $user)
gid=$(id -g $user)
mkdir -m 700 -p /run/user/$uid
chown $uid:$gid /run/user/$uid
tmpfs_root=/run/user/$uid/tmpfs
mkdir -m 700 -p $tmpfs_root
chown $uid:$gid $tmpfs_root
for target in .mozilla .cache/mozilla; do
if [ -d $path/$target ] && ! [ -e $tmpfs_root/$target ]; then
(
umask 077
mkdir -p $tmpfs_root/$target
chown $uid:$gid $tmpfs_root/$target
)
options="uid=$uid,gid=$gid,mode=$(stat -c %a $path/$target),size=50%"
mount -t tmpfs -o $options tmpfs $tmpfs_root/$target
rsync -a $path/$target/ $tmpfs_root/$target/
mount --move $tmpfs_root/$target $path/$target
fi
done
#
# on shutdown
#
user=$(basename $path)
grep -q $user /etc/passwd || break
uid=$(id -u $user)
gid=$(id -g $user)
tmpfs_root=/run/user/$uid/tmpfs
if ! [ -d $tmpfs_root ]; then
break
fi
for target in .mozilla .cache/mozilla; do
if mountpoint -q $path/$target && [ -d $tmpfs_root/$target ]; then
open_fd_pid=$(lsof +i -t $path/$target)
kill -15 $open_fd_pid 2> /dev/null
waitpid -t 5 -e $open_fd_pid 2> /dev/null
kill -9 $open_fd_pid 2> /dev/null
mount --move $path/$target $tmpfs_root/$target
rsync -a --checksum --inplace --no-whole-file --delete $tmpfs_root/$target/ $path/$target/
umount $tmpfs_root/$target
rmdir $tmpfs_root/$target
fi
done