diff --git a/_toc.yml b/_toc.yml index d6bb8b56..625690c7 100644 --- a/_toc.yml +++ b/_toc.yml @@ -5,6 +5,10 @@ root: index format: jb-book parts: +- caption: User Guide + chapters: + -file: user-guide/index + - caption: Admin Guide chapters: - file: admin-guide/index diff --git a/user-guide/firefox_profile_per_host.md b/user-guide/firefox_profile_per_host.md new file mode 100644 index 00000000..651112f3 --- /dev/null +++ b/user-guide/firefox_profile_per_host.md @@ -0,0 +1,64 @@ +# Per Host Default Profile for Firefox + +## Problem Description + +Firefox refuses to start with + +![error message Firefox already running](firefox_profile_per_host/firefox_already_running.png) + +when 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 -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 -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 priviledges it is not possible to do a normal bind mount. The alternative used here is `bindfs`, a tool implementing bind mounts as FUSE and runs without special priviledges. 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 only 1 MB resident memory per instance. + diff --git a/user-guide/firefox_profile_per_host/firefox_already_running.png b/user-guide/firefox_profile_per_host/firefox_already_running.png new file mode 100644 index 00000000..5dd5e202 Binary files /dev/null and b/user-guide/firefox_profile_per_host/firefox_already_running.png differ diff --git a/user-guide/index.md b/user-guide/index.md new file mode 100644 index 00000000..604a8cbd --- /dev/null +++ b/user-guide/index.md @@ -0,0 +1,16 @@ +--- +title: User Guide +description: User Guide for Red Hat Enterprise Linux at PSI +lead: "" +date: 2022-09-09T10:48:23+00:00 +lastmod: 2022-09-09T15:48:23+00:00 +draft: false +images: [] +toc: true +--- + +# User Guide + +This guide contains tricks and recipies for end users using Red Hat Enterprise Linux 7 or 8 as provided by the Core Linux Research Services group. + +- Firefox refuses to start with home directory on the network drive -> [Per Host Default Profile for Firefox](firefox_profile_per_host)