Подключить дополнительные IP из списка
import
sys
import
os
n
=
0
with
open
(
'ip.list'
,
'r'
) as f:
for
ip
in
f:
ip
=
ip.replace(
"\n"
, "")
if
len
(ip) >
0
:
with
open
(
'/etc/sysconfig/network-scripts/ifcfg-eth0:'
+
str
(n),
'wb'
) as f:
text
=
"\n"
.join([
"DEVICE=eth0:"
+
str
(n),
"BOOTPROTO=static"
,
"IPADDR="
+
ip,
"NETMASK=255.255.255.0"
"ONBOOT=yes"
])
f.write(text)
n
+
=
1
Генератор пароля
import
random
def
pwgen(length
=
15
):
keylist
=
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
password
=
[]
while
len
(password) < length:
a_char
=
random.choice(keylist)
password.append(a_char)
return
''.join(password)
print
pwgen()