All posts by mlapaglia

Installing Bitcoin Core on Headless Debian 8

This past week I took a few hours to get a Bitcoin full node running on my Debian server. As a believer in the Bitcoin project I’m more than happy to host a full node on my media server.

Compilation

From your home directory clone the bitcoin project. I used the 0.11 branch.

git clone https://github.com/bitcoin/bitcoin -b 0.11

Following the directions from the github readme I configured and compiled.

I installed the necessary tools and libraries to compile the code.

sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev

Then I got the build environment set up.

./autogen.sh

Since I didn’t need wallet functionality, I didn’t need to install Berkeley DB. I also enabled hardening because, well because why not right? Extra security!

./configure --disable-wallet --enable-hardening

After the configuration was complete I compiled. I noticed make was only utilizing one core and was taking a long time to run. I reran with make configured to utilize 9 (n + 1) cores.

make -j9

Since I’m on Debian I wanted to package the code up so I could install it via dpkg. CheckInstall puts the code into a .deb file that dpkg can then install. This will allow for future uninstall or upgrades to go smoothly, and is better than blindly placing files into the system.

sudo checkinstall

Next I needed to create a configuration file for bitcoind to use. I created a new bitcoin.conf file in ~/.bitcoin/ and placed the following text in it.

# server=1 tells Bitcoin-Qt and bitcoind to accept JSON-RPC commands
server=1

# You must set rpcuser and rpcpassword to secure the JSON-RPC api
rpcuser=superSecretUsername
rpcpassword=superSecretPassword

Autorun

I created a .service file for Debian so the application would autostart. I created a “bitcoinuser” user and “bitcoin” group for the process to run under.

[Unit]
Description=Bitcoin's distributed currency daemon
After=network.target

[Service]
User=bitcoinuser
Group=bitcoin

Type=forking
ExecStart=/usr/local/bin/bitcoind -daemon -conf=/home/bitcoinuser/.bitcoin/bitcoin.conf -datadir=/home/bitcoinuser/.bitcoin/

Restart=always
PrivateTmp=true
TimeoutStopSec=60s
TimeoutStartSec=20s
StartLimitInterval=1s
StartLimitBurst=5

[Install]
WantedBy=multi-user.target

I placed it in /lib/systemd/system/bitcoind.service

After creating, I updated the system to pick up the changes.

sudo systemctl daemon-reload

Then I could issue nice commands to handle everything for me like

sudo service bitcoind start

Remote Status

I wanted to be able to monitor the status of bitcoind remotely via the web, which requires bitcoind to listen to JSON-RPC commands. Craig Watson has a nice PHP project to do just this. I cloned his github repo and installed it into Apache. It needed a small amount of configuration, mainly setting the RPC username and password (that I assigned in the bitcoin.conf file previously), as well as configuring what information I wanted displayed on the main page. After installing the website and configuring Apache with the new route I got a nice screen.

Capture

It’s Working!

It took around 24 hours for it to download the entire blockchain (around 55GB at time of writing), quite surprising with the fast connection the server has.

Street Guardian SG9665GC

Hopefully by now we’ve all seen Russian dash cam videos on YouTube, most of which leave your jaw hanging and eyes wide open.

I recently received the Street Guardian SG9665GC as an early birthday present! After weeks of researching, forum hunting, and video review watching I came upon the Street Guardian and added it to my gadget wishlist.

The Street Guardian SG9665GC
The Street Guardian SG9665GC
Controls knobs on either side of the camera can adjust the position of the lens.
Controls knobs on either side of the camera can adjust the position of the lens.

I chose this model due to it’s better-than-average build quality. The Guardian contains a superior Sony IMX322 CMOS sensor along with an “all-metal” lens. Coupled with its Novatek 96655 Processor it’s able to record excellent 1080p 30fps video with h.264 encoding. The kit also comes with a GPS receiver, used to record the vehicle’s location and speed. Another reason I decided on the Guardian was it’s extremely small form factor. After installation behind my rear-view mirror, I could only see the three cords coming from the camera and going into the cat’s interior trim. My first thought when opening the packaging was “wow, this thing is tiny!”

The lens is made of glass instead of lower-end plastic, increasing the image quality
The 7 element lens is made of glass instead of lower-end plastic, increasing the image quality.

The kit comes with an extra long power cable that allowed me to run the cable along the top and side of my interior trim, hiding it from view. It plugs into a cigarette lighter for power. I plan on chopping the connector off and wiring directly to an accessory powered fuse so I can keep my cigarette lighter open for phone chargers etc.

Navigating the UI on the device can be a bit clumsy at first. The 5 discrete buttons on the body have multiple uses depending on which screen is being presented to the user. The unit truly is “set and forget” though, after some initial configuration (PAL to NTSC, 60 to 50hz, etc) Navigating the UI isn’t needed.

The camera “loops” over itself when the memory card is full. The oldest videos on the card are removed for new captures. A simple button press on the camera, or a g-sensor trigger, will cause the camera to put the currently recording video into a “protected” state where it cannot be deleted by this rolling over functionality. This is used for accidents or events the driver wants to capture for later review, without fear of the video being deleted automatically.

Unlike most included SD cards that come with products, the class 10 32GB micro SD card is no chump, continuously writing at 20MB/s and reading at 86MB/s. However, these speeds were measured with a USB 3.0 card reader. Using the included card reader limited reading to 20 MB/s and writing around 17 MB/s.

Capture

Downloading from SD card to SSD
Downloading from SD card to SSD

The camera logs the location information sent to it by the attached GPS receiver. The GPS coordinates are not overlayed on the video, but instead embedded in the file. Applications like Registrator Viewer can present the data when played back on a computer.

Registrator Viewer playing back a recording.
Registrator Viewer playing back a recording, note there was lots of ice on my windshield.

Registrator overlays the vehicle position on a map that automatically adjusts to keep the vehicle in view. It can also show “G-sensor” values, but the Street Guardian does not currently support logging the data.

headphone jack connectors on the bottom are used for GPS in and A/V out. Power is supplied via the USB-B connector.
headphone jack connectors on the bottom are used for GPS, A/V Out. Power is supplied via the USB-B connector.

The Guardian can be configured to start recording to a new video file every 1,3 or 5 minutes. When it does this I noticed the new file has ~1/4 second of overlap. A mild inconvenience, much better than having missed recording time though.
The Guardian also records audio from inside the car. I tested this by having a conversation in the car. At a normal “talking volume” the device picked up the words decently. When watching the video there was no trouble discerning what people inside the car were saying. A decent amount of road noise can be heard as well, but that could be due to the 2005 Cavalier not being too quiet of a car.

The recording light on the device flashes while in operation. It’s a dim LED though, I was unable to see it from behind the rear-view mirror at night. The screen can be configured to turn off after a set amount of time. I set it to turn off after 15 seconds of being on. This allows me to verify it’s working correctly before I start driving.

Once installed it tucks up neatly behind the rear-view mirror.
Once installed it tucks up neatly behind the rear-view mirror.

And lastly, a quick night time sample video. The sun had set several hours before the video. The camera does a good job at capturing as much light as it did! As I was driving I could not see the clouds from my seat.