darcs repository web UI and hosting app. This is the main darcsden trunk, which also runs hub.darcs.net. (http://hub.darcs.net)

root / Vagrantfile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant::Config.run do |config|
  config.vm.box = "precise32"
  config.vm.box_url = "http://files.vagrantup.com/precise32.box"
  config.vm.provision :puppet
  config.vm.forward_port 8900, 8900 # guest, host
end

# Custom vagrant commands for darcsdesn
module VagrantDarcsDen

  # Fairly evil way of avoiding to define a dozen classes
  def self.alias_ssh_command(name, intro_message, command)
    klass = Class.new(Vagrant::Command::Base)
    klass.class_eval %Q[
      def execute
        puts #{intro_message.to_s.inspect}
        @env.cli("ssh",
          "-c", #{command.to_s.inspect}
          )
      end
    ]
    Vagrant.commands.register(name.to_sym) { klass }
  end

  CABAL_INSTALL_COMMAND = "cabal install --only-dependencies && cabal install --builddir=/home/vagrant/darcsden-dist"
  DARCSDEN_INSTALL_COMMAND = "darcsden --install"

  # darcsden-init - Initialiation for darcsden, only needs to be run once. It is a combination of cabal update, cabal install, and darcsden install
  alias_ssh_command("darcsden-init", "Initializing darcsden", "cabal update && cd /vagrant && #{CABAL_INSTALL_COMMAND} && #{DARCSDEN_INSTALL_COMMAND}")

  # cabal-update - Runs the 'cabal update' command in the virtual environment.
  alias_ssh_command("cabal-update", "Running 'cabal update'", "cabal update")

  # cabal-install - Runs 'cabal install' on the darcsden source code within the virtual environment.
  alias_ssh_command("cabal-install", "Cabal installing darcsden", "cd /vagrant && #{CABAL_INSTALL_COMMAND}")

  # darcsden-install - Runs 'darcsden --install' in the virtual environment. Darcsden must be installed first, see
  # `cabal-install`
  alias_ssh_command("darcsden-install", "Installing darcsden", DARCSDEN_INSTALL_COMMAND)

  # darcsden-server - Starts the darcsden server in the virtual environment. This command is run in the foreground and
  # can be halted by hitting Ctrl-c
  alias_ssh_command("darcsden-server", "Starting darcsden", "cd /vagrant && sudo -Hu darcsden darcsden")

  # darcsden-ssh-server - Starts the darcsden-ssh server in the virtual environment. The command is run in the foreground
  # and can be halted by hitting Ctrl-c
  alias_ssh_command("darcsden-ssh-server", "Starting darcsden-ssh", "cd /vagrant && sudo -Hu darcsden darcsden-ssh")

  # darcsden-logs - Tails the logs from the darcsden-ssh server.
  alias_ssh_command("darcsden-logs", "Tailing darcsden logs", "tail -n 20 -f ~darcsden/log/{access,error}.log")

end