freedombone-utils-i2p 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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" || exit 346735
  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. service i2p stop
  60. apt-get -yq remove i2p-router --purge
  61. apt-get -yq remove i2p --purge
  62. apt-get -yq remove i2p-keyring --purge
  63. apt-get -yq autoremove
  64. # It's assumed here that ipv6 is only needed for i2p
  65. # This might not be true in future
  66. sed -i 's|net.ipv6.conf.all.disable_ipv6.*|net.ipv6.conf.all.disable_ipv6 = 1|g' /etc/sysctl.conf
  67. /sbin/sysctl -p -q
  68. if [ -d /var/lib/i2p ]; then
  69. rm -rf /var/lib/i2p
  70. fi
  71. if [ -d /etc/i2p ]; then
  72. rm -rf /etc/i2p
  73. fi
  74. if [ -d /usr/share/i2p ]; then
  75. rm -rf /usr/share/i2p
  76. fi
  77. if [ -d /var/log/i2p ]; then
  78. rm /var/log/i2p
  79. fi
  80. rm -rf /tmp/i2p*
  81. rm /etc/apt/sources.list.d/i2p.list
  82. }
  83. function i2p_enable_sam {
  84. if [ ! -f /var/lib/i2p/i2p-config/clients.config ]; then
  85. service i2p stop
  86. apt-get -yq remove i2p i2p-keyring --purge
  87. apt-get -yq remove i2p-router --purge
  88. if [ -d /var/lib/i2p ]; then
  89. rm -rf /var/lib/i2p
  90. fi
  91. if [ -d /etc/i2p ]; then
  92. rm -rf /etc/i2p
  93. fi
  94. if [ -d /usr/share/i2p ]; then
  95. rm -rf /usr/share/i2p
  96. fi
  97. if [ -d /var/log/i2p ]; then
  98. rm /var/log/i2p
  99. fi
  100. rm -rf /tmp/i2p*
  101. apt-get -yq install i2p i2p-keyring
  102. apt-get -yq install i2p-router --reinstall
  103. systemctl restart i2p
  104. sleep 10
  105. fi
  106. if [ ! -f /var/lib/i2p/i2p-config/clients.config ]; then
  107. echo $'File not found /var/lib/i2p/i2p-config/clients.config'
  108. exit 483648364834
  109. fi
  110. sed -i 's|clientApp.1.startOnLoad=.*|clientApp.1.startOnLoad=true|g' /var/lib/i2p/i2p-config/clients.config
  111. systemctl restart i2p
  112. }
  113. # NOTE: deliberately no exit 0