-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_kegbot
55 lines (46 loc) · 1.8 KB
/
run_kegbot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Runner for kegbot
# Setup some vars
MYSQL_DATA_DIR=/var/lib/mysql
KEGBOT_DATA_DIR=/kegbot-data/data
KEGBOT_SETTINGS_DIR=/kegbot-data/config
DB_USER=kegbot
DB_PASS=kegbot_r00t
# setup kegbot mysql user
if [[ ! -e ${MYSQL_DATA_DIR}/ibdata1 ]]; then
echo Creating new Kegbot db user...
mysql_install_db
DEBIAN_MYSQL_PASS=`cat /etc/mysql/debian.cnf | grep password | head -1 | cut -d' ' -f3`
DEBIAN_MYSQL_GRANT="GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '"$DEBIAN_MYSQL_PASS"'"
KEGBOT_MYSQL_GRANT="GRANT ALL PRIVILEGES ON *.* TO '"$DB_USER"'@'localhost' IDENTIFIED BY '"$DB_PASS"'"
/etc/init.d/mysql start
mysqladmin -u root create kegbot
mysql -u root -e "$DEBIAN_MYSQL_GRANT"
mysql -u root -e "$KEGBOT_MYSQL_GRANT"
mysql -u root -e "FLUSH PRIVILEGES"
# mysql has crappy timezone support, run this to hack in TZ info. See this post:
# https://kegbot.org/docs/server/troubleshooting/#date-errors-while-viewing-sessions
# note that you'll get back two warnings that look like:
# Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
# this is safe to ignore.
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
# also switch redis data dir ownership from root to redis
chown redis /var/lib/redis
fi
# Run kegbot setup script
if [[ ! -e ${KEGBOT_SETTINGS_DIR} ]]; then
echo Seeding initial Kegbot data...
setup-kegbot.py --allow_root True \
--data_root $KEGBOT_DATA_DIR \
--db_database $DB_USER \
--db_password $DB_PASS \
--db_type mysql \
--db_user $DB_USER \
--settings_dir $KEGBOT_SETTINGS_DIR \
--nointeractive
fi
# Ensure mysql and redis are up
/etc/init.d/mysql start
/etc/init.d/redis-server start
# Finally, run our kegbot server
KEGBOT_SETTINGS_DIR=$KEGBOT_SETTINGS_DIR kegbot runserver 0.0.0.0:8000