diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a977916 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vagrant/ diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..5cc2701 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,75 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure(2) do |config| + config.vm.box = "debian/jessie64" + + config.vm.synced_folder '.', '/vagrant' + #config.vm.synced_folder '.', '/vagrant_data' + + config.vm.provision "shell", inline: <<-SHELL + + # install what we need + sudo apt-get update + sudo apt-get install -y git-core \ + apache2 \ + libapache2-mod-fcgid \ + libyaml-syck-perl \ + libnet-ldap-perl \ + liblog-log4perl-perl \ + libcrypt-cbc-perl \ + libcgi-fast-perl \ + libfcgi-perl \ + libio-socket-inet6-perl \ + libsocket6-perl \ + liblog-dispatch-perl \ + libcrypt-blowfish-perl \ + libnetaddr-ip-perl + + # create self signed cert + sudo openssl req -x509 -nodes -days 365 -newkey rsa:4096 \ + -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" \ + -keyout /etc/ssl/private/apache-selfsigned.key \ + -out /etc/ssl/certs/apache-selfsigned.crt + + # setup data dir + NDIR=`grep namespace_dir /vagrant/src/server/etc/hostdb/server_conf.yaml | awk '{print $2}'` + sudo mkdir -p $NDIR/hosts/.perms + sudo mkdir -p $NDIR/tags/.perms + sudo mkdir -p $NDIR/tags/.members + + sudo echo "--- yaml host conf" > $NDIR/hosts/server1.yourdomain.com + sudo echo "--- yaml host conf" > $NDIR/hosts/server2.yourdomain.com + sudo echo "--- yaml tag conf" > $NDIR/tags/tag1 + sudo echo "--- yaml tag conf" > $NDIR/tags/tag2 + sudo echo "--- yaml tag conf" > $NDIR/tags/tag3 + sudo echo "server1.yourdomain.com" > $NDIR/tags/.members/tag1 + sudo echo "server2.yourdomain.com" > $NDIR/tags/.members/tag2 + sudo echo -e '@tag1\\n@tag2' > $NDIR/tags/.members/tag3 + sudo echo -e "---\\nadmin:\\n data: RW" > $NDIR/hosts/.perms/.default + sudo echo -e "---\\nadmin:\\n data: RW\\n members: RW" > $NDIR/tags/.perms/.default + pushd $NDIR + sudo git init . && git add * && git commit --allow-empty -am "init" + popd + + # copy config files + sudo cp -R /vagrant/src/server/etc/hostdb /etc/ + sudo cp -R /vagrant/src/server/etc/cron.d/hostdb /etc/cron.d/hostdb + sudo cp -R /vagrant/src/server/etc/logrotate.d/hostdb /etc/logrotate.d/ + sudo cp -R /vagrant/src/server/etc/apache2/sites-available/hostdb /etc/apache2/sites-available/hostdb + + # adjust apache config + sudo sed -i 's/SSLCACertificateFile.*//' /etc/apache2/sites-available/hostdb + sudo sed -i 's/crt\\/yourdomain.crt/certs\\/apache-selfsigned.crt/' /etc/apache2/sites-available/hostdb + sudo sed -i 's/crt\\/yourdomain.key/private\\/apache-selfsigned.key/' /etc/apache2/sites-available/hostdb + + # link stuff, so we can edit it in /vagrant and see the results more or less live + sudo ln -s /vagrant/src/server/usr/lib/cgi-bin/hostdb_rest.fcgi /usr/lib/cgi-bin/hostdb_rest.fcgi + sudo ln -s /vagrant/src/server/usr/local/lib/site_perl /usr/local/libsite_perl + sudo ln -s /vagrant/src/server/usr/local/bin/hostdb_git_gc.sh /usr/local/bin/hostdb_git_gc.sh + sudo ln -s /vagrant/src/webui/var/www/hostdb /var/www/hostdb + + # finish up + sudo /vagrant/src/server/DEBIAN/postinst + SHELL +end diff --git a/src/server/etc/apache2/sites-available/hostdb b/src/server/etc/apache2/sites-available/hostdb index 1986f17..f07c005 100644 --- a/src/server/etc/apache2/sites-available/hostdb +++ b/src/server/etc/apache2/sites-available/hostdb @@ -3,7 +3,7 @@ NameVirtualHost *:443 ServerName * DocumentRoot /var/www/hostdb - + SSLEngine On SSLCertificateFile /etc/ssl/crt/yourdomain.crt SSLCertificateKeyFile /etc/ssl/crt/yourdomain.key @@ -11,13 +11,13 @@ NameVirtualHost *:443 LogFormat "%v:%{local}p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %D" hostdb_log CustomLog /var/log/apache2/hostdb_access.log hostdb_log - + Alias /bootstrap "/var/www/hostdb/bootstrap/" Alias /assets "/var/www/hostdb/assets/" RewriteEngine on RewriteRule ^/(tags|hosts) /index.html - + RewriteEngine On RewriteRule ^(.+)$ /cgi-bin/hostdb_rest.fcgi [L] @@ -27,10 +27,10 @@ NameVirtualHost *:443 ServerName * DocumentRoot /usr/lib/cgi-bin/ - + LogFormat "%v:%{local}p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %D" hostdb_log CustomLog /var/log/apache2/hostdb_access.log hostdb_log - + RewriteEngine On RewriteRule ^/v1/?(.*)$ /hostdb_rest.fcgi [L] RewriteRule ^/?(.*) https://%{HTTP_HOST}/$1 [L]