./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

73
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.
""" """
class Configure():
def promptUser(self, prompt, default):
inp = raw_input("%s [%s]> " % (prompt, default))
if inp == "":
return default
return inp
def promptYesNo(self, prompt, defult=True):
inp = False if self.promptUser(prompt, "Y") == "N" else True
return inp
def go(self):
configflags = ["./configure"]
print(art) print(art)
print(welcome) print(welcome)
print("Please specify where you would like to install Elemental-IRCd.") print("Please specify where you would like to install Elemental-IRCd.")
installloc = promptUser("Install location?", "$HOME/ircd") installloc = self.promptUser("Install location?", "$HOME/ircd")
print("") print("")
print("Please specify the maximum nickname length. This must be the same across") print("Please specify the maximum nickname length. This must be the same across")
print("all servers in your network or you risk desyncs. The maximum is 50.") print("all servers in your network or you risk desyncs. The maximum is 50.")
nicklen = 100 nicklen = 890234
while nicklen > 51: nicklen_valid = False
if nicklen != 100: while not nicklen_valid:
print "Error: you must choose a value under 50." 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
nicklen = int(promptUser("Maximum nickname length?", "31")) 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("--prefix=%s" % installloc)
configflags.append("--with-nicklen=%s" % nicklen) configflags.append("--with-nicklen=%s" % nicklen)
if not smallnet: if not smallnet:
configflags.append("--enable-small-net") configflags.append("--enable-small-net")
else: else:
configflags.append("--disable-small-net") configflags.append("--disable-small-net")
print("\nThat should be it for now. Running %s" % " ".join(configflags)) print("\nThat should be it for now. Running %s" % " ".join(configflags))
raw_input("Press enter to continue... ") raw_input("Press enter to continue... ")
system(" ".join(configflags)) system(" ".join(configflags))
print(art) print(art)
print(""" print("""
Next, run make and make install. Then copy %s/etc/example.conf to 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