Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:crameleon:LibertaCasa
limnoria
limnoria_wizard-suse.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File limnoria_wizard-suse.patch of Package limnoria
--- Limnoria/src/scripts/limnoria_wizard.py 2024-01-07 06:00:00.872528999 +0100 +++ limnoria_wizard-suse 2024-01-07 06:50:13.394365772 +0100 @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/python3 ### # Copyright (c) 2003-2004, Jeremiah Fincher @@ -34,7 +34,21 @@ from __future__ import print_function import os +import pwd import sys +import time + +# Note: This warning block is the only patch in limnoria_wizard. The real patches happen in limnoria_wizard-suse. +SUSEREADMEPATH = '/usr/share/doc/packages/python311-limnoria/README.SUSE' +try: + print('') + print('------------------------------------------------------------') + print("""WARNING:\nYou are running the upstream limnoria_wizard. 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_wizard-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) def error(s): sys.stderr.write(s) @@ -45,7 +59,6 @@ import supybot import re -import time import pydoc import pprint import socket @@ -76,6 +89,16 @@ import supybot.questions as questions from supybot.questions import output, yn, anything, something, expect, getpass +### SUSE +SUSEREADMEPATH = '/usr/share/doc/packages/python310-limnoria/README.SUSE' +SUSEINSTANCECONFIG = '/etc/limnoria/.limnoria.configured' +SUSECONFDIR = '/etc/limnoria/' +SUSELOGDIR = '/var/log/limnoria/' +SUSEDATADIR = '/var/lib/limnoria/' +SUSEWEBDIR = '/srv/www/limnoria/' +SUSEPLUGINDIR = '/usr/local/limnoria/plugins/' +SUSETMPDIR = '/tmp/limnoria/' + def getPlugins(pluginDirs): plugins = set([]) join = os.path.join @@ -169,7 +192,7 @@ def _main(): import supybot.version as version parser = optparse.OptionParser(usage='Usage: %prog [options]', - version='Supybot %s' % version.version) + version='Limnoria (SUSE) %s' % version.version) parser.add_option('', '--allow-root', action='store_true', dest='allowRoot', help='Determines whether the wizard will be allowed to ' @@ -198,11 +221,8 @@ if os.name == 'posix': if (os.getuid() == 0 or os.geteuid() == 0) and not options.allowRoot: error('Running as root is not supported by default (see --allow-root).') - if os.name == 'posix': - if (os.getcwd() == os.path.expanduser('~')) and not options.allowHome: - error('Please, don\'t run this in your HOME directory.') - if (os.path.split(os.getcwd())[-1] == 'bin') and not options.allowBin: - error('Please, don\'t run this in a "bin" directory.') + if not pwd.getpwuid(os.getuid()).pw_name == 'limnoria': + error('Please run this script using `sudo -u limnoria limnoria_wizard-suse`.') if os.path.isfile(os.path.join('scripts', 'supybot-wizard')) or \ os.path.isfile(os.path.join('..', 'scripts', 'supybot-wizard')): print('') @@ -272,129 +292,88 @@ import supybot.conf as conf i18n.import_conf() # It imports the real conf module + ### Instances. + # This is a SUSE specific question allowing the user to define a bot name for the instantiated service to use. + output("""Please provide us with an arbitrary name for the bot instance you are about to configure. + This is not related to IRC, but used for directory and service names, allowing you to configure and run multiple Limnoria instances." If this is your first time running this script, don't worry about what you type here.""") + instance = something('Please specify an instance name for this bot:', default='geeko') + with open(SUSEINSTANCECONFIG, 'a+') as admFile: + if any(instance == instanceEntry.rstrip('\n') for instanceEntry in admFile): + error("""An instance with this name is already configured. Please specify a different name to spawn an additional bot.""") + instanceConfigDir = SUSECONFDIR + instance + instanceDataDir = SUSEDATADIR + instance + instanceBackupDir = instanceDataDir + '/backup/' + instanceLogDir = SUSELOGDIR + instance + instanceWebDir = SUSEWEBDIR + instance + instanceTmpDir = SUSETMPDIR + instance + instancePluginDir = SUSEPLUGINDIR + instance + os.mkdir(instanceConfigDir, mode=750) + os.mkdir(instanceDataDir, mode=750) + os.mkdir(instanceBackupDir, mode=750) + os.mkdir(instanceLogDir, mode=750) + os.mkdir(instanceWebDir, mode=750) + os.makedirs(instanceTmpDir, mode=750, exist_ok=True) + #os.mkdir(instancePluginDir, mode=750) + admFile.write(instance + '\n') + ### Directories. # We set these variables in cache because otherwise conf and log will # create directories for the default values, which might not be what the # user wants. - if advanced: - output("""Now we've got to ask you some questions about where some of - your directories are (or, perhaps, will be :)). If you're running this - wizard from the directory you'll actually be starting your bot from and - don't mind creating some directories in the current directory, then - just don't give answers to these questions and we'll create the - directories we need right here in this directory.""") - - # conf.supybot.directories.log - output("""Your bot will need to put its logs somewhere. Do you have - any specific place you'd like them? If not, just press enter and we'll - make a directory named "logs" right here.""") - (logDir, basedir) = getDirectoryName('logs') - conf.supybot.directories.log.setValue(logDir) - import supybot.log as log - log._stdoutHandler.setLevel(100) # *Nothing* gets through this! - - # conf.supybot.directories.data - output("""Your bot will need to put various data somewhere. Things - like databases, downloaded files, etc. Do you have any specific place - you'd like the bot to put these things? If not, just press enter and - we'll make a directory named "data" right here.""") - (dataDir, basedir) = getDirectoryName('data', basedir=basedir) - conf.supybot.directories.data.setValue(dataDir) - - # conf.supybot.directories.conf - output("""Your bot must know where to find its configuration files. - It'll probably only make one or two, but it's gotta have some place to - put them. Where should that place be? If you don't care, just press - enter and we'll make a directory right here named "conf" where it'll - store its stuff. """) - (confDir, basedir) = getDirectoryName('conf', basedir=basedir) - conf.supybot.directories.conf.setValue(confDir) - - # conf.supybot.directories.backup - output("""Your bot must know where to place backups of its conf and - data files. Where should that place be? If you don't care, just press - enter and we'll make a directory right here named "backup" where it'll - store its stuff.""") - (backupDir, basedir) = getDirectoryName('backup', basedir=basedir) - conf.supybot.directories.backup.setValue(backupDir) - - # conf.supybot.directories.data.tmp - output("""Your bot needs a directory to put temporary files (used - mainly to atomically update its configuration files).""") - (tmpDir, basedir) = getDirectoryName('tmp', basedir=basedir) - conf.supybot.directories.data.tmp.setValue(tmpDir) - - # conf.supybot.directories.data.web - output("""Your bot needs a directory to put files related to the web - server (templates, CSS).""") - (webDir, basedir) = getDirectoryName('web', basedir=basedir) - conf.supybot.directories.data.web.setValue(webDir) + # conf.supybot.directories.log + logDir = instanceLogDir + conf.supybot.directories.log.setValue(logDir) + + # conf.supybot.directories.data + dataDir = instanceDataDir + conf.supybot.directories.data.setValue(dataDir) + + # conf.supybot.directories.conf + confDir = instanceConfigDir + conf.supybot.directories.conf.setValue(confDir) + + # conf.supybot.directories.backup + backupDir = instanceBackupDir + conf.supybot.directories.backup.setValue(backupDir) + + # conf.supybot.directories.data.tmp + tmpDir = instanceTmpDir + conf.supybot.directories.data.tmp.setValue(tmpDir) + + # conf.supybot.directories.data.web + webDir = instanceWebDir + conf.supybot.directories.data.web.setValue(webDir) + + import limnoria.log as log + log._stdoutHandler.setLevel(100) # *Nothing* gets through this! + import limnoria.plugin as plugin + if advanced: # imports callbacks, which imports ircdb, which requires # directories.conf import supybot.plugin as plugin # pluginDirs - output("""Your bot will also need to know where to find its plugins at. - Of course, it already knows where the plugins that it came with are, - but your own personal plugins that you write for will probably be - somewhere else.""") pluginDirs = conf.supybot.directories.plugins() + pluginDirs.append(instancePluginDir) output("""Currently, the bot knows about the following directories:""") output(format('%L', pluginDirs + [plugin._pluginsDir])) - while yn('Would you like to add another plugin directory? ' - 'Adding a local plugin directory is good style.', - default=True): - (pluginDir, _) = getDirectoryName('plugins', basedir=basedir) + while yn('Would you like to add another plugin directory? ', + default=False): + (pluginDir, _) = getDirectoryName('plugins') if pluginDir not in pluginDirs: pluginDirs.append(pluginDir) conf.supybot.directories.plugins.setValue(pluginDirs) - else: - output("""Your bot needs to create some directories in order to store - the various log, config, and data files.""") - basedir = something("""Where would you like to create these - directories?""", default=os.curdir) - - # conf.supybot.directories.log - (logDir, basedir) = getDirectoryName('logs', - basedir=basedir, prompt=False) - conf.supybot.directories.log.setValue(logDir) - - # conf.supybot.directories.data - (dataDir, basedir) = getDirectoryName('data', - basedir=basedir, prompt=False) - conf.supybot.directories.data.setValue(dataDir) - (tmpDir, basedir) = getDirectoryName('tmp', - basedir=basedir, prompt=False) - conf.supybot.directories.data.tmp.setValue(tmpDir) - (webDir, basedir) = getDirectoryName('web', - basedir=basedir, prompt=False) - conf.supybot.directories.data.web.setValue(webDir) - - # conf.supybot.directories.conf - (confDir, basedir) = getDirectoryName('conf', - basedir=basedir, prompt=False) - conf.supybot.directories.conf.setValue(confDir) - - # conf.supybot.directories.backup - (backupDir, basedir) = getDirectoryName('backup', - basedir=basedir, prompt=False) - conf.supybot.directories.backup.setValue(backupDir) - # pluginDirs - pluginDirs = conf.supybot.directories.plugins() - (pluginDir, _) = getDirectoryName('plugins', - basedir=basedir, prompt=False) - if pluginDir not in pluginDirs: - pluginDirs.append(pluginDir) - conf.supybot.directories.plugins.setValue(pluginDirs) + output("""I will now perform some automatic directory configuration of your SUSE powered Limnoria instance ...""") - import supybot.log as log - log._stdoutHandler.setLevel(100) # *Nothing* gets through this! - import supybot.plugin as plugin + # pluginDirs + pluginDirs = conf.supybot.directories.plugins() + pluginDirs.append(instancePluginDir) - output("Good! We're done with the directory stuff.") + + output("Good! We're done with the directory stuff.") ### # Bot stuff @@ -799,22 +778,13 @@ # We're going to need to do a darcs predist thing here. #conf.supybot.debug.generated.setValue('...') - if advanced: - basedir = '.' - filename = os.path.join(basedir, '%s.conf') + basedir = '.' - filename = something("""In which file would you like to save - this config?""", default=filename % nick) - if not filename.endswith('.conf'): - filename += '.conf' - registry.close(conf.supybot, os.path.expanduser(filename)) + instanceConfigFile = instanceConfigDir + '/' + instance + '.conf' + registry.close(conf.supybot, instanceConfigFile) # Done! - output("""All done! Your new bot configuration is %s. If you're running - a *nix based OS, you can probably start your bot with the command line - "supybot %s". If you're not running a *nix or similar machine, you'll - just have to start it like you start all your other Python scripts.""" % \ - (filename, filename)) + output("""All done! Your bot instance %s is now configured. You can start it with ' sudo systemctl start limnoria@%s '. Please read %s if you have not already, otherwise make sure to have a lot of fun ...""" % (instance, instance, SUSEREADMEPATH)) def main(): try:
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