Commit 97f46205 authored by root's avatar root

Ask what the fuck i should do

parent f35b9f2a
......@@ -42,11 +42,37 @@ interface = "wlan0"
if sys.argv[-1] not in ['auto','boot',sys.argv[0]]:
interface = sys.argv[-1]
if not interface in psutil.net_if_stats().keys():
def detect_ifaces():
iplinks=sh("/sbin/ip link show").split()
j, interfaces = 1,[]
for i in range(len(iplinks)):
if iplinks[i] == str(j)+':':
j=j+1
iface=iplinks[i+1]
interfaces.append(iface[:-1])
return interfaces
def checkYN(res, default='N'):
if not res:
print(' '+default)
res=default
if res.lower()=='y' or res.lower()=='fuck yeah!':
return True
elif res.lower()=='n' or res.lower()=='fuck no!':
return False
print('WHAT? "'+res+'"? WHAT THE FUCK? I take it as a fuck no!')
return False
if not interface in detect_ifaces():
print("OH FUCK! Interface "+interface+" doesn't exists. Exiting...")
sys.exit(1)
# check for wpa_supplicant
wpas = False
for process in psutil.process_iter():
......@@ -54,22 +80,26 @@ for process in psutil.process_iter():
if interface in process.cmdline():
wpas = True
if not wpas:
if auto not boot:
if auto:
print("fucking wpa_supplicant for "+interface+" not running, shit loading it... ")
start_wpa(interface)
else:
print("fucking wpa_supplicant for "+interface+" not running, fuck the hell out... ")
sys.exit(1)
else:
if psutil.net_if_stats()[interface].isup:
# is interface up?
if interface in psutil.net_if_stats().keys() and psutil.net_if_stats()[interface].isup:
if boot:
print("fucking wpa_supplicant for "+interface+" already fucked, fuck the hell... ")
sys.exit(0)
else:
print("fucking wpa_supplicant for "+interface+" already fucked, refucking it")
start_wpa(interface)
# non siamo al boot, chiedere!
if checkYN(input("fucking wpa_supplicant for "+interface+" already fucked and up, should i refuck it? <y|N|fuck yeah!|FUCK NO!> ")):
print(' Ok, fucking it! ')
start_wpa(interface)
else:
print("fucking wpa_supplicant for "+interface+" already fucked, refucking it")
# no, it isn't!
print("fucking wpa_supplicant for "+interface+" already fucked but still down, refucking it")
start_wpa(interface)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment