Kegberry Single-Line Install Script


#1

Hello everyone,

I’m looking for help testing a script I’ve been working on that should get Kegbot (really Kegberry) installed on a Raspberry Pi with a single command. This should also work for both Raspbian Stretch and Raspbian Buster which is required if you want to use the new Raspberry Pi 4.

If anyone has a spare device and would like to try it out, simply run the following after booting up a fresh installation of Stretch or Buster.

bash <(wget -qO- https://raw.githubusercontent.com/johnnyruz/kegbot-server/add_my_pkgs_to_github/install_root.sh)

Please provide feedback if this works for you or if you run into any issues. I have not yet tested this fully with flow-meters etc, but after running this script you should have a fully functional Kegbot Server installation.

The only known issue is that the /home/kegbot/.kegbot/pycore-flags.txt files will have some extra ‘\n’ characters in the file that will need to be manually removed after installation.


#2

I just tested the script on a brand new Pi 3 B running Buster. Works like a champ. Now I just have to wait for the flow sensors to be delivered and flash my controller. You are the man!


#3

@johnnyruz singlehandendly keeping kegbot alive!


#4

@moad, thanks!

I’ve also found a way to install directly from package sources on github so I’m putting together a script that will install Kegbot with all of my updates. My intention is to have two scripts, one that installs Kegbot with the last iteration of code that was fully maintained by @mike and then have scripts that with automatically install Kegbot with all of my updates included. Will hopefully have more to share next week.


#5

Hi, it is the first time that i try to install Kegberry. I already would like to congratulate you for your work. I really want to use the kegbot in my house :slight_smile:

I don’t have any Raspberry Pi yet, i created a virtualbox with Debian 32bit and Raspberry Pi Desktop. (i’m on mac btw)

I’m a noob about coding but i know the basic.

Thanks

i have an issue when i install it what do you think?

INFO : Updating package list …
INFO : Installing required packages …
INFO : Cleaning up …
INFO : Checking if database exists …
INFO : Installing MySQL timezones …
INFO : Checking/installing virtualenv “kegbot-server.venv”…
INFO : Checking/installing virtualenv “kegbot-pycore.venv”…
INFO : Installing python server packages, this may take a while …
INFO : Installing pycore packages, this may take a while …
INFO : Installing Kegbot …
Traceback (most recent call last):
File “/home/kegbot/kegbot-server.venv/bin/kegbot”, line 56, in
django.setup()
File “/home/kegbot/kegbot-server.venv/local/lib/python2.7/site-packages/django/init.py”, line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File “/home/kegbot/kegbot-server.venv/local/lib/python2.7/site-packages/django/apps/registry.py”, line 108, in populate
app_config.import_models(all_models)
File “/home/kegbot/kegbot-server.venv/local/lib/python2.7/site-packages/django/apps/config.py”, line 202, in import_models
self.models_module = import_module(models_module_name)
File “/usr/lib/python2.7/importlib/init.py”, line 37, in import_module
import(name)
File “/home/kegbot/kegbot-server.venv/local/lib/python2.7/site-packages/pykeg/core/models.py”, line 33, in
from django.contrib.auth.models import AbstractBaseUser
File “/home/kegbot/kegbot-server.venv/local/lib/python2.7/site-packages/django/contrib/auth/models.py”, line 40, in
class Permission(models.Model):
File “/home/kegbot/kegbot-server.venv/local/lib/python2.7/site-packages/django/db/models/base.py”, line 122, in new
new_class.add_to_class(’_meta’, Options(meta, **kwargs))
File “/home/kegbot/kegbot-server.venv/local/lib/python2.7/site-packages/django/db/models/base.py”, line 297, in add_to_class
value.contribute_to_class(cls, name)
File “/home/kegbot/kegbot-server.venv/local/lib/python2.7/site-packages/django/db/models/options.py”, line 166, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File “/home/kegbot/kegbot-server.venv/local/lib/python2.7/site-packages/django/db/init.py”, line 40, in getattr
return getattr(connections[DEFAULT_DB_ALIAS], item)
File “/home/kegbot/kegbot-server.venv/local/lib/python2.7/site-packages/django/db/utils.py”, line 242, in getitem
backend = load_backend(db[‘ENGINE’])
File “/home/kegbot/kegbot-server.venv/local/lib/python2.7/site-packages/django/db/utils.py”, line 108, in load_backend
return import_module(’%s.base’ % backend_name)
File “/usr/lib/python2.7/importlib/init.py”, line 37, in import_module
import(name)
File “/home/kegbot/kegbot-server.venv/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py”, line 18, in
raise ImproperlyConfigured(“Error loading MySQLdb module: %s” % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: /home/kegbot/kegbot-server.venv/local/lib/python2.7/site-packages/_mysql.so: wrong ELF class: ELFCLASS64
ERROR: Command returned non-zero exit status (1)

Generated configuration:
CACHES = None
DATABASES = {‘default’: {‘ENGINE’: ‘django.db.backends.mysql’, ‘NAME’: ‘kegbot’, ‘HOST’: ‘’, ‘USER’: ‘root’, ‘PASSWORD’: ‘’, ‘OPTIONS’: {‘init_command’: ‘SET storage_engine=INNODB’}}}
KEGBOT_ROOT = ‘/home/kegbot/kegbot-data’
MEDIA_ROOT = ‘/home/kegbot/kegbot-data/media’
SECRET_KEY = ‘wl&y4ww$j(7#t9k17+8e($8+d6o!h53(_82ukp+6hfb7pygomi’
STATIC_ROOT = ‘/home/kegbot/kegbot-data/static’

Writing settings to /home/kegbot/.kegbot/local_settings.py …
Finishing setup …
Running command: kegbot syncdb --noinput -v 0

ERROR : Command returned error:
ERROR : Command: sudo su -l kegbot -c “. /home/kegbot/kegbot-server.venv/bin/activate && setup-kegbot.py --interactive=false --db_type=mysql --db_database=“kegbot” --data_root=/home/kegbot/kegbot-data”
ERROR : Return code: 1
Traceback (most recent call last):
File “/usr/local/bin/kegberry”, line 7, in
app.run()
File “/usr/local/lib/python2.7/dist-packages/kegberry/app.py”, line 210, in run
command_fn(*args)
File “/usr/local/lib/python2.7/dist-packages/kegberry/app.py”, line 293, in install
run_in_virtualenv(SERVER_VENV, cmd)
File “/usr/local/lib/python2.7/dist-packages/kegberry/app.py”, line 154, in run_in_virtualenv
return run_as_kegberry(cmd, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/kegberry/app.py”, line 148, in run_as_kegberry
return run_command(wrapped, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/kegberry/app.py”, line 142, in run_command
raise e
subprocess.CalledProcessError: Command ‘sudo su -l kegbot -c “. /home/kegbot/kegbot-server.venv/bin/activate && setup-kegbot.py --interactive=false --db_type=mysql --db_database=“kegbot” --data_root=/home/kegbot/kegbot-data”’ returned non-zero exit status 1


#6

Hi @dossp42,

Thanks for this info. I think the issue is the line here:

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: /home/kegbot/kegbot-server.venv/local/lib/python2.7/site-packages/_mysql.so: wrong ELF class: ELFCLASS64

With the Buster release of Debian there is some problem with compiling the MySql-Python package that Django uses, so with my script I include pre-compiled binaries of the package.

I’ve only included binaries for x86_64-linux-gnu (64-bit Intel processor) or arm-linux-gnueabihf (64-bit ARM processor - Raspberry Pi) since those are the two systems I have that I was able to compile things.

Are you able to install a 64-bit version of Debian in your virtualbox setup and try that? If it has to be 32-bit, I’ll try to get a pre-compiled binary included in the install script but may take me a week or so.


#7

Hi, thanks for your response.

Debian Buster (linux 10)
Debian Buster with Raspberry Pi Desktop
2019-09-25-rpd-x86-buster

still the same error :

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: /home/kegbot/kegbot-server.venv/local/lib/python2.7/site-packages/_mysql.so: wrong ELF class: ELFCLASS64

Debian Jessie (linux 8.11)
Debian Jessie with Raspberry Pi Desktop

Working :slight_smile:


#8

Yeah, Jessie (and Stretch) should work fine without any issues.

I’ve updated the script so that it should work correctly with Buster on VirtualBox on a Mac. However, whenever I try to run Buster with RPi desktop the install seems to just freeze up, but that could be my machine. It worked fine using the regular Debian Buster install ISO from the Debian site!

I would love it if your could give it a try at some point. Thanks!


#9

Well done! It is working on Debian Buster.
i’m heading to buy Pi 4 and the stuff with, soon :slight_smile:
Thanks!


#10

Gah…

I tried copying over some of your edits from GitHub, and now kegbot_core and kegboard_daemon aren’t launching.

Traceback (most recent call last):
File “/home/kegbot/kegbot-pycore.venv/bin/kegbot_core.py”, line 21, in
from kegbot.pycore import kegbot_app
ImportError: No module named kegbot.pycore


Traceback (most recent call last):
File “/home/kegbot/kegbot-pycore.venv/bin/kegboard_daemon.py”, line 46, in
from kegbot.util import app
ImportError: No module named kegbot.util

All of the other things within Supervisor are launching just fine. Not sure if there is something I need to register, or what…


#11

I was able to get them working again by re-running the kegberry setup script. It blew out all of the edited files I copied over. Might have to just edit each file by hand and see if that works.


#12

That worked. I just had to edit line by line and now I seem to have everything working. The RFID reader has some issues with reading the tags, but that might be a wiring issue on my end. Now, I just need to get new kegs and really test it out.


#13

I think I might do some modifications to the main page. I’m not sure how to make it more user friendly, but I’ll try. I have 1 user right now. I need to make it easy for them to register a token and adopt it, or just login and associate a pour.


#14

Absolutely! I think everyone would love any new enhancements.

And apologies for my lack or response with your issues integrating my updates, I’ve been traveling this week.

I am still working on getting the single-line script installed to include my updates so that it’s not such a pain to get things upgraded after the initial install. I’m re-configuring my full “DEV” environment with RFID reader so that I’ll be able to test and hopefully make progress.


#15

No problem. It was fun messing around with the code for a few days. I have a pretty good understanding of how things work now. I’ve been in IT for around 15 years now. I’m a Director of Security, and not a great programmer. I can hack at code to make it (mostly) work…

One improvement I was looking at is scraping Untappd when you add a new beer type. There are a few good examples out on Github using Python and Javascript. I think I’m also going to modify Fullscreen to use google fonts for the “What’s on tap”, instead of an image. That way I can change it someday… Maybe even dynamically, based on events.


#16

I love the font idea, definitely sounds like a good solution.

As far as Untappd, I know Kegbot has some out-of-the-box functionality for integrating. I tried to play with it a long time ago and applied for a developer API key through Untappd maybe 3 times and never got any type of response. If there’s other options for actually just making web requests and scraping the HTML rather than using an API integration that may work as well.


#17

I finally connected the flow meters last night. I am getting flows on the Arduino and kegbot is recording them. Now I get a spawn error every time I try to launch the node server.

listening on *:3000
/home/kegbot/kegbot-server.venv/node_server/server.js:109
bodyjson.objects.forEach((tap) => {
^

TypeError: Cannot read property ‘forEach’ of undefined
at Request._callback (/home/kegbot/kegbot-server.venv/node_server/server.js:109:24)
at Request.self.callback (/home/kegbot/kegbot-server.venv/node_server/node_modules/request/request.js:185:22)
at Request.emit (events.js:198:13)
at Request. (/home/kegbot/kegbot-server.venv/node_server/node_modules/request/request.js:1161:10)
at Request.emit (events.js:198:13)
at IncomingMessage. (/home/kegbot/kegbot-server.venv/node_server/node_modules/request/request.js:1083:12)
at Object.onceWrapper (events.js:286:20)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
listening on *:3000
/home/kegbot/kegbot-server.venv/node_server/server.js:109
bodyjson.objects.forEach((tap) => {
^

TypeError: Cannot read property ‘forEach’ of undefined
at Request._callback (/home/kegbot/kegbot-server.venv/node_server/server.js:109:24)
at Request.self.callback (/home/kegbot/kegbot-server.venv/node_server/node_modules/request/request.js:185:22)
at Request.emit (events.js:198:13)
at Request. (/home/kegbot/kegbot-server.venv/node_server/node_modules/request/request.js:1161:10)
at Request.emit (events.js:198:13)
at IncomingMessage. (/home/kegbot/kegbot-server.venv/node_server/node_modules/request/request.js:1083:12)
at Object.onceWrapper (events.js:286:20)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
listening on *:3000
/home/kegbot/kegbot-server.venv/node_server/server.js:109
bodyjson.objects.forEach((tap) => {
^


#18

Just figured it out. I changed the privacy settings from Public to Members Only. Looks like that won’t work with the node server… Changed it back to Public and now I am able to start node up again.


#19

Hmm, alright. Yeah the Node Server thing is a VERY manual process right now. I’ve been working throughout the day to get a one-line script with the RFID and latest stuff included, which actually has gone well. I’m just now starting on the Node Server stuff but will probably have to be tomorrow or next week before I get everything fully integrated.

One of those things that works perfectly on my PROD setup, but I can’t remember exactly how I set everything up in code since I was lax about actually checking into source control!

Stay tuned for updates and thanks for your help!


#20

I figured out my RFID issues. The code is fine but the module I was using…wasn’t. I bought a different brand with the pins already soldered, connected them to the board and everything worked as advertised. I am able to simulate pours and it’s great. My local beer store should have my kegs ready this week, so I can do more testing. I’m throwing a going away party at my house this weekend, so that will be the ultimate test. I need to fully figure out the rest of the settings for my reverse proxy by then. I don’t allow the guest WiFi to connect to my home vlans. I think I just need to make the node server available outside and change the base link to my FQDN. Also need to enable some security features too. I should hit the website with a vuln scan and probably burp it too.