# Directories _user=det # User _home=/home/$_user/ # $HOME ## Install for Mozilla Firefoxes _firefox() { echo -e "\nInstalling Mozilla Firefox leftovers..." # Try to use existing profiles IFS=$'\n' _ff_profiles=($(ls -d $_home/.mozilla/firefox/*.*/ 2>/dev/null)) if [[ $_ff_profiles ]]; then for _ff_profile in ${_ff_profiles[@]}; do # Install install -d -o $_user $_ff_profile/extensions/support@lastpass.com/ bsdtar -xf /usr/share/lastpass/lpfirefox_*.xpi -C $_ff_profile/extensions/support@lastpass.com/ # Enable auto-installation through 'extensions.autoDisableScopes' echo 'user_pref("extensions.autoDisableScopes", 10);' >> $_ff_profile/prefs.js echo 'user_pref("xpinstall.signatures.required", false);' >> $_ff_profile/prefs.js # Set the correct ownerships chown $_user $_ff_profile/extensions/ chown $_user -R $_ff_profile/extensions/support@lastpass.com/ done else # Create our own install -d $_home/.mozilla/firefox/lastpass.default/extensions/support@lastpass.com/ bsdtar -xf /usr/share/lastpass/lpfirefox_*.xpi -C \ $_home/.mozilla/firefox/lastpass.default/extensions/support@lastpass.com/ # Install 'profiles.ini' install -m644 /usr/share/lastpass/profiles.ini $_home/.mozilla/firefox/ # Enable the auto-installation echo "user_pref(\"extensions.autoDisableScopes\", 10);" >> \ $_home/.mozilla/firefox/lastpass.default/prefs.js echo 'user_pref("xpinstall.signatures.required", false);' >> \ $_home/.mozilla/firefox/lastpass.default/prefs.js # Set the correct ownerships chown $_user -R $_home/.mozilla/ fi } post_install() { _firefox # Create the settings dir install -d -o $_user $_home/.lastpass/ } post_upgrade() { post_install } post_remove() { ## Google Chromes/Chromiums echo -e "\nRemoving from Google Chromes/Chromiums..." for i in 'google-chrome' 'chromium' 'chromium-dev'; do for j in 'hdokiejnpimakedhajhdlcegeplioahd' 'debgaelkhoipmbjnhpoblmbacnmmgbeg' \ 'hnjalnkldgigidggphhmacmimbdlafdo' 'hgnkdfamjgnljokmokheijphenjjhkjc'; do rm -rf $_home/.config/$i/Default/Extensions/$j/ done done ## Mozilla Firefoxes echo -e "\nRemoving from Mozilla Firefoxes..." for i in $_home/.mozilla/firefox/*; do rm -rf $i/extensions/support@lastpass.com/ done # Get rid of anything we might have created # 1) Omit our own stuff with bash's extglob ("!(argument1|argument2)") (turned on by default) # 2) Use the $(wc -l)=2 to see, if extensions/ and prefs.js is all we have (our own stuff) if [[ $(ls -d ~/.mozilla/firefox/lastpass/ 2>&- | wc -l) = 2 ]]; then # Remove the profile folder rm -r $_home/.mozilla/firefox/lastpass/ # If ~/.mozilla/firefox/ or the whole thing was created by us, get rid of them too for j in firefox ""; do if [[ ! $(ls -d $_home/.mozilla/$j/!(profiles.ini) 2>&-) ]]; then rm -r $_home/.mozilla/$j/ fi done fi ## Operas echo -e "\nRemoving from Operas...\n" for i in .opera .opera-next; do rm -rf $_home/$i/widgets/lastpass-* # widgets.dat won't be cleaned automatically by Opera startup if [[ $(grep "wuid-" $_home/$i/widgets/widgets.dat 2>&-) ]]; then sed "/lastpass/,/section/d" \ -i $_home/$i/widgets/widgets.dat else rm $_home/$i/widgets/widgets.dat fi # If ~/.opera(-next)/widgets or the whole thing was created by us, get rid of them too for j in widgets ""; do if [[ ! $(ls $_home/$i/$j/ 2>&-) ]]; then rm -r $_home/$i/$j/ fi done done ## Remove the settings dir rm -rf $_home/.lastpass/ }