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
a0692874
Kaydet (Commit)
a0692874
authored
Eyl 29, 2005
tarafından
Onur Küçük
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
DHCP client betiği
üst
d0d47186
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
dhcpcd.py
betikler/dhcpcd.py
+55
-0
No files found.
betikler/dhcpcd.py
0 → 100755
Dosyayı görüntüle @
a0692874
#!/usr/bin/python
# -*- coding: utf-8 -*-
import
popen2
from
glob
import
glob
class
dhcpc
:
def
_run
(
self
,
args
):
cmd
=
"/sbin/dhcpcd "
+
args
a
=
popen2
.
Popen4
(
cmd
)
return
a
.
wait
()
def
start
(
self
,
ifname
,
timeout
=
"30"
):
""" Start the DHCP client daemon """
# Maybe we should leave this to GUI
if
ifname
in
self
.
getRunning
():
self
.
stop
(
ifname
)
# -R -Y -N to prevent dhcpcd rewrite nameservers
# we should add nameservers, not rewrite them
# -H to set hostname due to info from server
# -t for timeout
args
=
"-R -Y -N -H -t "
+
timeout
+
" "
+
ifname
return
self
.
_run
(
args
)
def
stop
(
self
,
ifname
):
""" Stop DHCP client daemon """
args
=
"-k "
+
ifname
return
self
.
_run
(
args
)
def
getNameServers
(
self
,
ifname
):
""" Get DNS server list provided by the server """
info_file
=
"/var/lib/dhcpc/dhcpcd-"
+
ifname
+
".info"
try
:
f
=
file
(
info_file
)
for
line
in
f
.
readlines
():
if
not
line
.
find
(
"DNS="
):
return
line
[
line
.
find
(
"DNS="
)
+
4
:]
.
rstrip
(
'
\n
'
)
.
split
(
','
)
f
.
close
except
IOError
:
return
"Could not open file"
# FIXME: put an error message here
def
getRunning
(
self
):
d
=
[]
for
i
in
glob
(
"/var/run/dhcpcd-*.pid"
):
d
.
append
(
i
.
rstrip
(
".pid"
)
.
lstrip
(
"/var/run/dhcpcd-"
))
return
d
if
__name__
==
"__main__"
:
dc
=
dhcpc
()
print
"Daemons are running for"
,
""
.
join
(
dc
.
getRunning
())
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