run-browser.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/sh
  2. cd `dirname $0`
  3. echo "Running I2P Bundle from $(pwd)..."
  4. # Runs i2pd
  5. _run_i2pd() {
  6. ulimit -n 4096
  7. if [ -f i2pd/i2pd ]; then
  8. i2pd/i2pd --datadir i2pd-data --httpproxy.enabled=1 --sam.enabled=1
  9. else
  10. i2pd --datadir i2pd-data --httpproxy.enabled=1 --sam.enabled=1
  11. fi
  12. }
  13. # Runs XD BitTorrent client
  14. _run_XD() {
  15. mkdir XD-data
  16. cd XD-data
  17. if [ -f ../XD/XD ]; then
  18. ../XD/XD torrents.ini
  19. else
  20. XD torrents.ini
  21. fi
  22. }
  23. # Runs tor
  24. _run_tor() {
  25. if [ -f tor/tor ]; then
  26. # NOTE: tor doesn't like relative paths in parameters
  27. # --User is left blank so that it can be run as normal user. Setting a
  28. # --User requires tor to be run as root, which is unnecessary.
  29. # Optionally, a custom torrc can be passed by adding:
  30. # -f "$PWD/tor-data/torrc"
  31. # Previously the parameters were in that torrc file above and the file
  32. # was passed with a -f parameter. But since there are just 3 changes
  33. # needed to run a basic i2p-tor browser setup, it's now parameterized.
  34. tor/tor --User "" --DataDirectory "$PWD/tor-data" --SOCKSPort 9450
  35. else
  36. tor --User "" --DataDirectory "$PWD/tor-data" --SOCKSPort 9450
  37. fi
  38. }
  39. _killit () {
  40. # Sends SIGQUIT (-3), waits for 7 seconds then sends SIGKILL (-9)
  41. pkill -3 $1 && sleep 7 && pkill -9 $1 || echo "$1 not running, so skipping pkill call"
  42. }
  43. # Run all the i2p stuff, plus tor before running browser
  44. # These will be killed later when browser quits. See "commands after semicolons" comment.
  45. _run_i2pd &
  46. _run_XD &
  47. _run_tor &
  48. # Prepare to run browser
  49. mkdir -p icecat-data
  50. echo "Attempting to run the browser..."
  51. echo "Once it runs you will be able to access:"
  52. echo "- i2pd panel: http://127.0.0.1:7070/"
  53. echo "- XD webui: http://127.0.0.1:1776/"
  54. # Run browser. Commands after semicolons are run after Ctrl+C is pressed or icecat is quit.
  55. icecat/icecat --no-remote --profile "$PWD/icecat-data";
  56. echo "Killing XD, i2pd and tor...";
  57. _killit XD &
  58. _killit i2pd &
  59. _killit tor &