# ------------------------------------------------------------------------------
dist_bin_SCRIPTS = \
- src/scripts/pakfire
+ src/scripts/pakfire \
+ src/scripts/pakfire-daemon
install-exec-local:
$(MKDIR_P) $(DESTDIR)/$(bindir)
cd $(DESTDIR)/$(bindir) && \
$(LN_S) -vf pakfire pakfire-builder && \
$(LN_S) -vf pakfire pakfire-client && \
- $(LN_S) -vf pakfire pakfire-daemon && \
$(LN_S) -vf pakfire pakfire-key
# ------------------------------------------------------------------------------
o.refresh()
-class CliDaemon(Cli):
- def parse_cli(self):
- parser = argparse.ArgumentParser(
- description = _("Pakfire daemon command line interface"),
- )
- self._add_common_arguments(parser, offline_switch=False)
-
- # There is only one default action
- parser.set_defaults(func=self.handle_run)
-
- return parser.parse_args()
-
- def handle_run(self, ns):
- """
- Runs the pakfire daemon
- """
- d = daemon.PakfireDaemon()
-
- try:
- d.run()
-
- # We cannot just kill the daemon, it needs a smooth shutdown
- except (SystemExit, KeyboardInterrupt):
- d.shutdown()
-
-
class CliKey(Cli):
def parse_cli(self):
parser = argparse.ArgumentParser(
raise AttributeError(key)
-class PakfireDaemon(object):
+class Daemon(object):
def __init__(self, config_file="daemon.conf"):
self.config = config.Config(config_file)
"pakfire" : pakfire.cli.Cli,
"pakfire-builder" : pakfire.cli.CliBuilder,
"pakfire-client" : pakfire.cli.CliClient,
- "pakfire-daemon" : pakfire.cli.CliDaemon,
"pakfire-key" : pakfire.cli.CliKey,
}
--- /dev/null
+#!/usr/bin/python3
+##############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2021 Pakfire development team #
+# #
+# 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 <http://www.gnu.org/licenses/>. #
+# #
+###############################################################################
+
+import argparse
+import sys
+
+import pakfire.daemon
+from pakfire.i18n import _
+
+class Cli(object):
+ def parse_cli(self):
+ parser = argparse.ArgumentParser(
+ description = _("Pakfire daemon command line interface"),
+ )
+
+ parser.add_argument("--config", "-c", nargs="?",
+ default="@sysconfdir@/daemon.conf", help=_("Configuration file to load"))
+
+ return parser.parse_args()
+
+ def __call__(self):
+ """
+ Runs the daemon
+ """
+ args = self.parse_cli()
+
+ # Initialize the daemon
+ d = pakfire.daemon.Daemon(
+ args.config,
+ )
+
+ # Run it
+ try:
+ r = d.run()
+
+ except (SytemExit, KeyboardInterrupt):
+ d.shutdown()
+
+ # Return the exit code
+ sys.exit(r or 0)
+
+if __name__ == "__main__":
+ c = Cli()
+ c()