From 1fa57228447abc46d58bcc377ab373c026ccd008 Mon Sep 17 00:00:00 2001 From: Philip Knirsch Date: Wed, 25 Feb 2009 11:28:06 +0100 Subject: - Add init() methods to each plugin - Call plugin init() methods during tuned's init() - Add support for command line parameters o -c conffile|--config==conffile to specify the location of the config file o -d to start tuned as a daemon (instead of as normal app) - Readded the debug output in case tuned isn't started as as daemon - Fixed initialization of max transfer values for net tuning plugin --- tuned | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'tuned') diff --git a/tuned b/tuned index a1b6cab..126200c 100755 --- a/tuned +++ b/tuned @@ -20,9 +20,12 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -import sys, os.path +import sys, os.path, getopt -if __name__ == "__main__": +def usage(): + print "Usage: tuned [-d|--daemon] [-c conffile|--config=conffile]" + +def daemonize(): try: pid = os.fork() if pid > 0: @@ -42,12 +45,37 @@ if __name__ == "__main__": sys.exit(1) sys.stdout = sys.stderr = open("/dev/null", 'a+') + +if __name__ == "__main__": + try: + opts, args = getopt.getopt(sys.argv[1:], "dc:", ["daemon", "config="]) + except getopt.error, e: + print >>sys.stderr, ("Error parsing command-line arguments: %s", e) + usage() + sys.exit(1) + + if len(args) > 0: + print >>sys.stderr, ("Too many arguments.") + usage() + sys.exit(1) + + daemon = False + cfgfile = "/etc/tuned.conf" + for (opt, val) in opts: + if opt in ['-d', "--daemon"]: + daemon = True + elif opt in ['-c', "--config"]: + cfgfile = val + + if daemon: + daemonize() + TUNEDDIR="/usr/share/tuned" if not TUNEDDIR in sys.path: sys.path.append(TUNEDDIR) from tuned import tuned - tuned.init(TUNEDDIR) + tuned.init(TUNEDDIR, cfgfile) tuned.run() tuned.cleanup() -- cgit