diff options
Diffstat (limited to 'cgi/weabot.bjoern')
-rwxr-xr-x | cgi/weabot.bjoern | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/cgi/weabot.bjoern b/cgi/weabot.bjoern new file mode 100755 index 0000000..8281ba1 --- /dev/null +++ b/cgi/weabot.bjoern @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import sys, os, pwd, grp, socket +#sys.path.insert(0, "/home/bai/public_html/cgi") + +import bjoern +import weabot + +USER="bai" +GROUP="bai" +U_PATH="/var/run/weabot-bjoern.sock" +U_USER="www-data" +U_GROUP="www-data" +U_UMASK='137' + +uid=pwd.getpwnam(USER)[2] +gid=grp.getgrnam(GROUP)[2] +u_uid=pwd.getpwnam(U_USER)[2] +u_gid=grp.getgrnam(U_GROUP)[2] + + +if __name__ == '__main__': + print("Running weabot bjoern server...") + try: + sock = socket.socket(socket.AF_UNIX) + + try: + os.unlink(U_PATH) + except OSError: + pass + oldumask = os.umask(int(U_UMASK, 8)) + + sock.bind(U_PATH) + sock.listen(1024) + + os.umask(oldumask) + + os.chown(U_PATH, u_uid, u_gid) + os.setgid(gid) + os.setuid(uid) + + bjoern.server_run(sock, weabot.weabot) + finally: + sock.close() + os.unlink(U_PATH) + + #bjoern.run(weabot.weabot, "unix:" + U_HOST) |