From: Michael Tremer Date: Fri, 4 Jun 2010 01:06:47 +0000 (+0200) Subject: network: Add some small databases for status monitoring and accounting. X-Git-Tag: 001~102 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=059469a867de526a7318de2a22dde33d9d58fbb8;p=people%2Fms%2Fnetwork.git network: Add some small databases for status monitoring and accounting. --- diff --git a/functions.constants b/functions.constants index 7521e6e8..2030dc9b 100644 --- a/functions.constants +++ b/functions.constants @@ -25,15 +25,18 @@ COLORS=1 BASE_DIR=/lib/network CONFIG_DIR=/etc/network HOOKS_DIR=${BASE_DIR}/hooks +LOG_DIR=/var/log/network RUN_DIR=/var/run/network ZONE_DIR=${CONFIG_DIR} -RED_RUN=/var/run/network/red +RED_RUN=${RUN_DIR}/red PPP_SECRETS=/etc/ppp/secrets CONFIG_FILE=${CONFIG_DIR}/network_config CONFIG_FILE_PARAMS="COLORS DEBUG SHELL" +DB_CONNECTION_FILE="${LOG_DIR}/connections.db" + # Proper error codes EXIT_OK=0 EXIT_ERROR=1 diff --git a/functions.db b/functions.db new file mode 100644 index 00000000..23e0e359 --- /dev/null +++ b/functions.db @@ -0,0 +1,113 @@ +#!/bin/bash +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2010 Michael Tremer & Christian Schmidt # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +function db_connection_init() { + if [ -e "${DB_CONNECTION_FILE}" ]; then + return ${EXIT_OK} + fi + + log DEBUG "Creating connection database ${DB_CONNECTION_FILE}." + + sqlite3 -batch ${DB_CONNECTION_FILE} <