HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/plogical/__pycache__/installUtilities.cpython-310.pyc
o

��h'L�@sZddlZddlZddlmZddlZddlZddlZddlZddl	m
Z
Gdd�d�ZdS)�N)�CyberCPLogFileWriter)�ProcessUtilitiesc@s�eZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	edd
��Z
edd��Zedd��Zedd��Z
edd��Zedd��Zedd��Zedd��Zedd��Zedd��Zed d!��Zd"S)#�installUtilitiesz/usr/local/lswsc
Cs�z=g}|�d�|�d�|�d�|�d�t�|�}|dkr/td�td�td�WdStd�td�td�WdStyZ}ztj�t|�d	�WYd}~d
Sd}~wt	yv}ztj�t|�d	�WYd}~d
Sd}~ww)N�yum�-y�installzepel-release��/###############################################z.         Could not add EPEL repo              z/          EPEL Repo Added                      z [enableEPELRepo]r)
�append�
subprocess�call�print�OSError�loggingr�writeToFile�str�
ValueError��cmd�res�msg�r�//usr/local/CyberCP/plogical/installUtilities.py�enableEPELRepos2





�
����zinstallUtilities.enableEPELRepoc
Cs�z+d}tj|dd�}|dkrtd�td�td�WdStd�td�td�WdStyH}ztj�t|�d�WYd}~d	Sd}~wtyd}ztj�t|�d�WYd}~d	Sd}~ww)
Nz*wget -O - https://repo.litespeed.sh | bashT)�shellrr	z.         Could not add Litespeed repo         z/          Litespeed Repo Added                 z [addLiteSpeedRepo]r)	rrr
rrrrrrrrrr�addLiteSpeedRepo*s*

�
	����z!installUtilities.addLiteSpeedRepoc
Cs�zAg}|�d�|�d�|�d�|�d�t�|�}|dkr3td�td�td�t��WdStd�td�td�WdSty^}ztj�	t
|�d	�WYd}~d
Sd}~wtyz}ztj�	t
|�d	�WYd}~d
Sd}~ww)Nrrr�
openlitespeedrr	z.         Could not install Litespeed          z/          Litespeed Installed                  z [installLiteSpeed]r�r
rrr
�sys�exitrrrrrrrrrr�installLiteSpeedEs4






�
	����z!installUtilities.installLiteSpeedc
Cs�z7g}|�d�|�d�t�|�}|dkr)td�td�td�t��WdStd�td�td�WdStyT}ztj�	t
|�d�WYd}~dSd}~wtyp}ztj�	t
|�d�WYd}~dSd}~ww)	Nz/usr/local/lsws/bin/lswsctrl�startrr	z/         Could not start Litespeed server      z/          Litespeed Started                    z [startLiteSpeed]rrrrrr�startLiteSpeedhs0




�
	����zinstallUtilities.startLiteSpeedc
Cs�zt��tjkrd}nd}t�|�WdSty1}ztj�t|�d�WYd}~dSd}~wt	yM}ztj�t|�d�WYd}~dSd}~ww)Nzsystemctl restart lswsz$/usr/local/lsws/bin/lswsctrl restart� [reStartLiteSpeed]rr)
r�decideServer�OLS�normalExecutionerrrrrr�
BaseException��commandrrrr�reStartLiteSpeed�s����z!installUtilities.reStartLiteSpeedc
C�zt��tjkrd}nd}t�|�WSty/}ztj�t|�d�WYd}~dSd}~wt	yK}ztj�t|�d�WYd}~dSd}~ww)N�sudo systemctl restart lsws�)sudo /usr/local/lsws/bin/lswsctrl restartr#r�
rr$r%�executionerrrrrrrr(rrr�reStartLiteSpeedSocket�����z'installUtilities.reStartLiteSpeedSocketc
Cr+)Nzsudo systemctl stop lswsz&sudo /usr/local/lsws/bin/lswsctrl stopr#rr.r(rrr�stopLiteSpeedSocket�r1z$installUtilities.stopLiteSpeedSocketc
Cs�z<t��tjkrd}nd}t�|�}t�|�}|dkr.td�td�td�t�	�WdStd�td�td�WdSt
yY}ztj�
t|�d�WYd}~dSd}~wtyu}ztj�
t|�d�WYd}~dSd}~ww)	Nr,r-rr	z/         Could not restart Litespeed serve     z/          Litespeed Re-Started                 z [reStartOpenLiteSpeed]r)rr$r%�shlex�splitrrr
rrrrrrrr)�restart�orestartr)rrrrrr�reStartOpenLiteSpeed�s2


�
����z%installUtilities.reStartOpenLiteSpeedc
Cs�z/td���}tdd�}|D]}|�d�dkr!|�|�dd��q|�|�q|��Wt��StyL}ztj�	t
|�d�WYd}~dSd}~ww)Nz&/usr/local/lsws/conf/httpd_config.conf�wz*:8088���z*:80z [changePortTo80]r)
�open�	readlines�find�
writelines�replace�close�IOErrorrrrrrr*)�data�writeDataToFile�itemsrrrr�changePortTo80�s

���zinstallUtilities.changePortTo80c
Cs�zDg}|�d�|�d�|�d�t�|�}|dkr.td�td�td�t��WdStd�td�td�ttjdd	�}WdSt	ya}zt
j�t
|�d
�WYd}~dSd}~wty}}zt
j�t
|�d
�WYd}~dSd}~ww)Nr�groupinstallz	lsphp-allrr	z/         Could not install PHP Binaries        z/          PHP Binaries installed               z/conf/httpd_config.conf�az [installAllPHPVersion]r)r
rrr
rrr:r�Server_root_pathrrrrrr)rrrBrrrr�installAllPHPVersion�s4




�����z%installUtilities.installAllPHPVersionc
Cs�zDtjd}tj�|�st�d|d�d}d}d}d}d}t|dd	�}|�|�|�|�|�|�|�|�|�|�|�	�WdSt
ya}ztj�
t|�d
�WYd}~dSd}~ww)
Nz/conf/�
phpconfigszinclude phpconfigs/php53.conf
zinclude phpconfigs/php54.conf
zinclude phpconfigs/php55.conf
zinclude phpconfigs/php56.conf
zinclude phpconfigs/php70.conf
zhttpd_config.confrFz [installAllPHPToLitespeed]rr)rrG�os�path�exists�shutil�copytreer:r=r?r@rrrr)rK�php53�php54�php55�php56�php70rBrrrr�installAllPHPToLitespeeds,






���z)installUtilities.installAllPHPToLitespeedcCs\t��dkr,t��dkr*t��dkr(t��dkr&t��r$t��r"dSdSdSdSdSdSdS)Nrr)rrrr r"rHrTrrrr�installMainWebServer;sz%installUtilities.installMainWebServerc
Cs0z>g}|�d�|�d�|�d�|�d�t�|�}|dkr1td�td�td�t��ntd�td�td�Wn9ty[}ztj�	t
|�d	�WYd}~d
Sd}~wtyw}ztj�	t
|�d	�WYd}~d
Sd}~wwz>g}|�d�|�d�|�d�|�d�t�|�}|dkr�td�td�td�ntd�td
�td�t��Wn9ty�}ztj�	t
|�d	�WYd}~d
Sd}~wty�}ztj�	t
|�d	�WYd}~d
Sd}~wwz	t�
tj�WdSt�y}ztj�	t
|�d	�WYd}~d
Sd}~ww)Nrr�removerrr	z/          Could not remove Litespeed           z/            Litespeed Removed                  z [removeWebServer]rzlsphp*z/           Could not PHP Binaries              z.            PHP Binaries Removed              )r
rrr
rrrrrrrrrM�rmtreerrGr'rrrr�removeWebServerQst





����





�������z installUtilities.removeWebServerc
Cs�z<g}|�d�|�d�|�d�t�|�}|dkr.td�td�td�t��WdStd�td�td�WdStyY}ztj�	t
|�d�WYd}~d	Sd}~wtyu}ztj�	t
|�d�WYd}~d	Sd}~ww)
N�	systemctlr!�mariadbrr	z/           Could not start MariaDB             z/              MariaDB Started                  z [startMariaDB]rrrrrr�startMariaDB�s2




�

����zinstallUtilities.startMariaDBc
Cs�z>g}|�d�|�d�|�d�|�d�t�|�}|dkr1td�td�td�t��ntd�td�td�Wn9ty[}ztj�	t
|�d	�WYd}~d
Sd}~wtyw}ztj�	t
|�d	�WYd}~d
Sd}~wwt�
�z9g}|�d�|�d�|�d
�t�|�}|dkr�td�td�td�t��ntd�td�td�Wn9ty�}ztj�	t
|�d�WYd}~d
Sd}~wty�}ztj�	t
|�d�WYd}~d
Sd}~wwt�|�dkr�dSd
S)Nrrrzmariadb-serverrr	z/         Could not install MariaDB             z/              MariaDB Installed                z [installMySQL]rrY�enablerZz/      Could not add mariadb to startup         z/          MariaDB Addded to startup            z0 Could not add mariadb to startup [installMySQL])r
rrr
rrrrrrrrrr[�secureMysqlInstallation)�passwordrrrrrr�installMySQL�sj





����	




����zinstallUtilities.installMySQLc
Cs�z�d}tjddd�}|�|�|�d�d}|�|�|�d�d}|�|�|�d	�d
}|�|�|�|�d}|�|�|�d�d}|�|�|�d�d
}|�|�|�d�d}|�|�|�d�|��|j�d�dks||j�d�dkrWdSWdStj	y�}z't
j�t
|�d�td�t|j�td�t|j�td�WYd}~dSd}~wty�}z'td�t|j�td�t|j�td�t
j�t
|�d�WYd}~dSd}~ww)Nz(enter for none):�mysql_secure_installationi N)�maxread�jzpassword? [Y/n]�Yz
New password:z
1qaz@9xvpsz
new password:zanonymous users? [Y/n]zroot login remotely? [Y/n]z%test database and access to it? [Y/n]z"Reload privilege tables now? [Y/n]zThanks for using MariaDB!r9rz Exception EOF [installMySQL]zI###########################Before########################################zH###########################After########################################zH########################################################################zH#############################Before#####################################zG############################After######################################z[installMySQL]r)�pexpect�spawn�expect�sendcontrol�sendline�wait�beforer<�after�EOFrrrrr
r')r^�expectation�securemysqlrrrrr]sd















 ��


��

��z(installUtilities.secureMysqlInstallationN)�__name__�
__module__�__qualname__rG�staticmethodrrr r"r*r0r2r7rDrHrTrUrXr[r_r]rrrrr
sD


"






)


B
"
Mr)rr�plogicalrrrMrdrJr3�plogical.processUtilitiesrrrrrr�<module>s