run-browser.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. tor/tor -f tor-data/torrc
  27. else
  28. tor -f tor-data/torrc
  29. fi
  30. }
  31. _killit () {
  32. # Sends SIGQUIT (-3), waits for 7 seconds then sends SIGKILL (-9)
  33. pidof $1 && pkill -3 $1 && sleep 7 && pkill -9 $1 || echo "$1 not running, so skipping pkill call"
  34. }
  35. # Run all the i2p stuff, plus tor before running browser
  36. # These will be killed later when browser quits. See "commands after semicolons" comment.
  37. _run_i2pd &
  38. _run_XD &
  39. _run_tor &
  40. # Prepare to run browser
  41. mkdir -p icecat-data
  42. echo "Attempting to run the browser..."
  43. echo "Once it runs you will be able to access:"
  44. echo "- i2pd panel: http://127.0.0.1:7070/"
  45. echo "- XD webui: http://127.0.0.1:1776/"
  46. # Run browser. Commands after semicolons are run after Ctrl+C is pressed or icecat is quit.
  47. icecat/icecat --no-remote --profile "$PWD/icecat-data";
  48. echo "Killing XD, i2pd and tor...";
  49. _killit XD &
  50. _killit i2pd &
  51. _killit tor &