Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:crameleon:LibertaCasa
limnoria
limnoria_adduser-suse.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File limnoria_adduser-suse.patch of Package limnoria
--- Limnoria/src/scripts/limnoria_adduser.py 2024-01-07 06:00:00.872528999 +0100 +++ limnoria_adduser-suse 2024-01-07 05:57:44.238344453 +0100 @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/python3 ### # Copyright (c) 2002-2004, Jeremiah Fincher @@ -31,20 +31,30 @@ ### +import sys +import time -import supybot +# Note: This warning block and the imports are the only patches in limnoria_adduser. The real patches happen in supybot-adduser-suse. +SUSEREADMEPATH = '/usr/share/doc/packages/python311-limnoria/README.SUSE' +try: + print('') + print('------------------------------------------------------------') + print("""WARNING:\nYou are running the upstream limnoria_adduser script. It does not know about the correct directory layout and may interfere with the system installation of Limnoria.\nWhilst you are free to proceed with this upstream script at your own risk, it is highly recommended to run ` sudo -u limnoria limnoria_adduser-suse ` instead.\nPlease read %s for further SUSE specific details on operating your Limnoria installation.\nThe script execution will now pause for 10 seconds, giving you time to abort using Ctrl-C.""" % SUSEREADMEPATH) + print('------------------------------------------------------------') + print('') + time.sleep(10) +except KeyboardInterrupt: + sys.exit(0) -from supybot.questions import * - -import os -import sys import optparse +import os +import pwd +import supybot +from supybot.questions import * def main(): - import supybot.log as log import supybot.conf as conf - conf.supybot.log.stdout.setValue(False) - parser = optparse.OptionParser(usage='Usage: %prog [options] <users.conf>', + parser = optparse.OptionParser(usage='Usage: sudo -u limnoria %prog [options] <instance>', version='supybot %s' % conf.version) parser.add_option('-u', '--username', action='store', default='', dest='name', @@ -57,20 +67,39 @@ help='capability the user should have; ' 'this option may be given multiple times.') (options, args) = parser.parse_args() + if not pwd.getpwuid(os.getuid()).pw_name == 'limnoria': + print('Please run this script using `sudo -u limnoria limnoria_adduser-suse <instance name>`.') + sys.exit(1) if len(args) != 1: - parser.error('Specify the users.conf file you\'d like to use. ' - 'Be sure *not* to specify your registry file, generated ' - 'by supybot-wizard. This is not the file you want. ' - 'Instead, take a look in your conf directory (usually ' - 'named "conf") and take a gander at the file ' - '"users.conf". That\'s the one you want.') - - filename = os.path.abspath(args[0]) - conf.supybot.directories.log.setValue('/') - conf.supybot.directories.conf.setValue('/') - conf.supybot.directories.data.setValue('/') - conf.supybot.directories.plugins.setValue(['/']) + parser.error('Specify the instance name of the bot you\'d like to add a user for.') + + ### SUSE + SUSEINSTANCECONFIG = '/etc/limnoria/.limnoria.configured' + SUSECONFDIR = '/etc/limnoria/' + SUSELOGDIR = '/var/log/limnoria/' + SUSEDATADIR = '/var/lib/limnoria/' + + instance = args[0] + + with open(SUSEINSTANCECONFIG, 'r') as admFile: + if not any(instance == instanceEntry.rstrip('\n') for instanceEntry in admFile): + print("""Unable to find a bot instance called %s, was it configured using limnoria_wizard-suse?""" % instance) + sys.exit(1) + + instanceConfigDir = SUSECONFDIR + instance + instanceDataDir = SUSEDATADIR + instance + instanceLogDir = SUSELOGDIR + instance + + conf.supybot.directories.log.setValue(instanceLogDir) + conf.supybot.directories.data.setValue(instanceDataDir) + conf.supybot.directories.conf.setValue(instanceConfigDir) + + import supybot.log as log + conf.supybot.log.stdout.setValue(False) + + filename = '/etc/limnoria/' + instance + '/users.conf' conf.supybot.databases.users.filename.setValue(filename) + import supybot.ircdb as ircdb if not options.name:
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor