Compare commits

..

No commits in common. "5b03e3d6ba8313eac13f35dba5254c6a400d7d75" and "1018f989862e24d470662e45a18f442d4f7dbf68" have entirely different histories.

2 changed files with 17 additions and 55 deletions

View File

@ -61,23 +61,19 @@ case $1 in
printf "cleanup current signup\n"
sudo sed -i"" "/\b$1\b/d" /var/signups_current
printf "removing .git from new homedir\n"
sudo rm -rf /home/$1/.git
printf "removing skel git README.md\n"
sudo rm /home/$1/README.md
printf "fix sorting in /etc/passwd\n"
sudo pwck -s
printf "applying disk quota\n"
sudo xfs_quota -x -c "limit -u bsoft=1G bhard=3G $1"
# printf "applying disk quota\n"
# sudo setquota -u "$1" 1048576 3145728 0 0 /home
printf "making znc user\n"
/usr/local/bin/znccreate.py "$1" "$newpw" "MaxNetworks=3"
printf "Adding user to Helpdesk\n"
/usr/local/bin/helpdesk_admin.sh "add" "$1" "$2"
/usr/local/bin/znccreate.py "$1" "$newpw"
esac

View File

@ -2,74 +2,40 @@
# Script created/contributed by ~jmjl
import socket, ssl, json, time, sys
# Takes the first argument as a username and the second as the password.
def loadconf(cfgfile):
with open(cfgfile, 'r') as f:
return json.load(f)
cfg = json.load(f)
return cfg
def send(msg):
s.send(f"{msg}\n".encode('utf-8'))
cfg = loadconf("/root/.znc-conf/znc-config.json")
readbuffer = ""
readbuffer=""
s = socket.socket()
if cfg.get('tls') == 'yes':
if cfg['tls'] == 'yes':
ctx = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
s = ctx.wrap_socket(s)
s.connect((cfg['srv'], int(cfg['port'])))
send("NICK bot")
send("USER bot 0 * :A bot to make users")
# Parse optional key=value settings after username/password.
# Example: MaxNetworks=3 MaxClients=5
cli_settings = {}
for arg in sys.argv[3:]:
if '=' in arg:
k, v = arg.split('=', 1)
k = k.strip()
v = v.strip()
if k:
cli_settings[k] = v
# Also allow defaults from config, but CLI wins.
# In /root/.znc-conf/znc-config.json you may add:
# { ..., "default_user_settings": { "MaxNetworks": "3" } }
default_settings = cfg.get("default_user_settings", {}) or {}
while True:
readbuffer += s.recv(2048).decode('utf-8', errors='ignore')
readbuffer = readbuffer + s.recv(2048).decode('utf-8')
temp = str.split(readbuffer, "\n")
readbuffer = temp.pop()
for line in temp:
line = line.rstrip("\r")
parts = line.split()
line = str.rstrip(line)
line = str.split(line)
if len(parts) < 2:
continue
# Authenticate when ZNC asks for PASS (ERR_PASSWDMISMATCH 464).
if parts[1] == '464':
#print(' '.join(line))
if line[1] == '464':
send(f"PASS {cfg['user']}:{cfg['password']}")
# On welcome (001), create user and apply settings.
# (Preserves your original hostname check.)
if parts[0][1:] == 'irc.znc.in' and parts[1] == '001':
if line[0][1:] == 'irc.znc.in' and line[1] == '001':
user = sys.argv[1]
pswd = sys.argv[2]
# Create user (unchanged)
send(f"PRIVMSG *controlpanel :AddUser {user} {pswd}")
# Merge defaults + CLI, CLI overrides
effective = dict(default_settings)
effective.update(cli_settings)
# Apply settings like: set MaxNetworks <user> <val>
for key, val in effective.items():
send(f"PRIVMSG *controlpanel :set {key} {user} {val}")
print(f"Maken znc user {user}")
sys.exit(0)