free web stats
Menu
A Raspberry Pi Evernote Alternative [TwoStairs Paperwork]

A Raspberry Pi Evernote Alternative [TwoStairs Paperwork]

Featured

My Evernote Alternative: Running TwoStairs Paperwork on a Raspberry Pi

I've been looking for a self-hosted evernote alternative for quite a while.

Since my interests in what can be done on the Raspberry Pi, I wanted to see what kind of self hosted Evernote solution I could come up with that would run off a Pi on my local home network.

paperwork main dashboard

There are various reasons for doing this, but primarily most people that are searching for the same thing are interested in controlling the data, and making sure it stays with them.

When you use a solution that is hosted out on the internet, there is a chance that your data could fall into the wrong hands.

While this isn't that much of a concern for me, I understand the argument, and running a self hosted Evernote Alternative on a Raspberry Pi addresses this concern in a large way.

Hosting applications behind your firewalled home or work network can greatly reduce the risk of data leakage.

Most ISPs firewall their routers which provides a basic level of security for the end user.

Add to that, the Raspberry Pi server that this Evernote alternative runs on will be moderately hardened with security measures put into place that you'd find on a publicly accessible webserver.

Third, I personally wanted an app that could do about 70% of what Evernote premium offers and have the same kind of structure to the notes (Groups -> Notebooks -> Individual Notes).

Many of the self hosted note taking apps are pretty flat. They either rely on tags for sorting, or are flat with no sort capability other than search.

During my research into this, I found from a number of sources that Evernote does not encrypt your data on their servers (one article that mentions this is the June 6 2017 article on Evernote Encryption, or the lack thereof -- https://www.lifewire.com/evernote-tips-you-should-avoid-153286).

Moderately Safe and Secure Evernote Alternative

I am now using Paperwork by TwoStairs as my Evernote alternative app.

Paperwork emulates a lot of what Evernote offers, but in a self hosted (and free) application.

In a quick overview, Paperwork offers:

  • Collections that group your notebooks together as desired
  • Notebooks to hold related notes
  • Individual notes with editor and uploader
  • Tags for further catagorization and sorting capabilities
  • Import function to migrate from Evernote to Paperwork
  • Choice to allow user registration, admin-only new user registration, or Admin only without registration

This takes care of the 70% I was looking for, so I decided to run TwoStairs Paperwork on a Raspberry Pi.

Notes About Running TwoStairs Paperwork On A Raspberry Pi

paperwork logo
It takes a bit of work, but you can run Paperwork ideally on a Raspberry Pi 2 or 3. When I tested this build on my local network, load times were under a tenth of a second.

TwoStairs Paperwork will also run on a Raspberry Pi Zero, Zero W and Pi B+ (512MB Single Core Version), but it's a bit slower with page loads around 1 to 3 seconds, so if nothing else, you can run it on an older Raspberry Pi model if it's just you that is using Paperwork and you don't mind a second or two lag.

I had no luck making Paperwork run on my original Raspberry Pi 256mb model A version and the first 512MB model B version.

My Primary Raspberry Pi Paperwork Build (home)

Raspberry Pi 3 Cana Kit http://amzn.to/2s09oWA - $49
SanDisk Extreme 64GB microSDXC http://amzn.to/2tTGyIH - $39

My Pi Zero W Paperwork Build (Work)

Raspberry Pi Zero W: https://www.adafruit.com/product/3400 - $10
SanDisk Extreme PRO 32GB U3 Micro SDHC: http://amzn.to/2tTvETm - $32
CanaKit 5V 2.5A Power Adapter: http://amzn.to/2tyC6zI - $10

IMPORTANT! - DONT Run Raspberry Pi Configuration if you plan to backup the default Paperwork SD Card with the intent of copying the card to create more Raspberry Pi's running Paperwork in the future. By not running raspi-config, the image will fit on a 4GB sd card with all the defaults in place.

BONUS!!! Premade Paperwork Raspberry Pi Image File

Lets say you don't want to go through all the stuff below, or it's just too technical for your skills...

You're in luck! I've created a Twostairs Paperwork Raspberry Pi Image and uploaded it to Google drive.

Just download the file, unzip it to your hard drive, and install it to the Pi's MicroSD card as you would with any other Raspberry Pi image!

Minimum Requirements:

Compatible with:
Raspberry Pi Zero W
Raspberry Pi 2
Raspberry Pi 3

4GB Class 10 SD Card or MicroSD card minimum needed.

A bit of patience if things don't go right because I provide NO support for this .img file or the installation.

See the very end of this tutorial for the download link and notes.

Setting Up The Pi

Install Raspbian Lite

win32 disk imager install

You could install Paperwork on a full Raspbian image if you wanted to run Paperwork completely offline.

I would recommend only using the Pi 3 for this because you'll need to load up the desktop environment, then open a browser and access Paperwork via localhost.

I did try this and performance does lag quite a bit, but on the flip side, unless someone actually stole the Raspberry Pi from your house, there's no chance that any normal person would be able to capture your data.

The better option for my use was to download the stripped down version of Raspbian that does not have the desktop environment. For me, I will be running Paperwork either on my local network, or by plugging the Pi directly into the laptop/desktop via Network cable, and accessing via the raspberrypi.local address.

I chose to use the Raspbian (Jessie) image that is current at the time of this writing (2017-04-10-raspbian-jessie-lite.img).

There's many ways to get the Raspbian image on your MicroSD card, so rather than rehash the instructions here, I will just link to some decent, clear instructions on another site. http://trendblog.net/install-raspbian-sd-card-os-x-windows/

Add Wifi and SSH files to the MicroSD card image

I run all my Raspberry Pi in headless mode. No keyboard, no mouse, no monitor. I find it easier to do everything via command line from my everyday laptop.

In order to make this happen, you have to add your Wifi network and enable SSH on the MicroSD card before inserting the card into the Pi.

NOTE: If your Pi is cable connected to the router, you can skip the Wi-Fi setup, but you still will need to enable SSH.

Enable Wi-Fi connectivity

The following instructions are designed for most home/work networks where you have a Wi-Fi name (or SSID) and need to enter a password (or PSK) in order to connect to the network. Conecting to open networks (Like Comcast's XFINITY or Starbucks) is really (As in "For the Love Of GOD, Don't Do It!") not recommended.

Open the MicroSD drive in your folder explorer. On windows it will look like another drive with the name "Boot".

Create a new file called "wpa_supplicant.conf". the extension must be .conf and not .txt!

Drop this text into the file, editing the SSID and PSK for your wi-fi network:

=== Begin Text ===

country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="YOURWIFISSID"
psk="YOURWIFIPASSWORD"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}

=== End Text ===

Enabling SSH

Next, create a new file that is totally empty and save it as "ssh" with no extension and of course, no quote marks. This file tells the pi upon first boot to enable SSH by default on the standard port 22.

Once both files are written, properly eject the MicroSD card from your computer and insert into your Raspberry Pi.

Power on the Pi, and give it roughly 30 seconds to boot up and connect to your Wi-Fi network.

Give the First boot on a Pi B+ 512MB version about 1 minute just to be safe to allow for wi-fi connection.

Getting the IP address (fing)

There's many ways to find out what the Raspberry Pi's IP address is, but the easiest that I've found is to download a phone App called FING. It essentially will list all the IP Addresses on the network when you're connected to your home or work network, and when you scan, you'll find that the Raspberry PI is called "raspberrypi" and there'll be an IP Address associated with it.

Connect via SSH

Windows 7, 8 & 10 users:

To connect via SSH, download puTTY. It's a free program that enables you to connect to IP addresses via SSH among other methods. Download from http://www.putty.org/

Open puTTY and enter the Pi's IP address under the "Host Name (or IP address)" field at the top. Make sure that the Port is set to 22, which it is by default.

Finally click the OPEN button to connect.

Since it's your first time connecting, there's going to be a security alert box that pops up that asks if you trust the connection. Click the YES button.

A black screen will pop up asking you to "Login as:" -- Enter "pi" as the login without the quotes.
Next, you'll see the password prompt that looks something like "pi@{IP Address}'s password:" -- enter "raspberry" as it's the default password for the user "pi" (again without the quotes).

You should now be connected, and you'll see something like this message:

========== Begin Message ============
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Jun 22 10:35:43 2017 from 192.168.1.XX
pi@raspberrypi:~ $
========== End Message ==============

The dollar sign ($) indicates the command prompt where you'll enter the commands below that start with "$ sudo" ...
When following this tutorial, you do not need to include the dollar sign from the line below. It's just there for identification to show a command prompt. Just copy the command without the dollar sign.

Pasting the command into PuTTY is as easy as right clicking just to the right of the dollar sign. The command is automatically pasted into the command line.

Mac & Linux users

Just paste the following command into the terminal window but replace <IP> with the IP address of the Raspberry Pi. Use Ctrl + Shift + V to paste in the terminal.

ssh pi@<IP>;

When the connection works you will see a security/authenticity warning. Type yes to continue. You will only see this warning the first time you connect.

Next you will be prompted for the password for the pi login: on Raspbian the default password is raspberry. You should now be able to see the Raspberry Pi prompt, which will be identical to the one found on the Raspberry Pi itself. You should see the following prompt:

pi@raspberrypi ~ $

You are now connected to the Pi remotely, and can execute commands.

Again, the dollar sign ($) indicates the command prompt where you'll enter the commands below that start with "$ sudo" ...
When following this tutorial, you do not need to include the dollar sign from the line below. It's just there for identification to show a command prompt. Just copy the command without the dollar sign.

First Things First... Update and upgrade the Pi (10 - 30 minutes on Pi 2 or 3, 30-60 minutes on a Pi B+ or Zero)

You first need to make sure that the Raspberry Pi is up to date. The TwoStairs Paperwork installation below will NOT work unless you've done this step.

During a later step, we will need to install PHP7.0. You have to prep the Pi to find the proper repositories to complete the install successfully.

Adding the correct repository so the Pi can find PHP7.0 during the initial webserver install is done by editing the sources.list as follows:

$ sudo nano /etc/apt/sources.list

When the sources.list opens, add these two lines at the end of the file to add the repository:

deb http://repozytorium.mati75.eu/raspbian jessie-backports main contrib non-free
#deb-src http://repozytorium.mati75.eu/raspbian jessie-backports main contrib non-free

add php7 repo

Hit CTRL-x and then Y and then enter to save the file, then run the next command:

$ sudo gpg --keyserver pgpkeys.mit.edu --recv-key CCD91D6111A06851 && $ sudo gpg --armor --export CCD91D6111A06851 | sudo apt-key add -

$ sudo apt-get update && sudo apt-get upgrade -y

Wait for the Pi to finish upgrading before moving on.

Securing the Raspberry Pi

Even though the Raspberry Pi is behind the firewall at home or in the office, we will not take any chances with security measures.

We will go through the basic "hardening" of the Raspberry Pi against low-level threats it could encounter.

Please note that these security steps are designed for a beginner user, and are by no means a complete solution to server hardening. Again, it's just a basic setup that's better than nothing, and will stop any low-level hacker wannabe on the network from gaining access to your Pi.

UFW - Uncomplicated Firewall
Just as your home network is likely firewalled at the router, we will be firewalling the Raspberry Pi. Essentially there will be two firewalls that a hacker would need to get through in order to access the Pi.

Note that this is only a basic setup to add some level of security to your Raspberry Pi. You can find more on UFW and configuring the Firewall here: https://www.digitalocean.com/community/tutorials/how-to-setup-a-firewall-with-ufw-on-an-ubuntu-and-debian-cloud-server

Install UFW by entering the following command:

$ sudo apt-get install UFW -y

UFW will install, and when complete, enter the next command:

$ sudo ufw default deny incoming

This will block access to all ports. Don't worry... in the next steps we'll be allowing access to only the essential ports needed to use the Pi with Paperwork.

$ sudo ufw default allow outgoing

This allows the Pi all outgoing connections from the Pi to other destinations.

$ sudo ufw allow 22

This enables port 22, your SSH port.

$ sudo ufw allow 80

This enables the web port for http:// connections.

$ sudo ufw allow 443

This enables the web port for https:// (secure) connections.

$ sudo ufw enable

The starts up the firewall.

The next few commands don't need to be run, but are here for reference:

$ sudo ufw status verbose

Shows you which ports are allowed through the firewall as well as your default rules.

$ sudo ufw disable

If you need to turn the firewall off for some reason.

$ sudo ufw reset

If you made a mistake, use the reset above to clear and start over (firewall must be disabled to use).

=== End Reference Commands ===

Fail2Ban - Brute Force Protection for your Raspberry Pi

Essentially, this will slow down or stop someone from trying to guess your SSH password (you did make it random right? LOL).

You can set the number of tries someone gets before the Raspberry Pi blocks them for a set amount of time or permanently.

Install Fail2Ban:

$ sudo apt-get install fail2ban

Now we will make a backup copy of the config file:

$ sudo cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local

Turn on Fail2Ban:

$ sudo service fail2ban start

Note: if for some reason you need to turn it off, you'd type in this: $ sudo service fail2ban stop

We are only performing basic configurations for this tutorial. More in-depth information on further securing your Pi can be found at https://www.digitalocean.com/community/tutorials/how-to-protect-ssh-with-fail2ban-on-ubuntu-14-04. (even though it is designed for Ubuntu servers, it works on Raspberry Pi too).

=== End Server Hardening ===

Paperwork Preinstallation Steps

Now we get to the fun stuff! We're going to install the webserver, database and everything else that TwoStairs Paperwork needs to run on your system.

Install NGiNX, MySQL, PHP7.0 and Node.js in one command:

$ sudo apt-get install npm zip mysql-server php7.0-mysql nginx php7.0-fpm curl wget git php7.0-cli php7.0-gd php7.0-mcrypt nodejs nodejs-legacy php-xml -y

*** Note: during the install, the command line will ask you to setup a password for the root user in MySQL. Its a blue screen with a reddish box where you put the password in. Make sure you REMEMBER THIS PASSWORD -- you'll need it when you go to set up your database below.

Since we're using MySQL, you need to set it up initially:

$ sudo /usr/bin/mysql_secure_installation

Next, Install Composer

$ sudo curl -sS https://getcomposer.org/installer | php

You will want to run composer with no path specified, so you need to run this command:

$ sudo mv composer.phar /usr/local/bin/composer

Installing TwoStairs Paperwork

CD into your webserver directory:

cd /var/www/html

If you need to install git, use this command:

$ sudo apt-get install git -y

Make sure that the folder and your user have appropriate permissions to the folder:

$ sudo chown -R www-data:www-data /var/www/html
$ sudo chmod -R 775 /var/www/html/
$ sudo usermod -a -G www-data pi

And clone the Twostairs Paperwork repository:

$ sudo git clone https://github.com/twostairs/paperwork.git

Drop into the front end directory:

cd paperwork/frontend/

Run composer install and composer update to ensure you have all dependencies

$ sudo composer install
$ sudo composer update

Set up the MySQL database

If you are using Paperwork at home behind your router's firewall (not publicly accessible), you can follow the next steps verbatim.

If you are will be using Paperwork publicly, you will need to drop down to Public Database Setup below.

Home/Work Network quick setup

mysql -uroot -p [enter password you setup during the install]

You will now see the command line look like this:

mysql>

Enter the following lines separately, but in succession:

DROP DATABASE IF EXISTS paperwork;
CREATE DATABASE IF NOT EXISTS paperwork DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON paperwork.* TO 'paperwork'@'localhost' IDENTIFIED BY 'paperwork' WITH GRANT OPTION;
FLUSH PRIVILEGES;
quit

Public Database Setup below

First setup your database:

mysql -uroot -p

[enter password you setup during the install]

Give your database a different name:

DROP DATABASE IF EXISTS [yourdatabasename];
CREATE DATABASE IF NOT EXISTS [yourdatabasename] DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

Create a new user by replacing [youdatabaseuser] and creating a pasword in {yournewpassword} fields.

GRANT ALL PRIVILEGES ON [yourdatabasename].* TO '[yourdatabaseuser]'@'localhost' IDENTIFIED BY '{yournewpassword}' WITH GRANT OPTION;

FLUSH PRIVILEGES;

quit

You will find yourself back at the command prompts (the dollar sign).
Now edit the default_database.json file:

$ sudo nano /var/www/html/paperwork/frontend/app/storage/config/default_database.json

Now run the migration jobs. This will fill the database:

$ sudo php artisan migrate

It will ask you if you really want to run the command:

"Do you really wish to run this command?"

Answer with a "y" and the enter button.

Now change the owner of the paperwork web directory to the www-data user

$ sudo chown www-data:www-data -R /var/www/html/

Edit the default site configuration file to match below:

$ sudo nano /etc/nginx/sites-available/default

Now erase what's in the current file, and replace with this:

server {
listen 80;
# listen 443 ssl;

root /var/www/html/paperwork/frontend/public;
index index.php index.html index.htm;

server_name example.com;

# server_name example.com;
# ssl_certificate /etc/nginx/ssl/server.crt;
# ssl_certificate_key /etc/nginx/ssl/server.key;

location / {
try_files $uri $uri/ /index.php;
}

error_page 404 /404.html;

# pass the PHP scripts to FastCGI server listening on the php-fpm socket
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;

}

}

Install gulp and bower:

$ sudo npm install -g gulp bower

And then npm dependencies inside project

$ sudo npm install

Then you install bower dependencies and just run the default task

$ sudo bower install --allow-root
$ sudo gulp

Restart Nginx and php

$ sudo service nginx restart
$ sudo service php7.0-fpm restart

Once this is completed go to another computer and try accessing the raspberry pi's IP address in a browser:

Open Chrome, Firefox or your browser of choice EXCEPT Internet Explorer (For God's sake DON'T use IE... EVER.).

Type in http://XXX.XXX.X.XXX/ where the X's are the IP address of the raspberry pi.

You should be greeted with the Twostairs Paperwork web installer where you'll setup the initial admin user's email and password that you'll use to login to the system with.

At This Point, STOP And Think:

You might want to back up the default image before going any further. Having a backup copy makes things easier for you in the long run.

Back Up The Raspberry Pi Micro SD card to .img file

Creating an .img file does two things:

1. Gives you a backup of your fully installed TwoStairs Paperwork app that's ready for configuration and addition of Admin account.
2. Allows you to deploy more Raspberry Pi's running TwoStairs Paperwork very quickly without having to go through all the steps.

Backup and Restore tutorials

Windows Tutorial on PiHut: https://thepihut.com/blogs/raspberry-pi-tutorials/17789160-backing-up-and-restoring-your-raspberry-pis-sd-card
Mac Tutorial via Medium: https://medium.com/a-swift-misadventure/backing-up-your-raspberry-pi-sd-card-on-mac-the-simple-way-398a630f899c

Keep in mind that you should do the backup before you run the $ sudo raspi-config command. That way, the disk image is the default image that fits on a 4GB sd card.
=== End Backup Instructions ===

Configuring Paperwork in the Browser

paperwork welcome

Step 1: Welcome

Just click next or reload in the lower right.

paperwork checking dependencies

Step 2: Checking Dependencies

This screen will show the Database as not connected in pink. The message is a bit cryptic, but don't worry about that. Just click next.

paperwork database setup

Step 3: Enter database info.

Make sure you're on the MySQL tab (leftmost tab).
Enter the server - localhost if you followed my home network instructions above in the MySQL section.
Enter the Port - 3306
Enter the Username - paperwork
Enter the Password - paperwork

Click next.

paperwork settings

Step 4: Paperwork Customization

This page will allow you to enable or disable user registration. This is the ONLY place that I know of that you can turn this off or on, so make your choice wisely. If it's just you that's using it, you may want to turn off the registration. If this is being used for your whole family, or a team in your workplace, turn this on to allow others to register.

There is a third option where only the admin user (you) can create new accounts. If you are not sure whether you will have other users in the future using TwoStairs Paperwork, then select this option to be on the safe side. It disables the user self-registration, but allows the admin to create new users.

paperwork admin setup

Step 5 Creating the Admin User

You as Admin will have full control over Paperwork. You'll have to type in the email address you wish to login with, then a nice, secure password. :D

Click next.

There will be one more screen that just says Paperwork is being setup. Give that about 10 seconds then hit the finish button on the lower right.

paperwork login screen

You are now directed to the main login screen where you can login for the first time into your Raspberry Pi Paperwork application!


Backing up Your Data - Don't Lose The Data!!!

TwoStairs Paperwork doesn't have it's own backup feature.

Don't fret, because there is a work around.

In the settings, you'll find an import/export tab.

Export all your data periodically and save it somewhere safe.

If your Raspberry Pi ever fails (or more likely, the MicroSD card goes wonky) you can import your last backup into a new instance of Paperwork.


Provided Everything is working correctly...

Now would be a good time to do the Raspberry Pi Configurations. This is just the standard configurations that you'd normally do on the first book after you've created a default Raspbian SD Card.

$ sudo raspi-config

Don't forget to expand the filesystem, set the locale including correct time and date, and change the password for the "pi" user!

Done. PHEW!


=== The Raspberry Pi TwoStairs Paperwork Image ===

OK guys. If you're too lazy to build it yourself, don't know what the above means, or just want something quick, then you can download my default image that I use to deploy more Raspberry Pi's running TwoStairs Paperwork.

>>> DOWNLOAD PAPERWORK RASPBERRY PI IMG <<<

SSH User: pi
SSH password: raspberry
MySQL password: raspberry

Before you insert the card into your Pi, you have to open up the SD Card on your main computer and find the wpa_supplicant.conf file.

Enter your Wi-Fi network SSID and Passcode into this file where it reads the following:

ssid="YOURWIFISSID"
psk="YOURWIFIPASSWORD"

Save the file, then insert the card into your Pi and boot up.

Once the pi has fully booted, and connected to your network, get the Pi's IP address and open a browser.

Go to http://[PI.IP.ADDRESS.HERE]

And fill out the mysql connection and admin user stuff.

That's all that there is to it, but you probably will want to change the pi user's password and such...

Oh, yeah... I didn't install UFW or Fail2Ban on purpose in this image either. That's on you.

Last Note: I don't provide troubleshooting or support. I had to learn programming the hard way. While I could support it, I choose not to because there's no better way to learn than to try and fix something when it breaks, and this is all about learning and growing.

Th image is only here to save time for "seasoned", well aquainted users, and is by no means supported by TwoStairs or Myself. Additionally, I am not associated or partnered in any way with TwoStairs... I just like Paperwork and created a way for it to fit my needs. :D

back to top