Changed names and extensions of configuration files

This commit is contained in:
clamsawd 2015-11-09 11:01:40 +01:00
parent 66cf345f32
commit ec0f4a61f4
2 changed files with 31 additions and 28 deletions

View File

@ -5,7 +5,7 @@
# ip2e (IP to email) - Create the configuration file. | # ip2e (IP to email) - Create the configuration file. |
# Created by clamsawd (clamsawd@openmailbox.org) | # Created by clamsawd (clamsawd@openmailbox.org) |
# Licensed by GPL v.3 | # Licensed by GPL v.3 |
# Last update: 06-11-2015 | # Last update: 09-11-2015 |
# | # |
# Compatible with Python 3.x | # Compatible with Python 3.x |
# -------------------------------------------------------------- # --------------------------------------------------------------
@ -47,7 +47,7 @@ if not os.path.exists(".ip2e"):
if os.path.exists(".ip2e"): if os.path.exists(".ip2e"):
os.chdir(".ip2e") os.chdir(".ip2e")
if os.path.isfile("ip2e-conf.py"): if os.path.isfile("ip2e.conf"):
ClearScreen() ClearScreen()
print ("") print ("")
print ("ip2e-config v"+version) print ("ip2e-config v"+version)
@ -62,7 +62,7 @@ if os.path.isfile("ip2e-conf.py"):
if OverWriteOrCheck == "o" or OverWriteOrCheck == "O": if OverWriteOrCheck == "o" or OverWriteOrCheck == "O":
print ("Create new configuration") print ("Create new configuration")
else: else:
exec(open("ip2e-conf.py").read()) exec(open("ip2e.conf").read())
#Import smtplib #Import smtplib
import smtplib import smtplib
try: try:
@ -81,7 +81,7 @@ if os.path.isfile("ip2e-conf.py"):
print ("") print ("")
exit(0) exit(0)
#Set variables of 'ip2e-conf.py' #Set variables of 'ip2e.conf'
ClearScreen() ClearScreen()
print ("") print ("")
print ("ip2e-config v"+version+" - Create config.file") print ("ip2e-config v"+version+" - Create config.file")
@ -92,12 +92,12 @@ FromEmailPass=input("Type the pass of email sender: ")
SmtpFromEmail=input("Type the server STMP of email sender: ") SmtpFromEmail=input("Type the server STMP of email sender: ")
ToEmail=input("Type the email receiver: ") ToEmail=input("Type the email receiver: ")
#Create 'ip2e-conf.py' #Create 'ip2e.conf'
if os.path.isfile("ip2e-conf.py"): if os.path.isfile("ip2e.conf"):
os.remove("ip2e-conf.py") os.remove("ip2e.conf")
ip2ecf=open('ip2e-conf.py','w') ip2ecf=open('ip2e.conf','w')
ip2ecf.close() ip2ecf.close()
ip2ecf=open('ip2e-conf.py','a') ip2ecf=open('ip2e.conf','a')
ip2ecf.write('# sample configuration file of ip2e\n') ip2ecf.write('# sample configuration file of ip2e\n')
ip2ecf.write('\n') ip2ecf.write('\n')
ip2ecf.write('FromEmail="'+FromEmail+'"\n') ip2ecf.write('FromEmail="'+FromEmail+'"\n')
@ -112,7 +112,7 @@ ClearScreen()
print ("") print ("")
print ("ip2e-config v"+version+" - Current config.file") print ("ip2e-config v"+version+" - Current config.file")
print ("") print ("")
readfile=open('ip2e-conf.py', 'r') readfile=open('ip2e.conf', 'r')
print(readfile.read()) print(readfile.read())
readfile.close() readfile.close()
@ -123,7 +123,7 @@ if TestConnection == "n":
print ("Exiting...") print ("Exiting...")
exit(0) exit(0)
else: else:
exec(open("ip2e-conf.py").read()) exec(open("ip2e.conf").read())
#Import smtplib #Import smtplib
import smtplib import smtplib
try: try:

View File

@ -51,9 +51,9 @@ if not os.path.exists(".ip2e"):
if os.path.exists(".ip2e"): if os.path.exists(".ip2e"):
os.chdir(".ip2e") os.chdir(".ip2e")
#Check if exists 'ip2e-conf.py' #Check if exists 'ip2e.conf'
if os.path.isfile("ip2e-conf.py"): if os.path.isfile("ip2e.conf"):
print ("ip2e-conf.py exists") print ("ip2e.conf exists")
else: else:
ClearScreen() ClearScreen()
print ("") print ("")
@ -63,19 +63,19 @@ else:
print ("") print ("")
exit(0) exit(0)
#Check if exists 'current-ip.py' #Check if exists 'IP.log'
if os.path.isfile("current-ip.py"): if os.path.isfile("IP.log"):
print ("current-ip.py exists") print ("IP.log exists")
else: else:
print ("current-ip.py created") print ("IP.log created")
ip2eIPcf=open('current-ip.py','w') ip2eIPcf=open('IP.log','w')
ip2eIPcf.close() ip2eIPcf.close()
ip2eIPcf=open('current-ip.py','a') ip2eIPcf=open('IP.log','a')
ip2eIPcf.write('CurrentIP="0.0.0.0"\n') ip2eIPcf.write('0.0.0.0')
ip2eIPcf.close() ip2eIPcf.close()
#Import variables from ip2e-conf.py #Import variables from ip2e.conf
exec(open("ip2e-conf.py").read()) exec(open("ip2e.conf").read())
#Import native OS color scheme #Import native OS color scheme
try: try:
@ -149,7 +149,10 @@ while PublicIP <= 2:
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Error getting IP\n") editlog.write("[ip2e-daemon] ["+CurrentTime+"] Error getting IP\n")
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Retrying in 10 seconds...\n") editlog.write("[ip2e-daemon] ["+CurrentTime+"] Retrying in 10 seconds...\n")
time.sleep(10) time.sleep(10)
exec(open("current-ip.py").read()) readfileIP=open('IP.log', 'r')
CurrentIPRaw=readfileIP.read()
CurrentIP=CurrentIPRaw.strip()
readfileIP.close()
if CurrentIP == NewIP: if CurrentIP == NewIP:
CurrentTime = time.strftime("%H:%M") CurrentTime = time.strftime("%H:%M")
GreenColor() GreenColor()
@ -195,11 +198,11 @@ while PublicIP <= 2:
editlog.write(MailMessage+" ("+ToEmail+")\n") editlog.write(MailMessage+" ("+ToEmail+")\n")
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Retrying in 10 seconds...\n") editlog.write("[ip2e-daemon] ["+CurrentTime+"] Retrying in 10 seconds...\n")
time.sleep(10) time.sleep(10)
os.remove("current-ip.py") os.remove("IP.log")
ip2eIPcf=open('current-ip.py','w') ip2eIPcf=open('IP.log','w')
ip2eIPcf.close() ip2eIPcf.close()
ip2eIPcf=open('current-ip.py','a') ip2eIPcf=open('IP.log','a')
ip2eIPcf.write('CurrentIP="'+NewIP+'"\n') ip2eIPcf.write(NewIP)
ip2eIPcf.close() ip2eIPcf.close()
CurrentTime = time.strftime("%H:%M") CurrentTime = time.strftime("%H:%M")
GreenColor() GreenColor()