65 lines
2.8 KiB
Markdown
65 lines
2.8 KiB
Markdown
# Per Host Default Profile for Firefox
|
|
|
|
## Problem Description
|
|
|
|
Firefox refuses to start with
|
|
|
|

|
|
|
|
if the user has the home directory on the network (AFS or NFS) and has Firefox already running on one computer and tries to start it on another computer.
|
|
|
|
A solution is to have an individual default profile for each host.
|
|
|
|
## Solution for Red Hat 7
|
|
|
|
Add to the bottom of `~/.bash_profile`:
|
|
|
|
```
|
|
if ! mountpoint -q ~/.mozilla/firefox; then
|
|
mkdir -p ~/.mozilla/firefox{_$(hostname --fqdn),}
|
|
bindfs --force-user="$(id -un)" --force-group="$(id -gn)" -o nonempty,no-allow-other ~/.mozilla/firefox_$(hostname --fqdn) ~/.mozilla/firefox
|
|
fi
|
|
```
|
|
|
|
and it will be ready with the next login. You may also run this code directly on the terminal if you wish to have it ready for the currently running session.
|
|
|
|
## Solution for Red Hat 8
|
|
|
|
Create the file `~/.config/systemd/user/private-firefox-profile-per-host.service` with following content:
|
|
|
|
```
|
|
[Unit]
|
|
Description=Private Firefox Profile per Host
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
RemainAfterExit=true
|
|
ExecStart=bash -c 'if ! mountpoint -q "%h/.mozilla/firefox"; then mkdir -p "%h/.mozilla/firefox"{_%H,}; bindfs --force-user="$(id -un)" --force-group="$(id -gn)" -o nonempty,no-allow-other "%h/.mozilla/firefox_%H" "%h/.mozilla/firefox"; fi'
|
|
ExecStop=fusermount -u %h/.mozilla/firefox
|
|
|
|
[Install]
|
|
WantedBy=default.target
|
|
```
|
|
|
|
To have it started automatically a symlink is needed from
|
|
`~/.config/systemd/user/default.target.wants/private-firefox-profile-per-host.service` to `../private-firefox-profile-per-host.service`, e.g. to be created with given user:
|
|
|
|
```
|
|
systemctl --user enable private-firefox-profile-per-host.service
|
|
```
|
|
It will be available after the next login. To start it immediately run
|
|
|
|
```
|
|
systemctl --user start private-firefox-profile-per-host.service
|
|
```
|
|
|
|
|
|
## Technical Discussion
|
|
|
|
The solution does a bind mount from `~/.mozilla/firefox_$FQDN` to `~/.mozilla/firefox` (and ensures that both directories exist). As normal user without special admin privileges it is not possible to do a normal bind mount. The alternative used here is `bindfs`, a tool implementing bind mounts as user space tool (FUSE) and runs without special privileges. By default `bindfs` is not available, but I will make it soon to be installed everywhere with by Puppet.
|
|
|
|
One can install both the RHEL 7 and the RHEL 8 solution at the same time, they are tolerant to each other.
|
|
|
|
The special solution for RHEL 7 is required because Red Hat patched out the support for `systemd --user`. An issue with this solution is that the bind mount is never cleared. It is ensured that there is only one per user, but this one stays until the machine shuts down or it is manually unmounted. But the the tool is slim and uses less than 1 MB resident memory per instance.
|
|
|