def install_git_repo(): candidates = getCandidates('GitHub', 'candidates.txt', True) for name in candidates.keys(): currentName = candidates.get(name) Color.writetoline('\n{+} Installing %s.. ' % currentName) proc = subprocess.Popen(['git', 'clone', currentName, '/opt/' + name], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout, stderr = proc.communicate() stdout = str(stdout) stderr = str(stderr) if stdout.startswith('b\"fatal:' or 'b\"error:') or stderr.startswith( 'b\"fatal:' or 'b\"error:'): Color.writetoline('{-} Installing %s...' % currentName) Color.write( '\n {-} An Error Occured While Installing %s, The error persists below:' % name) Color.write(' {-} %s {W}' % stdout[2:-3]) print('\n\n') if ask('continue'): print('\n\n') continue else: print('\n\n') sys.exit() Color.println('\n {?} Checking if %s needs any extra attention..' % name) for files in os.listdir('/opt/%s' % name): files = str(files).lower() if files == ('requirements.txt' or 'make' or 'makefile' or 'setup.py'): Color.writetoline( ' {+} %s requires additional setting up, doing that now.' % name) Color.write( '\n {+} Found %s file to install.. Doing that now.\n' % files) if files == 'requirements.txt': os.system( 'python3 -m pip install -r /opt/%s/requirements.txt' % name) os.system( 'python2 -m pip install -r /opt/%s/requirements.txt' % name) elif files == 'setup.py': os.system('python /opt/%s/setup.py build install' % name) elif files == 'make' or 'makefile': os.system('./opt/%s/configure') os.system('/opt/%s/make') os.system('/opt/%s/make install') break print('\n') Color.write(' {+} Successfully installed %s into /opt/%s \n' % (name, name))
def exit_gracefully(sig, frame): clear() banner() Color.log(Color.println('\n\n{?} SIGINT recieved, Exiting Gracefully..')) Color.writetoline('{+} SIGING recieved, Exiting Gracefully..Done \n\n{W}') sys.exit(0)
def check_prereq(): Color.log('Check pre-reqs..') banner() Color.log('Checking perms..') Color.println(' {?} Checking Proper Permissions..') if os.geteuid() != 0: Color.write('{-} You need root permissions to run this script.') sys.exit() Color.writetoline(' {+} Proper Permissions Verified!') import socket Color.log('Checking Internet Connection..') try: print('\n\n') Color.println(' {?} Checking Internet Connection..') socket.create_connection(("www.github.com", 80)) except OSError: Color.log('No internet connection!') Color.writetoline( ' {-} An active internet connection is needed to run this script!' ) Color.write( '\n {!}{C} This Check will change later on!{W}\n\n') sys.exit() Color.writetoline(' {+} You have internet connection!') Color.log('Checking if pip2 and pip3 is installed..') try: print('\n\n') Color.println(' {?} Checking if PIP 3 is installed..') test = subprocess.Popen(['python3', '-m', 'pip', '-V'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout, stderr = test.communicate() Color.write(str(stdout)[2:-3]) if 'no module' in str(stdout).lower(): raise ModuleNotFoundError('There was a problem getting PIP 3') Color.println(' {+} PIP 3 seems to be installed!') print('\n\n') Color.println(' {?} Checking if PIP 2 is installed..') test = subprocess.Popen(['python2', '-m', 'pip', '-V'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout, stderr = test.communicate() Color.write(str(stdout)[2:-3]) if 'no module' in str(stdout).lower(): raise ModuleNotFoundError('There was a problem getting PIP 2') Color.println(' {+} PIP 2 seems to be installed!') except (ImportError or ModuleNotFoundError) as e: Color.writetoline( ' {-} Error getting pip. Is it installed correctly?') Color.write('\n {-} %s \n{W}' % str(e)) sys.exit() Color.log('All seems good here.') time.sleep(5) clear()