Guest User

EphemeralFox

a guest
Jul 20th, 2019
1,840
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. ################################################################################
  3. # Author:  Michael Altfield <michael@michaelaltfield.net>
  4. # Created: 2019-03-03
  5. # Updated: 2019-03-06
  6. # Version: 0.2
  7. # Purpose: Start an Ephemeral Firefox session with basic extensions
  8. ################################################################################
  9.  
  10. ############
  11. # SETTINGS #
  12. ############
  13.  
  14. TMP_PATH="/media/veracrypt28/ephemeralFirefox"
  15. #TMP_PATH="/mnt/ramdisk2/"
  16. SKEL_PATH="$HOME/.mozilla/firefox/ephemeralFirefoxSkel"
  17.  
  18. ###############################
  19. # CLEANUP OLD ORPHAN TMP DATA #
  20. ###############################
  21.  
  22. # loop through all the Ephemeral Firefox temp dirs
  23. for tmpDir in $(find "${TMP_PATH}" -mindepth 1 -maxdepth 1 -type d); do
  24.     # is this temp dir for an Ephemeral Firefox that's still running? Or is it no longer needed?
  25.     if [[ -z `firejail --list | grep "${tmpDir}"` ]]; then
  26.         # this temp dir is no longer needed; delete it
  27.         echo "INFO: shredding data from old Ephemeral Firefox temp dir = ${tmpDir}"
  28.         srm -rfll "${tmpDir}"
  29.     fi
  30. done
  31.  
  32. ###################
  33. # CREATE TEMP DIR #
  34. ###################
  35.  
  36. # first create a temp dir in our (hopefully encrypted) $HOME dir, if first run
  37. [ ! -d "${TMP_PATH}" ] && mkdir -p "${TMP_PATH}"
  38.  
  39. # create temp dir for ephemeral session
  40. tmpDir=`/bin/mktemp -p "$TMP_PATH" -d`
  41. tmpProfileDir="${tmpDir}/firefoxProfile"
  42. mkdir -p "${tmpProfileDir}"
  43.  
  44.  
  45. echo $tmpProfileDir
  46. echo "INFO: created Ephemeral Firefox temp profile dir = ${tmpProfileDir}"
  47.  
  48. ###########################
  49. # START EPHEMERAL FIREFOX #
  50. ###########################
  51.  
  52. # what should the homepage be?
  53. url="${1}"
  54. if [[ -z ${url} ]]; then
  55.     url="https://start.duckduckgo.com"
  56. fi
  57.  
  58. # prepare extensions
  59. cp -r "${SKEL_PATH}/extensions" "${tmpProfileDir}/extensions"
  60. #cp -r "${SKEL_PATH}/browser-extension-data" ${tmpProfileDir}/
  61. cp "${SKEL_PATH}/user.js" "${tmpProfileDir}/"
  62. cp "${SKEL_PATH}/extensions.json" "${tmpProfileDir}/"
  63.  
  64. # try disabling 'seccomp' if you encounter issues
  65. #firejail --ignore=seccomp --whitelist="${tmpProfileDir}" firefox -no-remote -new-instance -profile "${tmpProfileDir}" "${url}"
  66.  
  67. firejail --whitelist="${tmpProfileDir}" firefox -no-remote -new-instance -profile "${tmpProfileDir}" "${url}"
  68.  
  69. ###########
  70. # CLEANUP #
  71. ###########
  72.  
  73. # fast (secure enough) wipe of tmp dir
  74. srm -vrfll "${tmpDir}"
  75.  
  76. # clean exit
  77. exit 0
  78. EOF
RAW Paste Data