Showing posts with label pi4. Show all posts
Showing posts with label pi4. Show all posts

Saturday, August 21, 2021

Experimenting with Wikis on the Raspberry PI

Why would I want to run my own wiki?


Why not? Searchable linked notes are awesome!


For work, I use tiddlywiki. It's just an html file with embedded javascript that handles tagging, searching and saving a new copy of itself when changes are made. It's by far the single simplest to run wiki since, it's just a local html file, without the need for a webserver.


It's really useful for storing links, bits of code, bits if information that may be useful etc. Once written and tagged, it's a quick search from getting that bit of information you just can't remember. You can link the page to other relevant pages you wouldn't think of at the time, that may prove invaluable.


But what if you want something you can access from multiple devices? Perhaps tiddlywiki on dropbox? A enticing as it sounds to take something I know and hack a solution around it, I decided to look at a couple other options.


I really didn't want a large setup. I wanted something easy to manage - backup, restore, setup from scratch via script. Something light for the PI since it's pulling double duty as a NAS. 

The first option I looked at was wiki.js. https://js.wiki/
What made this enticing was that it can use several different databases - sqlite included. Sqlite isn't as powerful as other database packages, but it's light. It's simple. Backup and restore is just copying the single file the DB is contained in.


I decided to try setting up a docker image pointing to the rather bare DB I setup.

#install docker
installdocker() {
  curl -fsSL https://get.docker.com -o get-docker.sh
  sudo sh get-docker.sh
  #add pi user to docker group
  sudo usermod -aG docker pi
}
type docker || installdocker

#make folder
mkdir /home/pi/wikidocker
cd /home/pi/wikidocker

config='port: 3000
db:
  type: sqlite
  ssl: false
  storage: /wiki/ggnotes.sqlite 
bindIP: 0.0.0.0
logLevel: info
offline: false
ha: false
dataPath: ./data'
echo "$config" > wikidocker.conf

docker run -d -p 8080:3000 --name GiaWiki \
           --restart unless-stopped -e "DB_TYPE=sqlite" \
	   -e "DB_FILEPATH=/home/pi/wikidocker/ggnotes.sqlite" \
           -v /home/pi/wikidocker/wikidocker.conf:/wiki/config.yml \
	   -v /home/pi/wikidocker/ggnotes.sqlite:/wiki/ggnotes.sqlite \
           requarks/wiki:2

So this little script starts by installing docker on the PI. It makes a folder, sets up a config, and kicks off a docker. 



It's not bad. But minutes after setting this up I found out they will no longer support sqlite on subsequent major releases.

I wanted a light system that would be relatively future proof. I'm not opposed to PostgreSQL, but I'd rather something easier to manage and lighter on resources for the PI. Maybe I'll try setting up PostgreSQL in a docker too. 

Ah! Dokuwiki! It's small, light, quick to setup. https://www.dokuwiki.org
This wiki doesn't use a DB, it's just files under a folder. I can grep out strings if I needed to, and backup is nothing more than tar - so, yay! Easy!

The install is scripted for us too - Thanks Dokuwiki :D

Install apache, and move or symlink the dokuwiki folder to /var/www/html/dokuwiki.

The wiki isn't as full featured as wiki.js but it's still decent.


Going to stick with this one. Backup can be done in the /var/www/html/dokuwiki/data/ folder as described on their site. https://www.dokuwiki.org/faq:backup


My daughter has been liking this. It's simple for her to use. Unlike wiki.js, there's no authentication needed.  There's good and bad for that. It's nice for us since we're just using it on the local network. Bad if we wanted top open this up with read-only permission. This can be put behind another service that handles the authentication though.


My future "todo" items:
  • Use docker more. It's relatively quick to setup and a app container should have all it's prerequisites (in general).
  • Revisit the wiki.js setup as 2 docker scripts. One for postgres, another for wiki.js. Include scripts for backup and restore too.

Cheers.



Wednesday, May 20, 2020

Odroid NAS died, Trying a Raspberry pi 4

My Odroid died over the weekend. It's been running every day for 4 years so, I guess it did OK doing what it wasn't really meant to do.


So I'll use something else not meant to do it again :D
This time a Raspberry Pi 4. USB 3 and gigabit ethernet.
https://magpi.raspberrypi.org/articles/raspberry-pi-4-specs-benchmarks



Using the Pi's Wifi:

beomagi@BeoBalthazar ~  2020-05-19 21:46:24
└─ $ ∙ iperf -c 192.168.1.42
------------------------------------------------------------
Client connecting to 192.168.1.42, TCP port 5001
TCP window size:  512 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.109 port 61000 connected with 192.168.1.42 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  91.2 MBytes  76.5 Mbits/sec

beomagi@BeoBalthazar ~  2020-05-19 21:46:45
└─ $ ∙ iperf -c 192.168.1.42
------------------------------------------------------------
Client connecting to 192.168.1.42, TCP port 5001
TCP window size:  512 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.109 port 61509 connected with 192.168.1.42 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  99.5 MBytes  83.4 Mbits/sec

2 runs showing this will generally be ~80 Mbps, so I can expect about 10 megabytes per second. It's not great, though it will handle HD videos (ish).
Benchmarking the wireless has not been great - so I'll have to hook it up to my router via gigabit ethernet.



Using the Pi's ethernet to my router, then over AC wifi:
Hooked up to my AC router, via gigabit ethernet, my PC over AC is getting much better bandwidth.


Using the Pi's ethernet to my router, then over AC wifi:

beomagi@BeoBalthazar ~  2020-05-19 22:07:18
└─ $ ∙ iperf -c 192.168.1.42
------------------------------------------------------------
Client connecting to 192.168.1.42, TCP port 5001
TCP window size:  512 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.109 port 49435 connected with 192.168.1.42 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   468 MBytes   392 Mbits/sec

beomagi@BeoBalthazar ~  2020-05-20 12:57:16
└─ $ ∙ iperf -c 192.168.1.42
------------------------------------------------------------
Client connecting to 192.168.1.42, TCP port 5001
TCP window size:  512 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.109 port 49454 connected with 192.168.1.42 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   483 MBytes   405 Mbits/sec

My HTPC is directly connected to the same router via cable, so pure wired numbers look excellent.
Downloading files are near 50MB/s so this is quite nice.



Using the Pi's purely over gigabit ethernet:

beomagi@beo-htpc ~  2020-05-20 13:11:17
└─ $ ∙ iperf -c 192.168.1.42
------------------------------------------------------------
Client connecting to 192.168.1.42, TCP port 5001
TCP window size:  604 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.108 port 54694 connected with 192.168.1.42 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.10 GBytes   943 Mbits/sec

beomagi@beo-htpc ~  2020-05-20 13:17:44
└─ $ ∙ iperf -c 192.168.1.42
------------------------------------------------------------
Client connecting to 192.168.1.42, TCP port 5001
TCP window size:  408 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.108 port 54706 connected with 192.168.1.42 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.09 GBytes   940 Mbits/sec

Now we're talking. This should be good for ~115MBps



Bottleneck - harddrive:

pi@raspberrypi:~/shares/major $ dd if=/dev/zero of=./testfile bs=1000M count=1 oflag=direct
1+0 records in
1+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 10.8304 s, 96.8 MB/s
pi@raspberrypi:~/shares/major $  dd if=./testfile of=/dev/null bs=1000M count=1
1+0 records in
1+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 8.92268 s, 118 MB/s


These are directly on the pi, so they give a decent indication of that USB 3 capability with harddrive storage. It's not far off from the gigabit throughput so it's well matched. The numbers are actually slightly better than the odroid, which is excellent.

Previous NAS setup:
https://beomagi.blogspot.com/2016/09/odroid-xu4-my-new-nas.html