Invoke as guest:
Code: Select all
$ bbprofile <browser>
Code: Select all
#!/usr/bin/env bash
#
# bbprofile: Saves your browser profile into a module
#
display_usage() {
echo "Usage: "${0##*/}" <browser>" >&2
echo -e "Supported Browsers: \n\t firefox\n\t palemoon\n\t opera\n\t vilvaldi\n\t chromium\n\t chrome"
exit 1
}
[[ $# -eq 1 ]] || display_usage
brcfg=
# (LOCATION OF BROWSER PROFILES AS OF 2020-05)
case "$1" in
firefox) brcfg=.mozilla ;;
palemoon) brcfg=".moonchild productions";;
opera) brcfg=".config/opera" ;;
vivaldi) brcfg=".config/vivaldi" ;;
chromium) brcfg=".config/chromium" ;;
chrome) brcfg=".config/google-chrome" ;;
*) display_usage ;;
esac
excludeopts="--exclude Cache --exclude data.safe.bin --exclude *backups --exclude *storage --exclude *rash* --exclude *dumps --exclude *report*"
read -n 1 -p "Exclude caches, backups, storage and reports (crashes,dumps...)? [y/*] "
echo
[[ ${REPLY,,} == y ]] || excludeopts=""
eval {X,empty}="$(mktemp -d)"; chmod 755 $X $empty
mkdir -p $X$HOME || exit
rsync -avR --delete-before --exclude=lock $excludeopts "$HOME/$brcfg/" "$X"
[ $EUID -eq 0 ] || sudo chown 0:0 $X/home ### FIXED [ -z "${HOME%/*}" ]
brcfg="009-$1-profile-$(date +%Y%m%d-%H%M)."
comp=" -b 1M -comp xz -Xbcj x86 -noappend"
read -n3 -p "Compression method? [xzm/zst] "
echo
[[ ${REPLY,,} == xzm ]] || comp=" -b 1M -comp zstd -Xcompression-level 22 -noappend"
mksquashfs $X /tmp/$brcfg$REPLY $comp ### $X"${HOME::5}"
echo
echo "Your profile module was saved in" /tmp/$brcfg
read -n 1 -p "Would you like to copy it into your $PORTDIR/modules folder? [y/n] "
echo
if [[ ${REPLY,,} == y ]]; then
cp -a /tmp/$brcfg $PORTDIR/modules 2> /dev/null
tput bold;tput setaf 2; echo "Module copied and ready to be activated at next boot"
else tput bold;tput setaf 1; echo "Module not copied into $PORTDIR/modules"
fi
sleep 2
sudo rsync -a --delete $empty/ $X && rmdir $X $empty && unset X empty brcfg excludeopts
exit 0
Let me know if it works for you

Cheers!