freedombone-utils-i2p 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # i2p functions
  12. #
  13. # There's a problem with installing this onto mesh images, which is
  14. # that qemu appears to run out of RAM when using yarn to add webpack.
  15. #
  16. # License
  17. # =======
  18. #
  19. # Copyright (C) 2017-2018 Bob Mottram <bob@freedombone.net>
  20. #
  21. # This program is free software: you can redistribute it and/or modify
  22. # it under the terms of the GNU Affero General Public License as published by
  23. # the Free Software Foundation, either version 3 of the License, or
  24. # (at your option) any later version.
  25. #
  26. # This program is distributed in the hope that it will be useful,
  27. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29. # GNU Affero General Public License for more details.
  30. #
  31. # You should have received a copy of the GNU Affero General Public License
  32. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  33. I2P_DOMAIN='deb.i2p2.de'
  34. function install_i2p {
  35. if [ ! -d $INSTALL_DIR ]; then
  36. mkdir -p $INSTALL_DIR
  37. fi
  38. # install the gpg key
  39. cd $INSTALL_DIR
  40. if [ -f i2p-debian-repo.key.asc ]; then
  41. rm i2p-debian-repo.key.asc
  42. fi
  43. wget https://geti2p.net/_static/i2p-debian-repo.key.asc
  44. if [ ! -f i2p-debian-repo.key.asc ]; then
  45. echo $'failed to ontain i2p repo gpg key'
  46. exit 7834627345
  47. fi
  48. apt-key add i2p-debian-repo.key.asc
  49. echo "deb https://${I2P_DOMAIN}/ stretch main" > /etc/apt/sources.list.d/i2p.list
  50. echo "deb-src https://${I2P_DOMAIN}/ stretch main" >> /etc/apt/sources.list.d/i2p.list
  51. # i2p needs ipv6 to be enabled
  52. sed -i 's|net.ipv6.conf.all.disable_ipv6.*|net.ipv6.conf.all.disable_ipv6 = 0|g' /etc/sysctl.conf
  53. /sbin/sysctl -p -q
  54. apt-get update
  55. apt-get -yq install i2p i2p-keyring
  56. systemctl restart i2p
  57. }
  58. function remove_i2p {
  59. apt-get -yq remove i2p-router --purge
  60. apt-get -yq remove i2p --purge
  61. apt-get -yq remove i2p-keyring --purge
  62. apt-get -yq autoremove
  63. # It's assumed here that ipv6 is only needed for i2p
  64. # This might not be true in future
  65. sed -i 's|net.ipv6.conf.all.disable_ipv6.*|net.ipv6.conf.all.disable_ipv6 = 1|g' /etc/sysctl.conf
  66. /sbin/sysctl -p -q
  67. if [ -d /var/lib/i2p ]; then
  68. rm -rf /var/lib/i2p
  69. fi
  70. if [ -d /etc/i2p ]; then
  71. rm -rf /etc/i2p
  72. fi
  73. if [ -d /usr/share/i2p ]; then
  74. rm -rf /usr/share/i2p
  75. fi
  76. }
  77. function i2p_enable_sam {
  78. if [ ! -f /var/lib/i2p/i2p-config/clients.config ]; then
  79. apt-get -yq remove i2p --purge
  80. apt-get -yq remove i2p-router --purge
  81. if [ -d /var/lib/i2p ]; then
  82. rm -rf /var/lib/i2p
  83. fi
  84. if [ -d /etc/i2p ]; then
  85. rm -rf /etc/i2p
  86. fi
  87. if [ -d /usr/share/i2p ]; then
  88. rm -rf /usr/share/i2p
  89. fi
  90. apt-get -yq install i2p i2p-keyring
  91. apt-get -yq install i2p-router
  92. sleep 10
  93. fi
  94. if [ ! -f /var/lib/i2p/i2p-config/clients.config ]; then
  95. echo $'File not found /var/lib/i2p/i2p-config/clients.config'
  96. exit 483648364834
  97. fi
  98. sed -i 's|clientApp.1.startOnLoad=.*|clientApp.1.startOnLoad=true|g' /var/lib/i2p/i2p-config/clients.config
  99. systemctl restart i2p
  100. }