Hackpad

I started using the hosted version of Hacked about a year ago, however, ever since they got bought out by Dropbox I haven't been using them as much. I don't believe it was the buy-out that triggered it, but most likely another alternative solution that I used instead.

Back in April of 2015 the Hackpad team announced they would be releasing the source code to Hackpad so one could host it on their own server. I was absolutely enthralled. However, once the buy-out happened, it took quite a while for them to actually release the source. Finally though it happened!

It should be noted that it looks like Hackpad is actually just a prettied up version of Etherpad with a few extra features.

Installing Hackpad is actually pretty easy, especially if you're familiar with installing self-hosted applications and have some system administration experience.

I setup a VPS to run my Hackpad install on. It has 4 virtual-cores, 6GBs of RAM and a 60GB hard disk. I also installed CentOS 6.7 64bit as my operating system.

Install Java JDK

Once you've got your system setup, you'll want to snag a copy of Java JDK:

cd /usr/src
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz"
tar zxvf jdk-7u79-linux-x64.tar.gz

This will download the Java software and then uncompress it. Next you'll need to install it.

cp -Rva jdk1.7.0_79/ /opt/
cd /opt/
cd jdk1.7.0_79/
alternatives --install /usr/bin/java java /opt/jdk1.7.0_60/bin/java 2
alternatives --config java
export JAVA_HOME=/opt/jdk1.7.0_79
export JRE_HOME=/opt/jdk1.7.0_79/jre
export PATH=$PATH:/opt/jdk1.7.0_79/bin:/opt/jdk1.7.0_79/jre/bin

Install Git

Next we'll install Git.

yum -y install git

Get the Hackpad Source Code

Now it's time to get the source code for Hackpad!

cd /opt
git clone https://github.com/dropbox/hackpad.git

Install Nginx

Now let's go back over to /usr/src and snag Nginx.

cd /usr/src
wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm
yum install nginx

Next, go into /etc/nginx/conf.d and create a hackpad.conf file.

cd /etc/nginx/conf.d
nano hackpad.conf

Place the following into the hackpad.conf file:

# Upstream configuration
upstream hackpad_upstream {  
     server 0.0.0.0:9000;
     keepalive 64;
 }

# Public
server {  
    listen 80;
    server_name ~^(.+)$; # domain of my site

   location / {
        proxy_http_version 1.1;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header   X-NginX-Proxy    true;
        proxy_set_header   Host             $http_host;
        proxy_set_header   Upgrade          $http_upgrade;
        proxy_redirect     off;
        proxy_pass         http://hackpad_upstream;
    }
}

Now make sure to enable Nginx on system start:

chkconfig nginx on

Install MySQL

Time to get MySQL installed. Use these commands to install MySQL 5.5.x.

yum -y install mysql-server
yum -y install mysql-client
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
rpm -q mysql mysql-server
yum install mysql.`uname -i` yum-plugin-replace
yum replace mysql --replace-with mysql55w
service mysqld start
/usr/bin/mysql_secure_installation

The last command will be a bit interactive and you'll be asked a few questions about root passwords and removing test data and such.

I also recommend setting MySQL to start on boot:

chkconfig mysqld on

Next bring up Nginx:

/etc/init.d/nginx restart

Install Scala

Now we need Scala!

cd /usr/src
wget http://www.scala-lang.org/files/archive/scala-2.11.7.tgz
tar xvf scala-2.11.7.tgz
cp -Rva scala-2.11.7/ /usr/lib/
ln -s /usr/lib/scala-2.11.7/ /usr/lib/scala
export PATH=$PATH:/usr/lib/scala/bin

Configuring Hackpad - Part I

Now we need to do a little bit of tweaking to the Hackpad files to get it to run properly in our CentOS environment.

cd /opt/hackpad/
nano bin/exports.sh

The following it what I need to change my exports.sh file to get it working in a CentOS 6.x environment:

# These lines assume you installed Scala via Homebrew.
export SCALA_HOME="/usr/lib/scala"
export SCALA="$SCALA_HOME/bin/scala"
export SCALA_LIBRARY_JAR="$SCALA_HOME/lib/scala-library.jar"

export JAVA_HOME="/opt/jdk1.7.0_79"
export JAVA="/opt/jdk1.7.0_79/bin/java"

Setting Up MySQL

The next part may be possible to do a different way, but I just wanted to get my Hackpad instance up and running quickly. First edit the following file:

nano contrib/scripts/setup-mysql-db.sh

Update the MySQL username and password, I just used the root MySQL user and password. That should be all you need to edit here. Now run this command:

contrib/scripts/setup-mysql-db.sh

This should populate MySQL with the necessary items to run Hackpad. Once that is done, I removed the credentials from the file.

Configuring Hackpad - Part II

I recommend creating a new MySQL user to use for your Hackpad. Google is great if you need some help creating a MySQL user and giving it access to the newly created hackpad database.

Next we'll want to create a configuration file for our Hackpad instance.

cp etherpad/etc/etherpad.localdev-default.properties etherpad/etc/etherpad.local.properties
nano etherpad/etc/etherpad.local.properties

If you followed my above recommendation on creating a new MySQL user, you'll want to edit the following in the configuration file:

etherpad.SQL_PASSWORD =
etherpad.SQL_USERNAME =

I also recommend editing the following as well:

topdomains =
customBrandingName =
customEmailAddress =
customEmailImapPassword =
supportEmailAddress =
etherpad.canonicalDomain =
smtpServer =
smtpUser =
smtpPass =

Save and you should be all set.

Build the App

Run this command which should build the app.

bin/build.sh 

Run the App

Now run this command which should start up the app. Upon first start it may take a minute so don't worry!

bin/run.sh

If all is well should be able to visit http://hackpad.yourdomain.com or whatever URL you've set it up within Nginx.

You can now create yourself an account via the web page interface of Hackpad. If you've setup the SMTP details you should have gotten an account verification email. If not, you'll need to go into the database to grab your token out of the email_signup table. Then visit a URL like this:

http://hackpad.yourdomain.com/ep/account/validate-email?email=YOUR_EMAIL&token=TOKEN

This will activate your account and you can start using Hackpad!

Notes

  1. I am not sure my MySQL installation notes are 100% right. I am thinking you may not need to do the yum install mysql-server and yum install mysql-client first. You may be able to just fetch the MySQL 5.5 repository and install that right off the bat. I just didn't have time to test this out.
  2. The SMTP stuff didn't work right even though I had filled out the SMTP details in the configuration file. I just got some giant Java error whenever the system tried sending an email. Having a second thought about this, it may be because I didn't install anything like Exim or Postfix, so that may be worth checking.
  3. Inserting images does not appear to be working. I assume images are uploaded to Amazon S3 but I can't seem to figure that out for sure. I didn't try using the URL of an image instead to use images in my documents but I assume that might actually work.

Hackpad

Resources