Permalink
Browse files

[core] Add systemd service file and other default config files for di…

…stros

See contrib/README for more information.
Also modified willie.py to support a new config key in [core]:
not_configured will cause the bot to refuse running if set to true.
This is useful to force users to configure the bot before trying to run it as the config wizard is not ideal for willie running as a service.

Issue #262
  • Loading branch information...
1 parent 7e1dc1e commit 5c9991a7fa1d2aea3f063788f6e2bd27369bf5ff @elad661 elad661 committed May 24, 2013
Showing with 54 additions and 1 deletion.
  1. +10 −0 contrib/README
  2. +19 −0 contrib/willie.cfg
  3. +2 −0 contrib/willie.conf
  4. +16 −0 contrib/willie.service
  5. +7 −1 willie.py
View
@@ -0,0 +1,10 @@
+This folder contains willie.service and willie.cfg designed to be distributed by 3rd party distrubtions such as Fedora Project or Arch Linux.
+
+willie.cfg is a default configuration file for willie, that assumes the OS is new enough to have /run and /usr/lib/tmpfiles.d
+
+willie.service is a systemd service file that assumes you are using a rather recent Willie and has no multiple instance support (TODO). It also assumes that the system has a special user named willie designated for running the bot and this user has access to /run/willie (should be setup by willie.conf in /usr/lib/tmpfiles.d), /var/log/willie and /var/lib/willie
+
+Default installation paths:
+ willie.cfg /etc
+ willie.conf /usr/lib/tmpfiles.d
+ willie.service /usr/lib/systemd/system
View
@@ -0,0 +1,19 @@
+#Default willie configuration file for Fedora
+#For information related to possible configuration values see
+# https://github.com/embolalia/willie/wiki/Core-configuration-settings
+# https://github.com/embolalia/willie/wiki/Module-Configuration
+#
+#IMPORTANT NOTE!
+#You must delete the not_configured line in order for the bot to work,
+# otherwise it will refuse to start.
+[core]
+not_configured=True
+host=chat.freenode.net
+port=6697
+use_ssl=True
+verify_ssl=True
+owner=
+logdir=/var/log/willie
+pid_dir=/run/willie
+homedir=/var/lib/willie
+
View
@@ -0,0 +1,2 @@
+# Willie tmporary directory setup
+d /run/willie 0755 wilie willie -
View
@@ -0,0 +1,16 @@
+[Unit]
+Description=Willie IRC bot
+Documentation=http://willie.dftba.net/
+After=network.target
+
+[Service]
+Type=simple
+User=willie
+PIDFile=/run/willie/willie.pid
+ExecStart=/usr/bin/willie -c /etc/willie.cfg --quiet
+ExecStop=/usr/bin/willie -c /etc/willie.cfg -q
+Restart=on-failure
+RestartPreventExitStatus=2
+
+[Install]
+WantedBy=multi-user.target
View
@@ -115,7 +115,13 @@ def main(argv=None):
config_module = Config(configpath)
except ConfigurationError as e:
stderr(e)
- sys.exit(1)
+ sys.exit(2)
+
+ if config_module.core.not_configured:
+ stderr('Bot is not configured, can\'t start')
+ # exit with code 2 to prevent auto restart on fail by systemd
+ sys.exit(2)
+
if not config_module.has_option('core', 'homedir'):
config_module.dotdir = homedir
config_module.homedir = homedir

0 comments on commit 5c9991a

Please sign in to comment.