Install Ubooquity on Raspberry Pi for Personal eBook Server

Ubooquity is a java application that will help you manage your book library. It is similar to miniDLNA but designed for electronic reading material. It grabs covers and allows you to search your library very easily from the web interface. Comic book files and PDFs can be read inside your browser too. If you are a digital bookworm, Ubooquity will be a nice addition to your home media server or NAS for sharing your books across your devices. You can also couple it with Dynamic DNS for additional convenience and even a reverse proxy for additional security. This guide was tested on the Raspberry Pi B+ and Pi 2 and should work on any debian based distro for ARMv7 processors like the ODROID-C1 and Banana Pi.

If you are trying to figure out which hardware would work best for you, consider reading the Pi benchmarks.

Pi Unit
Processor
RAM
RAM Bus
Network
WiFi
USB
SATA
Cost
Raspberry Pi 3
1.2 GHz ARMv8
Quad Core
1 GB DDR2
450 MHz
100 Mbit
Yes
4
No
$35
Raspberry Pi 2
900 MHz ARMv7
Quad Core
1 GB DDR2
450 MHz
100 Mbit
No
4
No
$35.00
Raspberry Pi
700 MHz ARMv6
Single Core
512 MB SDRAM
400 MHz
100 Mbit
No
4
No
$25
Banana Pi
1 GHz ARMv7
Dual Core
1 GB DDR3
432 MHz
Gigabit
No
2
Yes
$36.99
Banana Pi Pro
1 GHz ARMv7
Dual Core
1 GB DDR3
432 MHz
Gigabit
Yes
2
Yes
$45.00

Install Ubooquity on Raspberry Pi

During my tests I was able to browse PDFs inside the browser and comic files (.cbr). Mobi and epub files could only be downloaded. This could depend on your browser though, if it is able to render and decode the files it should be able to show them in the browser. I only tested Google Chrome for viewing.

You get a simple but nice interface for your ebooks

ubooquity show ebooks

Your comics look great too, which you can read in the browser for added convenience

Install Java on Raspberry Pi

Install Java with a repo thanks to this post

echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
sudo apt-get update
sudo apt-get install oracle-java8-installer -y

Agree to the license and accept the terms in the two popups that follow

Install Ubooquity on Raspberry Pi

Install unzip to unpack ubooquity

sudo apt-get install unzip -y

Create the ubooquity folder

sudo mkdir -p /opt/ubooquity

Enter the ubooquity folder

cd /opt/ubooquity

Grab the latest ubooquity package

sudo wget "http://vaemendis.net/ubooquity/service/download.php" -O ubooquity.zip
sudo unzip ubooquity*.zip
sudo rm ubooquity*.zip

Change ownership of the ubooquity folder to avoid permission issues

sudo chown -R pi:pi /opt/ubooquity

Start ubooquity in headless mode since we aren't relying on a gui and enable administration, you can change the port as well by adding -port portnumber at the end

sudo java -jar /opt/ubooquity/Ubooquity.jar -webadmin -headless -port 2022

Enter the ip address of your Raspberry Pi in a browser like this http://ip.address:2202/admin to start

If you don't add the /admin you will get this error ‘Sorry, you are not authorized to access any file on this server'

You set a password for your admin account, don't finish setting up now let's make ubooquity start on boot

Type Q in the SSH session to terminate the Ubooquity process

Ubooquity init.d Script

Create the Ubooquity init.d script

sudo nano /etc/init.d/ubooquity

Paste the Ubooquity init.d script

#!/bin/sh
### BEGIN INIT INFO
# Provides:          Ubooquity
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Ubooquity
# Description:       Ubooquity for ebook management
### END INIT INFO
 
 
# Documentation available at
# http://refspecs.linuxfoundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptfunc.html
# Debian provides some extra functions though
. /lib/lsb/init-functions
 
export UBOOQUITY_HOME=/opt/ubooquity 
DAEMON_NAME="Ubooquity"
DAEMON_USER=root
DAEMON_PATH="/usr/bin/java"
DAEMON_OPTS="-jar /opt/ubooquity/Ubooquity.jar -webadmin -headless -port 2022"
DAEMON_PWD="/opt/ubooquity"
DAEMON_DESC=$(get_lsb_header_val $0 "Short-Description")
DAEMON_PID="/var/run/${DAEMON_NAME}.pid"
DAEMON_NICE=0
DAEMON_LOG='/var/log/cherrymusic'
 
[ -r "/etc/default/${DAEMON_NAME}" ] && . "/etc/default/${DAEMON_NAME}"
 
do_start() {
  local result
 
	pidofproc -p "${DAEMON_PID}" "${DAEMON_PATH}" > /dev/null
	if [ $? -eq 0 ]; then
		log_warning_msg "${DAEMON_NAME} is already started"
		result=0
	else
		log_daemon_msg "Starting ${DAEMON_DESC}" "${DAEMON_NAME}"
		touch "${DAEMON_LOG}"
		chown $DAEMON_USER "${DAEMON_LOG}"
		chmod u+rw "${DAEMON_LOG}"
		if [ -z "${DAEMON_USER}" ]; then
			start-stop-daemon --start --quiet --oknodo --background \
				--nicelevel $DAEMON_NICE \
				--chdir "${DAEMON_PWD}" \
				--pidfile "${DAEMON_PID}" --make-pidfile \
				--exec "${DAEMON_PATH}" -- $DAEMON_OPTS
			result=$?
		else
			start-stop-daemon --start --quiet --oknodo --background \
				--nicelevel $DAEMON_NICE \
				--chdir "${DAEMON_PWD}" \
				--pidfile "${DAEMON_PID}" --make-pidfile \
				--chuid "${DAEMON_USER}" \
				--exec "${DAEMON_PATH}" -- $DAEMON_OPTS
			result=$?
		fi
		log_end_msg $result
	fi
	return $result
}
 
do_stop() {
	local result
 
	pidofproc -p "${DAEMON_PID}" "${DAEMON_PATH}" > /dev/null
	if [ $? -ne 0 ]; then
		log_warning_msg "${DAEMON_NAME} is not started"
		result=0
	else
		log_daemon_msg "Stopping ${DAEMON_DESC}" "${DAEMON_NAME}"
		killproc -p "${DAEMON_PID}" "${DAEMON_PATH}"
		result=$?
		log_end_msg $result
		rm "${DAEMON_PID}"
	fi
	return $result
}
 
do_restart() {
	local result
	do_stop
	result=$?
	if [ $result = 0 ]; then
		do_start
		result=$?
	fi
	return $result
}
 
do_status() {
	local result
	status_of_proc -p "${DAEMON_PID}" "${DAEMON_PATH}" "${DAEMON_NAME}"
	result=$?
	return $result
}
 
do_usage() {
	echo $"Usage: $0 {start | stop | restart | status}"
	exit 1
}
 
case "$1" in
start)   do_start;   exit $? ;;
stop)    do_stop;    exit $? ;;
restart) do_restart; exit $? ;;
status)  do_status;  exit $? ;;
*)       do_usage;   exit  1 ;;
esac

Make the Ubooquity init.d scripte executable

sudo chmod +x /etc/init.d/ubooquity

Tell the system to start Ubooquity on boot

sudo update-rc.d ubooquity defaults

If the Ubooquity init.d script fails you can use a cronjob.

Add a crontab which schedules processes or scripts to run at regular intervals. We are going to set one to run ubooquity when the Raspberry Pi reboots

crontab -e

Scroll to the bottom of the nano editor with Ctrl+V and paste this text. The sleep 180 is a 3 minute wait to make sure there are no conflicts. Again you can add -port portnumber if you want to use another port.

PATH_UBOOQUITY=/opt/ubooquity
@reboot sleep 180 && cd $PATH_UBOOQUITY && nohup /usr/bin/java -jar $PATH_UBOOQUITY/Ubooquity.jar -webadmin -headless -port 2022

Ctrl+X, Y and Enter to save the crontab
Now you can reboot

sudo reboot

If you want to access your ebook collection outside your home network then follow the Dynamic DNS guide. Now you can configure Ubooquity on your Raspberry Pi.