Setting up a Dev VM for Hyrax - UW-Libraries/druw GitHub Wiki

Setting up a Dev VM for Hyrax

This is a collection of notes for how to set up a dev VM for Hyrax that allows you contribute to the DRUW git repo. These instructions refer to the instructions on the vagrant-ansible-sufia repo's README but contains things specific for dev instances.

  1. Fork the DRUW repo. This is where you will do your developing and will use pull requests as described in the Git Workflow Notes

  2. Clone the vagrant-ansible-sufia repo on your host machine.

  3. In your copy of that repo, cp vars.yml.template vars.yml

  4. Start your vagrant box vagrant up --provider virtualbox

  5. Ssh into the box once it's up vagrant ssh

  6. Copy your bitbucket private key into your .ssh directory. Rename it to id_rsa if necessary and make sure the permissions are 600: chmod 600 ~/.ssh/id_rsa

  7. Change to the vagrant directory and run the ansible playbook:

      cd /vagrant
      ansible-playbook -i inventory playbook.yml
    

    This installs a vanilla hyrax app in ~/hyrax/. You'll NEVER actually use that app but it had to be created so you could do the next steps.

  8. Clone your fork of the DRUW repo from step 1 into your home directory. Make sure it gets placed anywhere EXCEPT for the hyrax directory.

  9. Copy all the yml templates to actual yml files:

     cd ~/[DRUW_REPO]/config
     for f in `ls *.yml.template |rev | cut -d '.' --complement -f 1 |rev`; do cp $f{.template,}; done
    

    Replace [DRUW_HOME] with the actual directory you cloned DRUW into.

  10. Copy the devise.rb template into the an actual rb file (code below assumes you're in the [DRUW_HOME]/config directory):

     cp initializers/devise.rb.template initializers/devise.rb
    
  11. Change to the DRUW directory

     cd ~/[DRUW_HOME]
    
  12. Run bundle install (doesn't appear to need sudo anymore)

  13. Start solr

     bundle exec solr_wrapper -d solr/config/ --collection_name hydra-development &
    
  14. Start fcrepo

     bundle exec fcrepo_wrapper -p 8984 &
    
  15. Generate the Hydra roles:

     rails generate roles
    
  16. Migrate your database

     rails db:migrate RAILS_ENV=development
    
  17. Create the default admin set

     rails hyrax:default_admin_set:create
    
  18. Create the generic worktype GenericWork.

     rails generate hyrax:work GenericWork
    

    This apparently only does one thing: insert the file config/initializers/hyrax.rb, but it makes Hyrax a lot happier.

  19. Finally, start the rails server:

     rails server -p 3000 -b 0.0.0.0
    
  20. Check http://localhost:3001 to see if everything is kosher. Initial rendering can take a bit.

  21. Create a user as before.

Creating your FIRST Administrator

The first administrator you create can only created via the command line as follows:

  1. Open the rails console

     rails c
    
  2. The following code creates the Admin role and adds your user to it

     admin = Role.create(name: "admin")
     u = User.find_by_user_key( "[email protected]" )
     admin.users << u
     admin.save
    
  3. Confirm that the user was made an admin

     u.admin?
    

    The above code should return a true value.

Creating Subsequent Administrators

To add other users an administrator, it's pretty straightforward.

  1. Make sure the user you want to make an admin has already created a regular user account.

  2. Login as an administrator

  3. Go to http://[hyrax_url:port]/roles

  4. Select a role and add users to that role.

Setting up SFTP with WinSCP (Windows only)

  1. From your terminal where you run vagrant, run vagrant ssh-config. Note the file location for IdentityFile. This is your vagrant private key.

  2. Run puttygen.exe

  3. Load the private key from the IdentityFile Location. You'll get a message saying it has been convert to putty format.

  4. Save private key. You can enter a passphrase if you want. Just choose a name like vagrant-putty-private.ppk.

  5. In WinSCP, set up your profile:

     Protocol: SFTP
     Host name: 127.0.0.1
     Port number: 2222
     User name: vagrant
    
  6. Open the Advanced Menu in the profile setup in WinSCP and choose the SSH -> Authentication tab. Under Authentication parameters:

    • Check Allow agent forwarding

    • In the Private key file include the path to the putty private key you created earlier.

  7. Save your profile and you should be able to connect to your VM via WinSCP.

⚠️ **GitHub.com Fallback** ⚠️