From 059469a867de526a7318de2a22dde33d9d58fbb8 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 4 Jun 2010 03:06:47 +0200 Subject: [PATCH] network: Add some small databases for status monitoring and accounting. --- functions.constants | 5 +- functions.db | 113 ++++++++++++++++++++++++++++++++++++++++++++ functions.ppp | 32 ++++--------- functions.zone | 19 ++++++++ 4 files changed, 144 insertions(+), 25 deletions(-) create mode 100644 functions.db 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} <