Skip to content

Instantly share code, notes, and snippets.

@antoine-briand
Last active December 23, 2015 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoine-briand/7129f3ccf25448cc9e77 to your computer and use it in GitHub Desktop.
Save antoine-briand/7129f3ccf25448cc9e77 to your computer and use it in GitHub Desktop.
import os
print("LXC-KICKSTART - Ajinov : Network Setting")
ip = raw_input("Entrez l'adresse ip > ")
passerelle = raw_input("Entrez la passerelle > ")
hostname = raw_input("Entrez le hostname > ")
os_type = raw_input("Debian ou Ubuntu ? (0/1) > ")
hostname_file = "/etc/hostname"
interface_file = "/etc/network/interfaces"
if os_type == "0":
resolvconf_file = "/etc/resolv.conf"
else:
resolvconf_file = "/etc/resolvconf/resolv.conf.d/base"
print("Configuration du hostname \n")
with open(hostname_file, "a") as configfile:
configfile.write(hostname)
print("Configuration de l'interface eth0 en ip statique : " + ip + " et passerelle : " + passerelle + "\n")
with open(interface_file, "a") as configfile:
configfile.write("auto eth0 \n" +
"iface eth0 inet static \n" +
"address " + ip + " \n" +
"netmask 255.255.255.0 \n" +
"gateway " + passerelle + "\n")
print("Prise en compte de eth0 \n")
os.system("ifup eth0")
print("Configuration des dns google (8.8.8.8 ; 8.8.4.4)")
with open(resolvconf_file, "a") as configfile:
configfile.write("nameserver 8.8.8.8 \n" +
"nameserver 8.8.4.4 \n")
if os_type != "0":
print("Prise en compte des serveurs DNS \n")
os.system("resolvconf -u")
print("Mise a jour du systeme")
os.system("apt-get update -y && apt-get upgrade -y")
print("KICKSTART COMPLETE")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment