+
     Gi)  c                   sV   ^RI Ht ^ RIt^ RIHt ^RI5 ^ RIt^ RIt^ RIt	^ RI
Ht ]	P                  P                  4       t]! 4       t ! R R4      t ! R R4      t ! R	 R
]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]P.                  4      tR# )i   )baseN)Z*)commandsc                   s*   a  ] tR t^t o RR ltRtV tR# )ServiceNc                s6    W n         Wn        W0n        W@n        R # N)enablestartcfg_filerunlevel)selfr   r   r   r      &&&&&A/usr/lib/python3.14/site-packages/tuned/plugins/plugin_service.py__init__ZService.__init__   s    +*--    )r   r   r   r   )NNNN)__name__
__module____qualname____firstlineno__r   __static_attributes____classdictcell____classdict__   @r
   r   r      s      r   r   c                   s>   a  ] tR t^t o R tR tR tR tR tRt	V t
R# )InitHandlerc                sr    \         P                  R .4      w  rV^ 8X  d   VP                  4       R,          # R# )r   Ni)cmdexecutesplitr   retcodeout   &  r
   runlevel_getZInitHandler.runlevel_get   s/    ;;
|,.7#qLR2d2r   c                s4    \         P                  R R.4       R# )ZtelinitZqNr   r   r      &r
   daemon_reloadZInitHandler.daemon_reload   s    ++y#r   c                    R # r    r   namer      &&&r
   cfg_installZInitHandler.cfg_install       r   c                r#   r   r$   r%   r'   r
   cfg_uninstallZInitHandler.cfg_uninstall   r)   r   c                r#   r   r$   r%   r'   r
   
cfg_verifyZInitHandler.cfg_verify"   s    	r   r$   N)r   r   r   r   r   r"   r(   r*   r+   r   r   r   r   r
   r   r      s#     3  r   r   c                   sD   a  ] tR t^&t o R tR tR tR tR tR t	Rt
V tR# )	SysVBasicHandlerc                6    \         P                  R VR.4       R# )servicer   Nr   r   r&      &&r
   r   ZSysVBasicHandler.start'   s    ++y$()r   c                r-   )r.   stopNr   r/   r0   r
   r1   ZSysVBasicHandler.stop*   s    ++y$'(r   c                    \        4       hr   ZNotImplementedErrorr   r&   r   r'   r
   r   ZSysVBasicHandler.enable-       r   c                r2   r   r3   r4   r'   r
   disableZSysVBasicHandler.disable0   r5   r   c                F    \         P                  R VR.^ .R7      w  r#V^ 8H  # )r.   statusZ	no_errorsr   r   r&   r   r      &&  r
   
is_runningZSysVBasicHandler.is_running3   s)    ;;	4:;L.7	Ar   c                r2   r   r3   r4   r'   r
   
is_enabledZSysVBasicHandler.is_enabled7   r5   r   r$   N)r   r   r   r   r   r1   r   r6   r<   r=   r   r   r   r   r
   r,   r,   &   s(     *) r   r,   c                   s2   a  ] tR t^:t o R tR tR tRtV tR# )SysVHandlerc                8    \         P                  R RW!R.4       R# )	chkconfig--levelonNr   r4   r'   r
   r   ZSysVHandler.enable;   s    ++{Ixt<=r   c                r?   )r@   rA   offNr   r4   r'   r
   r6   ZSysVHandler.disable>   s    ++{Ixu=>r   c                    \         P                  R RV.4      w  r4V^ 8X  d3   VP                  R\        V4      ,          4      ^,          R,          R8H  # R# )r@   --list%s:Ni   NrB   Nr   r   r   Zstrr   r&   r   r   r      &&&  r
   r=   ZSysVHandler.is_enabledA   sK    ;;Xt<=.7<CqL53x=(	)!	,R	0D	8RdRr   r$   N	r   r   r   r   r   r6   r=   r   r   r   r   r
   r>   r>   :   s     >?S Sr   r>   c                   s2   a  ] tR t^Et o R tR tR tRtV tR# )SysVRCHandlerc                r?   )sysv-rc-confrA   rB   Nr   r4   r'   r
   r   ZSysVRCHandler.enableF   s    ++~y($?@r   c                r?   )rM   rA   rC   Nr   r4   r'   r
   r6   ZSysVRCHandler.disableI   s    ++~y(%@Ar   c                rD   )rM   rE   rF   rG   rB   NrH   rI   rJ   r
   r=   ZSysVRCHandler.is_enabledL   sK    ;;$?@.7<CqL53x=(	)!	,R	0D	8RdRr   r$   NrK   r   r   r
   rL   rL   E   s     ABS Sr   rL   c                   sJ   a  ] tR t^Pt o R tR tR tR tR tR t	R t
RtV tR	# )
OpenRCHandlerc                sf    \         P                  R R.4      w  rV^ 8X  d   VP                  4       # R# )z	rc-statusz-rNr   r   Zstripr   r   r
   r   ZOpenRCHandler.runlevel_getQ   s.    ;;T23.71.$.r   c                r-   )
rc-servicer   Nr   r/   r0   r
   r   ZOpenRCHandler.startU   s    ++|T7+,r   c                r-   )rP   r1   Nr   r/   r0   r
   r1   ZOpenRCHandler.stopX   s    ++|T6*+r   c                6    \         P                  R RW.4       R# )	rc-updateZaddNr   r4   r'   r
   r   ZOpenRCHandler.enable[       ++{E423r   c                rQ   )rR   ZdelNr   r4   r'   r
   r6   ZOpenRCHandler.disable^   rS   r   c                r7   )rP   r8   r9   r   r:   r;   r
   r<   ZOpenRCHandler.is_runninga   s)    ;;dH=A3;O.7	Ar   c                s    \         P                  R RV.4      w  r4\        \        P                  ! R\        P
                  ! V4      ,           R,           V4      4      # )rR   Zshowz\b)r   r   ZboolreZsearchZescaperI   rJ   r
   r=   ZOpenRCHandler.is_enablede   sA    ;;VX>?.7	bii		$/%7=	>>r   r$   N)r   r   r   r   r   r   r1   r   r6   r<   r=   r   r   r   r   r
   rN   rN   P   s-     /-,44? ?r   rN   c                   s\   a  ] tR t^it o R tR tR tR tR tR t	R t
R tR	 tR
 tRtV tR# )SystemdHandlerc                r#   ) r$   r    r!   r
   r   ZSystemdHandler.runlevel_getk   s    	r   c                6    \         P                  R RV.4       R# )	systemctlZrestartNr   r/   r0   r
   r   ZSystemdHandler.startn       ++{It,-r   c                rW   )rX   r1   Nr   r/   r0   r
   r1   ZSystemdHandler.stopq   s    ++{FD)*r   c                rW   )rX   r   Nr   r4   r'   r
   r   ZSystemdHandler.enablet   s    ++{Hd+,r   c                rW   )rX   r6   Nr   r4   r'   r
   r6   ZSystemdHandler.disablew   rY   r   c                sF    \         P                  R RV.^ .R7      w  r#V^ 8H  # )rX   z	is-activer9   r   r:   r;   r
   r<   ZSystemdHandler.is_runningz   s)    ;;[$?aS;Q.7	Ar   c                s    \         P                  R RV.^ .R7      w  r4VP                  4       pVR8X  d   R# VR8X  d   R# R# )rX   z
is-enabledr9   ZenabledTZdisabledFNrO   )r   r&   r   r   r   r8      &&&   r
   r=   ZSystemdHandler.is_enabled~   sH    ;;\4@qc;R.799;&9$P6J3F%PDPr   c                s   \         P                  R V: RV: R24       \        P                  P	                  V4      '       g   \         P                  RV,          4       R# \        P                  V,          p \        P                  ! V\        P                  RR7       \        P                  Y#4       T P                  4        R#   \         d)   p\         P                  RT: RT: 24        Rp?R# Rp?ii ; i)	z/installing service configuration overlay file '' for service ''z)Unable to find service configuration '%s'NT)Zexist_okzUnable to create directory 'z': )loginfoospathexistserrorconstsSERVICE_SYSTEMD_CFG_PATHZmakedirsZDEF_SERVICE_CFG_DIR_MODEOSErrorr   Zcopyr"   )r   r&   r   dirpathZerJ   r
   r(   ZSystemdHandler.cfg_install   s    ((T\^bcd		!	!9988CD	++d2'
;;w77$G ((8	 
 
99gqAB	
s   :'C C;C66C;c                sd   \         P                  R V: RV: R24       \        P                  V,          pV: R\        P
                  P                  V4      : 2p\        P                  V4       V P                  4         \        P                  ! V4       R#   \        \        3 d     R# i ; i)z1uninstalling service configuration overlay file 'r[   r\   /N)r]   r^   rc   rd   r_   r`   basenamer   Zunlinkr"   ZrmdirZFileNotFoundErrorre   )r   r&   r   rf   r`   rJ   r
   r*   ZSystemdHandler.cfg_uninstall   s~    ((V^`def++d2'RWW--h7	8$**T88G
W	% s   B B/.B/c                s   Vf   R # \         P                  V,          : R\        P                  P	                  V4      : 2p\        P                  P                  V4      '       g!   \        P                  RV: RV: R24       R# \        P                  P                  V4      '       g!   \        P                  RV: RV: R24       R# \        P                  V4      p\        P                  V4      pWE8H  # )Nrg   zUnable to find service 'z' configuration 'r\   Fz	Service 'z"' configuration not installed in ')
rc   rd   r_   r`   rh   ra   r]   rb   r   Z	sha256sum)r   r&   r   r`   Z
sha256sum1Z
sha256sum2rZ   r
   r+   ZSystemdHandler.cfg_verify   s    
33d::BGG<L<LX<V	W$		!	!99xPQ
			994NO
}}X&*}}T"*		!!r   r$   N)r   r   r   r   r   r   r1   r   r6   r<   r=   r(   r*   r+   r   r   r   r   r
   rU   rU   i   s=     .+-.Q

" "r   rU   c                   s   a a ] tR t^t oRtV 3R ltR tR tR tR t	R t
R tR	 tR
 t]P                  3R ltRtVtV ;t# )ServicePlugina  
Plug-in for handling sysvinit, sysv-rc, openrc and systemd services.

The syntax is as follows:

[subs="quotes"]
----
[service]
service.__service_name__=__commands__[,file:__file__]
----

Supported service-handling `_commands_` are `start`, `stop`, `enable`
and `disable`. The optional `file:__file__` directive installs an overlay
configuration file `__file__`. Multiple commands must be comma (`,`)
or semicolon (`;`) separated. If the directives conflict, the last
one is used.

The service plugin supports configuration overlays only for systemd.
In other init systems, this directive is ignored. The configuration
overlay files are copied to `/etc/systemd/system/__service_name__.service.d/`
directories. Upon profile unloading, the directory is removed if it is empty.

With systemd, the `start` command is implemented by `restart` in order
to allow loading of the service configuration file overlay.

NOTE: With non-systemd init systems, the plug-in operates on the
current runlevel only.

.Start and enable the `sendmail` service with an overlay file
====
----
[service]
service.sendmail=start,enable,file:${i:PROFILE_DIR}/tuned-sendmail.conf
----
The internal variable `${i:PROFILE_DIR}` points to the directory
from which the profile is loaded.
====
c                sh   < \         \        V `
  ! V/ VB  R V n        V P	                  4       V n        R# )TN)Zsuperri   r   _has_dynamic_options_detect_init_system_init_handler)r   ZargsZkwargs	__class__s   &*,r
   r   ZServicePlugin.__init__   s0    t%t6v6"$//1$r   c                s@    \         P                  V^ .R7      w  r#V^ 8H  # )i    r9   r   )r   Zcommandr   r   r;   r
   
_check_cmdZServicePlugin._check_cmd   s"    ;;wQC;8.7	Ar   c                s   V P                  R R.4      '       d    \        P                  R4       \        4       # V P                  R.4      '       d    \        P                  R4       \	        4       # V P                  RR.4      '       d    \        P                  R4       \        4       # V P                  RR.4      '       d    \        P                  R	4       \        4       # \        P                  R
4      h)rX   r8   zdetected systemdr@   zdetected generic sysvinitzupdate-rc.dz-hzdetected sysv-rcrR   zdetected openrcz8Unable to detect your init system, disabling the plugin.)	rn   r]   ZdebugrU   r>   rL   rN   Z
exceptionsZNotSupportedPluginExceptionr    r!   r
   rk   Z!ServicePlugin._detect_init_system   s    	__k8,--99 

}%%99()
-t,--99 
/T*++99
/		/	/0j	kkr   c                sR   \         P                  ! R V4      p\        4       pV F  pVR8X  d
   RVn        K  VR8X  d
   RVn        K#  VR8X  d
   RVn        K3  VR8X  d
   RVn        KC  VR,          R8X  d   VR	,          Vn        Ka  \        P                  R
V: RV: R24       K  	  V# )z
\s*[,;]\s*r   Tr6   Fr   r1   :N   Nzfile::ro   NNz	service 'z': invalid service option: 'r\   )rT   r   r   r   r   r   r]   rb   )r   r&   ZvalZlr.   ZirZ   r
   _parse_service_optionsZ$ServicePlugin._parse_service_options   s    hh}c"!I'a8mGN	YGN	WGM	VGM	"uGIIdAFG  
.r   c                s   R Vn         RVn        \        P                  ! VP                  P                  4        UUu. uFb  w  r#VR,          R8X  g   K  \        V4      ^8  g   K'  VR,          V P                  VR,          V P                  P                  V4      4      3NKd  	  upp4      V n
        / Vn        R# u uppi )FT:N   Nzservice.:rq   NNN)Z_has_dynamic_tuningZ_has_static_tuningcollectionsZOrderedDictZoptionsitemsZlenrp   Z
_variablesZexpand	_services_services_original)r   instanceZoptionvaluer;   r
   _instance_initZServicePlugin._instance_init   s    !&( $(**8@8H8H8N8N8P,48P}vRjJ-##&v;?-#VBZ9T9TU[\^U_??% :" -#8P,4 5$. !#(,4s   B:
B:
%?B:
c                r#   r   r$   )r   rv   r0   r
   _instance_cleanupZServicePlugin._instance_cleanup  r)   r   c                s   V'       d   V P                   P                  V4       MVe   V P                   P                  V4       V'       d   V P                   P                  W4       R # Ve   V P                   P	                  W4       R # R # r   )rl   r   r1   r   r6   )r   r&   r   r   r   r	   r
   _process_serviceZServicePlugin._process_service
  si    
D!4 T,d- r   c                s   V P                   P                  4       pVf   \        P                  R4       R # V P                  P                  4        EF  pV P                   P                  V^ ,          V4      pV P                   P                  V^ ,          4      p\        WTV^,          P                  V4      VP                  V^ ,          &   V^,          P                  '       d5   V P                   P                  V^ ,          V^,          P                  4       V P                  V^ ,          V^,          P                  V^,          P                  V4       EK  	  R # )NzCannot detect runlevel)rl   r   r]   rb   rt   rs   r=   r<   r   r   ru   r(   rz   r   r   )r   rv   r   r.   r=   r<   s   &&    r
   _instance_apply_staticZ$ServicePlugin._instance_apply_static  s   ,,.(99%&	%%'g""--gaj(C:""--gaj9:-4ZWUVZM`M`bj-k8wqz*aj""71:wqz/B/BCWQZ%5%5wqz7H7H(S (r   c                s   V P                   P                  4       pVf-   \        P                  \        P
                  R,          4       R# RpV P                  P                  4        EF  pV P                   P                  V^ ,          V^,          P                  4      pV'       dM   \        P                  \        P                  R,          V^ ,          V^,          P                  3,          4       MVeO   \        P                  \        P
                  R,          V^ ,          V^,          P                  3,          4       RpMK\        P                  \        P                  R,          V^ ,          V^,          P                  3,          4       V P                   P                  V^ ,          V4      pV P                   P                  V^ ,          4      p	V P                  RV^ ,          ,          V^,          P                   W4      RJ d   RpV P                  RV^ ,          ,          V^,          P"                  W4      RJ g   EK  RpEK  	  V# )	Nzcannot detect runlevelFTz'service '%s' configuration '%s' matchesz'service '%s' configuration '%s' differszservice '%s' configuration '%s'z
%s runningz
%s enabled)rl   r   r]   rb   rc   ZSTR_VERIFY_PROFILE_FAILrt   rs   r+   r   r^   ZSTR_VERIFY_PROFILE_OKZ STR_VERIFY_PROFILE_VALUE_MISSINGr=   r<   Z_verify_valuer   r   )
r   rv   Zignore_missingZdevicesr   Zretr.   Zret_cfg_verifyr=   r<   s
   &&&&      r
   _instance_verify_staticZ%ServicePlugin._instance_verify_static"  s   ,,.(99V++.FFG
#%%'g&&11'!*gaj>Q>QR>HHV)),UUY`abYcelmneoexexXyyz"IIf,,/XX\cde\fhopqhrh{h{[||}
CHHV447XX\cde\fhopqhrh{h{[||}""--gaj(C:""--gaj9:

2GAJ4D4Djaejj
C

2GAJ4E4Ezbfkk
C ( 
*r   c                s.   \        VP                  P                  4       4       Fm  w  r4VP                  '       d&   V P                  P                  W4P                  4       V P                  W4P                  VP                  VP                  4       Ko  	  R # r   )
Zlistru   rs   r   rl   r*   rz   r   r   r   )r   rv   Zrollbackr&   rw   rJ   r
   _instance_unapply_staticZ&ServicePlugin._instance_unapply_static:  sa    (55;;=>kdnnn$$T>>:{{ELL%..I ?r   )rj   rl   rt   )r   r   r   r   Z__doc__r   rn   rk   rp   rx   ry   rz   r{   r|   rc   ZROLLBACK_SOFTr}   r   r   Z__classcell__)rm   r   s   @@r
   ri   ri      sR     %N2
l $#.T0 :@9M9M J Jr   ri   )rV   r    rr   Ztuned.constsrc   Z
decoratorsr_   rT   Z
tuned.logsZtunedZtuned.utils.commandsr   ZlogsZgetr]   r   r   r   r,   r>   rL   rN   rU   ZPluginri   r$   r   r
   <module>r~      s        	 	  )jjnnj  ${ (	S" 	S	S$ 	S?K ?2@"[ @"DSJDKK SJr   