provision_vagrant.sh 1.8 KB

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