install 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/bin/bash
  2. # Tor Client app for YunoHost
  3. # Copyright (C) 2015 Emile Morel <emile@bleuchtang.fr>
  4. # Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
  5. # Contribute at https://github.com/bleuchtang/torclient_ynh
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. # Retrieve arguments
  20. domain=${1}
  21. url_path=${2}
  22. # Check domain/path availability
  23. sudo yunohost app checkurl ${domain}${url_path} -a torclient
  24. if [ ! $? -eq 0 ]; then
  25. exit 1
  26. fi
  27. if [ ! -e /tmp/.ynh-hotspot-started ]; then
  28. echo "hotspot not started and/or not installed"
  29. fi
  30. echo 'deb http://deb.torproject.org/torproject.org wheezy main' | sudo tee "/etc/apt/sources.list.d/torproject.list"
  31. gpg --keyserver keys.gnupg.net --recv 886DDD89
  32. gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
  33. # Install packages
  34. packages='tor php5-fpm'
  35. sudo apt-get update
  36. DEBIAN_FRONTEND=noninteractive sudo apt-get --assume-yes --force-yes install ${packages}
  37. # Save arguments
  38. #sudo yunohost app setting torclient server_name -v "${server_name}"
  39. sudo install -o root -g root -m 0644 ../conf/torrc /etc/tor/torrc.tpl
  40. sudo install -b -o root -g root -m 0644 ../conf/nginx_torclient.conf "/etc/nginx/conf.d/${domain}.d/torclient.conf"
  41. sudo install -b -o root -g root -m 0644 ../conf/phpfpm_torclient.conf /etc/php5/fpm/pool.d/torclient.conf
  42. # Copy web sources
  43. sudo mkdir -pm 0755 /var/www/torclient/
  44. sudo cp -a ../sources/* /var/www/torclient/
  45. sudo chown -R root: /var/www/torclient/
  46. sudo chmod -R 0644 /var/www/torclient/*
  47. sudo find /var/www/torclient/ -type d -exec chmod +x {} \;
  48. # Fix confs
  49. ## nginx
  50. sudo sed "s|<TPL:NGINX_LOCATION>|${url_path}|g" -i "/etc/nginx/conf.d/${domain}.d/torclient.conf"
  51. sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/torclient/|g' -i "/etc/nginx/conf.d/${domain}.d/torclient.conf"
  52. sudo sed 's|<TPL:PHP_NAME>|torclient|g' -i "/etc/nginx/conf.d/${domain}.d/torclient.conf"
  53. ## php-fpm
  54. sudo sed 's|<TPL:PHP_NAME>|torclient|g' -i /etc/php5/fpm/pool.d/torclient.conf
  55. sudo sed 's|<TPL:PHP_USER>|admin|g' -i /etc/php5/fpm/pool.d/torclient.conf
  56. sudo sed 's|<TPL:PHP_GROUP>|admins|g' -i /etc/php5/fpm/pool.d/torclient.conf
  57. sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/torclient/|g' -i /etc/php5/fpm/pool.d/torclient.conf
  58. sudo sed 's|^;\?\s*max_execution_time.\+|max_execution_time = 600|' -i /etc/php5/fpm/php.ini
  59. # Fix sources
  60. sudo sed "s|<TPL:NGINX_LOCATION>|${url_path}|g" -i /var/www/torclient/config.php
  61. # Copy init script
  62. sudo install -o root -g root -m 0755 ../conf/init_ynh-torclient /etc/init.d/ynh-torclient
  63. # Allow Tor ports in firewall
  64. sudo yunohost firewall allow --no-upnp UDP 9053
  65. sudo yunohost firewall allow --no-upnp TCP 9040
  66. # Set default inits
  67. #php-fpm is already installed by yunohost hotspot app
  68. sudo service php5-fpm stop
  69. sudo service php5-fpm start
  70. sudo service nginx reload
  71. # Update SSO for vpnadmin
  72. sudo yunohost app ssowatconf
  73. # Stop tor client
  74. sudo service tor stop
  75. sudo insserv -r tor
  76. #sudo service ynh-torclient start
  77. sudo yunohost app setting torclient wifi_num -v -1
  78. sudo yunohost app setting torclient wifi_num_old -v -1
  79. # Start tor client at boot
  80. sudo insserv ynh-torclient
  81. exit 0