install 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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='privoxy tor php5-fpm'
  35. packages='tor php5-fpm'
  36. sudo apt-get update
  37. DEBIAN_FRONTEND=noninteractive sudo apt-get --assume-yes --force-yes install ${packages}
  38. # Save arguments
  39. #sudo yunohost app setting torclient server_name -v "${server_name}"
  40. sudo install -o root -g root -m 0644 ../conf/torrc /etc/tor/torrc.tpl
  41. sudo install -b -o root -g root -m 0644 ../conf/nginx_torclient.conf "/etc/nginx/conf.d/${domain}.d/torclient.conf"
  42. sudo install -b -o root -g root -m 0644 ../conf/phpfpm_torclient.conf /etc/php5/fpm/pool.d/torclient.conf
  43. # Copy web sources
  44. sudo mkdir -pm 0755 /var/www/torclient/
  45. sudo cp -a ../sources/* /var/www/torclient/
  46. sudo chown -R root: /var/www/torclient/
  47. sudo chmod -R 0644 /var/www/torclient/*
  48. sudo find /var/www/torclient/ -type d -exec chmod +x {} \;
  49. # Fix confs
  50. ## nginx
  51. sudo sed "s|<TPL:NGINX_LOCATION>|${url_path}|g" -i "/etc/nginx/conf.d/${domain}.d/torclient.conf"
  52. sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/torclient/|g' -i "/etc/nginx/conf.d/${domain}.d/torclient.conf"
  53. sudo sed 's|<TPL:PHP_NAME>|torclient|g' -i "/etc/nginx/conf.d/${domain}.d/torclient.conf"
  54. ## php-fpm
  55. sudo sed 's|<TPL:PHP_NAME>|torclient|g' -i /etc/php5/fpm/pool.d/torclient.conf
  56. sudo sed 's|<TPL:PHP_USER>|admin|g' -i /etc/php5/fpm/pool.d/torclient.conf
  57. sudo sed 's|<TPL:PHP_GROUP>|admins|g' -i /etc/php5/fpm/pool.d/torclient.conf
  58. sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/torclient/|g' -i /etc/php5/fpm/pool.d/torclient.conf
  59. sudo sed 's|^;\?\s*max_execution_time.\+|max_execution_time = 600|' -i /etc/php5/fpm/php.ini
  60. # Fix sources
  61. sudo sed "s|<TPL:NGINX_LOCATION>|${url_path}|g" -i /var/www/torclient/config.php
  62. # Copy init script
  63. sudo install -o root -g root -m 0755 ../conf/init_ynh-torclient /etc/init.d/ynh-torclient
  64. # Update firewall for DHCP
  65. sudo yunohost firewall allow --no-upnp UDP 9053
  66. sudo yunohost firewall allow --no-upnp TCP 9040
  67. # Set default inits
  68. #php-fpm is already installed by yunohost hotspot app
  69. sudo service php5-fpm stop
  70. sudo service php5-fpm start
  71. sudo service nginx reload
  72. # Update SSO for vpnadmin
  73. sudo yunohost app ssowatconf
  74. # Stop tor client
  75. sudo service tor stop
  76. sudo insserv -r tor
  77. #sudo service ynh-torclient start
  78. sudo yunohost app setting torclient wifi_ssid -v notset
  79. sudo yunohost app setting torclient wifi_device_old -v notset
  80. # Start tor client at boot
  81. sudo insserv ynh-torclient
  82. exit 0