Skip to content

Commit

Permalink
Feature: Auto Request 15 days trial for LSWS Ent
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Sep 19, 2019
1 parent 6b59900 commit e7437af
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
19 changes: 9 additions & 10 deletions manageSSL/templates/manageSSL/manageSSL.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -48,21 +48,20 @@ <h3 class="content-box-header">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label"></label> <label class="col-sm-3 control-label"></label>
<div class="col-sm-6"> <div class="col-sm-6">
<div ng-hide="canNotIssue" class="alert alert-danger"> <div ng-hide="canNotIssue" class="alert alert-danger">
<p>{% trans "Cannot issue SSL. Error message:" %} {$ errorMessage $}</p> <p>{% trans "Cannot issue SSL. Error message:" %} {$ errorMessage $}</p>
</div> </div>


<div ng-hide="sslIssued" class="alert alert-success"> <div ng-hide="sslIssued" class="alert alert-success">
<p>{% trans "SSL Issued for" %} <strong>{$ sslDomain $}</strong></p> <p>{% trans "SSL Issued for" %} <strong>{$ sslDomain $}</strong></p>
</div> </div>


<div ng-hide="couldNotConnect" class="alert alert-danger"> <div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p> <p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div> </div>
</div> </div>





</div> </div>




Expand Down
15 changes: 12 additions & 3 deletions serverStatus/serverStatusUtil.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -61,13 +61,22 @@ def installLiteSpeed(licenseKey, statusFile):
if ServerStatusUtil.executioner(command, statusFile) == 0: if ServerStatusUtil.executioner(command, statusFile) == 0:
return 0 return 0


if os.path.exists('/usr/local/CyberCP/lsws-5.3.8/'):
shutil.rmtree('/usr/local/CyberCP/lsws-5.3.8')


command = 'tar zxf lsws-5.3.8-ent-x86_64-linux.tar.gz -C /usr/local/CyberCP' command = 'tar zxf lsws-5.3.8-ent-x86_64-linux.tar.gz -C /usr/local/CyberCP'
if ServerStatusUtil.executioner(command, statusFile) == 0: if ServerStatusUtil.executioner(command, statusFile) == 0:
return 0 return 0


writeSerial = open('/usr/local/CyberCP/lsws-5.3.8/serial.no', 'w') if licenseKey == 'trial':
writeSerial.writelines(licenseKey) command = 'wget -q --output-document=/usr/local/CyberCP/lsws-5.3.8/trial.key http://license.litespeedtech.com/reseller/trial.key'
writeSerial.close() if ServerStatusUtil.executioner(command, statusFile) == 0:
return 0
else:
writeSerial = open('/usr/local/CyberCP/lsws-5.3.8/serial.no', 'w')
writeSerial.writelines(licenseKey)
writeSerial.close()


shutil.copy('/usr/local/CyberCP/serverStatus/litespeed/install.sh', '/usr/local/CyberCP/lsws-5.3.8/') shutil.copy('/usr/local/CyberCP/serverStatus/litespeed/install.sh', '/usr/local/CyberCP/lsws-5.3.8/')
shutil.copy('/usr/local/CyberCP/serverStatus/litespeed/functions.sh', '/usr/local/CyberCP/lsws-5.3.8/') shutil.copy('/usr/local/CyberCP/serverStatus/litespeed/functions.sh', '/usr/local/CyberCP/lsws-5.3.8/')
Expand Down
17 changes: 17 additions & 0 deletions serverStatus/templates/serverStatus/litespeedStatus.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -158,8 +158,25 @@ <h3 class="content-box-header">
<div class="col-sm-4"> <div class="col-sm-4">
<button type="button" ng-click="switchTOLSWS()" <button type="button" ng-click="switchTOLSWS()"
class="btn btn-primary btn-lg">{% trans "Switch" %}</button> class="btn btn-primary btn-lg">{% trans "Switch" %}</button>
<button type="button" ng-click="switchTOLSWS()"
class="btn btn-primary btn-lg">{% trans "Get 15 Days Trial" %}</button>


</div> </div>
<div class="col-sm-4">


</div>
</div>

<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-6">
<div class="alert alert-info">
<p>{% trans "Note: If you select 15 days trial there is no need to enter the serial key, CyberPanel will auto fetch 15 days trial key for you. Make sure this server have not used trial already." %}</p>
</div>
</div>


</div> </div>


</form> </form>
Expand Down
7 changes: 6 additions & 1 deletion serverStatus/views.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -343,8 +343,13 @@ def switchTOLSWS(request):


data = json.loads(request.body) data = json.loads(request.body)


try:
licenseKey = data['licenseKey']
except:
licenseKey = 'trial'

execPath = "sudo /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/serverStatus/serverStatusUtil.py" execPath = "sudo /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/serverStatus/serverStatusUtil.py"
execPath = execPath + " switchTOLSWS --licenseKey " + data['licenseKey'] execPath = execPath + " switchTOLSWS --licenseKey " + licenseKey


ProcessUtilities.popenExecutioner(execPath) ProcessUtilities.popenExecutioner(execPath)
time.sleep(2) time.sleep(2)
Expand Down

0 comments on commit e7437af

Please sign in to comment.