Skip to content

Commit 9863207

Browse files
committed
bug fix: incremental backups and upgrade process
1 parent 8c706c0 commit 9863207

6 files changed

Lines changed: 383 additions & 143 deletions

File tree

.idea/workspace.xml

Lines changed: 358 additions & 128 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

IncBackups/views.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import time
1717
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
1818
from loginSystem.views import loadLoginPage
19+
import stat
1920
# Create your views here.
2021

2122

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

119120
writeToFile = open(tmpFile, 'w')
120-
writeToFile.write(currentConfig)
121+
if currentConfig.find('cat') == -1:
122+
writeToFile.write(currentConfig)
121123

122124
content = """Host %s
123-
IdentityFile ~/.ssh/cyberpanel
124-
Port %s
125-
""" % (ipAddress, port)
126-
writeToFile.write(content)
125+
IdentityFile ~/.ssh/cyberpanel
126+
Port %s
127+
""" % (ipAddress, port)
128+
if currentConfig.find(ipAddress) == -1:
129+
writeToFile.write(content)
127130
writeToFile.close()
128131

129132

@@ -159,6 +162,8 @@ def addDestination(request):
159162
writeToFile.write(AWS_SECRET_ACCESS_KEY)
160163
writeToFile.close()
161164

165+
os.chmod(awsFile, stat.S_IRUSR | stat.S_IWUSR)
166+
162167
final_dic = {'status': 1}
163168
final_json = json.dumps(final_dic)
164169
return HttpResponse(final_json)

install/install.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3721,12 +3721,12 @@ def installRestic(self):
37213721
data = open(cronTab, 'r').read()
37223722

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

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

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

plogical/upgrade.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,10 @@ def setupVirtualEnv():
435435
##
436436

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

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

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

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

1279-
if os.path.exists('/usr/local/CyberCP/bin'):
1280-
shutil.rmtree('/usr/local/CyberCP/bin')
1281-
12821279
## Extract Latest files
12831280

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

1620-
16211617
@staticmethod
16221618
def someDirectories():
16231619
command = "mkdir -p /usr/local/lscpd/admin/"
@@ -1838,12 +1834,12 @@ def installRestic():
18381834
data = open(cronTab, 'r').read()
18391835

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

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

1846-
cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily'
1842+
cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n'
18471843
writeToFile.writelines(cronJob)
18481844
writeToFile.close()
18491845

preUpgrade.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
if [ ! -d "/usr/local/CyberPanel" ]; then
2+
virtualenv --system-site-packages /usr/local/CyberPanel
3+
source /usr/local/CyberPanel/bin/activate
4+
rm -rf requirments.txt
5+
wget https://raw.githubusercontent.com/usmannasir/cyberpanel/1.8.0/requirments.txt
6+
pip install --ignore-installed -r requirments.txt
7+
virtualenv --system-site-packages /usr/local/CyberPanel
8+
fi
9+

serverLogs/views.py

100644100755
File mode changed.

0 commit comments

Comments
 (0)