-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstaticIP
31 lines (29 loc) · 974 Bytes
/
staticIP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python3
import os
import getpass
import time
user = getpass.getuser()
if user == "root":
print("You have run this as root, please switch either stop using sudo or switch account")
time.sleep(10)
exit()
else:
pass
os.system("cd ~")
interface=input("Are you using WiFi(Press 1) or Ethernet (Press 2)")
interface=int(interface)
print("\n\n\n")
if interface==1:
result=os.system("ip route | grep wlan0")
interface="wlan0"
if interface==2:
result=os.system("ip route | grep eth0")
interface="eth0"
str(result)
print("\nThe rest of the questions are referring to the two lines above")
via=input("\nIn the top line between \"via\" and \"dev\", what is the IP (number)?\n")
currentIP=input("In the bottom line, between \"src\" and \"metric\" what is theIP (number)?\n")
addition="interface "+interface+"\nstatic ip_address="+currentIP+"/24"+"\nstatic routers="+via
file=open("/etc/dhcpcd.conf", "a")
file.write("\n"+addition)
file.close