-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
With workaround for librespeed/speedtest-go#12
- Loading branch information
1 parent
8097274
commit bf62b1c
Showing
5 changed files
with
54 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
CREATE DATABASE $DB_DATABASE; | ||
USE $DB_DATABASE; | ||
CREATE TABLE speedtest_users( -- https://github.com/librespeed/speedtest-go/blob/master/database/mysql/telemetry_mysql.sql | ||
id int(11) NOT NULL AUTO_INCREMENT, | ||
timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
ip text NOT NULL, | ||
ispinfo text, | ||
extra text, | ||
ua text NOT NULL, | ||
lang text NOT NULL, | ||
dl text, | ||
ul text, | ||
ping text, | ||
jitter text, | ||
log longtext, | ||
uuid text, | ||
PRIMARY KEY (id) | ||
); | ||
CREATE USER IF NOT EXISTS '$DB_USERNAME'@'%' IDENTIFIED WITH mysql_native_password BY '$DB_PASSWORD'; | ||
GRANT INSERT, SELECT ON $DB_DATABASE.speedtest_users TO '$DB_USERNAME'@'%'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,3 @@ | |
. settings.sh | ||
|
||
docker volume rm $CONTAINER_NAME-conf | ||
docker volume rm $CONTAINER_NAME-data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,45 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exit immediately if a pipeline, which may consist of a single simple command, | ||
# a list, or a compound command returns a non-zero status | ||
set -e | ||
|
||
# Elevate privileges | ||
[ $UID -eq 0 ] || exec sudo bash "$0" "$@" | ||
|
||
. settings.sh | ||
. ../lib/lib.sh | ||
|
||
readonly MYSQL="mysql --host=$DB_HOST --port=$DB_PORT --user=$DB_ROOT_USERNAME --password=$DB_ROOT_PASSWORD" | ||
|
||
initialize_database() { | ||
echo Initializing database... | ||
export DB_DATABASE DB_USERNAME DB_PASSWORD | ||
$MYSQL <<< "$(envsubst < init/initialize-database.sql)" | ||
echo ...database initialized | ||
} | ||
|
||
run() { | ||
docker run \ | ||
--name $CONTAINER_NAME \ | ||
--hostname $HOST_NAME \ | ||
--detach \ | ||
--volume /etc/localtime:/etc/localtime:ro --volume /etc/timezone:/etc/timezone:ro \ | ||
--volume $CONTAINER_NAME-conf:/etc/librespeed \ | ||
--volume $CONTAINER_NAME-data:/var/lib/librespeed \ | ||
--publish 8989:8989 \ | ||
$DEFAULT_GO_SETTINGS \ | ||
$DEFAULT_HEALTH_SETTINGS \ | ||
$DEFAULT_LOG_SETTINGS \ | ||
$IMAGE_NAME | ||
} | ||
|
||
$MYSQL --execute="USE $DB_DATABASE;" | ||
readonly USE_DB_RETCODE=$? | ||
|
||
# Exit immediately if a pipeline, which may consist of a single simple command, | ||
# a list, or a compound command returns a non-zero status | ||
set -e | ||
|
||
if [ "$USE_DB_RETCODE" -ne 0 ]; then | ||
initialize_database | ||
fi | ||
|
||
run | ||
wait_for_all_container_ports $CONTAINER_NAME $WAIT_TIMEOUT | ||
print_container_info $CONTAINER_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters