diff options
author | neptune | 2022-11-25 18:25:39 -0300 |
---|---|---|
committer | neptune | 2022-11-25 18:25:39 -0300 |
commit | ed200b218d860c32cae15525d9958fceb44e36da (patch) | |
tree | f279d28e69816f56eec863e30cd4ce3576f6d1b9 /cgi | |
parent | b09e855283b8521caa35e1aa0762cf8e986559d4 (diff) | |
download | weabot-ed200b218d860c32cae15525d9958fceb44e36da.tar.gz weabot-ed200b218d860c32cae15525d9958fceb44e36da.tar.xz weabot-ed200b218d860c32cae15525d9958fceb44e36da.zip |
Agregado servidor bjoern para weabot
Diffstat (limited to 'cgi')
-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) |