View Single Post
Old 01-11-2017, 10:54 PM   #17
very_rude_Turnip
Enthusiast
very_rude_Turnip will become famous soon enoughvery_rude_Turnip will become famous soon enoughvery_rude_Turnip will become famous soon enoughvery_rude_Turnip will become famous soon enoughvery_rude_Turnip will become famous soon enoughvery_rude_Turnip will become famous soon enough
 
Posts: 36
Karma: 560
Join Date: Dec 2016
Device: Kobo Aura v2
In the end, I never did get around to installing dropbear for ssh or anything like that. I disabled the 802.11 completely and don't use it. Instead I installed a physical console to the serial port by drilling a small rectangle on the bottom near the USB port and gluing a molex connector in place.

I sync my files by USB, an rsync script, and a udev rule. This works out really well.

Code:
ACTION=="add", SUBSYSTEMS=="usb", ENV{ID_VENDOR}=="Kobo", ENV{ID_SERIAL_SHORT}=="xxxxxxxxxxxx", SUBSYSTEM=="usb", RUN+="/home/xxxx/bin/kobo_usb_sync.sh"
This udev rule will execute the script when the Kobo is plugged in and I've pressed the "Connect" button on the screen.

Be warned that this script runs as root the way I have it set up.

Code:
#!/bin/bash

MYNAME=$(basename $0)
MOUNT_DIR=/mnt/kobo
SYNC_DIR=/home/xxxx/ebooks/booksync
BAKDIR=/home/xxxx/ebooks/kobo_backups
BAKVER=$(date '+%Y%m%d%H%M%S')-$$
SYNC_OUTDIR=$BAKDIR/kobo-BACKUP-$BAKVER
SYNC_TIMEOUT=30
SYNC_INCLUDE=$MOUNT_DIR

logger "$MYNAME: Starting ereader sync."

if ! [[ -d "$MOUNT_DIR" ]] ; then
	logger "$MYNAME: ERROR: Mount dir does not exist: $MOUNT_DIR"
	exit 1
fi

if ! [[ -d "$SYNC_DIR" ]] ; then
	logger "$MYNAME: ERROR: Source dir does not exist: $SYNC_DIR"
	exit 1
fi

while true ; do
	if [[ "$COUNTER" -gt 8 ]] ; then
		logger "$MYNAME: ERROR: Timeout waiting for kobo to mount."
		exit 1
	elif ! [[ -v "$COUNTER" ]] ; then
		COUNTER=0
		sleep 2
	else
		COUNTER=$(( $COUNTER + 1 ))
	fi
	mount -L KOBOeReader -o fmask=0117,dmask=0007 $MOUNT_DIR ; X_MOUNT=$?
	if [[ "$X_MOUNT" == 0 ]] ; then
		logger "$MYNAME: Mounted. Starting sync."
		rsync -r -t --delete --delete-excluded $SYNC_DIR $MOUNT_DIR
		logger "$MYNAME: Sync completed. Exit code $?."
		if [[ -d "$BAKDIR" ]] ; then
			logger "$MYNAME: Starting backup."
			SYNC_LINKDEST=$(find $BAKDIR -maxdepth 1 -type d -regextype egrep -regex ".*/kobo-BACKUP-[0-9]+-[0-9]+$" | sort | tail -n 1)
			if [[ -n "$SYNC_LINKDEST" ]] ; then
				SYNC_LINK_DEST_ARG="--link-dest=$SYNC_LINKDEST"
			else
				SYNC_LINK_DEST_ARG=""
			fi
			rsync -a \
				--delete \
				--delete-excluded \
				--exclude "/booksync" \
				$SYNC_LINK_DEST_ARG \
				--timeout=$SYNC_TIMEOUT \
				$SYNC_INCLUDE/ $SYNC_OUTDIR
				X_RSYNC="$?"
			# [[ -d "$SYNC_OUTDIR" ]] && chown -R user:user $SYNC_OUTDIR && chmod -R o-rwx $SYNC_OUTDIR
			logger "$MYNAME: Backup completed. Exit code $X_RSYNC."
		fi
		umount $MOUNT_DIR
		break
	else
		logger "$MYNAME: Mount failed on try $COUNTER."
		sleep 1
	fi
done ; unset COUNTER

logger "$MYNAME: Finished ereader sync."
The above script uses rsync to mirror a directory where I keep my ebook files onto the reader. It also backs up the filesystem (minus the booksync directory we just uploaded) in an efficient manner using hard links (deduplication). The script never cleans up old backups, but they are tiny and I don't expect that to be a problem.

Calibre works great on Linux as a GUI app and I am very happy with it. I threw some money at the author for his work.

And, I updated my OS manually by copying the update files over USB:

Code:
sudo mount -L KOBOeReader -o fmask=0000,dmask=0000 /mnt/kobo/
cd ~/tmp
wget http://download.kobobooks.com/firmwares/kobo6/December2016/kobo-update-4.2.8110.zip
sudo unzip ~tmp/kobo-update*.zip -d /mnt/kobo/.kobo/
sudo umount /mnt/kobo/
rm -f ~tmp/kobo-update*.zip
My biggest complaint right now is that PDF files are rendered poorly. Mostly it's the huge inefficient margins issue. I will stick to my tablet for PDFs.

Last edited by very_rude_Turnip; 01-13-2017 at 09:13 PM.
very_rude_Turnip is offline   Reply With Quote