Skip to content

Commit

Permalink
bug fix: incremental backups and upgrade process
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Oct 19, 2019
1 parent 8c706c0 commit 9863207
Show file tree
Hide file tree
Showing 6 changed files with 383 additions and 143 deletions.
486 changes: 358 additions & 128 deletions .idea/workspace.xml

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions IncBackups/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import time
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
from loginSystem.views import loadLoginPage
import stat
# Create your views here.


Expand Down Expand Up @@ -117,13 +118,15 @@ def addDestination(request):
tmpFile = '/home/cyberpanel/sshconfig'

writeToFile = open(tmpFile, 'w')
writeToFile.write(currentConfig)
if currentConfig.find('cat') == -1:
writeToFile.write(currentConfig)

content = """Host %s
IdentityFile ~/.ssh/cyberpanel
Port %s
""" % (ipAddress, port)
writeToFile.write(content)
IdentityFile ~/.ssh/cyberpanel
Port %s
""" % (ipAddress, port)
if currentConfig.find(ipAddress) == -1:
writeToFile.write(content)
writeToFile.close()


Expand Down Expand Up @@ -159,6 +162,8 @@ def addDestination(request):
writeToFile.write(AWS_SECRET_ACCESS_KEY)
writeToFile.close()

os.chmod(awsFile, stat.S_IRUSR | stat.S_IWUSR)

final_dic = {'status': 1}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
Expand Down
4 changes: 2 additions & 2 deletions install/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -3721,12 +3721,12 @@ def installRestic(self):
data = open(cronTab, 'r').read()

if data.find('IncScheduler') == -1:
cronJob = '0 12 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily'
cronJob = '0 12 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n'

writeToFile = open(cronTab, 'a')
writeToFile.writelines(cronJob)

cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily'
cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n'
writeToFile.writelines(cronJob)
writeToFile.close()

Expand Down
12 changes: 4 additions & 8 deletions plogical/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,10 @@ def setupVirtualEnv():
##

command = "pip install --ignore-installed -r /usr/local/CyberCP/requirments.txt"
Upgrade.executioner(command, 'CyberPanel requirements', 1)
Upgrade.executioner(command, 'CyberPanel requirements', 0)

command = "virtualenv --system-site-packages /usr/local/CyberCP"
Upgrade.executioner(command, 'Setting up VirtualEnv [Two]', 1)
Upgrade.executioner(command, 'Setting up VirtualEnv [Two]', 0)

Upgrade.stdOut('Virtual enviroment for CyberPanel successfully installed.')
except OSError, msg:
Expand Down Expand Up @@ -1276,9 +1276,6 @@ def downloadAndUpgrade(versionNumbring):

Upgrade.stdOut("Settings file backed up.")

if os.path.exists('/usr/local/CyberCP/bin'):
shutil.rmtree('/usr/local/CyberCP/bin')

## Extract Latest files

# command = "tar zxf CyberPanel.1.7.4.tar.gz"
Expand Down Expand Up @@ -1617,7 +1614,6 @@ def installPHP73():
command = 'cp /usr/local/lsws/lsphp71/bin/php /usr/bin/'
Upgrade.executioner(command, 'Set default PHP 7.0, 0')


@staticmethod
def someDirectories():
command = "mkdir -p /usr/local/lscpd/admin/"
Expand Down Expand Up @@ -1838,12 +1834,12 @@ def installRestic():
data = open(cronTab, 'r').read()

if data.find('IncScheduler') == -1:
cronJob = '0 12 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily'
cronJob = '0 12 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n'

writeToFile = open(cronTab, 'a')
writeToFile.writelines(cronJob)

cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily'
cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n'
writeToFile.writelines(cronJob)
writeToFile.close()

Expand Down
9 changes: 9 additions & 0 deletions preUpgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if [ ! -d "/usr/local/CyberPanel" ]; then
virtualenv --system-site-packages /usr/local/CyberPanel
source /usr/local/CyberPanel/bin/activate
rm -rf requirments.txt
wget https://raw.githubusercontent.com/usmannasir/cyberpanel/1.8.0/requirments.txt
pip install --ignore-installed -r requirments.txt
virtualenv --system-site-packages /usr/local/CyberPanel
fi

Empty file modified serverLogs/views.py
100644 → 100755
Empty file.

0 comments on commit 9863207

Please sign in to comment.