install 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/bash
  2. # VPN 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
  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. # Set default inits
  65. #php-fpm is already installed by yunohost hotspot app
  66. sudo service php-fpm stop
  67. sudo service php-fpm start
  68. sudo service nginx reload
  69. # Update SSO for vpnadmin
  70. sudo yunohost app ssowatconf
  71. # Start tor client
  72. service torclient start
  73. exit 0