Article View: news.software.nntp
Article #92597Script for creating groups
From: ejs
Date: Thu, 01 Jan 2026 13:03
Date: Thu, 01 Jan 2026 13:03
54 lines
2233 bytes
2233 bytes
Hi folks,
i've migrated the INN2 server recently to another host.
A Python script recreating the visible group hierarhy appeared.
Free to use and improve.
#!/bin/python3
import nntplib
import os
ctlinnd = '/usr/lib/news/bin/ctlinnd'
ng_opt = "y"
nntp_source = nntplib.NNTP('source.news.server')
nntp_target = nntplib.NNTP('target.news.server')
source_groups = list()
target_groups = list()
res_groups = list()
try:
s_ng = nntp_source.list()
except nntplib.NNTPTemporaryError:
pass
try:
t_ng = nntp_target.list()
except nntplib.NNTPTemporaryError:
print('Something wrong with this yougurt')
for ng in t_ng[1]:
if ng.group not in target_groups:
target_groups.append(ng.group)
for ng in s_ng[1]:
if ng.group not in target_groups:
res_groups.append(ng.group)
print(F"Appending TARGET: {ng.group}")
if len(res_groups) > 0:
for ng in res_groups:
res = F"sudo {ctlinnd} newgroup {ng} {ng_opt}"
print(F"Executing '{res}'")
os.system(res)
else:
print("\n\tNothing to do. Everything is already in sync.")
--
ejs
news://news.rkm.lt
Technical Details
Message-ID:
<10j5rac$3g4ra$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!spool1.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!spool1.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: ejs <Usernet.eternal-september@seniejitrakai.net> Newsgroups: news.software.nntp Subject: Script for creating groups Date: Thu, 1 Jan 2026 15:03:07 +0200 Organization: A noiseless patient Spider Lines: 54 Message-ID: <10j5rac$3g4ra$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 01 Jan 2026 13:03:09 +0000 (UTC) Injection-Info: dont-email.me; posting-host="1aa4e8d8aa2e418c3ecae1d535dd4a15"; logging-data="3674986"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/GKbgRBHVoZGEUYf3QPTBz" User-Agent: Mozilla Thunderbird Beta Cancel-Lock: sha1:oGhMGLXH42xLcXeYQoMIfuOvQ8k= Content-Language: lt