This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

Browser-Home-Profile

From Gentoo Wiki (test)
Jump to:navigation Jump to:search
Resources
Manage web-browser home profile and cache directories in temporary filesystem in order to improve responsiveness while keeping disk read/write low

Browser-Home-Profile is a shell script that manage web browsers home profile and cache directories similar to Profile-Sync-Daemon[1] bash script. However, bhp does not touch the underlying profile and cache directories contrary to psd with symbolic links which can render the profile/cache direcories unusable; it just bind mount temporary file system (see tmpfs for more info) on the directories leaving the default profile and cache directories usable no matter what may happen.

And lastly the script can be sourced in ~/.profile or ~/{,ba,z}shrc, by setting up the necessary directory first; and then, sub-sequent bhp commands in a terminal will, first, decompress the archived profile and cache directories and finally update the tarball archives by maintaining an extra backup archive.

So, an empty profile is thus the default when the script is sourced. Still, there is bash and zsh alternative which are optimized to be integrated into ~/.bashrc[2] or ~/.zshrc[3].

A module[4] for zprezto[5] is also available for zsh.

Installation

First getting bar-overlay[6] is necessary only for the POSIX shell script, else, follow the links for the other variant tailored to be sourced in a (login) shell.

layman is optional in this process especiallay if /etc/portage/repos.conf configuration set up is used which make it easy to add new overlays by simply adding a repos.conf file. Else, the easy way is using layman[git] (with git USE flag enabled.)

root #layman -a bar
root #emerge --ask www-misc/browser-home-profile

Configuration

Internal

There is nothing in particular to configure if theses scripts are used as standalone shell script. Just checkout the various options offered, notably the compressor command line switch.

When sourced, bhp.{ba,z}sh shell scripts offer the opportunity to finely set up the options and sub-profile by setting bhp associative array. zprezto module use zstyle framework for configuration, refer to the README.md file for more info.

External

When source, the first login shell will prompt to enter a pass phrase to bind mount the profile and cache directories to randomly generated temporary directories. Or else, similarly, a set up phase is required when any variant is executed or sourced the first time. Sub-sequent call will maintain the tarball archives backup.

So setting up sudo to give users the ability to mount drectories might be necessary if a pass phrase less set up is required. Fire up visudo in order to add a mount command group along with its execution permission set up.

FILE /etc/sudoerssudoers example
[...]
Cmnd_Alias	MOUNT = /bin/mount, /bin/umount, /usr/bin/udevil, /usr/bin/eject
[...]
%adm ALL=(ALL) NOPASSWD: MOUNT, HALT, SUSPEND, PRINTING
Note
Of course the bracketed elipses should be removed; and the others command aliases should be removed as well if not used. Second, adding users to tho @adm group should be done as well with `gpasswd --add $USER adm' to get the desired effect.

Usage

First, bhp would guess a web browser name if none is passed as the last argument and use the first match found! Still, this is only a warning. However, a more efficient way would be to append a browser name to set up.

bhp is not mean to be used by super user (root) so there is nothing special to specify a particular user, or rather home directory, but set HOME environment variable to get the desired effect in the right home directory. Specifying any particular profile, if many profile are available with e.g. firefox, can be done by either passing the browser name as the last argument or setting BROWSER environment variable.

Automatic backup

So, using a cron job to handle automatic backup should ensure the right USER and HOME environment variables to get the desired effects.

FILE /etc/cron.hourly/bhpcron example
*/30 * * * * HOME="$HOME" /usr/bin/browser-home-profile.sh --profile=abcdef01 firefox
# or else, using ~/bin/bhp.{ba,z}sh variant
*/30 * * * * $USER $HOME/bin/bhp.bash --profile=abcdef01 firefox

Alternatively atd from sys-process/at package can be used when need be to schedule backups.

Manual backup

Users using many terminals and accustomed to text interface would far prefer firing up a bhp command when need be. The author of this article prefer saving nad restoring when need be instead of an automatic setup. So, an empty profile, or anonymous, is available as long as a bhp command was not used. Similarly, saving is done when appropriate and the desire to save a particular session point is needed. And thus, using the right shell script for the shell in question seems to be more a propos about this kind of usage.

See also