Files
CyberPanel/plogical/virtualHostUtilities.pyc

439 lines
42 KiB
Plaintext
Raw Normal View History

2017-10-24 19:16:36 +05:00
<03>
2018-03-02 18:13:26 +05:00
<EFBFBD>d2Zc@sKddlZddlZddlZddlZddlZddlZddlZddl m
2017-12-14 06:56:27 -05:00
Z
ddl Z ddlm Z ddlm Z mZddlmZddlZdfd<00><00>YZd<00>Zd <00>Zd
2018-03-02 18:13:26 +05:00
<00>Zd <00>Zd <00>Zd <00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>Zd<00>ZedkrGe<00>ndS(i<><69><EFBFBD><EFBFBD>N(trandint(tjoin(tlistdirtrmdir(tmovetvirtualHostUtilitiescBs<>eZdZdZed<00><00>Zed<00><00>Zed<00><00>Zed<00><00>Zed<00><00>Z ed<00><00>Z
2017-12-14 06:56:27 -05:00
ed<00><00>Z ed <00><00>Z ed
2018-03-02 18:13:26 +05:00
<00><00>Z ed <00><00>Zed <00><00>Zed <00><00>Zed<00><00>Zed<00><00>Zed<00><00>ZRS(s/usr/local/lswss/usr/local/CyberCPcCs<>d|}d|d}d|d}tjd|}|d}ttjd<00>} d|d}
2017-12-14 06:56:27 -05:00
tj|
<00>} tj| d | d
tj <00>} d |}
tj|
<00>} tj| d | d
tj <00>} d |d |}
tj|
<00>} tj| d | d
tj <00>} yVtj
|<00>d|d|d |}
tj|
<00>} tj| d | d
tj <00>Wn4t k
r<>} t j jt| <00>d<17>ddgSXyVtj
|<00>d|d|d |}
tj|
<00>} tj| d | d
tj <00>Wn4t k
r} t j jt| <00>d<17>ddgSXy{tj
|<00>d%|}
tj|
<00>} tj| d | d
tj <00>d|}
tj|
<00>} tj| d | d
tj <00>Wn4t k
r<>} t j jt| <00>d<17>ddgSXytj
|<00>Wn4t k
r} t j jt| <00>d<17>ddgSXyHt|d<00>}d)|}
tj|
<00>} tj| d | d
tj <00>Wn4tk
r<>} t j jt| <00>d<17>ddgSXtj||||<00>dkr<>d|}
dd gSdd!gSdS(*Ns/home/s /public_htmls/logss /conf/vhosts/s /vhost.conftwsadduser s -Mtstdouttstderrs groupadd susermod -a -G t schown t:sU [27 Not able create to directories for virtual host [createDirectoryForVirtualHost]]isM[27 Not able to directories for virtual host [createDirectoryForVirtualHost]]sN [33 Not able to directories for virtual host [createDirectoryForVirtualHost]]sM[33 Not able to directories for virtual host [createDirectoryForVirtualHost]]tnobodys chmod -R 666 sN [39 Not able to directories for virtual host [createDirectoryForVirtualHost]]sM[39 Not able to directories for virtual host [createDirectoryForVirtualHost]]sN [45 Not able to directories for virtual host [createDirectoryForVirtualHost]]sM[45 Not able to directories for virtual host [createDirectoryForVirtualHost]]sw+tlsadms! [createDirectoryForVirtualHost]]is chmod -R 766 tNonesK[61 Not able to create per host virtual configurations [perHostVirtualConf]s chown nobodys chown nobody:schown nobody:nobodyschown nobody:nobody s chown lsadms chown lsadm:schown lsadm:lsadmschown lsadm:lsadm (Rt Server_roottopentostdevnulltshlextsplitt
subprocesstcalltSTDOUTtmakedirstOSErrortloggingtCyberCPLogFileWritert writeToFiletstrtIOErrortperHostVirtualConf(tvirtualHostNametadministratorEmailtvirtualHostUsert
phpVersiontpathtpathHTMLtpathLogstconfPathtcompletePathToConfigFiletFNULLtcommandtcmdtrestmsgtfile((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pytcreateDirectoryForVirtualHostsv
2017-10-24 19:16:36 +05:00

2017-12-14 06:56:27 -05:00

       

   
  

2018-03-02 18:13:26 +05:00
c:CsVy!t|d<00>}dd}dd}dd}d|d}dd} ddd}
2017-12-14 06:56:27 -05:00
|j|<00>|j|<00>|j|<00>|j|<00>|j| <00>|j|
2018-03-02 18:13:26 +05:00
<00>dD} d
d} d d} dF}|j| <00>|j| <00>|j| <00>|j|<00>d d}d
d}dd}dd}dH}|j|<00>|j|<00>|j|<00>|j|<00>|j|<00>dd}d
d}dd}dd}dd}d}dd}dJ}|j|<00>|j|<00>|j|<00>|j|<00>|j|<00>|j|<00>|j|<00>|j|<00>dK}d|dd}dM}|j|<00>|j|<00>|j|<00>|dkrqd}ni|dkr<>d}nT|dkr<>d}n?|dkr<>d}n*|dkr<>d }n|d!kr<>d"}nd#|d$}d%}d&|d'} d(}!d)}"d*}#d+}$d,}%d-}&d.|d/}'d0|d}(d1|d})d2}*d3}+d4},d5}-d6}.|j|<00>|j|<00>|j| <00>|j|!<00>|j|"<00>|j|#<00>|j|$<00>|j|%<00>|j|&<00>|j|'<00>|j|(<00>|j|)<00>|j|*<00>|j|+<00>|j|,<00>|j|-<00>|j|.<00>d7}/d8}d9}0d:}1d;}2d<}3d=}4d>}5d?}6d@}7d6}8|j|/<00>|j|<00>|j|0<00>|j|1<00>|j|2<00>|j|3<00>|j|4<00>|j|5<00>|j|6<00>|j|7<00>|j|8<00>|j<00>Wn.tk
rQ}9tjjt|9<00>dA<17>dBSXdCS(NNsw+s.docRoot $VH_ROOT/public_htmls
2017-12-14 06:56:27 -05:00
s"vhDomain $VH_NAMEs&vhAliases www.$VH_NAMEsadminEmails senableGzip 1senableIpGeo 1sindex {s useServer 0s/ indexFiles index.php, index.htmlt}s+errorlog $VH_ROOT/logs/$VH_NAME.error_log {s logLevel ERRORs rollingSize 10Ms-accesslog $VH_ROOT/logs/$VH_NAME.access_log {s6 logFormat "%v %h %l %u %t "%r" %>s %b"s logHeaders 5s keepDays 10s compressArchive 1sscripthandler {s add lsapi:s phpsPHP 5.3t53sPHP 5.4t55sPHP 5.5sPHP 5.6t56sPHP 7.0t70sPHP 7.1t71s extprocessor s {
s type lsapi
s, address UDS://tmp/lshttpd/s.sock
2018-03-02 18:13:26 +05:00
s maxConns 35
2017-12-14 06:56:27 -05:00
s initTimeout 60
s retryTimeout 0
s persistConn 1
s respBuffer 0
s autoStart 1
s/ path /usr/local/lsws/lsphps /bin/lsphp
s extUser s extGroup s memSoftLimit 2047M
s memHardLimit 2047M
s procSoftLimit 400
s procHardLimit 500
s}
scontext /.filemanager {
s type NULL
sC location /usr/local/lsws/Example/html/FileManager
s allowBrowse 1
s autoIndex 1
s accessControl {
s/ allow 127.0.0.1, localhost
s$ deny 0.0.0.0/0
s }
s addDefaultCharset off
s: [IO Error with per host config file [perHostVirtualConf]]iis index {
s}
s}
s}
s}
s}
s}
sscripthandler {
s}
s}
(Rt
2018-03-02 18:13:26 +05:00
writelinestcloset BaseExceptionRRRR(:tvhFileR R!R"tconfFiletdocRoottvhDomaint vhAliasest adminEmailst
2017-12-14 06:56:27 -05:00
enableGzipt enableIpGeotindext
userServert
indexFilest index_endt error_logt useServertlogLevelt rollingSizet error_log_endt
access_Logt logFormatt
2018-03-02 18:13:26 +05:00
logHeaderstkeepDaystcompressArchivetaccess_Log_endt scripthandlertaddtphp_endtphpt extprocessorttypetaddresstmaxConnst initTimeoutt retryTimeoutt persistConnt
respBuffert autoStartR#textUsertextGroupt memSoftLimitt memHardLimitt procSoftLimitt procHardLimittextprocessorEndtcontexttlocationt allowBrowset autoIndext accessControltallowtdenytaccessControlEndstdefaultCharSett contextEndsR,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pyRzs
2017-12-14 06:56:27 -05:00



      

    



     





2018-03-02 18:13:26 +05:00
                                                    cCsyDtd<00>j<00>}tdd<00>}d}d}d}d}d}d}d|d d
2017-10-24 19:16:36 +05:00
} |d |d d d
}
|d|dddd dd
} |d|dd
} |d|dd
} |d|dd
2017-12-14 06:56:27 -05:00
}d#}d|d|d
}d}d}x(|D] }|jd<00>dks;|jd<00>dkr<>|dkr<>|j| <00>|j|
2017-10-24 19:16:36 +05:00
<00>|j| <00>|j| <00>|j| <00>|j|<00>|j|<00>|jd
2017-12-14 06:56:27 -05:00
<00>|j|<00>d}q |jd<00>dks<>|jd <00>dkr|dkr|j|<00>|j|<00>d}q |j|<00>q W|j<00>dd!gSWn4tk
rz}tjjt |<00>d"<17>dd"gSXdS($Ns&/usr/local/lsws/conf/httpd_config.confRs s s s s s virtualHost s {s
2017-10-24 19:16:36 +05:00
tvhRoots/home/s$VH_NAMEt
configFiles $SERVER_ROOTs/conf/svhosts/s /vhost.conftallowSymbolLinkt1t enableScriptt
2017-12-14 06:56:27 -05:00
restrainedR/s map R it virtualHosti<74><69><EFBFBD><EFBFBD>t virtualhostislistener Default{s Default {R sH223 [IO Error with main config file [createConfigInMainVirtualHostFile]]s}
2017-10-24 19:16:36 +05:00
(
2017-12-14 06:56:27 -05:00
Rt readlinestfindR5R6R7RRRR(RtdatatwriteDataToFilet spaceonbacktspacetspace2tspace3tspace4tspace5t firstLinet
2017-10-24 19:16:36 +05:00
secondLinet thirdLinet forthLinet fifthLinet sixthLinet seventhLinetmaptcheckert
2018-03-02 18:13:26 +05:00
mapcheckertitemsR,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pyt!createConfigInMainVirtualHostFile#sR & 6          6   
2017-12-14 06:56:27 -05:00
c Cs<>ttjd<00>}tjd|}|d}yVtj|<00>d|d|d|} tj| <00>}
tj |
d|dtj
<00>Wn-t k
r<>} t j jt| <00>d <17>nXytj|<00>Wn4t k
r<>} t j jt| <00>d
<17>d d gSXyt|d <00>} Wn4tk
rD} t j jt| <00>d<17>d dgSXtj||||||<00>dkrsddgSd dgSdS(NRs /conf/vhosts/s /vhost.confschown R
2018-03-02 18:13:26 +05:00
R RRsP329 [Not able to create directories for virtual host [createDirectoryForDomain]]sP335 [Not able to create directories for virtual host [createDirectoryForDomain]]isI[344 Not able to directories for virtual host [createDirectoryForDomain]]sw+s [createDirectoryForDomain]]sI[351 Not able to directories for virtual host [createDirectoryForDomain]]iR sL[359 Not able to create per host virtual configurations [perHostVirtualConf](RRRRRRRRRRRRRRRRRtperHostDomainConf( t masterDomaintdomainR"R#R R!R(R&R'R)R*R,R-((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pytcreateDirectoryForDomaincs4
2017-12-14 06:56:27 -05:00
      
2018-03-02 18:13:26 +05:00
c2Cs<>y<>t|d<00>}d|d}dd}dd} d|d}
2017-12-14 06:56:27 -05:00
dd} ddd} |j|<00>|j|<00>|j| <00>|j|
2018-03-02 18:13:26 +05:00
<00>|j| <00>|j| <00>d>} d
d}d d}d@}|j| <00>|j|<00>|j|<00>|j|<00>d |dd}d
d}dd}dd}dB}|j|<00>|j|<00>|j|<00>|j|<00>|j|<00>d|dd}d
d}dd}dd}dd}d}dd}dD}|j|<00>|j|<00>|j|<00>|j|<00>|j|<00>|j|<00>|j|<00>|j|<00>ttdd<00><00>}dE}d||dd}dG}|j|<00>|j|<00>|j|<00>|dkr<>d} ni|dkr<>d} nT|d kr<>d} n?|d!kr<>d"} n*|d#kr<>d$} n|d%krd&} nd'||d(}!d)}"d*||d+}#d,}$d-}%d.}&d/}'d0}(d1})d2| d3}d4|d}*d5|d}+d6},d7}-d8}.d9}/d:}0|j|!<00>|j|"<00>|j|#<00>|j|$<00>|j|%<00>|j|&<00>|j|'<00>|j|(<00>|j|)<00>|j|<00>|j|*<00>|j|+<00>|j|,<00>|j|-<00>|j|.<00>|j|/<00>|j|0<00>|j<00>Wn.tk
r<>}1tjjt|1<00>d;<17>d<SXd=S(HNsw+sdocRoot s
2017-12-14 06:56:27 -05:00
s"vhDomain $VH_NAMEs&vhAliases www.$VH_NAMEsadminEmails senableGzip 1senableIpGeo 1sindex {s useServer 0s/ indexFiles index.php, index.htmlR/serrorlog $VH_ROOT/logs/s .error_log {s logLevel ERRORs rollingSize 10Msaccesslog $VH_ROOT/logs/s .access_log {s6 logFormat "%v %h %l %u %t "%r" %>s %b"s logHeaders 5s keepDays 10s compressArchive 1i<31>i'sscripthandler {s add lsapi:s phpsPHP 5.3R0sPHP 5.4R1sPHP 5.5sPHP 5.6R2sPHP 7.0R3sPHP 7.1R4s extprocessor s {
s type lsapi
s, address UDS://tmp/lshttpd/s.sock
2018-03-02 18:13:26 +05:00
s maxConns 35
2017-12-14 06:56:27 -05:00
s initTimeout 60
s retryTimeout 0
s persistConn 1
s respBuffer 0
s autoStart 1
s/ path /usr/local/lsws/lsphps /bin/lsphp
s extUser s extGroup s memSoftLimit 2047M
s memHardLimit 2047M
s procSoftLimit 400
s procHardLimit 500
s}
s9 [IO Error with per host config file [perHostDomainConf]]iis index {
2017-10-24 19:16:36 +05:00
s}
s}
s}
s}
s}
s}
sscripthandler {
s}
s}
2018-03-02 18:13:26 +05:00
( RR5RRR6R7RRR(2R#R<>R8R R"R!R9R:R;R<R=R>R?R@RARBRCRDRERFRGRHRIRJRKRLRMRNtsockRandomPathRORPRQRRRSRTRURVRWRXRYRZR[R\R]R^R_R`RaRbR,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pyR<79><00>s<> 
2017-10-24 19:16:36 +05:00


2017-12-14 06:56:27 -05:00
      
2017-10-24 19:16:36 +05:00

2017-12-14 06:56:27 -05:00
    
2017-10-24 19:16:36 +05:00


2017-12-14 06:56:27 -05:00
     
2017-10-24 19:16:36 +05:00




2018-03-02 18:13:26 +05:00
                                         cCsyDtd<00>j<00>}tdd<00>}d}d}d}d}d}d} d|d d
2017-12-14 06:56:27 -05:00
}
|d |d |d
} |d |dddddd
} |d|dd
} |d|dd
}|d| dd
}d$}d|d|d
}d}d}x(|D] }|jd<00>dks;|jd<00>dkr<>|dkr<>|j|
<00>|j| <00>|j| <00>|j| <00>|j|<00>|j|<00>|j|<00>|jd
<00>|j|<00>d}q |jd<00>dks<>|jd <00>dkr|dkr|j|<00>|j|<00>d}q |j|<00>q W|j<00>dd!gSWn4tk
rz}tjjt |<00>d"<17>dd#gSXdS(%Ns&/usr/local/lsws/conf/httpd_config.confRs s s s s s virtualHost s {s
2018-03-02 18:13:26 +05:00
Rms/home/Rns $SERVER_ROOTs/conf/svhosts/s$VH_NAMEs /vhost.confRoRpRqRrR/s map R iRsi<><69><EFBFBD><EFBFBD>Rtislistener Default{s Default {R sE [IO Error with main config file [createConfigInMainVirtualHostFile]]sH223 [IO Error with main config file [createConfigInMainVirtualHostFile]]s}
2017-12-14 06:56:27 -05:00
(
2018-03-02 18:13:26 +05:00
RRuRvR5R6R7RRRR(R<>R<>RwRxRyRzR{R|R}R~RR<>R<>R<>R<>R<>R<>R<>R<>R<>R<>R,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pyt createConfigInMainDomainHostFilesT & 6          6   
2017-12-14 06:56:27 -05:00
 c
Cs<>d|}ytj|<00>Wn-tk
2017-10-24 19:16:36 +05:00
rJ}tjjt|<00>d<17>nXy"tjd|}tj|<00>Wn-tk
r<>}tjjt|<00>d<17>nXyt d<00>j
<00>}t dd<00>}d}d}x<>|D]<5D>} |dkr<>| j |<00>dkr| j d |<17>dkrq<>n| j |<00>dkrb| j d
<00>dksY| j d <00>dkrbd }n| j d <00>dkr<>d }n|dkr<>|dkr<>|j | <00>n| j d<00>dkr<>|d ks<>|d kr<>d}d}q<>q<>| j |<00>dkr| j d |<17>dkrq<>n| j |<00>dkrc| j d
<00>dksZ| j d <00>dkrcd }n|dkr|j | <00>n| j d<00>dkr<>|d kr<>d}q<>q<>WWn.tk
2018-03-02 18:13:26 +05:00
r<>}tjjt|<00>d<17>d SXdS(Ns/home/sD [Not able to remove virtual host directory from /home continuing..]s /conf/vhosts/sF [Not able to remove virtual host configuration directory from /conf ]s&/usr/local/lsws/conf/httpd_config.confRii<><69><EFBFBD><EFBFBD>s map RsRtislistener SSL {R/sN [Not able to remove virtual host configuration from main configuration file.]( tshutiltrmtreeR7RRRRRRRRuRvR5(
Rt numberOfSitestvirtualHostPathR,R&RwRxtchecktsslCheckR<6B>((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pytdeleteVirtualHostConfigurations^sP
  .?  - .?  !cCstjjd|<17>rdSdS(Ns/home/ii(RR#texists(R((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pytcheckIfVirtualHostExists<74>sc
2017-12-14 06:56:27 -05:00
Cs<>d}yQt|d<00>j<00>}|dkr3d}ni|dkrHd}nT|dkr]d}n?|d krrd
}n*|d kr<>d }n|d kr<>d}nt|d<00>}ttdd<00><00>}d|d}dt|<00>d}xU|D]M}|jd<00>dkr)|jd<00>dkr)|j|<00>q<>|j|<00>q<>W|j<00>tjj<00>dGHWn>t k
r<>} t
j j t| <00>d<17>dt| <00>dgSXdS(NitrsPHP 5.3i5sPHP 5.4i6sPHP 5.5i7sPHP 5.6i8sPHP 7.0iFsPHP 7.1iGRi<>i's, address UDS://tmp/lshttpd/s.sock
s/ path /usr/local/lsws/lsphps /bin/lsphp
2018-03-02 18:13:26 +05:00
s/usr/local/lsws/lsphpi<70><69><EFBFBD><EFBFBD>R#s1,Nones1 [IO Error with per host config file [changePHP]]( RRuRRRvR5R6tinstallUtilitiestreStartLiteSpeedR7RRR(
R8R"tfinalphpRwRxR<>RUR#R<>R,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pyt changePHP<48>s<             *
2017-12-14 06:56:27 -05:00
   cCs<>yttjddd|dg<00>j<00>d}td<00>t|<00>}t|<00>t|<00>}t|<00>t|<00>g}|SWn@tk
r<>}tjjt |<00>d<17>td<00>td<00>gSXdS(Ntsudotdus-hss--block-size=1Miids [getDiskUsage](
Rt check_outputRtfloattintR7RRRR(R#t totalAllowedttotalUsageInMBt
2018-03-02 18:13:26 +05:00
percentageRwR,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pyt getDiskUsage<67>s(c Cs,y<>tjd|d}t|d<00>j<00>}d|dd}d}d}d }d
2017-12-14 06:56:27 -05:00
}d }tj|<00>d krun<>t|d <00>} | jd<00>| jd<00>| j|<00>| j|<00>| j|<00>| j|<00>| j|<00>| j|<00>| j<00>Wn.tk
r'}
tj j
t |
2018-03-02 18:13:26 +05:00
<00>d<17>dSXd S(Ns /conf/vhosts/s /vhost.confR<66>srewriteFile /home/s/public_html/.htaccesss
2017-12-14 06:56:27 -05:00
s rewrite {
s enable 1
s' rules <<<END_rules
s END_rules
s}
2018-03-02 18:13:26 +05:00
itas1 [IO Error with per host config file [changePHP]]i( RRRRutcheckIfRewriteEnabledR5R6R7RRRR( RR#Rwt dataToWrittentrewritetenablestrulestendRulestendRxR,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pytaddRewriteRules<65>s2        cCsgy2x'|D]}|jd<00>dkr
2017-12-14 06:56:27 -05:00
dSq
WdSWn.tk
2018-03-02 18:13:26 +05:00
rb}tjjt|<00>d<17>dSXdS(Ns .htaccessi<73><69><EFBFBD><EFBFBD>iis= [IO Error with per host config file [checkIfRewriteEnabled]](RvR7RRRR(RwR<>R,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pyR<79>s  cCs^y)tjd|}tj||d<17>Wn.tk
rY}tjjt|<00>d<17>dSXdS(Ns /conf/vhosts/s
-suspendeds [suspendVirtualHost]ii( RRR<>RR7RRRR(RR&R,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pytsuspendVirtualHosts cCs^y)tjd|}tj|d|<00>Wn.tk
rY}tjjt|<00>d<17>dSXdS(Ns /conf/vhosts/s
-suspendeds [UnsuspendVirtualHost]ii( RRR<>RR7RRRR(RR&R,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pytUnsuspendVirtualHost$s c Cs<>y,d|d|d}tjjd|d<17>s;dGHnd|d}tjj|<00>scdGHntjj|<00>r&yqt|<00>j<00>}t|djd<00><00>}tt|<00>d<15>}td
2017-12-14 06:56:27 -05:00
<00>t|<00>}t|<00>t|<00>}Wn dGHnX|d kr
d
}nt|<00>d t|<00>GHndGHWnct k
r`}t
j j t|<00>d <17>dGHn2t k
r<>}t
j j t|<00>d <17>dGHnXdS(Ns/home/s/logs/s .access_logs/logss0,0s /logs/bwmetais
2018-03-02 18:13:26 +05:00
g<00>@idgY@t,s [findDomainBW]g0A(RR#R<>RRuR<>tstripR<70>RRRRRt
2017-12-14 06:56:27 -05:00
ValueError( t
2018-03-02 18:13:26 +05:00
domainNameR<65>R#tbwmetaRwt currentUsedtinMBR<42>R,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pyt findDomainBW2s4    (t__name__t
2017-12-14 06:56:27 -05:00
__module__Rt
2018-03-02 18:13:26 +05:00
cyberPanelt staticmethodR.RR<>R<>R<>R<>R<>R<>R<>R<>R<>R<>R<>R<>R<>(((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pyRs"e<0F>@'<0F>?81+c Cs@y<>tj|<00>dkr!dGHdSttjd<00>}tj||||<00>}|ddkr<>tj||<00>dt|d<19>GHdStj|<00>}|ddkr<>tj||<00>dt|d<19>GHn|dkr/t j j
2017-12-14 06:56:27 -05:00
<00>t j |||<00>}|ddkr/tj||<00>dt|d<19>GHdSnt j j
<00>t jdd|d<17>d |d
|d d|d} tj| <00>}
tj|
d |d tj<00>tjd} dd | } tj| <00>}
tj|
d |d tj<00>dGHWnLtk
r;} tj||<00>tjjt| <00>d<17>dt| <00>GHnXdS(Nis(0,Virtual Host Directory already exists!Ris0,s/usr/local/CyberCP/index.htmls/home/s/public_html/index.htmlschown R
2018-03-02 18:13:26 +05:00
R RRs /conf/vhostss chown -R R s1,Nones [createVirtualHost]schown -R lsadmschown -R lsadm:schown -R lsadm:lsadm(RR<>RRRR.R<>RR<>R<>R<>t sslUtilitiestissueSSLForDomainR<6E>tcopyRRRRRRR7RRR( RR R"R!R<>tssltsslPathR(t retValuesR)R*t vhostPathR,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pytcreateVirtualHost^sH   "   c CsBy<>tj|<00>dkr!dGHdSttjd<00>} tj||||||<00>}
2017-12-14 06:56:27 -05:00
|
ddkr<>tjt|<00>dt|
d<19>GHdStj||<00>}
|
ddkr<>tjt|<00>dt|
d<19>GHdSt j j
<00>|dkr9t j |||<00>}
|
ddkr9tj||<00>dt|
d<19>GHdSnt j j
<00>t jd|d<17>d|d |d
|d} tj| <00>} tj| d | d tj<00>tjd } dd
| } tj| <00>} tj| d | d tj<00>dGHWnLtk
r=}tj||<00>tjjt|<00>d<17>dt|<00>GHnXdS(Nis(0,Virtual Host Directory already exists!Ris0,s/usr/local/CyberCP/index.htmls /index.htmlschown R
2018-03-02 18:13:26 +05:00
R RRs /conf/vhostss chown -R R s1,Nones [createDomain]schown -R lsadmschown -R lsadm:schown -R lsadm:lsadm(RR<>RRRR<>R<>RR<>R<>R<>R<>R<>R<>R<>RRRRRRR7RRR(R<>RR"R#R R!trestartR<74>R<>R(R<>R)R*R<>R,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pyt createDomain<69>sJ      cCs<>yDttjd<00>}d|d}d|d}tjdd|}|d}|d}tjj|<00>r|tj|<00>ntjj|<00>r<>tj|<00>ntjj|<00>o<>tjj|<00>sZtj |||<00>} | ddkr<>dt
2017-12-14 06:56:27 -05:00
| d <19>GHdSt j j <00>tjd
}
dd|
} t j| <00>} tj| d|dtj<00>dGHdSytj|<00>Wn-tk
r<>} tjjt
| <00>d<17>nXd|d}d|d}tj||<00>tj||<00>tjj|<00>t j j <00>tjd
}
dd|
} t j| <00>} tj| d|dtj<00>dGHdSWn<tk
r<>} tjjt
| <00>d<17>dt
| <00>GHnXdS(NRs/etc/letsencrypt/live/s /privkey.pems/fullchain.pems /conf/vhosts/sSSL-is0,is /conf/vhostss chown -R R R
2018-03-02 18:13:26 +05:00
R RRs1,Nones; [Directory for SSL already exists.. Continuing [issueSSL]]s [issueSSL]schown -R lsadmschown -R lsadm:schown -R lsadm:lsadmschown -R lsadmschown -R lsadm:schown -R lsadm:lsadm(RRRRRR#R<>tremoveR<65>R<>RR<>R<>RRRRRtmkdirR7RRRR<>R<>tinstallSSLForDomain(RsR#t
2017-12-14 06:56:27 -05:00
adminEmailR(t
2018-03-02 18:13:26 +05:00
srcPrivKeyt srcFullChaintpathToStoreSSLtpathToStoreSSLPrivKeytpathToStoreSSLFullChainR<6E>R<>R)R*R,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pytissueSSL<53>sX
2017-12-14 06:56:27 -05:00

$      c
Cs<>y<>ttjdd|g<00>jd<00>d<19>}|dkrRtjd|g<00>}n-|dkr<>|}|d}|dkr<>d}nd t|<00>d
t|<00>d }d |d|}tjtj|<00>d tj<00>}|jj <00>}n<>||dd}|d}|dkrd}nd t|<00>d
t|<00>d }d |d|}tjtj|<00>d tj<00>}|jj <00>}|GHWn2t
k
2018-03-02 18:13:26 +05:00
r<>} t j j t| <00>d<17>dGHnXdS(Ntwcs-lR iitcatiit'R<>sp'ssed -n Rs [getAccessLogs]s1,None(R<>RR<>RRtPopenRtPIPERtreadR7RRR(
tfileNametpagetnumberOfTotalLinesRwR<>tstarttstartingAndEndingR)tprocR,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pyt getAccessLogs s4+  
2017-12-14 06:56:27 -05:00
  "!
  "!  c
Cs<>y<>ttjdd|g<00>jd<00>d<19>}|dkrRtjd|g<00>}n-|dkr<>|}|d}|dkr<>d}nd t|<00>d
t|<00>d }d |d|}tjtj|<00>d tj<00>}|jj <00>}n<>||dd}|d}|dkrd}nd t|<00>d
t|<00>d }d |d|}tjtj|<00>d tj<00>}|jj <00>}|GHWn2t
k
2018-03-02 18:13:26 +05:00
r<>} t j j t| <00>d<17>dGHnXdS(NR<4E>s-lR iiR<>iiR<>R<>sp'ssed -n Rs [getErrorLogs]s1,None(R<>RR<>RRR<>RR<>RR<>R7RRR(
R<>R<>R<>RwR<>R<>R<>R)R<>R,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pyt getErrorLogs-s4+  
2017-12-14 06:56:27 -05:00
  "!
  "!  cCs<>ymt|d<00>}|jt|d<00>j<00><00>|j<00>tjj|<00>rZtj|<00>ntjj <00>dGHWn<t
k
2018-03-02 18:13:26 +05:00
r<>}t j j t|<00>d<17>dt|<00>GHnXdS(NRR<>s1,Nones [saveVHostConfigs]s0,(RtwriteR<65>R6RR#R<>R<>R<>R<>R7RRRR(R<>ttempPathtvhostR,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pytsaveVHostConfigsMs
2017-12-14 06:56:27 -05:00
   cCs<>yztj|<00>t|d<00>}|jt|d<00>j<00><00>|j<00>tjj|<00>rgtj |<00>nt
j
j <00>dGHWn<t k
2018-03-02 18:13:26 +05:00
r<>}t jjt|<00>d<17>dt|<00>GHnXdS(NRR<>s1,Nones [saveRewriteRules]s0,(RR<>RR<>R<>R6RR#R<>R<>R<>R<>R7RRRR(RsR<>R<>R<>R,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pytsaveRewriteRulesbs 
   cCs[y}ttjd<00>}tjj|<00>s7tj|<00>ntj|<00>sIn dGHdStjjd<00>s<>d}tj|<00>}t j
|d|dt j <00>} nd|}tj|<00>}t j
|d|dt j <00>} tjjd<00>sd }tj|<00>}t j
|d|dt j <00>} nd
|}tj|<00>}t j
|d|dt j <00>} |}
x?tt |
d <00><00>D](} t t |
d | <00>t |
| <00><00>qlWt|
d <17>tj|d |d <17>tj|d <17>|d} t| d<00>j<00>} t| d<00>}d|dd}d|dd}d|dd}x<>| D]<5D>}|jd<00>dkr}|jd<00>dkr<>|j|<00>q<>q:|jd<00>dkr<>|jd<00>dkr<>|j|<00>q<>q:|jd<00>dkr<>|j|<00>q:|j|<00>q:W|j<00>tj| |d<17>d|d|dd|d }tj|<00>}t j
|d|dt j <00>} tj|<00>tjj<00>d!GHWn<57>tk
rV}ytj|<00>Wntjjd"<00>nXd|d#}tjj|<00>sCttjd<00>}tj|<00>d|d|d|}tj|<00>}t j
|d|dt j <00>} nd$t |<00>GHdSXdS(%NRsX0,Target directory should be empty before installation, otherwise data loss could occur.s latest.tar.gzsOwget --no-check-certificate http://wordpress.org/latest.tar.gz -O latest.tar.gzRRstar -xzvf latest.tar.gz -C slitespeed-cache.1.1.5.1.zips^wget --no-check-certificate https://downloads.wordpress.org/plugin/litespeed-cache.1.1.5.1.zips%unzip litespeed-cache.1.1.5.1.zip -d t wordpressslitespeed-caches"wp-content/plugins/litespeed-cacheswp-config-sample.phpR<70>sdefine('DB_NAME', 's');s
2017-12-14 06:56:27 -05:00
sdefine('DB_USER', 'sdefine('DB_PASSWORD', 'tDB_NAMEi<45><69><EFBFBD><EFBFBD>tdatabase_name_heretDB_USERt username_heret DB_PASSWORDs wp-config.phps chown -R R
2018-03-02 18:13:26 +05:00
R s/home/s /public_html/s1,Nonesshutil.rmtree(finalPath)s /public_htmls0,(!RRRR#R<>RRRRRRRRRRR<>tcopytreeR<65>RuRvR5R6trenameRR<>R<>R<>R7RRRR<>R(R<>t finalPathR!tdbNametdbUsert
dbPasswordR(R)R*R+troottfilenamet wpconfigfileRwRxt defDBNamet defDBUsert defDBPasswordR<64>R,thomeDir((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pytinstallWordPressys<>!
2017-12-14 06:56:27 -05:00
!
&
 
2018-03-02 18:13:26 +05:00
"    !c
%CsLynttjd<00>}
tjj|<00>s7tj|<00>ntj|<00>sIn dGHdStj|<00>tjjd<00>s<>d|} tj | <00>} t
j | d|
dt
j <00>} n dGHdSd|d |} tj | <00>} t
j | d|
dt
j <00>} tj |d<17>d
|d |} tj | <00>} t
j | d|
dt
j <00>} tj|d <17>tj|d |d<17>tj|d|d<17>tj|d|d<17>|d}t|d<00>j<00>}t|d<00>}tj<00>}d|dd}d|dd}d|dd}d|dd}d|dd}d|dd}d|dd}d| dd} xs|D]k}|jd <00>d!kr<>|j|<00>qm|jd"<00>d!kr<>|j|<00>qm|jd#<00>d!kr<>|j|<00>qm|jd$<00>d!kr|j|<00>qm|jd%<00>d!kr,|j|<00>qm|jd&<00>d!krQ|j|<00>qm|jd'<00>d!krv|j|<00>qm|jd(<00>d!kr<>|j| <00>qm|jd)<00>d!kr<>qm|jd*<00>d!kr<>qm|j|<00>qmW|j<00>t|d+d<00>}td,d<00>}x'|D]}|j|jd-|<00><00>qW|j<00>|j<00>t
jd.d/|d0||gd1t
jdt
j<00>}d2||||f}|jt|d,<17>j<00>d|<17>\}} tj|d3<17>d4}!t|dd5<00>}"|"j|!<00>|"j<00>d6|d7|d8d9|d:} tj | <00>} t
j | d|
dt
j <00>} tj|<00>t j j!<00>d;GHWn<57>t"k
rG}#ytj|<00>Wnt#j$j%d<<00>nXd9|d=}$tjj|$<00>s4ttjd<00>}
tj&|$<00>d6|d7|d8|$} tj | <00>} t
j | d|
dt
j <00>} nd>t'|#<00>GHdSXdS(?NRsX0,Target directory should be empty before installation, otherwise data loss could occur.s staging.zipsXwget --no-check-certificate https://github.com/joomla/joomla-cms/archive/staging.zip -P RRs0,File already existssunzip sstaging.zip -d scp -r sjoomla-cms-staging/. sjoomla-cms-stagings#installation/configuration.php-distsconfiguration.phpsrobots.txt.dists
robots.txts htaccess.txts .htaccessR<73>s public $user = 's';s
2017-12-14 06:56:27 -05:00
s public $db = 's public $password = 's public $secret = 's public $log_path = 'sadministrator/logs';s public $tmp_path = 'sadministrator/tmp';s public $dbprefix = 's public $sitename = 's public $user i<><69><EFBFBD><EFBFBD>spublic $password s public $db spublic $log_path spublic $tmp_path spublic $secret spublic $dbprefix spublic $sitename s/*s *s!installation/sql/mysql/joomla.sqls(installation/sql/mysql/joomlaInstall.sqls#__tmysqls --user=%ss --password=%ststdins<6E>INSERT INTO `%susers`
(`name`, `username`, `password`, `params`)
VALUES ('Administrator', '%s',
'%s', '');
INSERT INTO `%suser_usergroup_map` (`user_id`,`group_id`)
VALUES (LAST_INSERT_ID(),'8');t installations<6E>
<IfModule LiteSpeed>
RewriteEngine on
CacheLookup on
CacheDisable public /
RewriteCond %{REQUEST_METHOD} ^HEAD|GET$
RewriteCond %{ORG_REQ_URI} !/administrator
RewriteRule .* - [E=cache-control:max-age=120]
</IfModule>
sa+s chown -R R
2018-03-02 18:13:26 +05:00
R s/home/s /public_html/s1,Nonesshutil.rmtree(finalPath)s /public_htmls0,((RRRR#R<>RRtchdirRRRRRR<>R<>R<>R<>RutrandomPasswordt generate_passRvR5R6R<>treplaceR<65>R<>t communicateR-R<>RR<>R<>R<>R7RRRR<>R(%R<>R<>R!R<>R<>R<>tusernametpasswordtprefixtsitenameR(R)R*R+t
configfileRwRxtsecretR<74>R<>R<>t secretKeytlogPathttmpPathtdbprefixR<78>tf1tf2tlineR<65>t usercreationtoutterrt htaccessCachetfR,R<>((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pyt installJoomla<6C>s<> 
2017-12-14 06:56:27 -05:00
!
  
 

5-  
2018-03-02 18:13:26 +05:00
"    !cCs>y<>ttjd<00>}d|d}d|d}tjdd|}|d}|d}d}d} tjj|<00>r<>tj|<00>ntjj|<00>r<>tj|<00>ntjj|<00>r<>tj|<00>ntjj| <00>r<>tj| <00>nd |}
2017-12-14 06:56:27 -05:00
tjj|<00>otjj|<00>s<>tj ||
|<00>} | d
d
krXd t
| d <19>GHdSt j ||<00>t j || <00>d } t j| <00>} tj| <00>}tjd}dd|} t j| <00>} tj| d|dtj<00>dGHnytj|<00>Wn-tk
r*}tjjt
|<00>d<17>nXd|d}d|d}t j ||<00>t j ||<00>t j ||<00>t j || <00>d } t j| <00>} tj| <00>}tjd}dd|} t j| <00>} tj| d|dtj<00>dGHdSWn<tk
r9}tjjt
|<00>d<17>d t
|<00>GHnXdS(NRs/etc/letsencrypt/live/s /privkey.pems/fullchain.pems /conf/vhosts/sSSL-s/usr/local/lscp/key.pems/usr/local/lscp/cert.pemsemail@is0,issystemctl restart lscpds /conf/vhostss chown -R R R
2018-03-02 18:13:26 +05:00
R RRs1,NonesF [Directory for SSL already exists.. Continuing [issueSSLForHostName]]s [issueSSLForHostName]schown -R lsadmschown -R lsadm:schown -R lsadm:lsadmschown -R lsadmschown -R lsadm:schown -R lsadm:lsadm(RRRRRR#R<>R<>R<>R<>RR<>R<>RRRRRR<>R7RRR(RsR#R(R<>R<>R<>R<>R<>t destPrivKeytdestCertR<74>R<>R)R*R+R<>R,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pytissueSSLForHostName<6D>sp
2017-12-14 06:56:27 -05:00


$   c Cs_ytjj|<00>s%tj|<00>n|d}|d}t|d<00>}|jt|d<00>j<00><00>|j<00>t|d<00>}|jt|d<00>j<00><00>|j<00>|dkr<>tjj |<00>nt
j
j <00>ttj d<00>} d|}
t j|
<00>} tj| d
| d tj<00>d GHWn<tk
2018-03-02 18:13:26 +05:00
rZ} tjjt| <00>d <17>dt| <00>GHnXdS(Ns /privkey.pems/fullchain.pemRR<>t0schown R R
R RRs1,Nones [saveSSL]s0,s chown lsadms chown lsadm:schown lsadm:lsadmschown lsadm:lsadm (RR#R<>R<>RR<>R<>R6R<>R<>R<>R<>RRRRRRR7RRRR( RsR<>tkeyPathtcertPathR<68>R<>R<>tprivkeyt fullchainR(R)R*R,((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pytsaveSSL<53>s.
2017-12-14 06:56:27 -05:00



  
  c Cs<>tjdd<00>}|jddd<00>|jddd<00>|jddd <00>|jd
dd <00>|jd dd <00>|jddd<00>|jddd<00>|jddd<00>|jddd<00>|jddd<00>|jddd<00>|jddd<00>|jddd<00>|jddd<00>|jd dd!<00>|jd"dd#<00>|jd$dd%<00>|jd&dd'<00>|jd(dd)<00>|jd*dd+<00>|jd,dd-<00>|jd.dd/<00>|jd0dd1<00>|jd2dd3<00>|j<00>}|jd4kr5t|j|j|j|j t
|j <00>t
|j <00>|j <00>n<>|jd5krctj|jt
|j <00><00>np|jd6kr<>t|j|j|j|j|j|j |jt
|j <00>t
|j <00><00> n|jd7kr<>t|j|j|j<00>n<>|jd8krtj|j|j<00>n<>|jd9kr<t|jt
|j<00><00>n<>|jd:krgt|jt
|j<00><00>nl|jd;kr<>t|j|j<00>nG|jd<kr<>t|j|j|j<00>n|jd=kr<>t|j|j|j|j|j<00>n<>|jd>kr+t |j|j|j |j!|j"|j#<00>n<>|jd?kr<>t$|j|j|j |j!|j"|j#|j%|j&|j'|j(<00>
nS|jd@kr<>t)|j|j<00>n.|jdAkr<>tj*|jt
|j+<00><00>ndS(BNt descriptionsCyberPanel InstallertfunctionthelpsSpecific a function to call!s--virtualHostNames Domain name!s--administratorEmailsAdministration Email!s --phpVersions PHP Versions--virtualHostUsers'Virtual Host Directory Owner and Group!s--numberOfSitessNumber of sites!s--sslsWeather to activate SSLs --sslPathsPath to website document root!s--masterDomains2Master Domain Needed While Creating Child Domains!s--paths'Path Needed for Child domains Creation!s --restarts2OLS Restart Frequency while child domain creation!s--pagesPage number to fetch logs!s
--tempPaths2Temporary path where configuration data is placed!s --tempKeyPathsTemporary path to store key!s--tempCertPathsTemporary path to store cert!s
--sslChecks(Weather SSL is already activated or not!s--dbNamesDatabase Name!s--dbUsersDatabase User!s --dbPasswordsDatabase Password!s --bandwidthsPack Bandwidth!s
--usernamesAdmin Username!s
--passwordsAdmin Password!s--prefixsDatabase Prefix!s
--sitenames
2018-03-02 18:13:26 +05:00
Site Name!R<>R<>R<>R<>R<>R<>R<>R<>R<>RR<>RRR<>(,targparsetArgumentParsert add_argumentt
parse_argsRR<>RR R"R!R<>R<>R<>R<>RR<>R<>R<>R#R<>R<>R<>R<>R<>R<>R<>R<>R<>Rt tempKeyPatht tempCertPathR<68>R<>R<>R<>R<>RRRRRRR<>t bandwidth(tparsertargs((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pytmainsl @L(.Ft__main__(tos.pathRR<>RRRR!RR<>trandomRR<>RRRRR<>RR<>R<>R<>R<>R<>R<>R<>R<>RRRR*R<>(((s3/usr/local/CyberCP/plogical/virtualHostUtilities.pyt<module>s<         <13><00><00>Q 1 9 E   t <09> ` $ Q