runner.sh 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. # -*- mode: sh; tab-width: 4; coding: utf-8 -*-
  2. # vim: ts=4 noet ai ft=sh
  3. # Run Firefox with an (unpackless) add-on.
  4. # This file is part of JPM.sh.
  5. # Copyright (C) 2016 the Desktopd developers
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. # Dependencies
  20. . "$gLibDir/tmpdir.sh"
  21. # @private
  22. jpmFirefoxGenPrefsJs () {
  23. cat <<EOF
  24. user_pref("app.update.auto", false);
  25. user_pref("app.update.enabled", false);
  26. user_pref("app.update.lastUpdateTime.browser-cleanup-thumbnails", 0);
  27. user_pref("app.update.lastUpdateTime.xpi-signature-verification", 0);
  28. user_pref("browser.EULA.3.accepted", true);
  29. user_pref("browser.EULA.override", true);
  30. user_pref("browser.bookmarks.restore_default_bookmarks", false);
  31. user_pref("browser.cache.disk.filesystem_reported", 1);
  32. user_pref("browser.cache.disk.smart_size.first_run", false);
  33. user_pref("browser.cache.frecency_experiment", 3);
  34. user_pref("browser.dom.window.dump.enabled", true);
  35. user_pref("browser.download.manager.showWhenStarting", false);
  36. user_pref("browser.laterrun.enabled", true);
  37. user_pref("browser.link.open_external", 2);
  38. user_pref("browser.link.open_newwindow", 2);
  39. user_pref("browser.migration.version", 36);
  40. user_pref("browser.newtabpage.enabled", false);
  41. user_pref("browser.newtabpage.enhanced", false);
  42. user_pref("browser.offline", false);
  43. user_pref("browser.pagethumbnails.storage_version", 3);
  44. user_pref("browser.places.smartBookmarksVersion", 7);
  45. user_pref("browser.safebrowsing.enabled", false);
  46. user_pref("browser.safebrowsing.malware.enabled", false);
  47. user_pref("browser.safebrowsing.provider.0.gethashURL", "data:,safebrowsing-dummy-gethash");
  48. user_pref("browser.safebrowsing.provider.0.keyURL", "data:,safebrowsing-dummy-newkey");
  49. user_pref("browser.safebrowsing.provider.0.updateURL", "data:,safebrowsing-dummy-update");
  50. user_pref("browser.search.suggest.enabled", false);
  51. user_pref("browser.search.update", false);
  52. user_pref("browser.sessionstore.resume_from_crash", false);
  53. user_pref("browser.shell.checkDefaultBrowser", false);
  54. user_pref("browser.startup.homepage", "about:blank");
  55. user_pref("browser.startup.page", 0);
  56. user_pref("browser.tabs.warnOnClose", false);
  57. user_pref("browser.tabs.warnOnOpen", false);
  58. user_pref("devtools.chrome.enabled", true);
  59. user_pref("devtools.debugger.remote-enabled", true);
  60. user_pref("devtools.errorconsole.enabled", true);
  61. user_pref("dom.apps.reset-permissions", true);
  62. user_pref("dom.disable_open_during_load", false);
  63. user_pref("dom.max_script_run_time", 30);
  64. user_pref("dom.mozApps.used", true);
  65. user_pref("experiments.activeExperiment", false);
  66. user_pref("extensions.autoDisableScopes", 10);
  67. user_pref("extensions.blocklist.enabled", false);
  68. user_pref("extensions.blocklist.pingCountVersion", 0);
  69. user_pref("extensions.blocklist.url", "data:,extensions-dummy-blocklistURL");
  70. user_pref("extensions.enabledScopes", 5);
  71. user_pref("extensions.getAddons.cache.enabled", false);
  72. user_pref("extensions.installDistroAddons", false);
  73. user_pref("extensions.pendingOperations", false);
  74. user_pref("extensions.sdk.console.logLevel", "info");
  75. user_pref("extensions.systemAddonSet", "{\"schema\":1,\"addons\":{}}");
  76. user_pref("extensions.ui.dictionary.hidden", true);
  77. user_pref("extensions.ui.experiment.hidden", true);
  78. user_pref("extensions.ui.lastCategory", "addons://list/extension");
  79. user_pref("extensions.ui.locale.hidden", true);
  80. user_pref("extensions.update.enabled", false);
  81. user_pref("extensions.update.notifyUser", false);
  82. user_pref("extensions.update.url", "data:,extensions-dummy-updateURL");
  83. user_pref("extensions.webservice.discoverURL", "data:,extensions-dummy-discoveryURL");
  84. user_pref("network.cookie.prefsMigrated", true);
  85. user_pref("network.http.max-connections-per-server", 10);
  86. user_pref("network.http.phishy-userpass-length", 255);
  87. user_pref("network.manage-offline-status", false);
  88. user_pref("network.predictor.cleaned-up", true);
  89. user_pref("prompts.tab_modal.enabled", false);
  90. user_pref("security.fileuri.origin_policy", 3);
  91. user_pref("security.fileuri.strict_origin_policy", false);
  92. user_pref("security.warn_entering_secure", false);
  93. user_pref("security.warn_entering_secure.show_once", false);
  94. user_pref("security.warn_entering_weak", false);
  95. user_pref("security.warn_entering_weak.show_once", false);
  96. user_pref("security.warn_leaving_secure", false);
  97. user_pref("security.warn_leaving_secure.show_once", false);
  98. user_pref("security.warn_submit_insecure", false);
  99. user_pref("security.warn_viewing_mixed", false);
  100. user_pref("security.warn_viewing_mixed.show_once", false);
  101. user_pref("signon.importedFromSqlite", true);
  102. user_pref("signon.rememberSignons", false);
  103. user_pref("startup.homepage_welcome_url", "about:blank");
  104. user_pref("toolkit.networkmanager.disable", true);
  105. user_pref("toolkit.telemetry.archive.enabled", false);
  106. user_pref("toolkit.telemetry.enabled", false);
  107. user_pref("toolkit.telemetry.prompted", 2);
  108. user_pref("toolkit.telemetry.rejected", true);
  109. user_pref("toolkit.telemetry.reportingpolicy.firstRun", false);
  110. user_pref("urlclassifier.updateinterval", 172800);
  111. user_pref("webdriver_accept_untrusted_certs", true);
  112. user_pref("webdriver_assume_untrusted_issuer", true);
  113. user_pref("webdriver_enable_native_events", true);
  114. user_pref("xpinstall.signatures.required", false);
  115. EOF
  116. }
  117. # jpmFirefoxStart <firefoxBinPath> <xpiId>
  118. # Note: Intentional use of subshell
  119. jpmFirefoxStart () (
  120. aFirefoxBin=$1
  121. aXpiId=$2
  122. jpmConsoleLog "runner: Preparing a temporary profile..."
  123. tmpDir=`jpmTempDirCreate`
  124. [ -d "$tmpDir" ] || {
  125. jpmConsoleError "runner: Failed to create a temporary directory"
  126. exit 1 # Exits this subshell
  127. }
  128. tmpHomeDir=$tmpDir/home
  129. tmpTmpDir=$tmpDir/tmp
  130. mkdir -p "$tmpHomeDir" "$tmpTmpDir" >&2
  131. TMP=$tmpTmpDir
  132. TMPDIR=$tmpTmpDir
  133. TEMP=$tmpTmpDir
  134. TEMPDIR=$tmpTmpDir
  135. HOME=$tmpHomeDir
  136. export TMP TMPDIR TEMP TEMPDIR HOME
  137. # Create profile directory
  138. profileDir=$HOME/profile.default
  139. extDir=$profileDir/extensions
  140. mkdir -p "$extDir" >&2
  141. [ -d "$extDir" ] || {
  142. jpmConsoleError "runner: Failed to create a profile directory"
  143. exit 1 # Exits this subshell
  144. }
  145. jpmFirefoxGenPrefsJs > "$profileDir/prefs.js"
  146. jpmConsoleLog "runner: Installing .xpi, receiving data..."
  147. [ "$aXpiId" ] && {
  148. cat > "$extDir/$aXpiId.xpi"
  149. }
  150. jpmConsoleLog "runner: Profile set up. Starting $gBrowserName..."
  151. #cd "$HOME"
  152. "$aFirefoxBin" -no-remote -profile "$profileDir"
  153. cd /
  154. jpmConsoleLog "runner: $gBrowserName finished. Deleting the temporary profile..."
  155. rm -rf "$tmpDir"
  156. )