Пример #1
0
    s = socket.create_connection((host, 80), 2)
except:
    print("I don't seem to be connected to the Internet")
    print("This script requires Internet connection")
    print("Please insure Internet availability and run this script again")
    sys.exit(2)

#===============================================================================
# Check for package install of freeswitch and distro trusty
#===============================================================================

if FPBXParms.PARMS["Distro"][0] == "trusty" and FPBXParms.PARMS["FS_Install_Type"][0] == 'P':
    print("There are no packages for Ubuntu trusty, I will install from source")
    FPBXParms.PARMS["FS_Install_Type"][0] = 's'

FPBXParms.save_parms()

#===============================================================================
# One last time let the user verify we are ready to begin
#===============================================================================

FPBXParms.show_parms()
print("The Linux distribution appears to be code named %s" % (FPBXParms.PARMS["Distro"][0]))
print()
INSTALL_PROGRESS = load_parms(INSTALL_PROGRESS)



#===============================================================================
# Ask the burning question
#===============================================================================
def iask_questions():    
    
    print("I am checking to see if there are parameters already defined")
    
    #===============================================================================
    # Load the previously saved parameters
    #===============================================================================
    
    if os.path.isfile("%s/resources/install.json" % (INSTALL_ROOT)):
    
        FPBXParms.PARMS = FPBXParms.load_parms(FPBXParms.PARMS)
    
        print("I found the following parameters")
        FPBXParms.show_parms()
    
        USEPARMS = ask_yn("Do you want to use them")
        if USEPARMS == "Yes":
            pass
#             print("In loop %d" % (LOOPNUMBER))
#             LOOPNUMBER += 1
        else:
    #===============================================================================
    # Start asking the hard questions
    #===============================================================================
            print("Very well I will ask you several questions.")
            print("Note: if a question has '(a/B)' in it, 'B' is the default")
            print("If a question has a value listed that is the default")
            print("All default values can be selected by just pressing Enter")
            print("If a parameter does not have a default, a value must be entered")
            
            s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
            s.connect(('google.com', 0))
            FPBXParms.PARMS["IP"][0] = (s.getsockname()[0])
        
            BDR_ANS = "No"
#             BDR_ANS = ask_yn(FPBXParms.PARMS["BDR"][1])
            FPBXParms.PARMS["BDR"][0] = BDR_ANS
            if BDR_ANS == "Yes":
                PARM_LIST = FPBXParms.BDR_PARMS
            else:
                PARM_LIST = FPBXParms.NON_BDR_PARMS
    
            if len(PARM_LIST) > 0:
                for index in PARM_LIST:
                    FPBXParms.ask_parm(index)
    
            for index in FPBXParms.COMMON_PARMS:
                FPBXParms.ask_parm(index)
    
    #======================================================================
    # Make up some passwords that are secure and easy to remember
    #======================================================================
    
    #         FPBXParms.PARMS["FPBXuserPassword"][0] = mkpass()
    #         FPBXParms.PARMS["FPBXDBUserPassword"][0] = mkpass()
    
            FPBXParms.save_parms()
    else:
        print("There is no predefined parameter file.")
        print("Please answer the following questions.")
        
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(('google.com', 0))
        FPBXParms.PARMS["IP"][0] = (s.getsockname()[0])
#        For now we are only installing a single switch, No BDR
        BDR_ANS = "No"
#         BDR_ANS = ask_yn(FPBXParms.PARMS["BDR"][1])
        FPBXParms.PARMS["BDR"][0] = BDR_ANS
        if BDR_ANS == "Yes":
            PARM_LIST = FPBXParms.BDR_PARMS
        else:
            PARM_LIST = FPBXParms.NON_BDR_PARMS
        if len(PARM_LIST) > 0:
            for index in PARM_LIST:
                FPBXParms.ask_parm(index)
    
        for index in FPBXParms.COMMON_PARMS:
            FPBXParms.ask_parm(index)
    
    #======================================================================
    # Make up some passwords that are secure and easy to remember
    #======================================================================
    
    #     FPBXParms.PARMS["FPBXuserPassword"][0] = mkpass()
    #     FPBXParms.PARMS["FPBXDBUserPassword"][0] = mkpass()
    
    #===========================================================================
    # We need to check for Ubuntu and insure it is a source install
    #===========================================================================
        
        if FPBXParms.PARMS["Distro"][0] == "trusty":
            FPBXParms.PARMS["FS_Install_Type"][0] = "s"
            print("This install is on Ubuntu and only source is currently configured")
            print("I have set your Freeswitch install type to source")
        
        FPBXParms.save_parms()
            
    return
Пример #3
0
REMOTE_SERVER = "www.google.com"
try:
    # see if we can resolve the host name -- tells us if there is
    # a DNS listening
    host = socket.gethostbyname(REMOTE_SERVER)
    # connect to the host -- tells us if the host is actually
    # reachable
    s = socket.create_connection((host, 80), 2)
except:
    print("I don't seem to be connected to the Internet")
    print("This script requires Internet connection")
    print("Please insure Internet availability and run this script again")
    sys.exit(2)


FPBXParms.save_parms()

#===============================================================================
# One last time let the user verify we are ready to begin
#===============================================================================

FPBXParms.show_parms()
print("The Debian Linux distribution appears to be code named %s" % (FPBXParms.PARMS["Distro"][0]))
print()
INSTALL_PROGRESS = load_parms(INSTALL_PROGRESS)

#===============================================================================
# Ask the burning question
#===============================================================================

if not args.restart:
Пример #4
0
def iask_questions():
    print("Welcome to FusionPBX installation.")
    print("I am checking to see if there are parameters already defined")

    #===============================================================================
    # Load the previously saved parameters
    #===============================================================================

    if os.path.isfile("%s/resources/install.json" % (INSTALL_ROOT)):

        FPBXParms.PARMS = FPBXParms.load_parms(FPBXParms.PARMS)

        print("I found the following parameters")
        FPBXParms.show_parms()

        USEPARMS = ask_yn("Do you want to use them")
        if USEPARMS == "Yes":
            pass
#             print("In loop %d" % (LOOPNUMBER))
#             LOOPNUMBER += 1
        else:
            #===============================================================================
            # Start asking the hard questions
            #===============================================================================
            print("Very well I will ask you several questions.")
            print("Note: if a question has '(a/B)' in it, 'B' is the default")
            print("If a question has a value listed that is the default")
            print("All default values can be selected by just pressing Enter")
            print(
                "If a parameter does not have a default, a value must be entered"
            )
            BDR_ANS = "No"
            #             BDR_ANS = ask_yn(FPBXParms.PARMS["BDR"][1])
            FPBXParms.PARMS["BDR"][0] = BDR_ANS
            if BDR_ANS == "Yes":
                PARM_LIST = FPBXParms.BDR_PARMS
            else:
                PARM_LIST = FPBXParms.NON_BDR_PARMS

            for index in PARM_LIST:
                FPBXParms.ask_parm(index)

            for index in FPBXParms.COMMON_PARMS:
                FPBXParms.ask_parm(index)

    #======================================================================
    # Make up some passwords that are secure and easy to remember
    #======================================================================

    #         FPBXParms.PARMS["FPBXuserPassword"][0] = mkpass()
    #         FPBXParms.PARMS["FPBXDBUserPassword"][0] = mkpass()

            FPBXParms.save_parms()
    else:
        print("There is no predefined parameter file.")
        print("Please answer the following questions.")
        #        For now we are only installing a single switch, No BDR
        BDR_ANS = "No"
        #         BDR_ANS = ask_yn(FPBXParms.PARMS["BDR"][1])
        FPBXParms.PARMS["BDR"][0] = BDR_ANS
        if BDR_ANS == "Yes":
            PARM_LIST = FPBXParms.BDR_PARMS
        else:
            PARM_LIST = FPBXParms.NON_BDR_PARMS

        for index in PARM_LIST:
            FPBXParms.ask_parm(index)

        for index in FPBXParms.COMMON_PARMS:
            FPBXParms.ask_parm(index)

    #======================================================================
    # Make up some passwords that are secure and easy to remember
    #======================================================================

    #     FPBXParms.PARMS["FPBXuserPassword"][0] = mkpass()
    #     FPBXParms.PARMS["FPBXDBUserPassword"][0] = mkpass()

        FPBXParms.save_parms()

#         if FPBXParms.PARMS["FS_Install_Type"][0] == "s":
#             print("WARNING: There are currently problems with Video and installing from source")
#             print("As of Freeswitch 1.6.")
#             print("You may need to disable video to compile Freeswitch")
#             ans = ask_yn("Do you wish to continue")
#             if ans == "No":
#                 sys.exit()

    return