MOON
Server: Apache
System: Linux s5.yayogua.com.py 6.12.0-124.55.3.el10_1.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:54:02 EDT 2026 x86_64
User: sanbercountryclu (1012)
PHP: 8.2.33
Disabled: NONE
Upload Files
File: //lib/python3.12/site-packages/tuned/plugins/__pycache__/plugin_service.cpython-312.pyc
�

�]�i�)��T�ddlmZddlZddlmZddl�ddlZddlZddlZ	ddl
mZe	jj�Ze�ZGd�d�ZGd�d	�ZGd
�de�ZGd�d
e�ZGd�de�ZGd�de�ZGd�de�ZGd�dej.�Zy)�)�base�N)�*)�commandsc��eZdZdd�Zy)�ServiceNc�<�||_||_||_||_y�N)�enable�start�cfg_file�runlevel)�selfrrr
rs     �A/usr/lib/python3.12/site-packages/tuned/plugins/plugin_service.py�__init__zService.__init__s���$�+��$�*��$�-��$�-�)NNNN)�__name__�
__module__�__qualname__r�rrrr
s��rrc�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�InitHandlerc�h�tjdg�\}}|dk(r|j�dSdS)Nrr���)�cmd�execute�split�r�retcode�outs   r�runlevel_getzInitHandler.runlevel_gets1���;�;�
�|�,�.�7�C�#�q�L�����R��2�d�2rc�2�tjddg�y)N�telinit�q�rr�rs r�
daemon_reloadzInitHandler.daemon_reloads���+�+�y�#��rc��yr
r�r�namer
s   r�cfg_installzInitHandler.cfg_install���rc��yr
rr)s   r�
cfg_uninstallzInitHandler.cfg_uninstallr,rc��yr
rr)s   r�
cfg_verifyzInitHandler.cfg_verify"s��	
rN)rrrr!r'r+r.r0rrrrrs��3� ���rrc�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�SysVBasicHandlerc�4�tjd|dg�y)N�servicerr%�rr*s  rrzSysVBasicHandler.start's���+�+�y�$��(�)rc�4�tjd|dg�y)Nr4�stopr%r5s  rr7zSysVBasicHandler.stop*s���+�+�y�$��'�(rc��t��r
��NotImplementedError�rr*rs   rrzSysVBasicHandler.enable-�����rc��t��r
r9r;s   r�disablezSysVBasicHandler.disable0r<rc�H�tjd|dgdg��\}}|dk(S)Nr4�statusr��	no_errorsr%�rr*rr s    r�
is_runningzSysVBasicHandler.is_running3s+���;�;�	�4��:���;�L�.�7�C�	�A��rc��t��r
r9r;s   r�
is_enabledzSysVBasicHandler.is_enabled7r<rN)	rrrrr7rr>rDrFrrrr2r2&s ��*�)����rr2c��eZdZd�Zd�Zd�Zy)�SysVHandlerc�8�tjdd||dg�y)N�	chkconfig�--level�onr%r;s   rrzSysVHandler.enable;s���+�+�{�I�x��t�<�=rc�8�tjdd||dg�y)NrJrK�offr%r;s   rr>zSysVHandler.disable>s���+�+�{�I�x��u�=�>rc��tjdd|g�\}}|dk(r&|jdt|�z�ddddk(SdS)NrJ�--listr�%s:r�rL�rrr�str�rr*rrr s     rrFzSysVHandler.is_enabledAsO���;�;��X�t�<�=�.�7�C�<C�q�L����5�3�x�=�(�	)�!�	,�R�a�	0�D�	8�R�d�RrN�rrrrr>rFrrrrHrH:s��>�?�SrrHc��eZdZd�Zd�Zd�Zy)�
SysVRCHandlerc�8�tjdd||dg�y)N�sysv-rc-confrKrLr%r;s   rrzSysVRCHandler.enableFs���+�+�~�y�(�D�$�?�@rc�8�tjdd||dg�y)NrZrKrNr%r;s   rr>zSysVRCHandler.disableIs���+�+�~�y�(�D�%�@�Arc��tjdd|g�\}}|dk(r&|jdt|�z�ddddk(SdS)NrZrPrrQrrRrLrSrUs     rrFzSysVRCHandler.is_enabledLsO���;�;���$�?�@�.�7�C�<C�q�L����5�3�x�=�(�	)�!�	,�R�a�	0�D�	8�R�d�RrNrVrrrrXrXEs��A�B�SrrXc�6�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	y)	�
OpenRCHandlerc�d�tjddg�\}}|dk(r|j�SdS)Nz	rc-statusz-rr�rr�striprs   rr!zOpenRCHandler.runlevel_getQs0���;�;��T�2�3�.�7�C��1������.�$�.rc�4�tjd|dg�y)N�
rc-servicerr%r5s  rrzOpenRCHandler.startUs���+�+�|�T�7�+�,rc�4�tjd|dg�y)Nrcr7r%r5s  rr7zOpenRCHandler.stopXs���+�+�|�T�6�*�+rc�6�tjdd||g�y)N�	rc-update�addr%r;s   rrzOpenRCHandler.enable[����+�+�{�E�4��2�3rc�6�tjdd||g�y)Nrf�delr%r;s   rr>zOpenRCHandler.disable^rhrc�H�tjd|dgdg��\}}|dk(S)Nrcr@rrAr%rCs    rrDzOpenRCHandler.is_runningas+���;�;��d�H�=�A�3�;�O�.�7�C�	�A��rc��tjdd|g�\}}ttjdtj
|�zdz|��S)Nrf�showz\b)rr�bool�re�search�escaperUs     rrFzOpenRCHandler.is_enabledesC���;�;��V�X�>�?�.�7�C�	
�b�i�i���	�	�$��/�%�7��=�	>�>rN)
rrrr!rr7rr>rDrFrrrr^r^Ps%��/�-�,�4�4��?rr^c�H�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�SystemdHandlerc��y)N�rr&s rr!zSystemdHandler.runlevel_getks��	rc�4�tjdd|g�y)N�	systemctl�restartr%r5s  rrzSystemdHandler.startn����+�+�{�I�t�,�-rc�4�tjdd|g�y)Nrwr7r%r5s  rr7zSystemdHandler.stopqs���+�+�{�F�D�)�*rc�4�tjdd|g�y)Nrwrr%r;s   rrzSystemdHandler.enablets���+�+�{�H�d�+�,rc�4�tjdd|g�y)Nrwr>r%r;s   rr>zSystemdHandler.disablewryrc�H�tjdd|gdg��\}}|dk(S)Nrwz	is-activerrAr%rCs    rrDzSystemdHandler.is_runningzs+���;�;��[�$�?�a�S�;�Q�.�7�C�	�A��rc�~�tjdd|gdg��\}}|j�}|dk(rdS|dk(rdSdS)	Nrwz
is-enabledrrA�enabledT�disabledFr`)rr*rrr r@s      rrFzSystemdHandler.is_enabled~sJ���;�;��\�4�@�q�c�;�R�.�7�C��9�9�;�&��9�$��P�6�J�3F�%�P�D�Prc���tjd|�d|�d��tjj	|�stjd|z�ytj|z}	tj|tjd��tj||�|j�y#t$r%}tjd|�d|���Yd}~yd}~wwxYw)	Nz/installing service configuration overlay file '�' for service '�'z)Unable to find service configuration '%s'T)�exist_okzUnable to create directory 'z': )�log�info�os�path�exists�error�consts�SERVICE_SYSTEMD_CFG_PATH�makedirs�DEF_SERVICE_CFG_DIR_MODE�OSErrorr�copyr')rr*r
�dirpath�es     rr+zSystemdHandler.cfg_install�s����(�(�T\�^b�c�d�	������	!��9�9�
8�8�
C�D�	��+�+�d�2�'�
��;�;�w��7�7�$�G��(�(�8�W�������	
�
��9�9�g�q�
A�B�	��
�s�)&B6�6	C$�?C�C$c�J�tjd|�d|�d��tj|z}|�dtj
j
|���}tj|�|j�	t	j|�y#ttf$rYywxYw)Nz1uninstalling service configuration overlay file 'r�r��/)
r�r�r�r�r�r��basenamer�unlinkr'�rmdir�FileNotFoundErrorr�)rr*r
r�r�s     rr.zSystemdHandler.cfg_uninstall�s~���(�(�V^�`d�e�f��+�+�d�2�'��R�W�W�-�-�h�7�	8�$��*�*�T��������8�8�G���
�W�	%����s�:B�B"�!B"c��|�ytj|z�dtjj	|���}tjj|�stjd|�d|�d��ytjj|�stjd|�d|�d��ytj|�}tj|�}||k(S)Nr�zUnable to find service 'z' configuration 'r�Fz	Service 'z"' configuration not installed in ')
r�r�r�r�r�r�r�r�r�	sha256sum)rr*r
r��
sha256sum1�
sha256sum2s      rr0zSystemdHandler.cfg_verify�s���
��
��3�3�d�:�B�G�G�<L�<L�X�<V�	W�$�	������	!��9�9��x�
P�Q�
�	������	��9�9�4��
N�O�
��}�}�X�&�*��}�}�T�"�*�	�z�	!�!rN)
rrrr!rr7rr>rDrFr+r.r0rrrrsrsis5���.�+�-�.��Q�
�
�"rrsc�p��eZdZdZ�fd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Ze
jfd�Z�xZS)�
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�d��tt|�
|i|��d|_|j	�|_y)NT)�superr�r�_has_dynamic_options�_detect_init_system�
_init_handler)r�args�kwargs�	__class__s   �rrzServicePlugin.__init__�s0����
�t�%�t�6�v�6�"�$���/�/�1�$�rc�B�tj|dg��\}}|dk(S)NrrAr%)r�commandrr s    r�
_check_cmdzServicePlugin._check_cmd�s$���;�;�w�Q�C�;�8�.�7�C�	�A��rc��|jddg�rtjd�t�S|jdg�rtjd�t	�S|jddg�rtjd�t�S|jd	dg�rtjd
�t
�Stjd��)Nrwr@zdetected systemdrJzdetected generic sysvinitzupdate-rc.dz-hzdetected sysv-rcrfzdetected openrcz8Unable to detect your init system, disabling the plugin.)	r�r��debugrsrHrXr^�
exceptions�NotSupportedPluginExceptionr&s rr�z!ServicePlugin._detect_init_system�s���	�_�_�k�8�,�-��9�9�
� �
�
������}�%��9�9�
(�)�
�-�����
�t�,�-��9�9�
� �
�/������T�*�+��9�9�
��
�/��	�	/�	/�0j�	k�krc��tjd|�}t�}|D]e}|dk(rd|_�|dk(rd|_�|dk(rd|_�*|dk(rd|_�7|ddd	k(r|dd|_�Jtjd
|�d|�d���g|S)
Nz
\s*[,;]\s*rTr>Frr7�zfile:z	service 'z': invalid service option: 'r�)rorrrrr
r�r�)rr*�val�lr4�is      r�_parse_service_optionsz$ServicePlugin._parse_service_options�s����h�h�}�c�"�!��I�'��a��8�m��G�N�	�Y���G�N�	�W���G�M�	�V���G�M�	�"�1�������u�G���I�I�d�A�F�G�
�
�.rc
�R�d|_d|_tj|jj�D��cgc]N\}}|dddk(rAt
|�dkDr3|dd|j|dd|jj|��f��Pc}}�|_
i|_ycc}}w)NFT�zservice.)�_has_dynamic_tuning�_has_static_tuning�collections�OrderedDict�options�items�lenr��
_variables�expand�	_services�_services_original)r�instance�option�values    r�_instance_initzServicePlugin._instance_init�s���!&�(�� $�(���*�*�8@�8H�8H�8N�8N�8P�,4�8P�}�v�u��R�a�j�J��3�v�;��?�.4�A�B�Z��9T�9T�U[�\]�\^�U_��?�?���%� �:"�-#�8P�,4�5�$�.�!#�(���,4s�AB#
c��yr
r)rr�s  r�_instance_cleanupzServicePlugin._instance_cleanupr,rc��|r|jj|�n|�|jj|�|r|jj||�y|�|jj	||�yyr
)r�rr7rr>)rr*rrrs     r�_process_servicezServicePlugin._process_service
sm��
������D�!��������4� �������T�8�,�
�������d�H�-�rc�N�|jj�}|�tjd�y|jj�D]�}|jj
|d|�}|jj|d�}t|||dj|�|j|d<|djr,|jj|d|dj�|j|d|dj|dj|���y)NzCannot detect runlevelrr)r�r!r�r�r�r�rFrDrr
r�r+r�rr)rr�rr4rFrDs      r�_instance_apply_staticz$ServicePlugin._instance_apply_statics��
�
�
�
,�
,�
.�(�
���9�9�
%�&�	����%�%�'�g��"�"�-�-�g�a�j�(�C�:��"�"�-�-�g�a�j�9�:�-4�Z��W�UV�Z�M`�M`�bj�-k�8���w�q�z�*�
�a�j������"�"�7�1�:�w�q�z�/B�/B�C�������W�Q�Z�%5�%5�w�q�z�7H�7H�(�S�
(rc���|jj�}|�'tjtj
dz�yd}|jj�D�]}}|jj|d|dj�}|r<tjtjdz|d|djfz�n{|�>tjtj
dz|d|djfz�d}n;tjtjdz|d|djfz�|jj|d|�}|jj|d�}	|jd	|dz|dj |	|�durd}|jd
|dz|dj"||�dus��|d}���|S)Nzcannot detect runlevelFTrrz'service '%s' configuration '%s' matchesz'service '%s' configuration '%s' differszservice '%s' configuration '%s'z
%s runningz
%s enabled)r�r!r�r�r��STR_VERIFY_PROFILE_FAILr�r�r0r
r��STR_VERIFY_PROFILE_OK� STR_VERIFY_PROFILE_VALUE_MISSINGrFrD�
_verify_valuerr)
rr��ignore_missing�devicesr�retr4�ret_cfg_verifyrFrDs
          r�_instance_verify_staticz%ServicePlugin._instance_verify_static"s���
�
�
�
,�
,�
.�(�
���9�9�V�
+�
+�.F�
F�G�
��#����%�%�'�g��&�&�1�1�'�!�*�g�a�j�>Q�>Q�R�>���H�H�V�
)�
)�,U�
U�Y`�ab�Yc�el�mn�eo�ex�ex�Xy�
y�z��"��I�I�f�,�,�/X�X�\c�de�\f�ho�pq�hr�h{�h{�[|�|�}�
�C��H�H�V�
4�
4�7X�
X�\c�de�\f�ho�pq�hr�h{�h{�[|�
|�}��"�"�-�-�g�a�j�(�C�:��"�"�-�-�g�a�j�9�:�
������
�2�G�A�J�4D�4D�j�R`�a�ej�j�
�C�
������
�2�G�A�J�4E�4E�z�Sa�b�fk�k�
�C�(�

�*rc�"�t|jj��D]i\}}|jr&|jj||j�|j
||j|j|j��kyr
)
�listr�r�r
r�r.r�rrr)rr��rollbackr*r�s     r�_instance_unapply_staticz&ServicePlugin._instance_unapply_static:se���(�5�5�;�;�=�>�k�d�E��n�n����$�$�T�5�>�>�:�����u�{�{�E�L�L�%�.�.�I�?r)rrr�__doc__rr�r�r�r�r�r�r�r�r��
ROLLBACK_SOFTr��
__classcell__)r�s@rr�r��sJ���%�N2�
�l� �$#��.�T�
�0:@�9M�9M�Jrr�)rurr��tuned.constsr��
decoratorsr�ro�
tuned.logs�tuned�tuned.utils.commandsr�logs�getr�rrrr2rHrXr^rs�Pluginr�rrr�<module>r�s�������	�	��)��j�j�n�n����j������$�{��(	S�"�	S�	S�$�	S�?�K�?�2@"�[�@"�DSJ�D�K�K�SJr