./Config: Somewhat rewrote script, improved nicklen prompting and interrupt handling.

This commit is contained in:
AppleDash 2014-06-12 10:14:10 -04:00 committed by Sam Dodrill
parent 26005c6f48
commit 47130005ae
1 changed files with 60 additions and 51 deletions

111
Config
View File

@ -8,21 +8,10 @@ This software is under GPL.
from os import system from os import system
def promptUser(prompt, default): try:
inp = raw_input("%s [%s]> " % (prompt, default)) raw_input = raw_input
except NameError:
if inp == "": raw_input = input
return default
else:
return inp
def promptYesNo(prompt, default=True):
inp = False if promptUser(prompt, "Y") == "N" else True
return inp
configflags = ["./configure"]
system("clear")
art = """ art = """
_______ __ __ __ _______ ______ ______ __ _______ __ __ __ _______ ______ ______ __
@ -35,49 +24,64 @@ Welcome to the Elemental-IRCd Configuration script. This script will help you ch
best compile flags for your installation of Elemental-IRCd. best compile flags for your installation of Elemental-IRCd.
""" """
print(art) class Configure():
print(welcome) def promptUser(self, prompt, default):
inp = raw_input("%s [%s]> " % (prompt, default))
if inp == "":
return default
return inp
print("Please specify where you would like to install Elemental-IRCd.") def promptYesNo(self, prompt, defult=True):
installloc = promptUser("Install location?", "$HOME/ircd") inp = False if self.promptUser(prompt, "Y") == "N" else True
return inp
print("") def go(self):
configflags = ["./configure"]
print(art)
print(welcome)
print("Please specify the maximum nickname length. This must be the same across") print("Please specify where you would like to install Elemental-IRCd.")
print("all servers in your network or you risk desyncs. The maximum is 50.") installloc = self.promptUser("Install location?", "$HOME/ircd")
nicklen = 100 print("")
while nicklen > 51: print("Please specify the maximum nickname length. This must be the same across")
if nicklen != 100: print("all servers in your network or you risk desyncs. The maximum is 50.")
print "Error: you must choose a value under 50."
nicklen = int(promptUser("Maximum nickname length?", "31")) nicklen = 890234
nicklen_valid = False
while not nicklen_valid:
try:
nicklen = int(self.promptUser("Maximum nickname length?", "31"))
if nicklen > 51 and nicklen != 890234:
nicklen_valid = False
else:
nicklen_valid = True
except ValueError:
nicklen_valid = False
if not nicklen_valid:
print("Error: you must choose an integer value under 50.")
print("") print("")
print("Would you like to disable small network support? This increases the size") print("Would you like to disable small network support? This increases the size")
print("of a few buffers in the code and can increase performance on large networks.") print("of a few buffers in the code and can increase performance on large networks.")
smallnet = self.promptYesNo("Small network? (Y/N)")
smallnet = promptYesNo("Small network? (Y/N)") configflags.append("--prefix=%s" % installloc)
configflags.append("--with-nicklen=%s" % nicklen)
if not smallnet:
configflags.append("--enable-small-net")
else:
configflags.append("--disable-small-net")
configflags.append("--prefix=%s" % installloc) print("\nThat should be it for now. Running %s" % " ".join(configflags))
configflags.append("--with-nicklen=%s" % nicklen) raw_input("Press enter to continue... ")
system(" ".join(configflags))
print(art)
if not smallnet: print("""
configflags.append("--enable-small-net") Next, run `make` and `make install`. Then copy %s/etc/example.conf to
else:
configflags.append("--disable-small-net")
print("\nThat should be it for now. Running %s" % " ".join(configflags))
raw_input("Press enter to continue... ")
system(" ".join(configflags))
print(art)
print("""
Next, run make and make install. Then copy %s/etc/example.conf to
%s/etc/ircd.conf and read through the example configuration completely to make %s/etc/ircd.conf and read through the example configuration completely to make
sure your install is tailored to your needs. After that, run %s/bin/ircd sure your install is tailored to your needs. After that, run %s/bin/ircd
and start to connect clients and servers as you need. and start to connect clients and servers as you need.
@ -85,8 +89,13 @@ and start to connect clients and servers as you need.
If you have any problems, please check the documentation in the doc/ folder If you have any problems, please check the documentation in the doc/ folder
of the source repository. If problems persist please stop by #elemental-ircd of the source repository. If problems persist please stop by #elemental-ircd
on irc.yolo-swag.com and ask. Running Elemental-IRCd in insane conditions may on irc.yolo-swag.com and ask. Running Elemental-IRCd in insane conditions may
make support either very difficult or at most impossible.""" %\ make support either very difficult or at most impossible.""" % (installloc, installloc, installloc))
(installloc, installloc, installloc))
system("clear")
c = Configure()
try:
c.go()
except KeyboardInterrupt:
print("\nInterrupted, exiting!")
# vim: set ts=4 sw=4 tw=0 et # vim: set ts=4 sw=4 tw=0 et