-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommunica_init_network_gen.py
More file actions
executable file
·78 lines (62 loc) · 2.28 KB
/
communica_init_network_gen.py
File metadata and controls
executable file
·78 lines (62 loc) · 2.28 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
# Script to make interface configs at servers in the communica server park
# get up automagically.
# Make an /etc/network/interfaces6 script to set em up
# and / or interfaces4
import os, sys, re, time, datetime
INIT_NETWORK_BOOT_SCRIPT = """
### BEGIN INIT INFO
# Provides: init-network
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Startupscript for the interfaces (ipv6 and ivp4) on this host.
# Description: What she said.
### END INIT INFO
# @description: startupscript for the network
# @author: technocake
#
# *!* - AUTOGENERATED BY communica_init_network_gen.py -*!*
# @date: 01.05.2011 03:00 ca.
# @auto-gen-date: %s
#
################################################################
echo "INITIALIZING INTERFACES"
"""
IPV4_SCRIPT = """
echo "#STARTING IPV4 INTERFACES"
/etc/network/interfaces4
"""
IPV6_SCRIPT = """
echo "#STARTING IPV6 INTERFACE"
/etc/network/interfaces6
"""
#In python 3, raw_input is renamed to input. In python v <3. input does something else.
def prompt(text):
try:
return raw_input(text)
except:
try:
return input(text)
except:
exit()
if __name__ == "__main__":
INIT_NETWORK_BOOT_SCRIPT = INIT_NETWORK_BOOT_SCRIPT % (datetime.date.today(),)
ipv6 = prompt ( "Create boot script for ipv6 addresses ? [y]")
ipv4 = prompt ( "Create boot script for ipv4 addresses ? [y]")
if re.search("n|N", ipv4) == None:
print ( "Adding /etc/network/interfaces4 to the /etc/init.d/init-network script" )
INIT_NETWORK_BOOT_SCRIPT += IPV4_SCRIPT
if re.search("n|N", ipv6) == None:
print ( "Adding /etc/network/interfaces6 to the /etc/init.d/init-network script" )
INIT_NETWORK_BOOT_SCRIPT += IPV6_SCRIPT
print ("Generated /etc/init.d/init-network : ")
print (INIT_NETWORK_BOOT_SCRIPT )
nf = open( "/etc/init.d/init-network", "w+")
nf.write(INIT_NETWORK_BOOT_SCRIPT)
nf.close()
print ( "CHMODing and making entries in the rc*.d folders")
os.system("chmod u+x /etc/init.d/init-network" )
os.system("update-rc.d init-network start 13 2 3 4 5 . stop 13 0 1 6 .")
print ( "Done! adios ")