provision_vagrant.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env bash
  2. apt-get install -y debconf-utils
  3. export TERM=linux
  4. export DEBIAN_FRONTEND=noninteractive
  5. echo 'debconf debconf/frontend select noninteractive' | debconf-set-selections
  6. locale-gen "en_US.UTF-8"
  7. dpkg-reconfigure --frontend=noninteractiv locales
  8. debconf-set-selections <<< 'mysql-server-5.6 mysql-server/root_password password toor'
  9. debconf-set-selections <<< 'mysql-server-5.6 mysql-server/root_password_again password toor'
  10. echo "LC_ALL=en_US.UTF-8" >> /etc/environment
  11. echo "LANG=en_US.UTF-8" >> /etc/environment
  12. PACKAGES="python-psycopg2 sqlite3 git \
  13. postgresql-server-dev-9.5 postgresql \
  14. postgresql-contrib \
  15. python-dev python3-dev libffi-dev \
  16. postgresql python3-psycopg2 build-essential \
  17. mysql-server-5.7
  18. "
  19. apt-get update
  20. apt-get install -y ${PACKAGES}
  21. if [ ! -f /usr/local/bin/pip3 ]; then
  22. wget https://bootstrap.pypa.io/get-pip.py
  23. sudo python3 get-pip.py
  24. fi
  25. PYTHON_PACKAGES="psycopg2 pymysql pymongo pexpect coverage pew"
  26. sudo pip3 install ${PYTHON_PACKAGES}
  27. # install mongodb
  28. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
  29. echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
  30. apt-get update
  31. apt-get install -y mongodb-org
  32. systemctl start mongod
  33. cd /home/vagrant
  34. if [ ! -d pwman3 ]; then
  35. git clone https://github.com/pwman3/pwman3.git
  36. chown vagrant:vagrant -R pwman3
  37. fi
  38. # setup mysql
  39. mysql -e 'CREATE DATABASE IF NOT EXISTS pwmantest' -uroot --password=toor
  40. mysql -e "create user 'pwman'@'localhost' IDENTIFIED BY '123456'" -uroot --password=toor
  41. mysql -e "grant all on pwmantest.* to 'pwman'@'localhost';" -uroot --password=toor
  42. # setup postgresql
  43. sudo -u postgres psql -c "CREATE USER tester WITH PASSWORD '123456';" -U postgres
  44. sudo -u postgres psql -c 'create database pwman;' -U postgres
  45. sudo -u postgres psql -c 'grant ALL ON DATABASE pwman to tester' -U postgres
  46. # setup mongodb
  47. mongo < /home/vagrant/pwman3/tests/init_mongo.js