Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
S
scom
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
SulinOS
scom
Commits
0e2b03f1
Kaydet (Commit)
0e2b03f1
authored
Agu 29, 2006
tarafından
Gürer Özen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bu dosya kendi paketinde (baselayout) duruyor zaten
bu dizinde sadece üzerinde çalışılan betikler dursun
üst
b510404a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
79 deletions
+0
-79
stack.py
betikler/stack.py
+0
-79
No files found.
betikler/stack.py
deleted
100644 → 0
Dosyayı görüntüle @
b510404a
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2005, TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version. Please read the COPYING file.
#
import
os
import
re
import
string
rc_path
=
"/etc/resolv.conf"
name_path
=
"/etc/conf.d/hostname"
hosts_path
=
"/etc/hosts"
env_cmd
=
"/usr/bin/update-environ.py"
host_cmd
=
"/usr/bin/hostname
%
s"
valid_name_chars
=
string
.
ascii_letters
+
string
.
digits
+
'.'
+
'_'
+
'-'
def
getNameServers
():
f
=
file
(
rc_path
)
list
=
[
x
.
split
(
" "
,
1
)[
1
]
.
rstrip
(
"
\n
"
)
for
x
in
f
.
readlines
()
if
x
.
startswith
(
"nameserver "
)
]
return
"
\n
"
.
join
(
list
)
def
setNameServers
(
nameservers
=
None
):
f
=
file
(
rc_path
)
list
=
filter
(
lambda
x
:
not
"nameserver"
in
x
,
f
.
readlines
())
f
.
close
()
servers
=
map
(
lambda
x
:
"nameserver
%
s
\n
"
%
x
,
nameservers
.
split
(
"
\n
"
))
f
=
file
(
rc_path
,
"w"
)
f
.
write
(
""
.
join
(
list
)
+
""
.
join
(
servers
))
f
.
close
()
def
getHostNames
():
dict
=
get_profile
(
"Net.Stack.setHostNames"
)
if
dict
and
dict
.
has_key
(
"hostnames"
):
return
dict
[
"hostnames"
]
return
""
def
setHostNames
(
hostnames
=
None
):
if
not
hostnames
:
return
invalid
=
filter
(
lambda
x
:
not
x
in
valid_name_chars
,
hostnames
)
if
len
(
invalid
)
>
0
:
fail
(
"Invalid characters '
%
s' in hostname"
%
(
""
.
join
(
invalid
)))
# hostname
f
=
file
(
name_path
)
data
=
f
.
read
()
f
.
close
()
data
=
re
.
sub
(
'HOSTNAME="(.*)"'
,
'HOSTNAME="
%
s"'
%
hostnames
,
data
)
f
=
file
(
name_path
,
"w"
)
f
.
write
(
data
)
f
.
close
()
# hosts
f
=
file
(
hosts_path
)
data
=
f
.
readlines
()
f
.
close
()
f
=
file
(
hosts_path
,
"w"
)
flag
=
1
for
line
in
data
:
if
line
.
startswith
(
"127.0.0.1"
):
line
=
"127.0.0.1 localhost
%
s
\n
"
%
hostnames
flag
=
0
f
.
write
(
line
)
if
flag
:
f
.
write
(
"127.0.0.1 localhost
%
s
\n
"
%
hostnames
)
f
.
close
()
# update environment
os
.
system
(
env_cmd
)
# we dont call the following command, it mess up system
# hostname changes take effect after restart
#os.system(host_cmd % hostnames)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment