diff options
Diffstat (limited to 'libre/iceweasel/rename-profile.sh')
-rw-r--r-- | libre/iceweasel/rename-profile.sh | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/libre/iceweasel/rename-profile.sh b/libre/iceweasel/rename-profile.sh new file mode 100644 index 000000000..655cb5335 --- /dev/null +++ b/libre/iceweasel/rename-profile.sh @@ -0,0 +1,101 @@ +#!/bin/bash + +# rename existing 'firefox' user profile directory to 'iceweasel' +# +# NOTE: Prior to v99, if another Firefox is installed in addition to Iceweasel, +# both applications would share a profile, which is not very sane behavior. +# TODO: This source file could be deleted after a reasonable deprecation period. +# +# NOTE: The Iceweasel binary is inaccessible via the usual means +# (`iceweasel`, `/usr/bin/iceweasel`, or the iceweasel.desktop launcher). +# The binary has been renamed to ice-weasel, and replaced by this script. +# Therefore all usual means of launching, will go through this script. + + +Defer() +{ + gxmessage -title "Parabola Iceweasel Updater" \ + -buttons "OK:0" \ + -default "OK" \ + -font "sans 16" \ + -geometry 620x460 \ + -center -wrap -ontop -sticky \ +"A new version of Iceweasel has been installed; +but the upgrade can not continue just yet. + +A previous version of Iceweasel is already running. + +Please close all running Iceweasel windows, +then start Iceweasel again. + +If this message persists, try restarting the computer." +} + +Prompt() +{ + gxmessage -title "Parabola Iceweasel Updater" \ + -buttons "Move:0,Copy:1" \ + -default "Move" \ + -font "monospace 12" \ + -geometry 780x580 \ + -center -wrap -ontop -sticky \ +"A new version of Iceweasel has been installed; but the upgrade can not continue just yet. + +This upgrade intends to move the storage location of the Iceweasel user profile, from ~/.mozilla/firefox to ~/.mozilla/iceweasel, in order to isolate it from other Firefox variants. + +You have two options: + + * 'Move': This is the recommended option, + if you do not have any other Firefox variants installed. + However, if you have another Firefox variant installed, + the other's preferences may be reset to defaults. + Parabola does not distribute any other Firefox variant, + which would be affected by this decision. + If all software on your computer came from the Parabola repos + (as recommended), then 'Move' is the best option. + + * 'Copy': If you have another Firefox variant installed, + it will keep all user preferences as they are, + and Iceweasel will inherit the preferences. + +Note that neither option would affect Icecat, nor any other Firefox variant +which does not store user profiles under ~/.mozilla/firefox. +" +} + +Launch() { /usr/lib/iceweasel/ice-weasel "$@" ; } + + +if [[ -d ~/.mozilla/firefox ]] && \ + ! [[ -e ~/.mozilla/iceweasel ]] +then # This is the expected case, where the user has previously run + # either Iceweasel or Firefox on this system; + # and this is the first time, that this script has run. + pids=( $(pgrep --euid ${EUID} firefox ) \ + $(pgrep --euid ${EUID} iceweasel) ) + if [[ -n "${pids[*]/$$/}" ]] + then # In this case, Firefox or Iceweasel is already running; + # so ask the user to terminate them. + Defer + else # Ready to move the profile directory. + # Give the user the option to preserve the Firefox profile, + # then launch the binary. + if Prompt + then mv ~/.mozilla/{firefox,iceweasel} + else cp -a ~/.mozilla/{firefox,iceweasel} + fi + Launch "$@" + fi +else # This branch is executed in any of three cases: + # 1) The user has run Iceweasel or some other Firefox variant in the past, + # AND ~/.mozilla/iceweasel already exists for some reason. + # 2) The expected case, where the user has previously selected 'Copy' + # during a previous run of this script, + # perhaps from a previous Iceweasel release. + # 3) The remaining expected case, where the user has never run + # neither Iceweasel nor Firefox on this system. + # So, simply launch the binary. + # This is potentially problematic in the (unlikely) case #1; + # but is easily resolved manually: $ rm -rf ~/.mozilla/iceweasel + Launch "$@" +fi |