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
a18f9036
Kaydet (Commit)
a18f9036
authored
Şub 10, 2008
tarafından
Bahadır Kandemir
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Call 'service x ready' to run services on startup.
üst
b6ee8ce9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
51 deletions
+77
-51
mudur.py
mudur/bin/mudur.py
+36
-26
service.py
mudur/bin/service.py
+41
-25
No files found.
mudur/bin/mudur.py
Dosyayı görüntüle @
a18f9036
...
...
@@ -19,6 +19,7 @@ import gettext
import
time
import
signal
import
fcntl
import
termios
import
socket
#
...
...
@@ -422,6 +423,24 @@ def mount(part, args):
#
# COMAR functions
#
def
fork_handler
():
# Set umask to a sane value
# (other and group has no write permission by default)
os
.
umask
(
022
)
# Detach from controlling terminal
try
:
tty_fd
=
os
.
open
(
"/dev/tty"
,
os
.
O_RDWR
)
fcntl
.
ioctl
(
tty_fd
,
termios
.
TIOCNOTTY
)
os
.
close
(
tty_fd
)
except
OSError
:
pass
# Close IO channels
devnull_fd
=
os
.
open
(
"/dev/null"
,
os
.
O_RDWR
)
os
.
dup2
(
devnull_fd
,
0
)
os
.
dup2
(
devnull_fd
,
1
)
os
.
dup2
(
devnull_fd
,
2
)
# Detach from process group
os
.
setsid
()
def
startDBus
():
os
.
setuid
(
0
)
...
...
@@ -433,27 +452,17 @@ def startDBus():
"--"
,
"--system"
)
waitBus
(
"/var/run/dbus/system_bus_socket"
)
def
readyService
(
service
,
bus
):
obj
=
bus
.
get_object
(
"tr.org.pardus.comar"
,
"/package/
%
s"
%
service
,
introspect
=
False
)
obj
.
ready
(
dbus_interface
=
"tr.org.pardus.comar.System.Service"
,
ignore_reply
=
True
)
def
readyService
(
service
):
cmd
=
[
"/bin/service"
,
"--quiet"
,
service
,
"ready"
]
subprocess
.
Popen
(
cmd
,
close_fds
=
True
,
preexec_fn
=
fork_handler
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
def
startService
(
service
,
bus
,
detach
=
False
):
if
not
detach
:
ui
.
info
(
"Starting
%
s..."
%
service
)
obj
=
bus
.
get_object
(
"tr.org.pardus.comar"
,
"/package/
%
s"
%
service
,
introspect
=
False
)
obj
.
start
(
dbus_interface
=
"tr.org.pardus.comar.System.Service"
)
else
:
obj
=
bus
.
get_object
(
"tr.org.pardus.comar"
,
"/package/
%
s"
%
service
,
introspect
=
False
)
obj
.
start
(
dbus_interface
=
"tr.org.pardus.comar.System.Service"
,
ignore_reply
=
True
)
def
stopService
(
service
,
bus
,
detach
=
False
):
if
not
detach
:
ui
.
info
(
"Stopping
%
s..."
%
service
)
obj
=
bus
.
get_object
(
"tr.org.pardus.comar"
,
"/package/
%
s"
%
service
,
introspect
=
False
)
obj
.
stop
(
dbus_interface
=
"tr.org.pardus.comar.System.Service"
)
else
:
obj
=
bus
.
get_object
(
"tr.org.pardus.comar"
,
"/package/
%
s"
%
service
,
introspect
=
False
)
obj
.
stop
(
dbus_interface
=
"tr.org.pardus.comar.System.Service"
,
ignore_reply
=
True
)
def
startService
(
service
):
cmd
=
[
"/bin/service"
,
"--quiet"
,
service
,
"start"
]
subprocess
.
Popen
(
cmd
,
close_fds
=
True
,
preexec_fn
=
fork_handler
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
def
stopService
(
service
):
cmd
=
[
"/bin/service"
,
"--quiet"
,
service
,
"stop"
]
subprocess
.
Popen
(
cmd
,
close_fds
=
True
,
preexec_fn
=
fork_handler
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
def
getServices
(
bus
):
obj
=
bus
.
get_object
(
"tr.org.pardus.comar"
,
"/"
,
introspect
=
False
)
...
...
@@ -470,20 +479,21 @@ def startServices(extras=None):
ui
.
error
(
_
(
"Cannot connect to DBus, services won't be started"
))
return
# Almost everything depends on logger, so start manually
startService
(
"sysklogd"
,
bus
,
detach
=
True
)
startService
(
"sysklogd"
)
if
extras
:
for
service
in
extras
:
try
:
startService
(
service
,
bus
,
detach
=
True
)
startService
(
service
)
except
dbus
.
DBusException
:
pass
return
# Give login screen a headstart
if
config
.
get
(
"head_start"
):
startService
(
config
.
get
(
"head_start"
)
,
bus
,
detach
=
True
)
startService
(
config
.
get
(
"head_start"
))
if
not
config
.
get
(
"safe"
):
for
service
in
getServices
(
bus
):
readyService
(
service
,
bus
)
services
=
getServices
(
bus
)
for
service
in
services
:
readyService
(
service
)
def
stopServices
():
ui
.
info
(
_
(
"Stopping services"
))
...
...
@@ -494,7 +504,7 @@ def stopServices():
return
for
service
in
getServices
(
bus
):
stopService
(
service
,
bus
,
detach
=
True
)
stopService
(
service
)
def
stopDBus
():
ui
.
info
(
_
(
"Stopping DBus"
))
...
...
mudur/bin/service.py
Dosyayı görüntüle @
a18f9036
...
...
@@ -112,27 +112,35 @@ def format_service_list(services, use_color=True):
)
print
line
def
start
Service
(
service
,
bus
):
def
ready
Service
(
service
,
bus
):
obj
=
bus
.
get_object
(
"tr.org.pardus.comar"
,
"/package/
%
s"
%
service
,
introspect
=
False
)
print
_
(
"Starting
%
s..."
%
service
)
obj
.
ready
(
dbus_interface
=
"tr.org.pardus.comar.System.Service"
)
def
startService
(
service
,
bus
,
quiet
=
False
):
obj
=
bus
.
get_object
(
"tr.org.pardus.comar"
,
"/package/
%
s"
%
service
,
introspect
=
False
)
if
not
quiet
:
print
_
(
"Starting
%
s..."
%
service
)
obj
.
start
(
dbus_interface
=
"tr.org.pardus.comar.System.Service"
)
def
stopService
(
service
,
bus
):
def
stopService
(
service
,
bus
,
quiet
=
False
):
obj
=
bus
.
get_object
(
"tr.org.pardus.comar"
,
"/package/
%
s"
%
service
,
introspect
=
False
)
print
_
(
"Stopping
%
s..."
%
service
)
if
not
quiet
:
print
_
(
"Stopping
%
s..."
%
service
)
obj
.
stop
(
dbus_interface
=
"tr.org.pardus.comar.System.Service"
)
def
setServiceState
(
service
,
state
,
bus
):
def
setServiceState
(
service
,
state
,
bus
,
quiet
=
False
):
obj
=
bus
.
get_object
(
"tr.org.pardus.comar"
,
"/package/
%
s"
%
service
,
introspect
=
False
)
obj
.
setState
(
state
,
dbus_interface
=
"tr.org.pardus.comar.System.Service"
)
if
state
==
"on"
:
print
_
(
"Service '
%
s' will be auto started."
)
%
service
else
:
print
_
(
"Service '
%
s' won't be auto started."
)
%
service
if
not
quiet
:
if
state
==
"on"
:
print
_
(
"Service '
%
s' will be auto started."
)
%
service
else
:
print
_
(
"Service '
%
s' won't be auto started."
)
%
service
def
reloadService
(
service
,
bus
):
def
reloadService
(
service
,
bus
,
quiet
=
False
):
obj
=
bus
.
get_object
(
"tr.org.pardus.comar"
,
"/package/
%
s"
%
service
,
introspect
=
False
)
print
_
(
"Reloading
%
s..."
%
service
)
if
not
quiet
:
print
_
(
"Reloading
%
s..."
%
service
)
obj
.
reload
(
dbus_interface
=
"tr.org.pardus.comar.System.Service"
)
def
getServiceInfo
(
service
,
bus
):
...
...
@@ -156,28 +164,28 @@ def list_services(use_color=True):
lala
.
append
(
Service
(
service
,
info
))
format_service_list
(
lala
,
use_color
)
def
manage_service
(
service
,
op
,
use_color
=
True
):
def
manage_service
(
service
,
op
,
use_color
=
True
,
quiet
=
False
):
bus
=
dbus
.
SystemBus
()
if
op
==
"start"
:
startService
(
service
,
bus
)
if
op
==
"ready"
:
readyService
(
service
,
bus
)
elif
op
==
"start"
:
startService
(
service
,
bus
,
quiet
)
elif
op
==
"stop"
:
stopService
(
service
,
bus
)
stopService
(
service
,
bus
,
quiet
)
elif
op
==
"reload"
:
pass
#reloadService(service)
#print _("Service '%s' reloaded.") % service
reloadService
(
service
,
bus
,
quiet
)
elif
op
==
"on"
:
setServiceState
(
service
,
"on"
,
bus
)
setServiceState
(
service
,
"on"
,
bus
,
quiet
)
elif
op
==
"off"
:
setServiceState
(
service
,
"off"
,
bus
)
setServiceState
(
service
,
"off"
,
bus
,
quiet
)
elif
op
in
[
"info"
,
"status"
,
"list"
]:
info
=
getServiceInfo
(
service
,
bus
)
s
=
Service
(
service
,
info
)
format_service_list
([
s
],
use_color
)
elif
op
==
"restart"
:
manage_service
(
service
,
"stop"
)
manage_service
(
service
,
"start"
)
manage_service
(
service
,
"stop"
,
use_color
,
quiet
)
manage_service
(
service
,
"start"
,
use_color
,
quiet
)
return
# Usage
...
...
@@ -195,13 +203,15 @@ where command is:
restart Stop the service, then start again
reload Reload the configuration (if service supports this)
and option is:
-N, --no-color Don't use color in output"""
)
-N, --no-color Don't use color in output
-q, --quiet Don't print replies"""
)
# Main
def
main
(
args
):
operations
=
(
"start"
,
"stop"
,
"info"
,
"list"
,
"restart"
,
"reload"
,
"status"
,
"on"
,
"off"
)
operations
=
(
"start"
,
"stop"
,
"info"
,
"list"
,
"restart"
,
"reload"
,
"status"
,
"on"
,
"off"
,
"ready"
)
use_color
=
True
quiet
=
False
# Parameters
if
"--no-color"
in
args
:
...
...
@@ -210,6 +220,12 @@ def main(args):
if
"-N"
in
args
:
args
.
remove
(
"-N"
)
use_color
=
False
if
"--quiet"
in
args
:
args
.
remove
(
"--quiet"
)
quiet
=
True
if
"-q"
in
args
:
args
.
remove
(
"-q"
)
quiet
=
True
# Operations
if
args
==
[]:
...
...
@@ -225,7 +241,7 @@ def main(args):
usage
()
elif
args
[
1
]
in
operations
:
manage_service
(
args
[
0
],
args
[
1
],
use_color
)
manage_service
(
args
[
0
],
args
[
1
],
use_color
,
quiet
)
else
:
usage
()
...
...
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