22import socket
33import os
44import subprocess
5+ import shutil
56import distro
67import requests
78import json
@@ -92,14 +93,17 @@ def setup():
9293
9394
9495def system ():
95- menu_options = ["[1] System Info" , "[2] System Load" ]
96+ menu_options = ["[1] System Info" , "[2] System Load" , "[3] Back" ]
9697 terminal_menu = TerminalMenu (menu_options , title = "System" )
9798 option = terminal_menu .show ()
9899
99100 if option == 0 :
100101 info ()
101102 elif option == 1 :
102103 load ()
104+ elif option == 2 :
105+ back ()
106+ return 1
103107
104108def info ():
105109 try :
@@ -112,7 +116,9 @@ def info():
112116 print ("RAM Size: " + str (psutil .virtual_memory ()[0 ]/ 1024 / 1024 // 1024 )+ ' GB' )
113117 print ("Disk Size: " + str (psutil .disk_usage ('/' )[0 ]/ 1024 / 1024 // 1024 )+ 'GB' + '\n ' )
114118 print ("Cardano-Node: " + node )
115- latest = requests .get ("https://api.github.com/repos/input-output-hk/cardano-node/releases/latest" ).json ()["tag_name" ]
119+ latest = requests .get (
120+ "https://api.github.com/repos/input-output-hk/cardano-node/releases/latest"
121+ ).json ()["tag_name" ]
116122 if latest <= node :
117123 print (colored ("Cardano-Node is up to date" , "green" ))
118124 else :
@@ -146,8 +152,8 @@ def nmapscan():
146152 print (colored ("Nmap version: " + nmap_v , "green" ))
147153 except :
148154 #run_cmd("sudo apt-get install nmap -y")
149- print (colored ("nmap not installed." , "red" ))
150- print ('You will need nmap to use this feature.\n ' )
155+ print (colored ("Nmap not installed." , "red" ))
156+ print ('You will need Nmap to use this feature.\n ' )
151157 return 1
152158 print (colored ("Installing vulnerability scanning scripts...." , "yellow" ))
153159 if not os .path .exists ("vulners.nse" ):
@@ -203,11 +209,50 @@ def submenu():
203209 scanner (port_range )
204210
205211 elif suboption == 2 :
206- os .system ("clear" )
207- banner ()
208- break
212+ back ()
213+ return 1
209214
210215
216+ def installer ():
217+ print (colored ('Experimental Feature' ,"red" ))
218+ print ("Use with with caution.\n " )
219+ menu_options = ["[1] Cardano-node" , "[2] Back" ]
220+ print (colored ("-------One-Click Installer---------\n " , "magenta" ))
221+ terminal_menu = TerminalMenu (menu_options )
222+ option = terminal_menu .show ()
223+
224+ if option == 0 :
225+ print (colored ("Installing Cardano-node..." , "yellow" ))
226+ try :
227+ subprocess .check_output (['cardano-node' ,'version' ]).decode ()
228+ path = shutil .which ("cardano-node" )[:- 13 ]
229+ run_cmd (f"cd { path } " )
230+ except :
231+ path = "/usr/local/bin"
232+ print (colored ("No existing version found..." , "yellow" ))
233+ print (colored ("Downloading Cardano-node..." , "yellow" ))
234+ download = subprocess .Popen (
235+ "wget https://hydra.iohk.io/job/Cardano/cardano-node/cardano-node-linux/latest-finished/download --output-document latest-node.tar.xf" ,
236+ shell = True ,
237+ cwd = path
238+ )
239+ download .wait ()
240+ unzip = subprocess .Popen (
241+ "sudo tar -xf latest-node.tar.xf && sudo rm latest-node.tar.xf" ,
242+ shell = True ,
243+ cwd = path
244+ )
245+ unzip .wait ()
246+ print (colored ("Cardano-node is now installed\n " , "yellow" ))
247+ run_cmd ("cardano-node version" )
248+ elif option == 1 :
249+ back ()
250+ return 1
251+
252+ def back ():
253+ os .system ("clear" )
254+ banner ()
255+
211256def quit ():
212257 os .system ("clear" )
213258 print ("Happy Minting!" )
@@ -217,15 +262,15 @@ def quit():
217262def menu ():
218263 menu_options = [
219264 "[1] System" , "[2] Port Scanner" , "[3] Vulnerability Scanner" ,
220- "[4] Setup" , "[5] Exit"
265+ "[4] One-Click Installer" , "[5] Setup" , "[6 ] Exit"
221266 ]
222267 terminal_menu = TerminalMenu (menu_options , title = "Home" )
223268 return terminal_menu .show ()
224269
225270
226271def select (option ):
227272
228- menu_func = [system , scan , nmapscan , setup , quit ]
273+ menu_func = [system , scan , nmapscan , installer , setup , quit ]
229274
230275 print ()
231276 return menu_func [option ]()
0 commit comments