mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-08-09 19:37:59 +02:00
Merge branch 'v2.0.1' of https://github.com/usmannasir/cyberpanel into v2.0.1
This commit is contained in:
353
CPScripts/mailscannerinstaller.sh
Normal file
353
CPScripts/mailscannerinstaller.sh
Normal file
@@ -0,0 +1,353 @@
|
||||
#!/bin/bash
|
||||
#systemctl stop firewalld
|
||||
|
||||
echo 'backup configs';
|
||||
cp /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf-bak_$(date '+%Y-%m-%d_%H_%M:%S');
|
||||
cp /etc/postfix/master.cf /etc/postfix/master.cf-bak_$(date '+%Y-%m-%d_%H_%M:%S');
|
||||
cp /etc/postfix/main.cf /etc/postfix/main.cf-bak_$(date '+%Y-%m-%d_%H_%M:%S');
|
||||
cp /etc/dovecot/dovecot-sql.conf.ext /etc/dovecot/dovecot-sql.conf.ext-bak_$(date '+%Y-%m-%d_%H_%M:%S')
|
||||
|
||||
|
||||
ZONE=$(firewall-cmd --get-default-zone)
|
||||
firewall-cmd --zone=$ZONE --add-port=4190/tcp --permanent
|
||||
systemctl stop firewalld
|
||||
|
||||
echo 'Stop CSF'
|
||||
csf -x
|
||||
|
||||
MAILSCANNER=/etc/MailScanner
|
||||
|
||||
if [ -d $MAILSCANNER ];then
|
||||
|
||||
echo "MailScanner found. If you wish to reinstall then remove the package and revert"
|
||||
echo "Postfix back to its original config at /etc/postfix/main.cf and remove"
|
||||
echo "/etc/MailScanner and /usr/share/MailScanner directories"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -f /etc/os-release ];then
|
||||
OS=$(head -1 /etc/os-release)
|
||||
UBUNTUVERSION=$(sed '6q;d' /etc/os-release)
|
||||
CENTOSVERSION=$(sed '5q;d' /etc/os-release)
|
||||
fi
|
||||
|
||||
if [ "$CENTOSVERSION" = "VERSION_ID=\"7\"" ];then
|
||||
|
||||
setenforce 0
|
||||
yum install -y perl yum-utils perl-CPAN
|
||||
yum install -y gcc cpp perl bzip2 zip make patch automake rpm-build perl-Archive-Zip perl-Filesys-Df perl-OLE-Storage_Lite perl-Sys-Hostname-Long perl-Sys-SigAction perl-Net-CIDR perl-DBI perl-MIME-tools perl-DBD-SQLite binutils glibc-devel perl-Filesys-Df zlib unzip zlib-devel wget mlocate clamav "perl(DBD::mysql)"
|
||||
|
||||
rpm -Uvh https://forensics.cert.org/centos/cert/7/x86_64/unrar-5.4.0-1.el7.x86_64.rpm
|
||||
export PERL_MM_USE_DEFAULT=1
|
||||
curl -L https://cpanmin.us | perl - App::cpanminus
|
||||
cpanm Encoding::FixLatin
|
||||
cpanm Digest::SHA1
|
||||
cpanm Geo::IP
|
||||
cpanm Razor2::Client::Agent
|
||||
cpanm Net::Patricia
|
||||
|
||||
freshclam -v
|
||||
DIR=/etc/mail/spamassassin
|
||||
|
||||
if [ -d "$DIR" ]; then
|
||||
sa-update
|
||||
|
||||
else
|
||||
|
||||
echo "Please install spamassassin through the CyberPanel interface before proceeding"
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
elif [ "$CENTOSVERSION" = "VERSION_ID=\"8\"" ];then
|
||||
|
||||
setenforce 0
|
||||
yum install -y perl yum-utils perl-CPAN
|
||||
dnf --enablerepo=PowerTools install -y perl-IO-stringy
|
||||
yum install -y gcc cpp perl bzip2 zip make patch automake rpm-build perl-Archive-Zip perl-Filesys-Df perl-OLE-Storage_Lite perl-Net-CIDR perl-DBI perl-MIME-tools perl-DBD-SQLite binutils glibc-devel perl-Filesys-Df zlib unzip zlib-devel wget mlocate clamav clamav-update "perl(DBD::mysql)"
|
||||
|
||||
rpm -Uvh https://forensics.cert.org/centos/cert/8/x86_64/unrar-5.4.0-1.el8.x86_64.rpm
|
||||
|
||||
export PERL_MM_USE_DEFAULT=1
|
||||
curl -L https://cpanmin.us | perl - App::cpanminus
|
||||
cpanm Encoding::FixLatin
|
||||
cpanm Digest::SHA1
|
||||
cpanm Geo::IP
|
||||
cpanm Razor2::Client::Agent
|
||||
cpanm Sys::Hostname::Long
|
||||
cpanm Sys::SigAction
|
||||
|
||||
freshclam -v
|
||||
|
||||
DIR=/etc/mail/spamassassin
|
||||
|
||||
if [ -d "$DIR" ]; then
|
||||
sa-update
|
||||
|
||||
else
|
||||
|
||||
echo "Please install spamassassin through the CyberPanel interface before proceeding"
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
elif [ "$OS" = "NAME=\"Ubuntu\"" ];then
|
||||
|
||||
apt-get install -y libmysqlclient-dev
|
||||
|
||||
apt-get install -y cpanminus gcc perl bzip2 zip make patch automake rpm libarchive-zip-perl libfilesys-df-perl libole-storage-lite-perl libsys-hostname-long-perl libsys-sigaction-perl libregexp-common-net-cidr-perl libmime-tools-perl libdbd-sqlite3-perl binutils build-essential libfilesys-df-perl zlib1g unzip mlocate clamav libdbd-mysql-perl unrar libclamav-dev libclamav-client-perl libclamunrar9
|
||||
|
||||
cpanm Encoding::FixLatin
|
||||
cpanm Digest::SHA1
|
||||
cpanm Geo::IP
|
||||
cpanm Razor2::Client::Agent
|
||||
cpanm Net::Patricia
|
||||
cpanm Net::CIDR
|
||||
|
||||
sudo systemctl stop clamav-freshclam.service
|
||||
|
||||
freshclam
|
||||
|
||||
sudo systemctl start clamav-freshclam.service
|
||||
|
||||
DIR=/etc/spamassassin
|
||||
if [ -d "$DIR" ]; then
|
||||
|
||||
apt-get -y install razor pyzor libencode-detect-perl libgeo-ip-perl libnet-patricia-perl
|
||||
sa-update
|
||||
else
|
||||
echo "Please install spamassassin through the CyberPanel interface before proceeding"
|
||||
exit
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
echo "header_checks = regexp:/etc/postfix/header_checks" >> /etc/postfix/main.cf
|
||||
echo "/^Received:/ HOLD" >> /etc/postfix/header_checks
|
||||
|
||||
systemctl restart postfix
|
||||
|
||||
wget https://github.com/MailScanner/v5/archive/master.zip
|
||||
unzip master.zip
|
||||
|
||||
cd /usr/local/CyberCP/CPScripts/v5-master/builds
|
||||
|
||||
if [ "$OS" = "NAME=\"Ubuntu\"" ];then
|
||||
|
||||
dpkg -i *.noarch.deb
|
||||
|
||||
mkdir /var/run/MailScanner
|
||||
mkdir /var/lock/subsys
|
||||
mkdir /var/lock/subsys/MailScanner
|
||||
chown -R postfix:postfix /var/run/MailScanner
|
||||
chown -R postfix:postfix /var/lock/subsys/MailScanner
|
||||
chown -R postfix:postfix /var/spool/MailScanner
|
||||
|
||||
elif [ "$OS" = "NAME=\"CentOS Linux\"" ];then
|
||||
|
||||
rpm -Uvh *.rhel.noarch.rpm
|
||||
|
||||
fi
|
||||
|
||||
mkdir /var/spool/MailScanner/spamassassin
|
||||
|
||||
chown postfix.mtagroup /var/spool/MailScanner/spamassassin
|
||||
chown root.mtagroup /var/spool/MailScanner/incoming/
|
||||
chown postfix.mtagroup /var/spool/MailScanner/milterin
|
||||
chown postfix.mtagroup /var/spool/MailScanner/milterout
|
||||
chown postfix.mtagroup /var/spool/postfix/hold
|
||||
chown postfix.mtagroup /var/spool/postfix/incoming
|
||||
usermod -a -G mtagroup nobody
|
||||
|
||||
chmod g+rx /var/spool/postfix/incoming
|
||||
chmod g+rx /var/spool/postfix/hold
|
||||
chmod -R 0775 /var/spool/postfix/incoming
|
||||
chmod -R 0775 /var/spool/postfix/hold
|
||||
|
||||
sed -i 's/^Run As User =.*/& postfix/' /etc/MailScanner/MailScanner.conf
|
||||
sed -i 's/^Run As Group =.*/& postfix/' /etc/MailScanner/MailScanner.conf
|
||||
sed -i 's/^Incoming Queue Dir =.*/Incoming Queue Dir = \/var\/spool\/postfix\/hold/' /etc/MailScanner/MailScanner.conf
|
||||
sed -i 's/^Outgoing Queue Dir =.*/Outgoing Queue Dir = \/var\/spool\/postfix\/incoming/' /etc/MailScanner/MailScanner.conf
|
||||
sed -i 's/^MTA =.*/MTA = postfix/' /etc/MailScanner/MailScanner.conf
|
||||
sed -i 's/^Quarantine User =.*/& postfix/' /etc/MailScanner/MailScanner.conf
|
||||
sed -i 's/^Quarantine Group =.*/& mtagroup/' /etc/MailScanner/MailScanner.conf
|
||||
sed -i 's/^Quarantine Permissions =.*/Quarantine Permissions = 640/' /etc/MailScanner/MailScanner.conf
|
||||
sed -i 's/^Virus Scanners =.*/Virus Scanners = clamav/' /etc/MailScanner/MailScanner.conf
|
||||
sed -i 's/^Is Definitely Not Spam =.*/Is Definitely Not Spam = \&SQLWhitelist/' /etc/MailScanner/MailScanner.conf
|
||||
sed -i 's/^Is Definitely Spam =.*/Is Definitely Spam = \&SQLBlacklist/' /etc/MailScanner/MailScanner.conf
|
||||
sed -i 's/^SpamAssassin User State Dir =.*/& \/var\/spool\/MailScanner\/spamassassin/' /etc/MailScanner/MailScanner.conf
|
||||
sed -i 's/^Always Looked Up Last =.*/Always Looked Up Last = \&MailWatchLogging/' /etc/MailScanner/MailScanner.conf
|
||||
sed -i 's/^Quarantine Whole Message =.*/Quarantine Whole Message = yes/' /etc/MailScanner/MailScanner.conf
|
||||
sed -i 's/^Spam List =.*/Spam List = SBL + XBL/' /etc/MailScanner/MailScanner.conf
|
||||
|
||||
mkdir /usr/local/CyberCP/public/mailwatch
|
||||
|
||||
cd /usr/local/CyberCP/public/mailwatch
|
||||
|
||||
git clone --depth=1 https://github.com/mailwatch/MailWatch.git --branch 1.2 --single-branch
|
||||
|
||||
mv /usr/local/CyberCP/public/mailwatch/MailWatch/* /usr/local/CyberCP/public/mailwatch/
|
||||
|
||||
PASSWORD=$(cat /etc/cyberpanel/mysqlPassword)
|
||||
USER=root
|
||||
DATABASE=mailscanner
|
||||
ADMINPASS=$(cat /etc/cyberpanel/adminPass)
|
||||
mysql -u${USER} -p${PASSWORD} < "/usr/local/CyberCP/public/mailwatch/create.sql"
|
||||
mysql -u${USER} -p${PASSWORD} -e "use mailscanner";
|
||||
mysql -u${USER} -D${DATABASE} -p${PASSWORD} -e "GRANT ALL ON mailscanner.* TO root@localhost IDENTIFIED BY '${PASSWORD}';"
|
||||
mysql -u${USER} -D${DATABASE} -p${PASSWORD} -e "FLUSH PRIVILEGES;"
|
||||
mysql -u${USER} -D${DATABASE} -p${PASSWORD} -e "INSERT INTO mailscanner.users SET username = 'admin', password = MD5('${ADMINPASS}'), fullname = 'admin', type = 'A';"
|
||||
|
||||
cp /usr/local/CyberCP/public/mailwatch/mailscanner/conf.php.example /usr/local/CyberCP/public/mailwatch/mailscanner/conf.php
|
||||
|
||||
sed -i "s/^define('DB_USER',.*/define('DB_USER','root');/" /usr/local/CyberCP/public/mailwatch/mailscanner/conf.php
|
||||
sed -i "s/^define('DB_PASS',.*/define('DB_PASS','${PASSWORD}');/" /usr/local/CyberCP/public/mailwatch/mailscanner/conf.php
|
||||
sed -i "s/^define('MAILWATCH_HOME',.*/define(\'MAILWATCH_HOME\', \'\/usr\/local\/CyberCP\/public\/mailwatch\/mailscanner');/" /usr/local/CyberCP/public/mailwatch/mailscanner/conf.php
|
||||
|
||||
MSDEFAULT=/etc/MailScanner/defaults
|
||||
if [ -f "$MSDEFAULT" ];then
|
||||
sed -i 's/^run_mailscanner=.*/run_mailscanner=1/' /etc/MailScanner/defaults
|
||||
elif [ ! -f "$MSDEFAULT" ];then
|
||||
touch /etc/MailScanner/defaults
|
||||
echo "run_mailscanner=1" >> /etc/MailScanner/defaults
|
||||
fi
|
||||
|
||||
cp /usr/local/CyberCP/public/mailwatch/MailScanner_perl_scripts/MailWatchConf.pm /usr/share/MailScanner/perl/custom/
|
||||
sed -i 's/^my (\$db_user) = .*/my (\$db_user) = \x27'${USER}'\x27;/' /usr/share/MailScanner/perl/custom/MailWatchConf.pm
|
||||
sed -i 's/^my (\$db_pass) = .*/my (\$db_pass) = \x27'${PASSWORD}'\x27;/' /usr/share/MailScanner/perl/custom/MailWatchConf.pm
|
||||
ln -s /usr/local/CyberCP/public/mailwatch/MailScanner_perl_scripts/MailWatch.pm /usr/share/MailScanner/perl/custom
|
||||
ln -s /usr/local/CyberCP/public/mailwatch/MailScanner_perl_scripts/SQLBlackWhiteList.pm /usr/share/MailScanner/perl/custom
|
||||
ln -s /usr/local/CyberCP/public/mailwatch/MailScanner_perl_scripts/SQLSpamSettings.pm /usr/share/MailScanner/perl/custom
|
||||
sed -i "s/^\$pathToFunctions =.*/\$pathToFunctions = '\/usr\/local\/CyberCP\/public\/mailwatch\/mailscanner\/functions.php';/" /usr/local/CyberCP/public/mailwatch/upgrade.php
|
||||
|
||||
/usr/local/lsws/lsphp72/bin/php /usr/local/CyberCP/public/mailwatch/upgrade.php
|
||||
systemctl enable mailscanner
|
||||
systemctl restart mailscanner
|
||||
|
||||
IPADDRESS=$(cat /etc/cyberpanel/machineIP)
|
||||
|
||||
|
||||
echo 'Setting up spamassassin and sieve to deliver spam to Junk folder by default'
|
||||
#echo "If you wish mailscanner/spamassassin to send spam email to a spam folder please follow the tutorial on the Cyberpanel Website"
|
||||
echo 'Fix protocols'
|
||||
sed -i 's/^protocols =.*/protocols = imap pop3 lmtp sieve/g' /etc/dovecot/dovecot.conf
|
||||
|
||||
|
||||
sed -i "s|^user_query.*|user_query = SELECT '5000' as uid, '5000' as gid, '/home/vmail/%d/%n' as home,mail FROM e_users WHERE email='%u';|g" /etc/dovecot/dovecot-sql.conf.ext
|
||||
|
||||
if [ "$OS" = "NAME=\"Ubuntu\"" ];then
|
||||
if [ "$UBUNTUVERSION" = "VERSION_ID=\"18.04\"" ];then
|
||||
apt-get install -y dovecot-managesieved dovecot-sieve dovecot-lmtpd net-tools pflogsumm
|
||||
elif [ "$UBUNTUVERSION" = "VERSION_ID=\"20.04\"" ];then
|
||||
apt-get install -y libmysqlclient-dev
|
||||
sed -e '/deb/ s/^#*/#/' -i /etc/apt/sources.list.d/dovecot.list
|
||||
apt install -y dovecot-lmtpd dovecot-managesieved dovecot-sieve net-tools pflogsumm
|
||||
fi
|
||||
|
||||
elif [ "$CENTOSVERSION" = "VERSION_ID=\"7\"" ];then
|
||||
|
||||
yum install -y nano net-tools dovecot-pigeonhole postfix-perl-scripts
|
||||
|
||||
elif [ "$CENTOSVERSION" = "VERSION_ID=\"8\"" ];then
|
||||
|
||||
rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-11.gf.el8.noarch.rpm
|
||||
dnf --enablerepo=gf-plus upgrade -y dovecot23*
|
||||
dnf --enablerepo=gf-plus install -y dovecot23-pigeonhole
|
||||
dnf install -y net-tools postfix-perl-scripts
|
||||
|
||||
fi
|
||||
|
||||
|
||||
# Create Sieve files
|
||||
mkdir -p /etc/dovecot/sieve/global
|
||||
touch /var/log/{dovecot-lda-errors.log,dovecot-lda.log}
|
||||
touch /var/log/{dovecot-sieve-errors.log,dovecot-sieve.log}
|
||||
touch /var/log/{dovecot-lmtp-errors.log,dovecot-lmtp.log}
|
||||
touch /etc/dovecot/sieve/default.sieve
|
||||
chown vmail: -R /etc/dovecot/sieve
|
||||
chown vmail:mail /var/log/dovecot-*
|
||||
|
||||
echo 'Create Sieve Default spam to Junk rule'
|
||||
cat >> /etc/dovecot/sieve/default.sieve <<EOL
|
||||
require "fileinto";
|
||||
if header :contains "X-Spam-Flag" "YES" {
|
||||
fileinto "INBOX.Junk E-mail";
|
||||
}
|
||||
EOL
|
||||
|
||||
|
||||
echo "Adding Sieve to /etc/dovecot/dovecot.conf"
|
||||
cat >> /etc/dovecot/dovecot.conf <<EOL
|
||||
|
||||
service managesieve-login {
|
||||
inet_listener sieve {
|
||||
port = 4190
|
||||
}
|
||||
}
|
||||
service managesieve {
|
||||
}
|
||||
protocol sieve {
|
||||
managesieve_max_line_length = 65536
|
||||
managesieve_implementation_string = dovecot
|
||||
log_path = /var/log/dovecot-sieve-errors.log
|
||||
info_log_path = /var/log/dovecot-sieve.log
|
||||
}
|
||||
plugin {
|
||||
sieve = /home/vmail/%d/%n/dovecot.sieve
|
||||
sieve_global_path = /etc/dovecot/sieve/default.sieve
|
||||
sieve_dir = /home/vmail/%d/%n/sieve
|
||||
sieve_global_dir = /etc/dovecot/sieve/global/
|
||||
}
|
||||
protocol lda {
|
||||
mail_plugins = $mail_plugins sieve quota
|
||||
postmaster_address = postmaster@example.com
|
||||
hostname = server.example.com
|
||||
auth_socket_path = /var/run/dovecot/auth-master
|
||||
log_path = /var/log/dovecot-lda-errors.log
|
||||
info_log_path = /var/log/dovecot-lda.log
|
||||
}
|
||||
protocol lmtp {
|
||||
mail_plugins = $mail_plugins sieve quota
|
||||
log_path = /var/log/dovecot-lmtp-errors.log
|
||||
info_log_path = /var/log/dovecot-lmtp.log
|
||||
}
|
||||
EOL
|
||||
|
||||
hostname=$(hostname);
|
||||
|
||||
echo 'Fix postmaster email in sieve'
|
||||
postmaster_address=$(grep postmaster_address /etc/dovecot/dovecot.conf | sed 's/.*=//' |sed -e 's/^[ \t]*//'| sort -u)
|
||||
|
||||
sed -i "s|postmaster@example.com|$postmaster_address|g" /etc/dovecot/dovecot.conf
|
||||
sed -i "s|server.example.com|$hostname|g" /etc/dovecot/dovecot.conf
|
||||
sed -i "s|postmaster@example.com|$postmaster_address|g" /etc/dovecot/dovecot.conf
|
||||
|
||||
#Sieve the global spam filter
|
||||
sievec /etc/dovecot/sieve/default.sieve
|
||||
|
||||
#Sieve the global spam filter
|
||||
sievec /etc/dovecot/sieve/default.sieve
|
||||
|
||||
if [ "$OS" = "NAME=\"Ubuntu\"" ];then
|
||||
sed -i 's|^spamassassin.*|spamassassin unix - n n - - pipe flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -f -e /usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}|g' /etc/postfix/master.cf
|
||||
|
||||
elif [ "$OS" = "NAME=\"CentOS Linux\"" ];then
|
||||
sed -i 's|^spamassassin.*|spamassassin unix - n n - - pipe flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -f -e /usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}|g' /etc/postfix/master.cf
|
||||
|
||||
fi
|
||||
|
||||
|
||||
echo 'Restart and check services are up'
|
||||
systemctl restart dovecot && systemctl restart postfix && systemctl restart spamassassin;
|
||||
|
||||
csf -e
|
||||
|
||||
echo "MailScanner successfully installed. MailWatch successfully installed."
|
||||
echo "Visit https://${IPADDRESS}:8090/mailwatch/mailscanner"
|
||||
echo "Username: admin"
|
||||
echo "Password: ${ADMINPASS}"
|
||||
#echo "If you wish mailscanner/spamassassin to send spam email to a spam folder please follow the tutorial on the Cyberpanel Website"
|
||||
echo "Firewalld is stopped. Either enable, install CSF or use an alternative!"
|
||||
echo "Optional cpan/cpanm modules are available for MailScanner. Cronjobs and further postfix tools are available for MailWatch"
|
||||
echo "See https://www.mailwatch.org and https://docs.mailwatch.org/install/optional-setup.html"
|
||||
exit
|
||||
@@ -73,7 +73,7 @@ class secMiddleware:
|
||||
or key == 'imageByPass' or key == 'passwordByPass' or key == 'cronCommand' \
|
||||
or key == 'emailMessage' or key == 'configData' or key == 'rewriteRules' \
|
||||
or key == 'modSecRules' or key == 'recordContentTXT' or key == 'SecAuditLogRelevantStatus' \
|
||||
or key == 'fileContent' or key == 'commands':
|
||||
or key == 'fileContent' or key == 'commands' or key == 'gitHost':
|
||||
continue
|
||||
if value.find(';') > -1 or value.find('&&') > -1 or value.find('|') > -1 or value.find('...') > -1 \
|
||||
or value.find("`") > -1 or value.find("$") > -1 or value.find("(") > -1 or value.find(")") > -1 \
|
||||
|
||||
@@ -122,7 +122,8 @@ class IncJobs(multi.Thread):
|
||||
|
||||
def findRestorePath(self):
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8 \
|
||||
or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
self.restoreTarget = '/'
|
||||
return 1
|
||||
else:
|
||||
|
||||
@@ -100,10 +100,16 @@ def addDestination(request):
|
||||
|
||||
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
|
||||
execPath = execPath + " submitDestinationCreation --ipAddress " + ipAddress + " --password " \
|
||||
+ password + " --port " + port
|
||||
+ password + " --port " + port + ' --user %s' % ('root')
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(execPath)
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(output)
|
||||
|
||||
if output.find('1,') > -1:
|
||||
|
||||
content = '%s\n%s' % (ipAddress, port)
|
||||
|
||||
@@ -7,15 +7,13 @@
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Terminal" %} - <a target="_blank" href="https://cyberpanel.net/docs/web-terminal/"
|
||||
style="height: 23px;line-height: 21px;"
|
||||
class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>{% trans "Web Terminal Docs" %}</span></a></h2>
|
||||
style="height: 23px;line-height: 21px;"
|
||||
class="btn btn-border btn-alt border-red btn-link font-red"
|
||||
title=""><span>{% trans "Web Terminal Docs" %}</span></a></h2>
|
||||
<p>{% trans "Execute your terminal commands." %}</p>
|
||||
</div>
|
||||
|
||||
@@ -50,5 +48,4 @@
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -593,7 +593,6 @@ def runAWSBackups(request):
|
||||
except BaseException as msg:
|
||||
logging.writeToFile(str(msg) + ' [API.runAWSBackups]')
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
def submitUserCreation(request):
|
||||
try:
|
||||
|
||||
@@ -9,7 +9,7 @@ django.setup()
|
||||
import json
|
||||
from plogical.acl import ACLManager
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from websiteFunctions.models import Websites, Backups, dest, backupSchedules
|
||||
from websiteFunctions.models import Websites, Backups, dest, backupSchedules, BackupJob, BackupJobLogs
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
import subprocess
|
||||
import shlex
|
||||
@@ -1115,32 +1115,27 @@ class BackupManager:
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
if os.path.isfile(backupLogPath):
|
||||
command = "sudo cat " + backupLogPath
|
||||
status = ProcessUtilities.outputExecutioner(command)
|
||||
command = "sudo cat " + backupLogPath
|
||||
status = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if status.find("completed[success]") > -1:
|
||||
command = "rm -rf " + removalPath
|
||||
ProcessUtilities.executioner(command)
|
||||
data_ret = {'remoteTransferStatus': 1, 'error_message': "None", "status": status, "complete": 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
elif status.find("[5010]") > -1:
|
||||
command = "sudo rm -rf " + removalPath
|
||||
ProcessUtilities.executioner(command)
|
||||
data = {'remoteTransferStatus': 0, 'error_message': status,
|
||||
"status": "None", "complete": 0}
|
||||
json_data = json.dumps(data)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
data_ret = {'remoteTransferStatus': 1, 'error_message': "None", "status": status, "complete": 0}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
data_ret = {'remoteTransferStatus': 0, 'error_message': "No such log found", "status": "None",
|
||||
"complete": 0}
|
||||
if status.find("completed[success]") > -1:
|
||||
command = "rm -rf " + removalPath
|
||||
ProcessUtilities.executioner(command)
|
||||
data_ret = {'remoteTransferStatus': 1, 'error_message': "None", "status": status, "complete": 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
elif status.find("[5010]") > -1:
|
||||
command = "sudo rm -rf " + removalPath
|
||||
ProcessUtilities.executioner(command)
|
||||
data = {'remoteTransferStatus': 0, 'error_message': status,
|
||||
"status": "None", "complete": 0}
|
||||
json_data = json.dumps(data)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
data_ret = {'remoteTransferStatus': 1, 'error_message': "None", "status": status, "complete": 0}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data = {'remoteTransferStatus': 0, 'error_message': str(msg), "status": "None", "complete": 0}
|
||||
json_data = json.dumps(data)
|
||||
@@ -1191,3 +1186,96 @@ class BackupManager:
|
||||
data = {'cancelStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def backupLogs(self, request = None, userID = None, data = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
all_files = []
|
||||
|
||||
logFiles = BackupJob.objects.all().order_by('-id')
|
||||
|
||||
for logFile in logFiles:
|
||||
all_files.append(logFile.logFile)
|
||||
|
||||
return render(request, 'backup/backupLogs.html', {'backups': all_files})
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
def fetchLogs(self, userID = None, data = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
page = int(str(data['page']).rstrip('\n'))
|
||||
recordsToShow = int(data['recordsToShow'])
|
||||
logFile = data['logFile']
|
||||
|
||||
logJob = BackupJob.objects.get(logFile=logFile)
|
||||
|
||||
logs = logJob.backupjoblogs_set.all()
|
||||
|
||||
from s3Backups.s3Backups import S3Backups
|
||||
from plogical.backupSchedule import backupSchedule
|
||||
|
||||
pagination = S3Backups.getPagination(len(logs), recordsToShow)
|
||||
endPageNumber, finalPageNumber = S3Backups.recordsPointer(page, recordsToShow)
|
||||
finalLogs = logs[finalPageNumber:endPageNumber]
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
counter = 0
|
||||
|
||||
for log in finalLogs:
|
||||
|
||||
if log.status == backupSchedule.INFO:
|
||||
status = 'INFO'
|
||||
else:
|
||||
status = 'ERROR'
|
||||
|
||||
dic = {
|
||||
'LEVEL': status, "Message": log.message
|
||||
}
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
counter = counter + 1
|
||||
|
||||
json_data = json_data + ']'
|
||||
|
||||
if logJob.location == backupSchedule.LOCAL:
|
||||
location = 'local'
|
||||
else:
|
||||
location = 'remote'
|
||||
|
||||
|
||||
data = {
|
||||
'status': 1,
|
||||
'error_message': 'None',
|
||||
'logs': json_data,
|
||||
'pagination': pagination,
|
||||
'jobSuccessSites': logJob.jobSuccessSites,
|
||||
'jobFailedSites': logJob.jobFailedSites,
|
||||
'location': location
|
||||
}
|
||||
|
||||
|
||||
json_data = json.dumps(data)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data = {'remoteRestoreStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
@@ -1347,6 +1347,7 @@ app.controller('remoteBackupControl', function ($scope, $http, $timeout) {
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.backupProcessStarted = true;
|
||||
|
||||
if (response.data.remoteTransferStatus === 1) {
|
||||
|
||||
@@ -1540,4 +1541,68 @@ app.controller('remoteBackupControl', function ($scope, $http, $timeout) {
|
||||
|
||||
});
|
||||
|
||||
///** Backup site ends **///
|
||||
///** Backup site ends **///
|
||||
|
||||
|
||||
//*** Remote Backup site ****//
|
||||
app.controller('backupLogsScheduled', function ($scope, $http, $timeout) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.logDetails = true;
|
||||
|
||||
$scope.currentPage = 1;
|
||||
$scope.recordsToShow = 10;
|
||||
|
||||
$scope.fetchLogs = function () {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
logFile: $scope.logFile,
|
||||
recordsToShow: $scope.recordsToShow,
|
||||
page: $scope.currentPage
|
||||
};
|
||||
|
||||
dataurl = "/backup/fetchLogs";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.logDetails = false;
|
||||
$scope.logs = JSON.parse(response.data.logs);
|
||||
$scope.pagination = response.data.pagination;
|
||||
$scope.jobSuccessSites = response.data.jobSuccessSites;
|
||||
$scope.jobFailedSites = response.data.jobFailedSites;
|
||||
$scope.location = response.data.location;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
||||
///** Backup site ends **///
|
||||
|
||||
125
backup/templates/backup/backupLogs.html
Executable file
125
backup/templates/backup/backupLogs.html
Executable file
@@ -0,0 +1,125 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Backup Logs - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Backup Logs" %}</h2>
|
||||
<p>{% trans "On this page you can view detailed logs of your local and remote scheduled backups." %}</p>
|
||||
</div>
|
||||
|
||||
<div ng-controller="backupLogsScheduled" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
{% trans "Backup Logs" %} <img ng-hide="cyberpanelLoading" src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<form action="/" class="form-horizontal bordered-row">
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select Log File" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-change="fetchLogs()" ng-model="logFile" class="form-control">
|
||||
{% for items in backups %}
|
||||
<option>{{ items }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<div ng-hide="logDetails" class="form-group">
|
||||
<div style="margin-bottom: 2%" class="col-sm-12">
|
||||
|
||||
<table class="table" style="margin: 0px; padding: 0px">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Successful Sites" %}</th>
|
||||
<th>{% trans "Failed Sites" %}</th>
|
||||
<th>{% trans "Location" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{$ jobSuccessSites $}</td>
|
||||
<td>{$ jobFailedSites $}</td>
|
||||
<td>{$ location $}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="logDetails" class="col-sm-10"
|
||||
style="padding: 0px; box-shadow: 0px 0px 1px 0px #888888; margin-bottom: 2%">
|
||||
<input placeholder="Search..."
|
||||
ng-model="packSearch" name="packSearch" type="text"
|
||||
class="form-control" required>
|
||||
</div>
|
||||
<div ng-hide="logDetails" class="col-sm-2">
|
||||
<div class="form-group">
|
||||
<select ng-model="recordsToShow" ng-change="fetchLogs()"
|
||||
class="form-control" id="example-select">
|
||||
<option>10</option>
|
||||
<option>50</option>
|
||||
<option>100</option>
|
||||
<option>500</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-hide="logDetails" class="form-group">
|
||||
<div class="col-sm-12">
|
||||
|
||||
<table class="table" style="margin: 0px; padding: 0px">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "LEVEL" %}</th>
|
||||
<th>{% trans "Message" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="log in logs | filter:packSearch">
|
||||
<td ng-bind="log.LEVEL"></td>
|
||||
<td ng-bind="log.Message"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-hide="logDetails" style="margin-top: 2%" class="row">
|
||||
<div style="margin-top: 2%" class="col-md-12">
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<select ng-model="currentPage" class="form-control"
|
||||
ng-change="fetchLogs()">
|
||||
<option ng-repeat="page in pagination">{$ $index + 1 $}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end row -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -11,7 +11,7 @@
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Schedule Back up" %} - <a target="_blank" href="http://go.cyberpanel.net/remote-backup"
|
||||
style="height: 23px;line-height: 21px;"
|
||||
style="height: 23px;line-height: 21px; text-decoration: underline"
|
||||
class="btn btn-border btn-alt border-red btn-link font-red"
|
||||
title=""><span>{% trans "Remote Backups" %}</span></a></h2>
|
||||
<p>{% trans "On this page you can schedule Back ups to localhost or remote server (If you have added one)." %}</p>
|
||||
@@ -20,8 +20,11 @@
|
||||
<div ng-controller="scheduleBackup" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
{% trans "Schedule Back up" %} <img ng-hide="scheduleBackupLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
{% trans "Schedule Back up" %} - <img ng-hide="scheduleBackupLoading"
|
||||
src="{% static 'images/loading.gif' %}"> <a target="_blank"
|
||||
href="{% url 'backupLogs' %}"
|
||||
style="height: 23px;line-height: 21px;"
|
||||
title="">{% trans "Backup Logs" %}</a>
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ urlpatterns = [
|
||||
|
||||
url(r'^localInitiate$', views.localInitiate, name='localInitiate'),
|
||||
|
||||
|
||||
|
||||
url(r'^backupLogs$', views.backupLogs, name='backupLogs'),
|
||||
url(r'^fetchLogs$', views.fetchLogs, name='fetchLogs'),
|
||||
|
||||
]
|
||||
@@ -327,6 +327,23 @@ def cancelRemoteBackup(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def backupLogs(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
bm = BackupManager()
|
||||
return bm.backupLogs(request, userID)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def fetchLogs(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
wm = BackupManager()
|
||||
return wm.fetchLogs(userID, json.loads(request.body))
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
@csrf_exempt
|
||||
def localInitiate(request):
|
||||
|
||||
@@ -765,6 +765,9 @@
|
||||
<li><a href="{% url 'services' %}"
|
||||
title="{% trans 'Services Status' %}"><span>{% trans "Services Status" %}</span></a>
|
||||
</li>
|
||||
<li><a href="{% url 'packageManager' %}"
|
||||
title="{% trans 'Package Manager' %}"><span>{% trans "Package Manager" %}</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!-- .sidebar-submenu -->
|
||||
|
||||
@@ -59,7 +59,7 @@ def getAdminStatus(request):
|
||||
pdns = PDNSStatus.objects.get(pk=1)
|
||||
currentACL['dnsAsWhole'] = pdns.serverStatus
|
||||
except:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
pdnsPath = '/etc/powerdns'
|
||||
else:
|
||||
pdnsPath = '/etc/pdns'
|
||||
|
||||
@@ -1080,7 +1080,7 @@ class CloudManager:
|
||||
finalData['ramInGB'] = inGB
|
||||
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
finalData['conf'] = ProcessUtilities.outputExecutioner('sudo cat /etc/my.cnf')
|
||||
else:
|
||||
finalData['conf'] = ProcessUtilities.outputExecutioner('sudo cat /etc/mysql/my.cnf')
|
||||
|
||||
126
cyberpanel.sh
126
cyberpanel.sh
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
#CyberPanel installer script for CentOS 7.X, CentOS 8.X, CloudLinux 7.X and Ubuntu 18.04
|
||||
#CyberPanel installer script for CentOS 7.X, CentOS 8.X, CloudLinux 7.X, Ubuntu 18.04 and Ubuntu 20.04
|
||||
|
||||
SUDO_TEST=$(set)
|
||||
|
||||
@@ -21,14 +21,28 @@ KEY_SIZE=""
|
||||
ADMIN_PASS="1234567"
|
||||
MEMCACHED="ON"
|
||||
REDIS="ON"
|
||||
TOTAL_RAM=$(free -m | awk '/Mem\:/ { print $2 }')
|
||||
TOTAL_RAM=$(free -m | awk '/Mem:/ { print $2 }')
|
||||
CENTOS_8="False"
|
||||
UBUNTU_20="False"
|
||||
WATCHDOG="OFF"
|
||||
BRANCH_NAME="v${TEMP:12:3}.${TEMP:25:1}"
|
||||
VIRT_TYPE=""
|
||||
GIT_URL="github.com/usmannasir/cyberpanel"
|
||||
GIT_CONTENT_URL="raw.githubusercontent.com/usmannasir/cyberpanel"
|
||||
|
||||
disable_repos() {
|
||||
|
||||
if [[ $SERVER_OS == "CentOS" ]] ; then
|
||||
sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Base.repo
|
||||
sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Debuginfo.repo
|
||||
sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Media.repo
|
||||
sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Vault.repo
|
||||
sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-CR.repo
|
||||
sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-fasttrack.repo
|
||||
sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Sources.repo
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
check_return() {
|
||||
#check previous command result , 0 = ok , non-0 = something wrong.
|
||||
@@ -45,7 +59,6 @@ if [[ ! -f /usr/bin/cyberpanel_utility ]] ; then
|
||||
wget -q -O /usr/bin/cyberpanel_utility https://cyberpanel.sh/misc/cyberpanel_utility.sh
|
||||
chmod 700 /usr/bin/cyberpanel_utility
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
watchdog_setup() {
|
||||
@@ -404,13 +417,15 @@ if [[ $SERVER_OS == "CentOS" ]] ; then
|
||||
else
|
||||
pip3.6 install virtualenv
|
||||
fi
|
||||
check_return
|
||||
fi
|
||||
check_return
|
||||
|
||||
fi
|
||||
|
||||
if [[ $SERVER_OS == "Ubuntu" ]] ; then
|
||||
|
||||
apt update -y
|
||||
DEBIAN_FRONTEND=noninteractive apt upgrade -y
|
||||
DEBIAN_FRONTEND=noninteracitve apt install -y htop telnet libcurl4-gnutls-dev libgnutls28-dev libgcrypt20-dev libattr1 libattr1-dev liblzma-dev libgpgme-dev libmariadbclient-dev libcurl4-gnutls-dev libssl-dev nghttp2 libnghttp2-dev idn2 libidn2-dev libidn2-0-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev libldap2-dev libgssapi-krb5-2 libk5crypto3 libkrb5-dev libcomerr2 libldap2-dev virtualenv git socat vim
|
||||
DEBIAN_FRONTEND=noninteracitve apt install -y htop telnet libcurl4-gnutls-dev libgnutls28-dev libgcrypt20-dev libattr1 libattr1-dev liblzma-dev libgpgme-dev libmariadbclient-dev libcurl4-gnutls-dev libssl-dev nghttp2 libnghttp2-dev idn2 libidn2-dev libidn2-0-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev libldap2-dev libgssapi-krb5-2 libk5crypto3 libkrb5-dev libcomerr2 libldap2-dev virtualenv git socat vim unzip zip
|
||||
check_return
|
||||
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y python3-pip
|
||||
@@ -421,6 +436,11 @@ if [[ $SERVER_OS == "Ubuntu" ]] ; then
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y python3-venv
|
||||
check_return
|
||||
|
||||
if [[ $UBUNTU_20 == "True" ]] ; then
|
||||
pip3 install virtualenv==16.7.9
|
||||
fi
|
||||
check_return
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -544,6 +564,7 @@ fi
|
||||
check_OS() {
|
||||
echo -e "\nChecking OS..."
|
||||
OUTPUT=$(cat /etc/*release)
|
||||
|
||||
if echo $OUTPUT | grep -q "CentOS Linux 7" ; then
|
||||
echo -e "\nDetecting CentOS 7.X...\n"
|
||||
SERVER_OS="CentOS"
|
||||
@@ -562,12 +583,23 @@ elif echo $OUTPUT | grep -q "Ubuntu 18.04" ; then
|
||||
echo -e "\nUbuntu 18.04 x32 detected...ths only works on x64 system."
|
||||
exit
|
||||
fi
|
||||
elif echo $OUTPUT | grep -q "Ubuntu 20.04" ; then
|
||||
if uname -m | grep -q 64 ; then
|
||||
echo -e "\nDetecting Ubuntu 20.04 ...\n"
|
||||
SERVER_OS="Ubuntu"
|
||||
UBUNTU_20="True"
|
||||
else
|
||||
echo -e "\nUbuntu 20 x32 detected...ths only works on x64 system."
|
||||
exit
|
||||
fi
|
||||
else
|
||||
cat /etc/*release
|
||||
echo -e "\nUnable to detect your OS...\n"
|
||||
echo -e "\nCyberPanel is supported on Ubuntu 18.04 x86_64, CentOS 7.x, CentOS 8.x and CloudLinux 7.x...\n"
|
||||
echo -e "\nCyberPanel is supported on Ubuntu 18.04 x86_64, Ubuntu 20.04 x86_64, CentOS 7.x, CentOS 8.x and CloudLinux 7.x...\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
check_root() {
|
||||
@@ -985,9 +1017,9 @@ if [[ $debug == "0" ]] ; then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ $debug == "1" ]] ; then
|
||||
/usr/local/CyberPanel/bin/pip3 install --ignore-installed /usr/local/pip-packs/*
|
||||
|
||||
if [[ $debug == "1" ]] ; then
|
||||
pip3.6 install --ignore-installed /usr/local/pip-packs/*
|
||||
if [[ $REDIS_HOSTING == "Yes" ]] ; then
|
||||
/usr/local/CyberPanel/bin/python install.py $SERVER_IP $SERIAL_NO $LICENSE_KEY --postfix $POSTFIX_VARIABLE --powerdns $POWERDNS_VARIABLE --ftp $PUREFTPD_VARIABLE --redis enable
|
||||
else
|
||||
@@ -1009,6 +1041,7 @@ if [[ $REDIS == "ON" ]] ; then
|
||||
fi
|
||||
after_install
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
pip_virtualenv() {
|
||||
@@ -1025,16 +1058,25 @@ export LC_ALL=en_US.UTF-8
|
||||
if [[ $DEV == "ON" ]] ; then
|
||||
#install dev branch
|
||||
#wget https://raw.githubusercontent.com/usmannasir/cyberpanel/$BRANCH_NAME/requirments.txt
|
||||
cd /usr/local/
|
||||
virtualenv -p /usr/bin/python3 CyberPanel
|
||||
source /usr/local/CyberPanel/bin/activate
|
||||
wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/cyberpanel-pip.zip
|
||||
check_return
|
||||
unzip /usr/local/cyberpanel-pip.zip -d /usr/local
|
||||
check_return
|
||||
pip3.6 install --ignore-installed /usr/local/pip-packs/*
|
||||
check_return
|
||||
cd -
|
||||
virtualenv -p /usr/bin/python3 /usr/local/CyberPanel
|
||||
|
||||
if [[ $UBUNTU_20 == "False" ]] ; then
|
||||
source /usr/local/CyberPanel/bin/activate
|
||||
wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/cyberpanel-pip.zip
|
||||
check_return
|
||||
unzip /usr/local/cyberpanel-pip.zip -d /usr/local
|
||||
check_return
|
||||
pip3.6 install --ignore-installed /usr/local/pip-packs/*
|
||||
check_return
|
||||
else
|
||||
. /usr/local/CyberPanel/bin/activate
|
||||
wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/ubuntu-pip.zip
|
||||
check_return
|
||||
unzip /usr/local/cyberpanel-pip.zip -d /usr/local
|
||||
check_return
|
||||
pip3 install --ignore-installed /usr/local/packages/*
|
||||
check_return
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f requirements.txt ] && [ -d cyberpanel ] ; then
|
||||
@@ -1122,13 +1164,24 @@ trusted-host=pypi.python.org
|
||||
EOF
|
||||
fi
|
||||
|
||||
virtualenv -p /usr/bin/python3 /usr/local/CyberCP
|
||||
source /usr/local/CyberCP/bin/activate
|
||||
pip3.6 install --ignore-installed /usr/local/pip-packs/*
|
||||
check_return
|
||||
systemctl restart lscpd
|
||||
fi
|
||||
|
||||
virtualenv -p /usr/bin/python3 /usr/local/CyberCP
|
||||
|
||||
if [[ $UBUNTU_20 == "False" ]] ; then
|
||||
source /usr/local/CyberCP/bin/activate
|
||||
check_return
|
||||
pip3 install --ignore-installed /usr/local/pip-packs/*
|
||||
check_return
|
||||
else
|
||||
. /usr/local/CyberCP/bin/activate
|
||||
check_return
|
||||
pip3 install --ignore-installed /usr/local/packages/*
|
||||
check_return
|
||||
fi
|
||||
|
||||
systemctl restart lscpd
|
||||
|
||||
for version in $(ls /usr/local/lsws | grep lsphp);
|
||||
do
|
||||
php_ini=$(find /usr/local/lsws/$version/ -name php.ini)
|
||||
@@ -1251,6 +1304,10 @@ fi
|
||||
fi
|
||||
#fix php.ini & issue
|
||||
|
||||
if [[ $UBUNTU_20 == "True" ]] ; then
|
||||
cp /usr/local/lsws/lsphp73/bin/php /usr/bin
|
||||
fi
|
||||
|
||||
#clear
|
||||
echo "###################################################################"
|
||||
echo " CyberPanel Successfully Installed "
|
||||
@@ -1382,6 +1439,8 @@ else
|
||||
fi
|
||||
}
|
||||
|
||||
##START
|
||||
|
||||
if [ $# -eq 0 ] ; then
|
||||
echo -e "\nInitializing...\n"
|
||||
else
|
||||
@@ -1480,6 +1539,8 @@ else
|
||||
DOWNLOAD_SERVER="cdn.cyberpanel.sh"
|
||||
fi
|
||||
|
||||
##END
|
||||
|
||||
check_OS
|
||||
check_virtualization
|
||||
check_root
|
||||
@@ -1488,9 +1549,6 @@ check_process
|
||||
check_provider
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if [[ $SILENT = "ON" ]] ; then
|
||||
argument_mode
|
||||
else
|
||||
@@ -1511,18 +1569,4 @@ main_install
|
||||
|
||||
### Disable Centos Default Repos
|
||||
|
||||
disable_repos() {
|
||||
|
||||
if [[ $SERVER_OS == "CentOS" ]] ; then
|
||||
sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Base.repo
|
||||
sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Debuginfo.repo
|
||||
sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Media.repo
|
||||
sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Vault.repo
|
||||
sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-CR.repo
|
||||
sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-fasttrack.repo
|
||||
sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Sources.repo
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
disable_repos
|
||||
@@ -12,6 +12,7 @@ GIT_URL="github.com/usmannasir/cyberpanel"
|
||||
GIT_CONTENT_URL="raw.githubusercontent.com/usmannasir/cyberpanel"
|
||||
SERVER_COUNTRY="unknow"
|
||||
SERVER_COUNTRY=$(curl --silent --max-time 5 https://cyberpanel.sh/?country)
|
||||
UBUNTU_20="False"
|
||||
|
||||
### Update and remove not needed repos
|
||||
|
||||
@@ -159,6 +160,7 @@ check_root
|
||||
|
||||
echo -e "\nChecking OS..."
|
||||
OUTPUT=$(cat /etc/*release)
|
||||
|
||||
if echo $OUTPUT | grep -q "CentOS Linux 7" ; then
|
||||
echo -e "\nDetecting CentOS 7.X...\n"
|
||||
SERVER_OS="CentOS7"
|
||||
@@ -189,6 +191,10 @@ elif echo $OUTPUT | grep -q "CentOS Linux 8" ; then
|
||||
elif echo $OUTPUT | grep -q "Ubuntu 18.04" ; then
|
||||
echo -e "\nDetecting Ubuntu 18.04...\n"
|
||||
SERVER_OS="Ubuntu"
|
||||
elif echo $OUTPUT | grep -q "Ubuntu 20.04" ; then
|
||||
echo -e "\nDetecting Ubuntu 20.04...\n"
|
||||
SERVER_OS="Ubuntu"
|
||||
UBUNTU_20="True"
|
||||
else
|
||||
cat /etc/*release
|
||||
echo -e "\nUnable to detect your OS...\n"
|
||||
@@ -236,9 +242,17 @@ else
|
||||
fi
|
||||
|
||||
rm -f requirments.txt
|
||||
wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/cyberpanel-pip.zip
|
||||
|
||||
if [[ $UBUNTU_20 == "False" ]] ; then
|
||||
wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/cyberpanel-pip.zip
|
||||
else
|
||||
wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/ubuntu-pip.zip
|
||||
fi
|
||||
|
||||
check_return
|
||||
rm -rf /usr/local/pip-packs/
|
||||
rm -rf /usr/local/packages
|
||||
|
||||
unzip /usr/local/cyberpanel-pip.zip -d /usr/local
|
||||
check_return
|
||||
. /usr/local/CyberPanel/bin/activate
|
||||
@@ -247,7 +261,11 @@ check_return
|
||||
if [ $SERVER_OS = "Ubuntu" ] ; then
|
||||
. /usr/local/CyberPanel/bin/activate
|
||||
check_return
|
||||
pip3 install --ignore-installed /usr/local/pip-packs/*
|
||||
if [[ $UBUNTU_20 == "False" ]] ; then
|
||||
pip3 install --ignore-installed /usr/local/pip-packs/*
|
||||
else
|
||||
pip3 install --ignore-installed /usr/local/packages/*
|
||||
fi
|
||||
check_return
|
||||
else
|
||||
source /usr/local/CyberPanel/bin/activate
|
||||
@@ -292,7 +310,11 @@ check_return
|
||||
if [ $SERVER_OS = "Ubuntu" ] ; then
|
||||
. /usr/local/CyberCP/bin/activate
|
||||
check_return
|
||||
pip3 install --ignore-installed /usr/local/pip-packs/*
|
||||
if [[ $UBUNTU_20 == "False" ]] ; then
|
||||
pip3 install --ignore-installed /usr/local/pip-packs/*
|
||||
else
|
||||
pip3 install --ignore-installed /usr/local/packages/*
|
||||
fi
|
||||
check_return
|
||||
else
|
||||
source /usr/local/CyberCP/bin/activate
|
||||
@@ -304,11 +326,15 @@ fi
|
||||
|
||||
##
|
||||
|
||||
rm -f wsgi-lsapi-1.4.tgz
|
||||
rm -f wsgi-lsapi-1.5.tgz
|
||||
rm -f wsgi-lsapi-1.6.tgz
|
||||
rm -rf wsgi-lsapi-1.4
|
||||
wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.5.tgz
|
||||
tar xf wsgi-lsapi-1.5.tgz
|
||||
cd wsgi-lsapi-1.5
|
||||
rm -rf wsgi-lsapi-1.5
|
||||
rm -rf wsgi-lsapi-1.6
|
||||
wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.6.tgz
|
||||
tar xf wsgi-lsapi-1.6.tgz
|
||||
cd wsgi-lsapi-1.6
|
||||
/usr/local/CyberPanel/bin/python ./configure.py
|
||||
make
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ app.controller('createDatabase', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.dbPassword = randomPassword(12);
|
||||
$scope.dbPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -447,7 +447,7 @@ app.controller('listDBs', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.dbPassword = randomPassword(12);
|
||||
$scope.dbPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -493,4 +493,4 @@ app.controller('phpMyAdmin', function ($scope, $http, $window) {
|
||||
}
|
||||
setupPHPMYAdminSession();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ class Records(models.Model):
|
||||
domain_id = models.IntegerField(blank=True, null=True)
|
||||
name = models.CharField(max_length=255, blank=True, null=True)
|
||||
type = models.CharField(max_length=10, blank=True, null=True)
|
||||
content = models.CharField(max_length=64000, blank=True, null=True)
|
||||
content = models.CharField(max_length=1000, blank=True, null=True)
|
||||
ttl = models.IntegerField(blank=True, null=True)
|
||||
prio = models.IntegerField(blank=True, null=True)
|
||||
change_date = models.IntegerField(blank=True, null=True)
|
||||
@@ -41,7 +41,7 @@ class Comments(models.Model):
|
||||
type = models.CharField(max_length=10)
|
||||
modified_at = models.IntegerField()
|
||||
account = models.CharField(max_length=40)
|
||||
comment = models.CharField(max_length=64000)
|
||||
comment = models.TextField()
|
||||
|
||||
class Meta:
|
||||
db_table = 'comments'
|
||||
|
||||
@@ -18,7 +18,9 @@ class DockerInstall:
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Starting Docker Installation..\n", 1)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'sudo dnf install -y docker-ce --nobest'
|
||||
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
command = 'sudo yum install -y docker'
|
||||
else:
|
||||
command = 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io'
|
||||
|
||||
@@ -64,10 +64,11 @@ def downloadFile(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
import urllib.parse
|
||||
from urllib.parse import quote
|
||||
from django.utils.encoding import iri_to_uri
|
||||
|
||||
fileToDownload = request.build_absolute_uri().split('fileToDownload')[1][1:]
|
||||
fileToDownload = urllib.parse.unquote(fileToDownload)
|
||||
fileToDownload = iri_to_uri(fileToDownload)
|
||||
|
||||
domainName = request.GET.get('domainName')
|
||||
|
||||
|
||||
@@ -2171,8 +2171,6 @@ app.controller('installImunify', function ($scope, $http, $timeout, $window) {
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ app.controller('createFTPAccount', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.ftpPassword = randomPassword(12);
|
||||
$scope.ftpPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -451,11 +451,11 @@ app.controller('listFTPAccounts', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.ftpPassword = randomPassword(12);
|
||||
$scope.ftpPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
$scope.generatedPasswordView = true;
|
||||
};
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,7 +36,7 @@ class HAManager(multi.Thread):
|
||||
def setupNode(self):
|
||||
try:
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
mesg = 'Clusters are only supported on Ubuntu 18.04. [404]'
|
||||
logging.statusWriter(self.data['tempStatusPath'], mesg)
|
||||
return 0
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
[cyberpanel]
|
||||
name=Cyber Panel
|
||||
baseurl=http://repo.cyberpersons.com
|
||||
gpgcheck=0
|
||||
[CyberPanel]
|
||||
name=CyberPanel
|
||||
baseurl=https://rep.cyberpanel.net/
|
||||
gpgkey=https://rep.cyberpanel.net/RPM-GPG-KEY-cyberpanel
|
||||
gpgcheck=1
|
||||
@@ -323,7 +323,7 @@ class preFlightsChecks:
|
||||
os._exit(os.EX_SOFTWARE)
|
||||
|
||||
elif self.distro == centos:
|
||||
command = 'rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm'
|
||||
command = 'rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.2-1.el7.noarch.rpm'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
elif self.distro == cent8:
|
||||
command = 'rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm'
|
||||
@@ -1494,13 +1494,13 @@ imap_folder_list_limit = 0
|
||||
def setupPythonWSGI(self):
|
||||
try:
|
||||
|
||||
command = "wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.4.tgz"
|
||||
command = "wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.6.tgz"
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
command = "tar xf wsgi-lsapi-1.4.tgz"
|
||||
command = "tar xf wsgi-lsapi-1.6.tgz"
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
os.chdir("wsgi-lsapi-1.4")
|
||||
os.chdir("wsgi-lsapi-1.6")
|
||||
|
||||
command = "/usr/local/CyberPanel/bin/python ./configure.py"
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
@@ -7,12 +7,32 @@ import randomPassword
|
||||
import errno
|
||||
import MySQLdb as mariadb
|
||||
import install
|
||||
from os.path import exists
|
||||
|
||||
#distros
|
||||
centos=0
|
||||
ubuntu=1
|
||||
cent8=2
|
||||
|
||||
def get_Ubuntu_release():
|
||||
release = -1
|
||||
if exists("/etc/lsb-release"):
|
||||
distro_file = "/etc/lsb-release"
|
||||
with open(distro_file) as f:
|
||||
for line in f:
|
||||
if line[:16] == "DISTRIB_RELEASE=":
|
||||
release = float(line[16:])
|
||||
|
||||
if release == -1:
|
||||
print("Can't find distro release name in " + distro_file + " - fatal error")
|
||||
|
||||
else:
|
||||
logging.InstallLog.writeToFile("Can't find linux release file - fatal error")
|
||||
print("Can't find linux release file - fatal error")
|
||||
os._exit(os.EX_UNAVAILABLE)
|
||||
|
||||
return release
|
||||
|
||||
class InstallCyberPanel:
|
||||
|
||||
mysql_Root_password = ""
|
||||
@@ -308,8 +328,11 @@ class InstallCyberPanel:
|
||||
conn = mariadb.connect(user='root', passwd=self.mysql_Root_password)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('set global innodb_file_per_table = on;')
|
||||
cursor.execute('set global innodb_file_format = Barracuda;')
|
||||
cursor.execute('set global innodb_large_prefix = on;')
|
||||
try:
|
||||
cursor.execute('set global innodb_file_format = Barracuda;')
|
||||
cursor.execute('set global innodb_large_prefix = on;')
|
||||
except BaseException as msg:
|
||||
self.stdOut('%s. [ERROR:335]' % (str(msg)))
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
@@ -333,17 +356,18 @@ class InstallCyberPanel:
|
||||
command = 'DEBIAN_FRONTEND=noninteractive apt install pure-ftpd-mysql -y'
|
||||
os.system(command)
|
||||
|
||||
command = 'wget https://rep.cyberpanel.net/pure-ftpd-common_1.0.47-3_all.deb'
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
if get_Ubuntu_release() == 18.10:
|
||||
command = 'wget https://rep.cyberpanel.net/pure-ftpd-common_1.0.47-3_all.deb'
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = 'wget https://rep.cyberpanel.net/pure-ftpd-mysql_1.0.47-3_amd64.deb'
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
command = 'wget https://rep.cyberpanel.net/pure-ftpd-mysql_1.0.47-3_amd64.deb'
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = 'dpkg --install --force-confold pure-ftpd-common_1.0.47-3_all.deb'
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
command = 'dpkg --install --force-confold pure-ftpd-common_1.0.47-3_all.deb'
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = 'dpkg --install --force-confold pure-ftpd-mysql_1.0.47-3_amd64.deb'
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
command = 'dpkg --install --force-confold pure-ftpd-mysql_1.0.47-3_amd64.deb'
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
elif self.distro == centos:
|
||||
command = "yum install -y pure-ftpd"
|
||||
@@ -385,8 +409,11 @@ class InstallCyberPanel:
|
||||
except:
|
||||
logging.InstallLog.writeToFile("[ERROR] Could not create directory for FTP SSL")
|
||||
|
||||
if (self.distro == centos or self.distro == cent8) or (self.distro == ubuntu and get_Ubuntu_release() == 18.14):
|
||||
command = 'openssl req -newkey rsa:1024 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem'
|
||||
else:
|
||||
command = 'openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem'
|
||||
|
||||
command = 'openssl req -newkey rsa:1024 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem'
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
os.chdir(self.cwd)
|
||||
|
||||
@@ -18,7 +18,7 @@ MaxLoad 4
|
||||
AntiWarez yes
|
||||
Umask 133:022
|
||||
MinUID 1000
|
||||
UseFtpUsers no
|
||||
#UseFtpUsers no
|
||||
AllowUserFXP no
|
||||
AllowAnonymousFXP no
|
||||
ProhibitDotFilesWrite no
|
||||
|
||||
Binary file not shown.
@@ -6189,7 +6189,11 @@ msgstr "Instale o WordPress com LSCache."
|
||||
|
||||
#: websiteFunctions/templates/websiteFunctions/installWordPress.html:28
|
||||
msgid "Blog Title"
|
||||
msgstr ""
|
||||
msgstr "Título do Blog"
|
||||
|
||||
#: websiteFunctions/templates/websiteFunctions/installWordPress.html:58
|
||||
msgid "Leave empty to install in website home directory. (Without preceding slash)"
|
||||
msgstr "Deixe em branco para instalar no diretório inicial do site. (Sem barra anterior)"
|
||||
|
||||
#: websiteFunctions/templates/websiteFunctions/launchChild.html:29
|
||||
msgid "Copy/Sync to Master"
|
||||
|
||||
Binary file not shown.
@@ -6724,7 +6724,11 @@ msgstr "Instale o WordPress com LSCache."
|
||||
|
||||
#: websiteFunctions/templates/websiteFunctions/installWordPress.html:28
|
||||
msgid "Blog Title"
|
||||
msgstr ""
|
||||
msgstr "Título do Blog"
|
||||
|
||||
#: websiteFunctions/templates/websiteFunctions/installWordPress.html:58
|
||||
msgid "Leave empty to install in website home directory. (Without preceding slash)"
|
||||
msgstr "Deixe em branco para instalar no diretório inicial do site. (Sem barra anterior)"
|
||||
|
||||
#: websiteFunctions/templates/websiteFunctions/launchChild.html:32
|
||||
msgid "Copy/Sync to Master"
|
||||
|
||||
@@ -197,21 +197,21 @@
|
||||
<select ng-model="languageSelection" ng-init="languageSelection='english'"
|
||||
class="form-control">
|
||||
<option value="english">English</option>
|
||||
<option>Chinese</option>
|
||||
<option>Italian</option>
|
||||
<option>French</option>
|
||||
<option>Bulgarian</option>
|
||||
<option>Portuguese</option>
|
||||
<option>Japanese</option>
|
||||
<option>Bosnian</option>
|
||||
<option>Greek</option>
|
||||
<option>Russian</option>
|
||||
<option>Turkish</option>
|
||||
<option>Spanish</option>
|
||||
<option>Polish</option>
|
||||
<option>Vietnamese</option>
|
||||
<option>Bulgarian</option>
|
||||
<option>Chinese</option>
|
||||
<option>French</option>
|
||||
<option>German</option>
|
||||
<option>Greek</option>
|
||||
<option>Italian</option>
|
||||
<option>Indonesian</option>
|
||||
<option>Japanese</option>
|
||||
<option>Polish</option>
|
||||
<option>Portuguese</option>
|
||||
<option>Russian</option>
|
||||
<option>Spanish</option>
|
||||
<option>Turkish</option>
|
||||
<option>Vietnamese</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -235,4 +235,4 @@
|
||||
<script src="{% static 'loginSystem/login-systen.js' %}"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -226,6 +226,38 @@ class MailServerManager:
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def fixMailSSL(self):
|
||||
try:
|
||||
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
data = json.loads(self.request.body)
|
||||
selectedDomain = data['selectedDomain']
|
||||
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
if ACLManager.checkOwnership(selectedDomain, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('status', 0)
|
||||
|
||||
website = Websites.objects.get(domain=selectedDomain)
|
||||
|
||||
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
execPath = '%s setupAutoDiscover --virtualHostName %s --websiteOwner %s' % (execPath, selectedDomain, website.admin.userName)
|
||||
|
||||
ProcessUtilities.executioner(execPath)
|
||||
|
||||
data_ret = {'status': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def emailForwarding(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
@@ -476,6 +508,19 @@ class MailServerManager:
|
||||
except:
|
||||
raise BaseException('No emails exist for this domain.')
|
||||
|
||||
postfixMapPath = '/etc/postfix/vmail_ssl.map'
|
||||
|
||||
if os.path.exists(postfixMapPath):
|
||||
|
||||
postfixMapData = open(postfixMapPath, 'r').read()
|
||||
|
||||
if postfixMapData.find(selectedDomain) == -1:
|
||||
mailConfigured = 0
|
||||
else:
|
||||
mailConfigured = 1
|
||||
else:
|
||||
mailConfigured = 0
|
||||
|
||||
records = emailDomain.eusers_set.all()
|
||||
|
||||
json_data = "["
|
||||
@@ -492,7 +537,7 @@ class MailServerManager:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
|
||||
json_data = json_data + ']'
|
||||
final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data})
|
||||
final_json = json.dumps({'status': 1, 'fetchStatus': 1,'serverHostname': 'mail.%s' % (selectedDomain), 'mailConfigured': mailConfigured, 'error_message': "None", "data": json_data})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException as msg:
|
||||
@@ -607,6 +652,12 @@ class MailServerManager:
|
||||
return ACLManager.loadError()
|
||||
|
||||
try:
|
||||
|
||||
import tldextract
|
||||
|
||||
extractDomain = tldextract.extract(domainName)
|
||||
domainName = extractDomain.domain + '.' + extractDomain.suffix
|
||||
|
||||
path = "/etc/opendkim/keys/" + domainName + "/default.txt"
|
||||
command = "sudo cat " + path
|
||||
output = ProcessUtilities.outputExecutioner(command, 'opendkim')
|
||||
@@ -617,6 +668,8 @@ class MailServerManager:
|
||||
command = "sudo cat " + path
|
||||
privateKey = ProcessUtilities.outputExecutioner(command, 'opendkim')
|
||||
|
||||
DNS.createDKIMRecords(domainName)
|
||||
|
||||
data_ret = {'status': 1, 'fetchStatus': 1, 'keysAvailable': 1, 'publicKey': output[leftIndex:rightIndex],
|
||||
'privateKey': privateKey, 'dkimSuccessMessage': 'Keys successfully fetched!',
|
||||
'error_message': "None"}
|
||||
|
||||
@@ -110,7 +110,7 @@ app.controller('createEmailAccount', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.emailPassword = randomPassword(12);
|
||||
$scope.emailPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -465,7 +465,7 @@ app.controller('changeEmailPassword', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.emailPassword = randomPassword(12);
|
||||
$scope.emailPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -1124,6 +1124,7 @@ app.controller('listEmails', function ($scope, $http) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.emailsAccounts = true;
|
||||
$scope.mailConfigured = 1;
|
||||
|
||||
$scope.populateCurrentRecords = function () {
|
||||
$scope.cyberpanelLoading = false;
|
||||
@@ -1151,6 +1152,9 @@ app.controller('listEmails', function ($scope, $http) {
|
||||
if (response.data.status === 1) {
|
||||
$scope.emailsAccounts = false;
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.mailConfigured = response.data.mailConfigured;
|
||||
$scope.serverHostname = response.data.serverHostname;
|
||||
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Emails Successfully Fetched.',
|
||||
@@ -1229,6 +1233,55 @@ app.controller('listEmails', function ($scope, $http) {
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.fixMailSSL = function (email) {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
var url = "/email/fixMailSSL";
|
||||
|
||||
var data = {
|
||||
selectedDomain: $scope.selectedDomain,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
if (response.data.status === 1) {
|
||||
$scope.populateCurrentRecords();
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Configurations applied successfully.',
|
||||
type: 'success'
|
||||
});
|
||||
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.changePasswordInitial = function (email) {
|
||||
@@ -1291,4 +1344,4 @@ app.controller('listEmails', function ($scope, $http) {
|
||||
});
|
||||
|
||||
|
||||
/* Java script code for List Emails Ends here */
|
||||
/* Java script code for List Emails Ends here */
|
||||
|
||||
@@ -56,7 +56,106 @@
|
||||
|
||||
<div ng-hide="emailsAccounts" class="form-group">
|
||||
|
||||
<div class="col-sm-12">
|
||||
<div ng-hide="mailConfigured==1" class="col-sm-12">
|
||||
<div class="alert alert-danger">
|
||||
<p>{% trans "SSL for email is not configured properly, you may get Self-Signed error on mail clients such as Outlook and Thunderbird. More details " %}<a href="https://cyberpanel.net/docs/6-self-signed-ssl-error-on-outlook-thunderbird/">here</a>. </p>
|
||||
</div>
|
||||
<a target="_blank" href="">
|
||||
<button style="margin-bottom: 2%" ng-click='fixMailSSL()' class="btn btn-primary">Fix Now</button>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4">
|
||||
|
||||
<h4>{% trans "Details To Configure Mail Clients" %}</h4>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "POP3" %}</th>
|
||||
<th>{% trans "Details" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{% trans "Server Hostname" %}</td>
|
||||
<td>{$ serverHostname $}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "Port" %}</td>
|
||||
<td>110</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "Port" %}</td>
|
||||
<td>995 (SSL)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "SSL" %}</td>
|
||||
<td>STARTTLS</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "IMAP" %}</th>
|
||||
<th>{% trans "Details" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{% trans "Server Hostname" %}</td>
|
||||
<td>{$ serverHostname $}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "Port" %}</td>
|
||||
<td>143</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "Port" %}</td>
|
||||
<td>993 (SSL)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "SSL" %}</td>
|
||||
<td>STARTTLS</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "SMTP" %}</th>
|
||||
<th>{% trans "Details" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{% trans "Server Hostname" %}</td>
|
||||
<td>{$ serverHostname $}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "Port" %}</td>
|
||||
<td>25</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "Port" %}</td>
|
||||
<td>587 (SSL)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "Port" %}</td>
|
||||
<td>465 (SSL)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "SSL" %}</td>
|
||||
<td>STARTTLS</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-8">
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
@@ -74,7 +173,8 @@
|
||||
class="btn btn-border btn-alt border-purple btn-link font-purple"
|
||||
href="#"
|
||||
title=""><span>{% trans 'Change Password' %}</span></a>
|
||||
<a ng-click="deleteEmailAccountFinal(record.email)" class="btn btn-border btn-alt border-red btn-link font-red" href="#"
|
||||
<a ng-click="deleteEmailAccountFinal(record.email)"
|
||||
class="btn btn-border btn-alt border-red btn-link font-red" href="#"
|
||||
title=""><span>{% trans 'Delete' %}</span></a>
|
||||
|
||||
<!--- Modal --->
|
||||
|
||||
@@ -20,6 +20,7 @@ urlpatterns = [
|
||||
url(r'^deleteEmailAccount', views.deleteEmailAccount, name='deleteEmailAccount'),
|
||||
url(r'^getEmailsForDomain$', views.getEmailsForDomain, name='getEmailsForDomain'),
|
||||
url(r'^submitEmailDeletion', views.submitEmailDeletion, name='submitEmailDeletion'),
|
||||
url(r'^fixMailSSL', views.fixMailSSL, name='fixMailSSL'),
|
||||
|
||||
|
||||
## Change email password
|
||||
|
||||
@@ -91,6 +91,18 @@ def submitEmailDeletion(request):
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def fixMailSSL(request):
|
||||
try:
|
||||
|
||||
msM = MailServerManager(request)
|
||||
coreResult = msM.fixMailSSL()
|
||||
|
||||
return coreResult
|
||||
except KeyError as msg:
|
||||
data_ret = {'deleteEmailStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def emailForwarding(request):
|
||||
try:
|
||||
msM = MailServerManager(request)
|
||||
|
||||
@@ -1085,7 +1085,7 @@ def installExtensions(request):
|
||||
|
||||
phpPath = ''
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpPath = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php70.xml')
|
||||
else:
|
||||
phpPath = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp70.xml')
|
||||
@@ -1116,7 +1116,7 @@ def installExtensions(request):
|
||||
|
||||
phpPath = ''
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpPath = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php71.xml')
|
||||
else:
|
||||
phpPath = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp71.xml')
|
||||
@@ -1144,7 +1144,7 @@ def installExtensions(request):
|
||||
|
||||
php72Path = ''
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
php72Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php72.xml')
|
||||
else:
|
||||
php72Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp72.xml')
|
||||
@@ -1172,7 +1172,7 @@ def installExtensions(request):
|
||||
|
||||
php73Path = ''
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
php73Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php73.xml')
|
||||
else:
|
||||
php73Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp73.xml')
|
||||
@@ -1200,7 +1200,7 @@ def installExtensions(request):
|
||||
|
||||
php74Path = ''
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
php74Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'php74.xml')
|
||||
else:
|
||||
php74Path = os.path.join('/usr', 'local', 'CyberCP', 'managePHP', 'ubuntuphp74.xml')
|
||||
@@ -1344,7 +1344,7 @@ def getRequestStatus(request):
|
||||
|
||||
checkCommand = ''
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
checkCommand = 'yum list installed'
|
||||
checkCommand = shlex.split(checkCommand)
|
||||
else:
|
||||
@@ -1469,7 +1469,7 @@ def getRequestStatusApache(request):
|
||||
|
||||
checkCommand = ''
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
checkCommand = 'yum list installed'
|
||||
checkCommand = shlex.split(checkCommand)
|
||||
else:
|
||||
@@ -1607,7 +1607,7 @@ def getCurrentPHPConfig(request):
|
||||
|
||||
phpVers = "php" + PHPManager.getPHPString(phpVers)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
|
||||
else:
|
||||
initial = phpVers[3]
|
||||
@@ -1767,7 +1767,7 @@ def getCurrentAdvancedPHPConfig(request):
|
||||
|
||||
phpVers = "php" + PHPManager.getPHPString(phpVers)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
|
||||
else:
|
||||
initial = phpVers[3]
|
||||
@@ -1809,7 +1809,7 @@ def savePHPConfigAdvance(request):
|
||||
|
||||
phpVers = "php" + PHPManager.getPHPString(phpVers)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
|
||||
else:
|
||||
initial = phpVers[3]
|
||||
|
||||
@@ -126,7 +126,7 @@ def sslForHostName(request):
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID, 1)
|
||||
|
||||
return render(request, 'manageSSL/sslForHostName.html', {'websiteList': websitesName})
|
||||
except KeyError:
|
||||
@@ -151,11 +151,15 @@ def obtainHostNameSSL(request):
|
||||
data = json.loads(request.body)
|
||||
virtualHost = data['virtualHost']
|
||||
|
||||
path = "/home/" + virtualHost + "/public_html"
|
||||
try:
|
||||
website = Websites.objects.get(domain=virtualHost)
|
||||
path = "/home/" + virtualHost + "/public_html"
|
||||
except:
|
||||
website = ChildDomains.objects.get(domain=virtualHost)
|
||||
path = website.path
|
||||
|
||||
data = json.loads(request.body)
|
||||
virtualHost = data['virtualHost']
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
if ACLManager.checkOwnership(virtualHost, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
|
||||
@@ -6,6 +6,8 @@ from manageServices.models import SlaveServers
|
||||
|
||||
class ServiceManager:
|
||||
|
||||
slaveConfPath = '/home/cyberpanel/slaveConf'
|
||||
|
||||
def __init__(self, extraArgs):
|
||||
self.extraArgs = extraArgs
|
||||
|
||||
@@ -24,14 +26,14 @@ class ServiceManager:
|
||||
ipStringNoSubnet = ''
|
||||
|
||||
for items in SlaveServers.objects.all():
|
||||
ipsString = ipsString + '%s/32 ' % (items.slaveServerIP)
|
||||
ipStringNoSubnet = ipStringNoSubnet + '%s ' % (items.slaveServerIP)
|
||||
|
||||
ipsString = ipsString.rstrip(' ')
|
||||
ipStringNoSubnet = ipStringNoSubnet.rstrip(' ')
|
||||
|
||||
ipsString = ipsString + '%s/32, ' % (items.slaveServerIP)
|
||||
ipStringNoSubnet = ipStringNoSubnet + '%s, ' % (items.slaveServerIP)
|
||||
|
||||
ipsString = ipsString.rstrip(', ')
|
||||
ipStringNoSubnet = ipStringNoSubnet.rstrip(', ')
|
||||
|
||||
tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
writeToFile = open(tempPath, 'w')
|
||||
|
||||
for items in data:
|
||||
if items.find('allow-axfr-ips') > -1:
|
||||
@@ -49,14 +51,14 @@ class ServiceManager:
|
||||
if items.find('slave') > -1:
|
||||
continue
|
||||
|
||||
if items.find('master') > -1:
|
||||
continue
|
||||
|
||||
counter = counter + 1
|
||||
|
||||
tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
writeToFile = open(tempPath, 'w')
|
||||
|
||||
for items in data:
|
||||
writeToFile.writelines(items + '\n')
|
||||
|
||||
|
||||
writeToFile.writelines('allow-axfr-ips=' + ipsString + '\n')
|
||||
writeToFile.writelines('also-notify=' + ipStringNoSubnet + '\n')
|
||||
writeToFile.writelines('daemon=no\n')
|
||||
@@ -64,33 +66,42 @@ class ServiceManager:
|
||||
writeToFile.writelines('master=yes\n')
|
||||
writeToFile.close()
|
||||
else:
|
||||
counter = 0
|
||||
import os
|
||||
|
||||
for items in data:
|
||||
if items.find('allow-axfr-ips') > -1:
|
||||
continue
|
||||
if not os.path.exists(ServiceManager.slaveConfPath):
|
||||
|
||||
if items.find('also-notify') > -1:
|
||||
continue
|
||||
writeToFile = open(ServiceManager.slaveConfPath, 'w')
|
||||
writeToFile.write('configured')
|
||||
writeToFile.close()
|
||||
|
||||
if items.find('daemon=') > -1:
|
||||
continue
|
||||
counter = 0
|
||||
|
||||
if items.find('disable-axfr') > -1:
|
||||
continue
|
||||
for items in data:
|
||||
if items.find('allow-axfr-ips') > -1:
|
||||
continue
|
||||
|
||||
if items.find('slave') > -1:
|
||||
continue
|
||||
if items.find('also-notify') > -1:
|
||||
continue
|
||||
|
||||
counter = counter + 1
|
||||
if items.find('daemon=') > -1:
|
||||
continue
|
||||
|
||||
tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
writeToFile = open(tempPath, 'w')
|
||||
if items.find('disable-axfr') > -1:
|
||||
continue
|
||||
|
||||
for items in data:
|
||||
writeToFile.writelines(items + '\n')
|
||||
if items.find('slave') > -1:
|
||||
continue
|
||||
|
||||
slaveData = """slave=yes
|
||||
counter = counter + 1
|
||||
|
||||
tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
writeToFile = open(tempPath, 'w')
|
||||
|
||||
for items in data:
|
||||
writeToFile.writelines(items + '\n')
|
||||
|
||||
slaveData = """
|
||||
slave=yes
|
||||
daemon=yes
|
||||
disable-axfr=yes
|
||||
guardian=yes
|
||||
@@ -103,15 +114,14 @@ setuid=pdns
|
||||
superslave=yes
|
||||
"""
|
||||
|
||||
writeToFile.writelines(slaveData)
|
||||
writeToFile.close()
|
||||
writeToFile.writelines(slaveData)
|
||||
writeToFile.close()
|
||||
|
||||
command = 'sudo mv ' + tempPath + ' ' + path
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
for items in Supermasters.objects.all():
|
||||
items.delete()
|
||||
|
||||
Supermasters(ip=self.extraArgs['masterServerIP'], nameserver=self.extraArgs['slaveServerNS'], account='').save()
|
||||
|
||||
command = 'sudo mv ' + tempPath + ' ' + path
|
||||
#subprocess.call(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
|
||||
@@ -51,57 +51,57 @@
|
||||
|
||||
<div ng-hide="masterServerHD" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Slave Server" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<div ng-init="slaveServerNS='{{ slaveServerNS }}'" class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="slaveServerNS" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="masterServerHD" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Master Server IP" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<div ng-init="masterServerIP='{{ masterServerIP }}'" class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="masterServerIP" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="slaveIPs" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Slave Server 1" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<div ng-init="slaveServer='{{ slaveServer }}'" class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="slaveServer" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="slaveIPs" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Slave Server IP" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<div ng-init="slaveServerIP='{{ slaveServerIP }}'" class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="slaveServerIP" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="slaveIPs" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Slave Server 2 (Optional)" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<div ng-init="slaveServer2='{{ slaveServer2 }}'" class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="slaveServer2" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="slaveIPs" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Slave Server IP 2 (Optional)" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<div ng-init="slaveServerIP2='{{ slaveServerIP2 }}'" class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="slaveServerIP2" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="slaveIPs" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Slave Server 3 (Optional)" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<div ng-init="slaveServer3='{{ slaveServer3 }}'" class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="slaveServer3" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="slaveIPs" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Slave Server IP 3 (Optional)" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="slaveIPData" required>
|
||||
<div ng-init="slaveServerIP3='{{ slaveServerIP3 }}'" class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="slaveServerIP3" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import HttpResponse, redirect
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
@@ -14,19 +13,41 @@ from .serviceManager import ServiceManager
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
# Create your views here.
|
||||
|
||||
|
||||
def managePowerDNS(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
try:
|
||||
return render(request, 'manageServices/managePowerDNS.html', {"status": 1})
|
||||
|
||||
data = {}
|
||||
data['status'] = 1
|
||||
|
||||
pdnsStatus = PDNSStatus.objects.get(pk=1)
|
||||
|
||||
if pdnsStatus.type == 'MASTER':
|
||||
counter = 1
|
||||
|
||||
for items in SlaveServers.objects.all():
|
||||
|
||||
if counter == 1:
|
||||
data['slaveServer'] = items.slaveServer
|
||||
data['slaveServerIP'] = items.slaveServerIP
|
||||
else:
|
||||
data['slaveServer%s' % (str(counter))] = items.slaveServer
|
||||
data['slaveServerIP%s' % (str(counter))] = items.slaveServerIP
|
||||
|
||||
counter = counter + 1
|
||||
else:
|
||||
data['slaveServerNS'] = pdnsStatus.masterServer
|
||||
data['masterServerIP'] = pdnsStatus.masterIP
|
||||
|
||||
return render(request, 'manageServices/managePowerDNS.html', data)
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse("See CyberCP main log file.")
|
||||
|
||||
@@ -405,13 +405,19 @@ class ACLManager:
|
||||
return admin.package_set.all()
|
||||
|
||||
@staticmethod
|
||||
def findAllSites(currentACL, userID):
|
||||
def findAllSites(currentACL, userID, fetchChilds = 0):
|
||||
websiteNames = []
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
allWebsites = Websites.objects.all()
|
||||
|
||||
for items in allWebsites:
|
||||
websiteNames.append(items.domain)
|
||||
|
||||
if fetchChilds:
|
||||
for child in items.childdomains_set.all():
|
||||
websiteNames.append(child.domain)
|
||||
|
||||
else:
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
@@ -421,11 +427,19 @@ class ACLManager:
|
||||
for items in websites:
|
||||
websiteNames.append(items.domain)
|
||||
|
||||
if fetchChilds:
|
||||
for child in items.childdomains_set.all():
|
||||
websiteNames.append(child.domain)
|
||||
|
||||
for items in admins:
|
||||
webs = items.websites_set.all()
|
||||
for web in webs:
|
||||
websiteNames.append(web.domain)
|
||||
|
||||
if fetchChilds:
|
||||
for child in web.childdomains_set.all():
|
||||
websiteNames.append(child.domain)
|
||||
|
||||
|
||||
return websiteNames
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
|
||||
if self.installApp == 'wordpress':
|
||||
self.installWordPress()
|
||||
elif self.installApp == 'joomla':
|
||||
@@ -51,10 +52,55 @@ class ApplicationInstaller(multi.Thread):
|
||||
self.installMagento()
|
||||
elif self.installApp == 'convertDomainToSite':
|
||||
self.convertDomainToSite()
|
||||
elif self.installApp == 'updatePackage':
|
||||
self.updatePackage()
|
||||
|
||||
except BaseException as msg:
|
||||
logging.writeToFile(str(msg) + ' [ApplicationInstaller.run]')
|
||||
|
||||
def updatePackage(self):
|
||||
try:
|
||||
|
||||
package = self.extraArgs['package']
|
||||
|
||||
from serverStatus.serverStatusUtil import ServerStatusUtil
|
||||
|
||||
f = open(ServerStatusUtil.lswsInstallStatusPath, 'a')
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
|
||||
if package == 'all':
|
||||
command = 'DEBIAN_FRONTEND=noninteractive apt-get update -y'
|
||||
f.write(ProcessUtilities.outputExecutioner(command))
|
||||
|
||||
f.flush()
|
||||
|
||||
command = 'apt-get upgrade -y'
|
||||
f.write(ProcessUtilities.outputExecutioner(command))
|
||||
else:
|
||||
command = 'apt-get install --only-upgrade %s -y' % (package)
|
||||
f.write(ProcessUtilities.outputExecutioner(command))
|
||||
|
||||
f.close()
|
||||
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
if package == 'all':
|
||||
command = 'yum update -y'
|
||||
f.write(ProcessUtilities.outputExecutioner(command))
|
||||
else:
|
||||
command = 'yum update %s -y' % (package)
|
||||
f.write(ProcessUtilities.outputExecutioner(command))
|
||||
|
||||
f.close()
|
||||
|
||||
logging.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
'Package(s) upgraded successfully. [200]',
|
||||
1)
|
||||
|
||||
except BaseException as msg:
|
||||
from serverStatus.serverStatusUtil import ServerStatusUtil
|
||||
logging.statusWriter(ServerStatusUtil.lswsInstallStatusPath, 'Failed. Error: %s. [404]' % (str(msg)), 1)
|
||||
return 0
|
||||
|
||||
def convertDomainToSite(self):
|
||||
try:
|
||||
|
||||
@@ -368,7 +414,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
homeDir = "/home/" + domainName + "/public_html"
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
groupName = 'nobody'
|
||||
else:
|
||||
groupName = 'nogroup'
|
||||
@@ -544,7 +590,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
homeDir = "/home/" + domainName + "/public_html"
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
groupName = 'nobody'
|
||||
else:
|
||||
groupName = 'nogroup'
|
||||
@@ -704,7 +750,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
shutil.rmtree(finalPath + "installation")
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
groupName = 'nobody'
|
||||
else:
|
||||
groupName = 'nogroup'
|
||||
@@ -730,7 +776,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
homeDir = "/home/" + domainName + "/public_html"
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
groupName = 'nobody'
|
||||
else:
|
||||
groupName = 'nogroup'
|
||||
@@ -918,7 +964,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
homeDir = "/home/" + domainName + "/public_html"
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
groupName = 'nobody'
|
||||
else:
|
||||
groupName = 'nogroup'
|
||||
|
||||
@@ -12,7 +12,7 @@ import os
|
||||
import time
|
||||
from plogical.backupUtilities import backupUtilities
|
||||
from re import match,I,M
|
||||
from websiteFunctions.models import Backups
|
||||
from websiteFunctions.models import Backups, BackupJob, BackupJobLogs
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from random import randint
|
||||
import json, requests
|
||||
@@ -22,14 +22,23 @@ import signal
|
||||
|
||||
class backupSchedule:
|
||||
now = datetime.now()
|
||||
LOCAL = 0
|
||||
REMOTE = 1
|
||||
INFO = 0
|
||||
ERROR = 1
|
||||
backupLog = ''
|
||||
runningPath = '/home/cyberpanel/remoteBackupPID'
|
||||
|
||||
@staticmethod
|
||||
def remoteBackupLogging(fileName, message):
|
||||
def remoteBackupLogging(fileName, message, status = 0):
|
||||
try:
|
||||
file = open(fileName,'a')
|
||||
file.writelines("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] "+ message + "\n")
|
||||
print(("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] "+ message + "\n"))
|
||||
file.close()
|
||||
|
||||
BackupJobLogs(owner=backupSchedule.backupLog, status=status, message="[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] "+ message).save()
|
||||
|
||||
except IOError as msg:
|
||||
return "Can not write to error file."
|
||||
|
||||
@@ -74,11 +83,45 @@ class backupSchedule:
|
||||
except:
|
||||
fileName = "Fetching.."
|
||||
|
||||
ifRunning = ProcessUtilities.outputExecutioner('ps aux')
|
||||
|
||||
if (ifRunning.find('startBackup') > -1 or ifRunning.find('BackupRoot') > -1) and ifRunning.find('/%s/' % (backupDomain)):
|
||||
pass
|
||||
else:
|
||||
if os.path.exists(status):
|
||||
|
||||
status = open(status, 'r').read()
|
||||
time.sleep(2)
|
||||
|
||||
if status.find("Completed") > -1:
|
||||
|
||||
### Removing Files
|
||||
|
||||
command = 'sudo rm -f ' + status
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
command = 'sudo rm -f ' + backupFileNamePath
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
command = 'sudo rm -f ' + pid
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Backup Completed for: " + virtualHost)
|
||||
try:
|
||||
os.remove(pathToFile)
|
||||
except:
|
||||
pass
|
||||
return 1, tempStoragePath
|
||||
else:
|
||||
return 0, 'Backup process killed without reporting any error.'
|
||||
else:
|
||||
|
||||
return 0, 'Backup process killed without reporting any error.'
|
||||
|
||||
## file name read ends
|
||||
|
||||
if os.path.exists(status):
|
||||
status = open(status, 'r').read()
|
||||
print(status)
|
||||
time.sleep(2)
|
||||
|
||||
if status.find("Completed") > -1:
|
||||
@@ -120,18 +163,25 @@ class backupSchedule:
|
||||
except:
|
||||
pass
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "An error occurred, Error message: " + status)
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Local backup creating failed for %s, Error message: %s" % (virtualHost, status), backupSchedule.ERROR)
|
||||
|
||||
try:
|
||||
os.remove(pathToFile)
|
||||
except:
|
||||
pass
|
||||
return 0, tempStoragePath
|
||||
|
||||
elif os.path.exists(schedulerPath):
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, 'Backup process killed without reporting any error.',
|
||||
backupSchedule.ERROR)
|
||||
os.remove(schedulerPath)
|
||||
return 0, 'Backup process killed without reporting any error.'
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [119:startBackup]")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath,
|
||||
"Local backup creating failed for %s, Error message: %s" % (
|
||||
virtualHost, str(msg)), backupSchedule.ERROR)
|
||||
return 0, str(msg)
|
||||
|
||||
@staticmethod
|
||||
@@ -168,6 +218,8 @@ class backupSchedule:
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||
else:
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, 'Remote backup creation failed for %s.' % (virtualHost) )
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||
|
||||
@@ -196,6 +248,9 @@ class backupSchedule:
|
||||
command = "sudo scp -o StrictHostKeyChecking=no -P "+port+" -i /root/.ssh/cyberpanel " + backupPath + " " + user + "@" + IPAddress+":~/backup/" + ipAddressLocal + "/" + time.strftime("%a-%b") + "/"
|
||||
subprocess.call(shlex.split(command), stdout=writeToFile)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile(command)
|
||||
|
||||
## Remove backups already sent to remote destinations
|
||||
|
||||
os.remove(backupPath)
|
||||
@@ -206,16 +261,15 @@ class backupSchedule:
|
||||
@staticmethod
|
||||
def prepare():
|
||||
try:
|
||||
destinations = backupUtilities.destinationsPath
|
||||
|
||||
backupLogPath = "/usr/local/lscp/logs/backup_log."+time.strftime("%m.%d.%Y_%H-%M-%S")
|
||||
if os.path.exists(backupSchedule.runningPath):
|
||||
pid = open(backupSchedule.runningPath, 'r').read()
|
||||
print('\n\nRemote backup is already running with PID: %s. If you want to run again kindly kill the backup process: \n\n kill -9 %s.\n\n' % (pid, pid))
|
||||
return 0
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath,"#################################################")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath," Backup log for: " +time.strftime("%m.%d.%Y_%H-%M-%S"))
|
||||
backupSchedule.remoteBackupLogging(backupLogPath,"#################################################\n")
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||
writeToFile = open(backupSchedule.runningPath, 'w')
|
||||
writeToFile.write(str(os.getpid()))
|
||||
writeToFile.close()
|
||||
|
||||
## IP of Remote server.
|
||||
|
||||
@@ -230,6 +284,27 @@ class backupSchedule:
|
||||
|
||||
ipAddress = data['ipAddress']
|
||||
|
||||
jobSuccessSites = 0
|
||||
jobFailedSites = 0
|
||||
|
||||
backupLogPath = "/usr/local/lscp/logs/backup_log." + time.strftime("%m.%d.%Y_%H-%M-%S")
|
||||
|
||||
backupSchedule.backupLog = BackupJob(logFile=backupLogPath, location=backupSchedule.REMOTE,
|
||||
jobSuccessSites=jobSuccessSites, jobFailedSites=jobFailedSites,
|
||||
ipAddress=ipAddress, port=port)
|
||||
backupSchedule.backupLog.save()
|
||||
|
||||
|
||||
destinations = backupUtilities.destinationsPath
|
||||
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath,"#################################################")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath," Backup log for: " +time.strftime("%m.%d.%Y_%H-%M-%S"))
|
||||
backupSchedule.remoteBackupLogging(backupLogPath,"#################################################\n")
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||
|
||||
## IPAddress of local server
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
@@ -262,7 +337,8 @@ class backupSchedule:
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Remote backup job completed.\n")
|
||||
|
||||
|
||||
if os.path.exists(backupSchedule.runningPath):
|
||||
os.remove(backupSchedule.runningPath)
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [prepare]")
|
||||
|
||||
@@ -17,18 +17,35 @@ from plogical.processUtilities import ProcessUtilities
|
||||
from re import match,I,M
|
||||
import signal
|
||||
from datetime import datetime
|
||||
from websiteFunctions.models import BackupJob, BackupJobLogs
|
||||
|
||||
class backupScheduleLocal:
|
||||
localBackupPath = '/home/cyberpanel/localBackupPath'
|
||||
runningPath = '/home/cyberpanel/localBackupPID'
|
||||
now = datetime.now()
|
||||
|
||||
|
||||
@staticmethod
|
||||
def prepare():
|
||||
try:
|
||||
|
||||
if os.path.exists(backupScheduleLocal.runningPath):
|
||||
pid = open(backupScheduleLocal.runningPath, 'r').read()
|
||||
print('\n\nLocal backup is already running with PID: %s. If you want to run again kindly kill the backup process: \n\n kill -9 %s.\n\n' % (pid, pid))
|
||||
return 0
|
||||
|
||||
writeToFile = open(backupScheduleLocal.runningPath, 'w')
|
||||
writeToFile.write(str(os.getpid()))
|
||||
writeToFile.close()
|
||||
|
||||
backupRunTime = time.strftime("%m.%d.%Y_%H-%M-%S")
|
||||
backupLogPath = "/usr/local/lscp/logs/local_backup_log." + backupRunTime
|
||||
|
||||
jobSuccessSites = 0
|
||||
jobFailedSites = 0
|
||||
|
||||
backupSchedule.backupLog = BackupJob(logFile=backupLogPath, location=backupSchedule.LOCAL, jobSuccessSites=jobSuccessSites, jobFailedSites=jobFailedSites)
|
||||
backupSchedule.backupLog.save()
|
||||
|
||||
writeToFile = open(backupLogPath, "a")
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "#################################################")
|
||||
@@ -43,6 +60,10 @@ class backupScheduleLocal:
|
||||
try:
|
||||
retValues = backupSchedule.createLocalBackup(virtualHost, backupLogPath)
|
||||
|
||||
if retValues[0] == 0:
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, '[ERROR] Backup failed for %s, error: %s moving on..' % (virtualHost, retValues[1]), backupSchedule.ERROR)
|
||||
continue
|
||||
|
||||
if os.path.exists(backupScheduleLocal.localBackupPath):
|
||||
backupPath = retValues[1] + ".tar.gz"
|
||||
localBackupPath = '%s/%s' % (open(backupScheduleLocal.localBackupPath, 'r').read().rstrip('/'), backupRunTime)
|
||||
@@ -52,12 +73,14 @@ class backupScheduleLocal:
|
||||
|
||||
command = 'mv %s %s' % (backupPath, localBackupPath)
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
jobSuccessSites = jobSuccessSites + 1
|
||||
except BaseException as msg:
|
||||
|
||||
jobFailedSites = jobFailedSites + 1
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath,
|
||||
'[ERROR] Backup failed for %s, error: %s moving on..' % (virtualHost, str(msg)))
|
||||
|
||||
|
||||
|
||||
'[ERROR] Backup failed for %s, error: %s moving on..' % (virtualHost, str(msg)), backupSchedule.ERROR)
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||
@@ -71,6 +94,14 @@ class backupScheduleLocal:
|
||||
|
||||
writeToFile.close()
|
||||
|
||||
job = BackupJob.objects.get(logFile=backupLogPath)
|
||||
job.jobFailedSites = jobFailedSites
|
||||
job.jobSuccessSites = jobSuccessSites
|
||||
job.save()
|
||||
|
||||
if os.path.exists(backupScheduleLocal.runningPath):
|
||||
os.remove(backupScheduleLocal.runningPath)
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [214:startBackup]")
|
||||
|
||||
|
||||
@@ -493,7 +493,6 @@ class backupUtilities:
|
||||
items.status = 1
|
||||
items.size = totalSize
|
||||
items.save()
|
||||
logging.CyberCPLogFileWriter.writeToFile(' again size: %s' % (totalSize))
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile('%s. [backupRoot:499]' % str(msg))
|
||||
for items in backupObs:
|
||||
@@ -925,6 +924,11 @@ class backupUtilities:
|
||||
expectation.append("Permission denied")
|
||||
expectation.append("100%")
|
||||
|
||||
## Temp changes
|
||||
|
||||
command = 'chmod 600 %s' % ('/root/.ssh/cyberpanel.pub')
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "scp -o StrictHostKeyChecking=no -P " + port + " /root/.ssh/cyberpanel.pub " + user + "@" + IPAddress + ":~/.ssh/authorized_keys"
|
||||
setupKeys = pexpect.spawn(command, timeout=3)
|
||||
|
||||
@@ -950,15 +954,32 @@ class backupUtilities:
|
||||
else:
|
||||
raise BaseException
|
||||
|
||||
## Temp changes
|
||||
|
||||
command = 'chmod 644 %s' % ('/root/.ssh/cyberpanel.pub')
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
return [1, "None"]
|
||||
|
||||
except pexpect.TIMEOUT as msg:
|
||||
|
||||
command = 'chmod 644 %s' % ('/root/.ssh/cyberpanel.pub')
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [sendKey]")
|
||||
return [0, "TIMEOUT [sendKey]"]
|
||||
except pexpect.EOF as msg:
|
||||
|
||||
command = 'chmod 644 %s' % ('/root/.ssh/cyberpanel.pub')
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [sendKey]")
|
||||
return [0, "EOF [sendKey]"]
|
||||
except BaseException as msg:
|
||||
|
||||
command = 'chmod 644 %s' % ('/root/.ssh/cyberpanel.pub')
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [sendKey]")
|
||||
return [0, str(msg) + " [sendKey]"]
|
||||
|
||||
@@ -981,7 +1002,7 @@ class backupUtilities:
|
||||
expectation.append("Permission denied")
|
||||
expectation.append("File exists")
|
||||
|
||||
command = "ssh -o StrictHostKeyChecking=no -p " + port + ' ' + user + "@" + IPAddress + ' "mkdir ~/.ssh || rm -f ~/.ssh/temp && rm -f ~/.ssh/authorized_temp && cp ~/.ssh/authorized_keys ~/.ssh/temp"'
|
||||
command = "ssh -o StrictHostKeyChecking=no -p " + port + ' ' + user + "@" + IPAddress + ' "mkdir ~/.ssh || rm -f ~/.ssh/temp && rm -f ~/.ssh/authorized_temp && cp ~/.ssh/authorized_keys ~/.ssh/temp || chmod 700 ~/.ssh || chmod g-w ~"'
|
||||
setupKeys = pexpect.spawn(command, timeout=3)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
@@ -1183,6 +1204,7 @@ class backupUtilities:
|
||||
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
|
||||
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel " + user + "@" + IPAddress + ' "cat ~/.ssh/authorized_temp > ~/.ssh/authorized_keys"'
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
|
||||
@@ -9,7 +9,7 @@ class CronUtil:
|
||||
def getWebsiteCron(externalApp):
|
||||
try:
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
cronPath = "/var/spool/cron/" + externalApp
|
||||
else:
|
||||
cronPath = "/var/spool/cron/crontabs/" + externalApp
|
||||
@@ -29,7 +29,7 @@ class CronUtil:
|
||||
try:
|
||||
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
cronPath = "/var/spool/cron/" + externalApp
|
||||
else:
|
||||
cronPath = "/var/spool/cron/crontabs/" + externalApp
|
||||
@@ -51,7 +51,7 @@ class CronUtil:
|
||||
try:
|
||||
line -= 1
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
cronPath = "/var/spool/cron/" + externalApp
|
||||
else:
|
||||
cronPath = "/var/spool/cron/crontabs/" + externalApp
|
||||
@@ -81,7 +81,7 @@ class CronUtil:
|
||||
@staticmethod
|
||||
def addNewCron(externalApp, finalCron):
|
||||
try:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
cronPath = "/var/spool/cron/" + externalApp
|
||||
else:
|
||||
cronPath = "/var/spool/cron/crontabs/" + externalApp
|
||||
@@ -100,7 +100,7 @@ class CronUtil:
|
||||
commandT = 'chmod 755 %s' % (cronParent)
|
||||
ProcessUtilities.executioner(commandT, 'root')
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'chmod 755 /var/spool/cron/crontabs'
|
||||
ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
@@ -109,7 +109,7 @@ class CronUtil:
|
||||
commandT = 'chmod 700 %s' % (cronParent)
|
||||
ProcessUtilities.executioner(commandT, 'root')
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'chmod 1730 /var/spool/cron/crontabs'
|
||||
ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
|
||||
@@ -70,10 +70,10 @@ class CSF(multi.Thread):
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
# install required packages for CSF perl and /usr/bin/host
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'yum install bind-utils net-tools perl-libwww-perl.noarch perl-LWP-Protocol-https.noarch perl-GDGraph ipset -y'
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
elif ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
elif ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'apt-get install dnsutils libwww-perl liblwp-protocol-https-perl libgd-graph-perl net-tools ipset -y'
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
command = 'ln -s /bin/systemctl /usr/bin/systemctl'
|
||||
@@ -309,7 +309,7 @@ class CSF(multi.Thread):
|
||||
##
|
||||
|
||||
# Some Ubuntu initial configurations
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
data = open('/etc/csf/csf.conf', 'r').readlines()
|
||||
writeToConf = open('/etc/csf/csf.conf', 'w')
|
||||
|
||||
|
||||
@@ -121,7 +121,6 @@ class DNS:
|
||||
subDomain = extractDomain.subdomain
|
||||
|
||||
if len(subDomain) == 0:
|
||||
|
||||
if Domains.objects.filter(name=topLevelDomain).count() == 0:
|
||||
try:
|
||||
pdns = PDNSStatus.objects.get(pk=1)
|
||||
@@ -440,13 +439,67 @@ class DNS:
|
||||
|
||||
DNS.createDNSRecord(zone, actualSubDomain, "A", ipAddress, 0, 3600)
|
||||
|
||||
## Mail Record
|
||||
|
||||
DNS.createDNSRecord(zone, 'mail.' + actualSubDomain, "A", ipAddress, 0, 3600)
|
||||
|
||||
# CNAME Records.
|
||||
|
||||
cNameValue = "www." + actualSubDomain
|
||||
|
||||
DNS.createDNSRecord(zone, cNameValue, "CNAME", actualSubDomain, 0, 3600)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
## MX Records
|
||||
|
||||
mxValue = "mail." + actualSubDomain
|
||||
|
||||
record = Records(domainOwner=zone,
|
||||
domain_id=zone.id,
|
||||
name=actualSubDomain,
|
||||
type="MX",
|
||||
content=mxValue,
|
||||
ttl=3600,
|
||||
prio="10",
|
||||
disabled=0,
|
||||
auth=1)
|
||||
record.save()
|
||||
|
||||
## TXT Records
|
||||
|
||||
record = Records(domainOwner=zone,
|
||||
domain_id=zone.id,
|
||||
name=actualSubDomain,
|
||||
type="TXT",
|
||||
content="v=spf1 a mx ip4:" + ipAddress + " ~all",
|
||||
ttl=3600,
|
||||
prio=0,
|
||||
disabled=0,
|
||||
auth=1)
|
||||
record.save()
|
||||
|
||||
record = Records(domainOwner=zone,
|
||||
domain_id=zone.id,
|
||||
name="_dmarc." + actualSubDomain,
|
||||
type="TXT",
|
||||
content="v=DMARC1; p=none",
|
||||
ttl=3600,
|
||||
prio=0,
|
||||
disabled=0,
|
||||
auth=1)
|
||||
record.save()
|
||||
|
||||
record = Records(domainOwner=zone,
|
||||
domain_id=zone.id,
|
||||
name="_domainkey." + actualSubDomain,
|
||||
type="TXT",
|
||||
content="t=y; o=~;",
|
||||
ttl=3600,
|
||||
prio=0,
|
||||
disabled=0,
|
||||
auth=1)
|
||||
record.save()
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'sudo systemctl restart pdns'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
@@ -465,6 +518,7 @@ class DNS:
|
||||
|
||||
extractDomain = tldextract.extract(domain)
|
||||
topLevelDomain = extractDomain.domain + '.' + extractDomain.suffix
|
||||
subDomain = extractDomain.subdomain
|
||||
|
||||
zone = Domains.objects.get(name=topLevelDomain)
|
||||
|
||||
@@ -474,18 +528,33 @@ class DNS:
|
||||
leftIndex = output.index('(') + 2
|
||||
rightIndex = output.rindex(')') - 1
|
||||
|
||||
record = Records(domainOwner=zone,
|
||||
domain_id=zone.id,
|
||||
name="default._domainkey." + topLevelDomain,
|
||||
type="TXT",
|
||||
content=output[leftIndex:rightIndex],
|
||||
ttl=3600,
|
||||
prio=0,
|
||||
disabled=0,
|
||||
auth=1)
|
||||
record.save()
|
||||
if Records.objects.filter(domainOwner=zone, name="default._domainkey." + topLevelDomain).count() == 0:
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
record = Records(domainOwner=zone,
|
||||
domain_id=zone.id,
|
||||
name="default._domainkey." + topLevelDomain,
|
||||
type="TXT",
|
||||
content=output[leftIndex:rightIndex],
|
||||
ttl=3600,
|
||||
prio=0,
|
||||
disabled=0,
|
||||
auth=1)
|
||||
record.save()
|
||||
|
||||
if len(subDomain) > 0:
|
||||
if Records.objects.filter(domainOwner=zone, name="default._domainkey." + domain).count() == 0:
|
||||
record = Records(domainOwner=zone,
|
||||
domain_id=zone.id,
|
||||
name="default._domainkey." + domain,
|
||||
type="TXT",
|
||||
content=output[leftIndex:rightIndex],
|
||||
ttl=3600,
|
||||
prio=0,
|
||||
disabled=0,
|
||||
auth=1)
|
||||
record.save()
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = ' systemctl restart pdns'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
@@ -566,7 +635,7 @@ class DNS:
|
||||
auth=1)
|
||||
record.save()
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'sudo systemctl restart pdns'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
@@ -585,7 +654,7 @@ class DNS:
|
||||
auth=1)
|
||||
record.save()
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'sudo systemctl restart pdns'
|
||||
ProcessUtilities.executioner(command)
|
||||
return
|
||||
@@ -602,7 +671,7 @@ class DNS:
|
||||
auth=1)
|
||||
record.save()
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'sudo systemctl restart pdns'
|
||||
ProcessUtilities.executioner(command)
|
||||
return
|
||||
@@ -618,7 +687,7 @@ class DNS:
|
||||
disabled=0,
|
||||
auth=1)
|
||||
record.save()
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'sudo systemctl restart pdns'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ class FirewallUtilities:
|
||||
|
||||
@staticmethod
|
||||
def resFailed(res):
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu and res != 0:
|
||||
if (ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20) and res != 0:
|
||||
return True
|
||||
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos and res == 1:
|
||||
elif (ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8) and res == 1:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@@ -214,41 +214,39 @@ class mailUtilities:
|
||||
|
||||
import tldextract
|
||||
|
||||
#extractDomain = tldextract.extract(virtualHostName)
|
||||
#virtualHostName = extractDomain.domain + '.' + extractDomain.suffix
|
||||
actualDomain = virtualHostName
|
||||
extractDomain = tldextract.extract(virtualHostName)
|
||||
virtualHostName = extractDomain.domain + '.' + extractDomain.suffix
|
||||
|
||||
if os.path.exists("/etc/opendkim/keys/" + virtualHostName + "/default.txt"):
|
||||
return 1, "None"
|
||||
if not os.path.exists("/etc/opendkim/keys/" + virtualHostName + "/default.txt"):
|
||||
path = '/etc/opendkim/keys/%s' % (virtualHostName)
|
||||
command = 'mkdir %s' % (path)
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
## Generate keys
|
||||
|
||||
path = '/etc/opendkim/keys/%s' % (virtualHostName)
|
||||
command = 'mkdir %s' % (path)
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = "/usr/sbin/opendkim-genkey -D /etc/opendkim/keys/%s -d %s -s default" % (virtualHostName, virtualHostName)
|
||||
else:
|
||||
command = "opendkim-genkey -D /etc/opendkim/keys/%s -d %s -s default" % (
|
||||
virtualHostName, virtualHostName)
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
## Fix permissions
|
||||
|
||||
## Generate keys
|
||||
command = "chown -R root:opendkim /etc/opendkim/keys/" + virtualHostName
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
command = "/usr/sbin/opendkim-genkey -D /etc/opendkim/keys/%s -d %s -s default" % (virtualHostName, virtualHostName)
|
||||
else:
|
||||
command = "opendkim-genkey -D /etc/opendkim/keys/%s -d %s -s default" % (
|
||||
virtualHostName, virtualHostName)
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
## Fix permissions
|
||||
command = "chmod 640 /etc/opendkim/keys/" + virtualHostName + "/default.private"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
command = "chown -R root:opendkim /etc/opendkim/keys/" + virtualHostName
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
command = "chmod 640 /etc/opendkim/keys/" + virtualHostName + "/default.private"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
command = "chmod 644 /etc/opendkim/keys/" + virtualHostName + "/default.txt"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
command = "chmod 644 /etc/opendkim/keys/" + virtualHostName + "/default.txt"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
## Edit key file
|
||||
|
||||
|
||||
keyTable = "/etc/opendkim/KeyTable"
|
||||
configToWrite = "default._domainkey." + virtualHostName + " " + virtualHostName + ":default:/etc/opendkim/keys/" + virtualHostName + "/default.private\n"
|
||||
configToWrite = "default._domainkey." + actualDomain + " " + actualDomain + ":default:/etc/opendkim/keys/" + virtualHostName + "/default.private\n"
|
||||
|
||||
writeToFile = open(keyTable, 'a')
|
||||
writeToFile.write(configToWrite)
|
||||
@@ -257,7 +255,7 @@ class mailUtilities:
|
||||
## Edit signing table
|
||||
|
||||
signingTable = "/etc/opendkim/SigningTable"
|
||||
configToWrite = "*@" + virtualHostName + " default._domainkey." + virtualHostName + "\n"
|
||||
configToWrite = "*@" + actualDomain + " default._domainkey." + actualDomain + "\n"
|
||||
|
||||
writeToFile = open(signingTable, 'a')
|
||||
writeToFile.write(configToWrite)
|
||||
@@ -266,7 +264,7 @@ class mailUtilities:
|
||||
## Trusted hosts
|
||||
|
||||
trustedHosts = "/etc/opendkim/TrustedHosts"
|
||||
configToWrite = virtualHostName + "\n"
|
||||
configToWrite = actualDomain + "\n"
|
||||
|
||||
writeToFile = open(trustedHosts, 'a')
|
||||
writeToFile.write(configToWrite)
|
||||
@@ -451,7 +449,7 @@ milter_default_action = accept
|
||||
def installSpamAssassin(install, SpamAssassin):
|
||||
try:
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'sudo yum install spamassassin -y'
|
||||
else:
|
||||
command = 'sudo apt-get install spamassassin spamc -y'
|
||||
@@ -502,7 +500,7 @@ milter_default_action = accept
|
||||
def configureSpamAssassin():
|
||||
try:
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
confFile = "/etc/mail/spamassassin/local.cf"
|
||||
confData = open(confFile).readlines()
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class modSec:
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'sudo yum install ols-modsecurity -y'
|
||||
else:
|
||||
command = 'sudo DEBIAN_FRONTEND=noninteractive apt-get install ols-modsecurity -y'
|
||||
|
||||
@@ -413,7 +413,7 @@ password=%s
|
||||
def applyMySQLChanges(data):
|
||||
try:
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'sudo mv /etc/my.cnf /etc/my.cnf.bak'
|
||||
else:
|
||||
command = 'sudo mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak'
|
||||
@@ -430,7 +430,7 @@ password=%s
|
||||
writeToFile.close()
|
||||
|
||||
##
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'sudo mv ' + tempPath + ' /etc/my.cnf'
|
||||
else:
|
||||
command = 'sudo mv ' + tempPath + ' /etc/mysql/my.cnf'
|
||||
@@ -440,7 +440,7 @@ password=%s
|
||||
return 1, None
|
||||
|
||||
except BaseException as msg:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'sudo mv /etc/my.cnf.bak /etc/my.cnf'
|
||||
else:
|
||||
command = 'sudo mv /etc/mysql/my.cnf.bak /etc/mysql//my.cnf'
|
||||
|
||||
@@ -20,7 +20,7 @@ class phpUtilities:
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'sudo yum install ' + extension + ' -y'
|
||||
else:
|
||||
command = 'sudo apt-get install ' + extension + ' -y'
|
||||
@@ -54,7 +54,7 @@ class phpUtilities:
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'sudo rpm --nodeps -e ' + extension + ' -v'
|
||||
else:
|
||||
command = 'sudo apt-get remove -y ' + extension
|
||||
@@ -103,7 +103,7 @@ class phpUtilities:
|
||||
command = 'touch %s' % (serverLevelPHPRestart)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
|
||||
else:
|
||||
initial = phpVers[3]
|
||||
|
||||
@@ -16,6 +16,7 @@ class ProcessUtilities(multi.Thread):
|
||||
centos = 1
|
||||
cent8 = 2
|
||||
ubuntu = 0
|
||||
ubuntu20 = 3
|
||||
server_address = '/usr/local/lscpd/admin/comm.sock'
|
||||
token = "unset"
|
||||
|
||||
@@ -139,6 +140,8 @@ class ProcessUtilities(multi.Thread):
|
||||
distroPath = '/etc/lsb-release'
|
||||
|
||||
if os.path.exists(distroPath):
|
||||
if open(distroPath, 'r').read().find('20.04') > -1:
|
||||
return ProcessUtilities.ubuntu20
|
||||
return ProcessUtilities.ubuntu
|
||||
else:
|
||||
if open('/etc/redhat-release', 'r').read().find('CentOS Linux release 8') > -1:
|
||||
@@ -190,8 +193,7 @@ class ProcessUtilities(multi.Thread):
|
||||
sock = ret[0]
|
||||
|
||||
if user == None:
|
||||
|
||||
if command.find('export') > -1 and ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
if command.find('export') > -1:
|
||||
pass
|
||||
elif command.find('sudo') == -1:
|
||||
command = 'sudo %s' % (command)
|
||||
|
||||
@@ -1233,6 +1233,37 @@ class Upgrade:
|
||||
CONSTRAINT `websiteFunctions_git_owner_id_ce74c7de_fk_websiteFu` FOREIGN KEY (`owner_id`) REFERENCES `websiteFunctions_websites` (`id`)
|
||||
)"""
|
||||
|
||||
try:
|
||||
cursor.execute(query)
|
||||
except:
|
||||
pass
|
||||
|
||||
qeury = """CREATE TABLE `websiteFunctions_backupjob` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`logFile` varchar(1000) NOT NULL,
|
||||
`ipAddress` varchar(50) NOT NULL,
|
||||
`port` varchar(15) NOT NULL,
|
||||
`jobFailedSites` int(11) NOT NULL,
|
||||
`jobSuccessSites` int(11) NOT NULL,
|
||||
`location` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
)"""
|
||||
try:
|
||||
cursor.execute(query)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
query = """CREATE TABLE `websiteFunctions_backupjoblogs` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`message` longtext NOT NULL,
|
||||
`owner_id` int(11) NOT NULL,
|
||||
`status` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `websiteFunctions_bac_owner_id_af3d15f9_fk_websiteFu` (`owner_id`),
|
||||
CONSTRAINT `websiteFunctions_bac_owner_id_af3d15f9_fk_websiteFu` FOREIGN KEY (`owner_id`) REFERENCES `websiteFunctions_backupjob` (`id`)
|
||||
)"""
|
||||
|
||||
try:
|
||||
cursor.execute(query)
|
||||
except:
|
||||
|
||||
@@ -91,7 +91,7 @@ class vhost:
|
||||
try:
|
||||
os.makedirs(pathHTML)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
groupName = 'nobody'
|
||||
else:
|
||||
groupName = 'nogroup'
|
||||
@@ -112,7 +112,7 @@ class vhost:
|
||||
try:
|
||||
os.makedirs(pathLogs)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
groupName = 'nobody'
|
||||
else:
|
||||
groupName = 'nogroup'
|
||||
@@ -403,7 +403,7 @@ class vhost:
|
||||
|
||||
##
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'userdel -r -f %s' % (externalApp)
|
||||
else:
|
||||
command = 'deluser %s' % (externalApp)
|
||||
@@ -468,7 +468,7 @@ class vhost:
|
||||
|
||||
##
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'userdel -r -f %s' % (externalApp)
|
||||
else:
|
||||
command = 'deluser %s' % (externalApp)
|
||||
@@ -848,7 +848,7 @@ class vhost:
|
||||
try:
|
||||
os.makedirs(path)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
groupName = 'nobody'
|
||||
else:
|
||||
groupName = 'nogroup'
|
||||
|
||||
@@ -55,6 +55,65 @@ class virtualHostUtilities:
|
||||
cyberPanel = "/usr/local/CyberCP"
|
||||
redisConf = '/usr/local/lsws/conf/dvhost_redis.conf'
|
||||
|
||||
@staticmethod
|
||||
def setupAutoDiscover(mailDomain, tempStatusPath, virtualHostName, admin):
|
||||
|
||||
if mailDomain:
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Creating mail child domain..,80')
|
||||
childDomain = 'mail.%s' % (virtualHostName)
|
||||
childPath = '/home/%s/public_html/%s' % (virtualHostName, childDomain)
|
||||
|
||||
virtualHostUtilities.createDomain(virtualHostName, childDomain, 'PHP 7.2', childPath, 1, 0, 0,
|
||||
admin.userName, 0, "/home/cyberpanel/" + str(randint(1000, 9999)))
|
||||
|
||||
## update dovecot conf to enable auto-discover
|
||||
|
||||
dovecotPath = '/etc/dovecot/dovecot.conf'
|
||||
|
||||
if os.path.exists(dovecotPath):
|
||||
dovecotContent = open(dovecotPath, 'r').read()
|
||||
|
||||
if dovecotContent.find(childDomain) == -1:
|
||||
content = """\nlocal_name %s {
|
||||
ssl_cert = </etc/letsencrypt/live/%s/fullchain.pem
|
||||
ssl_key = </etc/letsencrypt/live/%s/privkey.pem
|
||||
}\n""" % (childDomain, childDomain, childDomain)
|
||||
|
||||
writeToFile = open(dovecotPath, 'a')
|
||||
writeToFile.write(content)
|
||||
writeToFile.close()
|
||||
|
||||
command = 'systemctl restart dovecot'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
### Update postfix configurations
|
||||
|
||||
postFixPath = '/etc/postfix/main.cf'
|
||||
|
||||
postFixContent = open(postFixPath, 'r').read()
|
||||
|
||||
if postFixContent.find('tls_server_sni_maps') == -1:
|
||||
writeToFile = open(postFixPath, 'a')
|
||||
writeToFile.write('\ntls_server_sni_maps = hash:/etc/postfix/vmail_ssl.map\n')
|
||||
writeToFile.close()
|
||||
|
||||
postfixMapFile = '/etc/postfix/vmail_ssl.map'
|
||||
|
||||
mapContent = '%s /etc/letsencrypt/live/%s/privkey.pem /etc/letsencrypt/live/%s/fullchain.pem\n' % (
|
||||
childDomain, childDomain, childDomain)
|
||||
|
||||
writeToFile = open(postfixMapFile, 'a')
|
||||
writeToFile.write(mapContent)
|
||||
writeToFile.close()
|
||||
|
||||
command = 'postmap -F hash:/etc/postfix/vmail_ssl.map'
|
||||
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'systemctl restart postfix'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
@staticmethod
|
||||
def createVirtualHost(virtualHostName, administratorEmail, phpVersion, virtualHostUser, ssl,
|
||||
dkimCheck, openBasedir, websiteOwner, packageName, apache,
|
||||
@@ -206,57 +265,7 @@ class virtualHostUtilities:
|
||||
|
||||
### For autodiscover of mail clients.
|
||||
|
||||
if mailDomain:
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Creating mail child domain..,80')
|
||||
childDomain = 'mail.%s' % (virtualHostName)
|
||||
childPath = '/home/%s/public_html/%s' % (virtualHostName, childDomain)
|
||||
|
||||
virtualHostUtilities.createDomain(virtualHostName, childDomain, 'PHP 7.2', childPath, 1, 0, 0, admin.userName, 0, "/home/cyberpanel/" + str(randint(1000, 9999)))
|
||||
|
||||
## update dovecot conf to enable auto-discover
|
||||
|
||||
dovecotPath = '/etc/dovecot/dovecot.conf'
|
||||
|
||||
if os.path.exists(dovecotPath):
|
||||
dovecotContent = open(dovecotPath, 'r').read()
|
||||
|
||||
if dovecotContent.find(childDomain) == -1:
|
||||
content = """\nlocal_name %s {
|
||||
ssl_cert = </etc/letsencrypt/live/%s/fullchain.pem
|
||||
ssl_key = </etc/letsencrypt/live/%s/privkey.pem
|
||||
}\n""" % (childDomain, childDomain, childDomain)
|
||||
|
||||
writeToFile = open(dovecotPath, 'a')
|
||||
writeToFile.write(content)
|
||||
writeToFile.close()
|
||||
|
||||
command = 'systemctl restart dovecot'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
### Update postfix configurations
|
||||
|
||||
postFixPath = '/etc/postfix/main.cf'
|
||||
|
||||
postFixContent = open(postFixPath, 'r').read()
|
||||
|
||||
if postFixContent.find('tls_server_sni_maps') == -1:
|
||||
writeToFile = open(postFixPath, 'a')
|
||||
writeToFile.write('\ntls_server_sni_maps = hash:/etc/postfix/vmail_ssl.map\n')
|
||||
writeToFile.close()
|
||||
|
||||
postfixMapFile = '/etc/postfix/vmail_ssl.map'
|
||||
|
||||
mapContent = '%s /etc/letsencrypt/live/%s/privkey.pem /etc/letsencrypt/live/%s/fullchain.pem\n' % (childDomain, childDomain, childDomain)
|
||||
|
||||
writeToFile = open(postfixMapFile, 'a')
|
||||
writeToFile.write(mapContent)
|
||||
writeToFile.close()
|
||||
|
||||
command = 'postmap -F hash:/etc/postfix/vmail_ssl.map'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'systemctl restart postfix'
|
||||
ProcessUtilities.executioner(command)
|
||||
virtualHostUtilities.setupAutoDiscover(mailDomain, tempStatusPath, virtualHostName, admin)
|
||||
|
||||
###
|
||||
|
||||
@@ -299,10 +308,7 @@ class virtualHostUtilities:
|
||||
print("0, %s file is symlinked." % (fileName))
|
||||
return 0
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
groupName = 'nobody'
|
||||
else:
|
||||
groupName = 'nogroup'
|
||||
groupName = 'nobody'
|
||||
|
||||
numberOfTotalLines = int(ProcessUtilities.outputExecutioner('wc -l %s' % (fileName), groupName).split(" ")[0])
|
||||
|
||||
@@ -1429,6 +1435,9 @@ def main():
|
||||
virtualHostUtilities.createVirtualHost(args.virtualHostName, args.administratorEmail, args.phpVersion,
|
||||
args.virtualHostUser, int(args.ssl), dkimCheck, openBasedir,
|
||||
args.websiteOwner, args.package, apache, tempStatusPath, int(args.mailDomain))
|
||||
elif args.function == "setupAutoDiscover":
|
||||
admin = Administrator.objects.get(userName=args.websiteOwner)
|
||||
virtualHostUtilities.setupAutoDiscover(1, '/home/cyberpanel/templogs', args.virtualHostName, admin)
|
||||
elif args.function == "deleteVirtualHostConfigurations":
|
||||
vhost.deleteVirtualHostConfigurations(args.virtualHostName)
|
||||
elif args.function == "createDomain":
|
||||
|
||||
@@ -6,9 +6,7 @@ backports.ssl-match-hostname==3.5.0.1
|
||||
bcrypt==3.1.7
|
||||
boto3==1.9.64
|
||||
botocore==1.12.64
|
||||
certbot==0.21.1
|
||||
certifi==2018.4.16
|
||||
cffi==1.11.5
|
||||
chardet==3.0.4
|
||||
cloudflare==2.6.1
|
||||
ConfigArgParse==0.15.2
|
||||
|
||||
@@ -131,12 +131,12 @@ def getLogsFromFile(request):
|
||||
elif type == "error":
|
||||
fileName = installUtilities.Server_root_path + "/logs/error.log"
|
||||
elif type == "email":
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
fileName = "/var/log/maillog"
|
||||
else:
|
||||
fileName = "/var/log/mail.log"
|
||||
elif type == "ftp":
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
fileName = "/var/log/messages"
|
||||
else:
|
||||
fileName = "/var/log/syslog"
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Java script code to start/stop litespeed */
|
||||
app.controller('litespeedStatus', function ($scope, $http) {
|
||||
|
||||
@@ -49,8 +48,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
|
||||
$scope.actionResultBad = true;
|
||||
$scope.serverStatusCouldNotConnect = true;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$scope.restartorStopLoading = true;
|
||||
$scope.actionResult = true;
|
||||
@@ -109,8 +107,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
|
||||
$scope.actionResultBad = true;
|
||||
$scope.serverStatusCouldNotConnect = true;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$scope.restartorStopLoading = true;
|
||||
$scope.actionResult = true;
|
||||
@@ -174,8 +171,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
|
||||
});
|
||||
$scope.lsSerial = response.data.lsSerial;
|
||||
$scope.lsexpiration = response.data.lsexpiration;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.cpLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
@@ -229,8 +225,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
|
||||
text: 'License successfully Updated',
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.cpLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
@@ -292,8 +287,7 @@ app.controller('readCyberCPLogFile', function ($scope, $http) {
|
||||
$scope.logsData = response.data.logsdata;
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$scope.logFileLoading = true;
|
||||
$scope.logsFeteched = true;
|
||||
@@ -347,8 +341,7 @@ app.controller('readCyberCPLogFile', function ($scope, $http) {
|
||||
$scope.logsData = response.data.logsdata;
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$scope.logFileLoading = true;
|
||||
$scope.logsFeteched = true;
|
||||
@@ -409,8 +402,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.olsStart = false;
|
||||
$scope.olsStop = true;
|
||||
$scope.olsMem = Math.round(parseInt(response.data.memUsage.litespeed) / 1048576) + " MB";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.olsStatus = "Stopped";
|
||||
$scope.olsStats = false;
|
||||
$scope.olsStart = true;
|
||||
@@ -421,8 +413,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.dockerStatus = "Running";
|
||||
$scope.dockerStart = false;
|
||||
$scope.dockerStop = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.dockerStatus = "Stopped";
|
||||
$scope.dockerStart = true;
|
||||
$scope.dockerStop = false;
|
||||
@@ -435,8 +426,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.sqlStart = false;
|
||||
$scope.sqlStop = true;
|
||||
$scope.sqlMem = Math.round(parseInt(response.data.memUsage.mysql) / 1048576) + " MB";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.sqlStatus = "Stopped";
|
||||
$scope.sqlStats = false;
|
||||
$scope.sqlStart = true;
|
||||
@@ -451,8 +441,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.dnsStart = false;
|
||||
$scope.dnsStop = true;
|
||||
$scope.dnsMem = Math.round(parseInt(response.data.memUsage.powerdns) / 1048576) + " MB";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.dnsStatus = "Stopped";
|
||||
$scope.dnsStats = false;
|
||||
$scope.dnsStart = true;
|
||||
@@ -467,8 +456,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.ftpStart = false;
|
||||
$scope.ftpStop = true;
|
||||
$scope.ftpMem = Math.round(parseInt(response.data.memUsage.pureftp) / 1048576) + " MB";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.ftpStatus = "Stopped";
|
||||
$scope.ftpStats = false;
|
||||
$scope.ftpStart = true;
|
||||
@@ -487,6 +475,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getServiceStatus();
|
||||
|
||||
$scope.serviceAction = function (serviceName, action) {
|
||||
@@ -524,8 +513,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.actionLoader = false;
|
||||
$scope.btnDisable = false;
|
||||
}, 3000);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setTimeout(function () {
|
||||
getServiceStatus();
|
||||
$scope.ActionSuccessfull = false;
|
||||
@@ -583,8 +571,7 @@ app.controller('lswsSwitch', function ($scope, $http, $timeout, $window) {
|
||||
if (response.data.status === 1) {
|
||||
$scope.installBoxGen = false;
|
||||
getRequestStatus();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
@@ -626,8 +613,7 @@ app.controller('lswsSwitch', function ($scope, $http, $timeout, $window) {
|
||||
if (response.data.abort === 0) {
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
$timeout(getRequestStatus, 1000);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Notifications
|
||||
$scope.cyberPanelLoading = true;
|
||||
$timeout.cancel();
|
||||
@@ -720,8 +706,7 @@ app.controller('topProcesses', function ($scope, $http, $timeout) {
|
||||
$scope.zombieProcesses = response.data.zombieProcesses;
|
||||
|
||||
$timeout($scope.topProcessesStatus, 3000);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
@@ -771,8 +756,7 @@ app.controller('topProcesses', function ($scope, $http, $timeout) {
|
||||
text: 'Process successfully killed.',
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
@@ -793,4 +777,236 @@ app.controller('topProcesses', function ($scope, $http, $timeout) {
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
///
|
||||
|
||||
|
||||
app.controller('listOSPackages', function ($scope, $http, $timeout) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
|
||||
$scope.currentPage = 1;
|
||||
$scope.recordsToShow = 10;
|
||||
var globalType;
|
||||
|
||||
$scope.fetchPackages = function (type = 'installed') {
|
||||
$scope.cyberpanelLoading = false;
|
||||
globalType = type;
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
page: $scope.currentPage,
|
||||
recordsToShow: $scope.recordsToShow,
|
||||
type: type
|
||||
};
|
||||
|
||||
dataurl = "/serverstatus/fetchPackages";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.allPackages = JSON.parse(response.data.packages);
|
||||
$scope.pagination = response.data.pagination;
|
||||
$scope.fetchedPackages = response.data.fetchedPackages;
|
||||
$scope.totalPackages = response.data.totalPackages;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
$scope.fetchPackages('upgrade');
|
||||
|
||||
$scope.fetchPackageDetails = function (packageFetch) {
|
||||
$scope.cyberpanelLoading = false;
|
||||
$scope.package = packageFetch;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
package: packageFetch
|
||||
};
|
||||
|
||||
dataurl = "/serverstatus/fetchPackageDetails";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.packageDetails = response.data.packageDetails;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.updatePackage = function (packageToUpgrade = 'all') {
|
||||
$scope.cyberpanelLoading = false;
|
||||
$scope.package = packageToUpgrade;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
package: packageToUpgrade
|
||||
};
|
||||
|
||||
dataurl = "/serverstatus/updatePackage";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
getRequestStatus();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
function getRequestStatus() {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
url = "/serverstatus/switchTOLSWSStatus";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
if (response.data.abort === 0) {
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
$timeout(getRequestStatus, 1000);
|
||||
} else {
|
||||
// Notifications
|
||||
$timeout.cancel();
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$scope.lockStatus = function (lockPackage, type) {
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
package: lockPackage,
|
||||
type: type,
|
||||
};
|
||||
|
||||
dataurl = "/serverstatus/lockStatus";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Status updated.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.fetchPackages(globalType);
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
589
serverStatus/templates/serverStatus/packageManager.html
Executable file
589
serverStatus/templates/serverStatus/packageManager.html
Executable file
@@ -0,0 +1,589 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Package Manager - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div ng-controller="listOSPackages" class="container">
|
||||
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Package Manager" %}</h2>
|
||||
<p>{% trans "On this page you can manage your system packages. On backend system available package manager is used (apt/yum)." %}</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
|
||||
<div class="example-box-wrapper">
|
||||
<ul class="nav-responsive nav nav-tabs">
|
||||
<li class="active"><a ng-click="fetchPackages('upgrade')" href="#tab4"
|
||||
data-toggle="tab">Updates</a></li>
|
||||
<li><a ng-click="fetchPackages()" href="#tab6" data-toggle="tab">All Packages</a></li>
|
||||
<li><a ng-click="fetchPackages('CyberPanel')" href="#tab7" data-toggle="tab">CyberPanel Packages</a></li>
|
||||
<img ng-hide="cyberpanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="tab4">
|
||||
<a style="float: left ; margin-bottom: 2%"
|
||||
class="btn btn-border btn-alt border-azure btn-link font-azure" href="#"
|
||||
title=""><span>Total Upgradeable Packages: {$ totalPackages $}</span></a>
|
||||
<a style="float: left; margin-bottom: 2%; margin-left: 2%"
|
||||
class="btn btn-border btn-alt border-blue-alt btn-link font-blue-alt" href="#"
|
||||
title=""><span>Fetched Packages: {$ fetchedPackages $}</span></a>
|
||||
|
||||
<a ng-click="updatePackage('all')" data-toggle="modal"
|
||||
data-target="#updatePackage" style="margin-left: 1%"
|
||||
class="btn btn-border btn-alt border-azure btn-link font-azure"
|
||||
href="#"
|
||||
title=""><span>Update All</span></a>
|
||||
|
||||
<div id="updatePackage" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal">
|
||||
×
|
||||
</button>
|
||||
<h4 class="modal-title">Upgrading {$ package $}
|
||||
package(s).
|
||||
<img ng-hide="cyberpanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="requestData"
|
||||
class="form-control"
|
||||
rows="12"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
ng-disabled="savingSettings"
|
||||
class="btn btn-default"
|
||||
data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-10"
|
||||
style="padding: 0px; box-shadow: 0px 0px 1px 0px #888888; margin-bottom: 2%">
|
||||
<input placeholder="Search..."
|
||||
ng-model="packSearch" name="packSearch" type="text"
|
||||
class="form-control" required>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<div class="form-group">
|
||||
<select ng-model="recordsToShow" ng-change="fetchPackages('upgrade')"
|
||||
class="form-control" id="example-select">
|
||||
<option>10</option>
|
||||
<option>50</option>
|
||||
<option>100</option>
|
||||
<option>500</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
|
||||
<table class="table" style="margin: 0px; padding: 0px">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Package" %}</th>
|
||||
<th>{% trans "Version" %}</th>
|
||||
<th>{% trans "Upgrade" %}</th>
|
||||
<th>{% trans "Lock" %}</th>
|
||||
<th>{% trans "Actions" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="record in allPackages | filter:packSearch">
|
||||
<td ng-bind="record.package"></td>
|
||||
<td ng-bind="record.version"></td>
|
||||
<td ng-bind="record.upgrade"></td>
|
||||
<td>
|
||||
<a ng-click="lockStatus(record.package, 0)" href=""><i ng-show="record.lock==1" class="glyph-icon tooltip-button demo-icon icon-lock" title="Packed is locked for upgrade."></i></a>
|
||||
<a ng-click="lockStatus(record.package, 1)" href=""><i ng-show="record.lock==0" class="glyph-icon tooltip-button demo-icon icon-unlock" title="Package is unlocked"></i></a>
|
||||
</td>
|
||||
<td>
|
||||
<a data-toggle="modal" data-target="#packageDetails"
|
||||
ng-click="fetchPackageDetails(record.package)"
|
||||
class="btn btn-border btn-alt border-blue-alt btn-link font-blue-alt"
|
||||
href="#"
|
||||
title=""><span>Details</span></a>
|
||||
<div id="packageDetails" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal">
|
||||
×
|
||||
</button>
|
||||
<h4 class="modal-title">Package {$ package $}
|
||||
details.
|
||||
<img ng-hide="cyberpanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="packageDetails"
|
||||
class="form-control"
|
||||
rows="12"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
ng-disabled="savingSettings"
|
||||
class="btn btn-default"
|
||||
data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a ng-click="updatePackage(record.package)" data-toggle="modal"
|
||||
data-target="#updatePackage" style="margin-left: 1%"
|
||||
class="btn btn-border btn-alt border-azure btn-link font-azure"
|
||||
href="#"
|
||||
title=""><span>Update</span></a>
|
||||
<div id="updatePackage" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal">
|
||||
×
|
||||
</button>
|
||||
<h4 class="modal-title">Upgrading {$ package $}
|
||||
package(s).
|
||||
<img ng-hide="cyberpanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="requestData"
|
||||
class="form-control"
|
||||
rows="12"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
ng-disabled="savingSettings"
|
||||
class="btn btn-default"
|
||||
data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 2%" class="row">
|
||||
<div style="margin-top: 2%" class="col-md-12">
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<select ng-model="currentPage" class="form-control"
|
||||
ng-change="fetchPackages('upgrade')">
|
||||
<option ng-repeat="page in pagination">{$ $index + 1 $}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end row -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab6">
|
||||
<a style="float: left ; margin-bottom: 2%"
|
||||
class="btn btn-border btn-alt border-azure btn-link font-azure" href="#"
|
||||
title=""><span>Total Packages: {$ totalPackages $}</span></a>
|
||||
<a style="float: left; margin-bottom: 2%; margin-left: 2%"
|
||||
class="btn btn-border btn-alt border-blue-alt btn-link font-blue-alt" href="#"
|
||||
title=""><span>Fetched Packages: {$ fetchedPackages $}</span></a>
|
||||
<div class="col-sm-10"
|
||||
style="padding: 0px; box-shadow: 0px 0px 1px 0px #888888; margin-bottom: 2%">
|
||||
<input placeholder="Search..."
|
||||
ng-model="packSearch" name="packSearch" type="text"
|
||||
class="form-control" required>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<div class="form-group">
|
||||
<select ng-model="recordsToShow" ng-change="fetchPackages()"
|
||||
class="form-control" id="example-select">
|
||||
<option>10</option>
|
||||
<option>50</option>
|
||||
<option>100</option>
|
||||
<option>500</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
|
||||
<table class="table" style="margin: 0px; padding: 0px">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Package" %}</th>
|
||||
<th>{% trans "Version" %}</th>
|
||||
<th>{% trans "Upgrade" %}</th>
|
||||
<th>{% trans "Lock" %}</th>
|
||||
<th>{% trans "Actions" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="record in allPackages | filter:packSearch">
|
||||
<td ng-bind="record.package"></td>
|
||||
<td ng-bind="record.version"></td>
|
||||
<td ng-bind="record.upgrade"></td>
|
||||
<td>
|
||||
<a ng-click="lockStatus(record.package, 0)" href=""><i ng-show="record.lock==1" class="glyph-icon tooltip-button demo-icon icon-lock" title="Packed is locked for upgrade."></i></a>
|
||||
<a ng-click="lockStatus(record.package, 1)" href=""><i ng-show="record.lock==0" class="glyph-icon tooltip-button demo-icon icon-unlock" title="Package is unlocked"></i></a>
|
||||
</td>
|
||||
<td>
|
||||
<a data-toggle="modal" data-target="#packageDetailsInstalled"
|
||||
ng-click="fetchPackageDetails(record.package)"
|
||||
class="btn btn-border btn-alt border-blue-alt btn-link font-blue-alt"
|
||||
href="#"
|
||||
title=""><span>Details</span></a>
|
||||
<div id="packageDetailsInstalled" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal">
|
||||
×
|
||||
</button>
|
||||
<h4 class="modal-title">Package {$ package $}
|
||||
details.
|
||||
<img ng-hide="cyberpanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="packageDetails"
|
||||
class="form-control"
|
||||
rows="12"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
ng-disabled="savingSettings"
|
||||
class="btn btn-default"
|
||||
data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 2%" class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<select ng-model="currentPage" class="form-control"
|
||||
ng-change="fetchPackages()">
|
||||
<option ng-repeat="page in pagination">{$ $index + 1 $}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end row -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab7">
|
||||
<a style="float: left ; margin-bottom: 2%"
|
||||
class="btn btn-border btn-alt border-azure btn-link font-azure" href="#"
|
||||
title=""><span>Total Packages: {$ totalPackages $}</span></a>
|
||||
<a style="float: left; margin-bottom: 2%; margin-left: 2%"
|
||||
class="btn btn-border btn-alt border-blue-alt btn-link font-blue-alt" href="#"
|
||||
title=""><span>Fetched Packages: {$ fetchedPackages $}</span></a>
|
||||
|
||||
<div id="updatePackage" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal">
|
||||
×
|
||||
</button>
|
||||
<h4 class="modal-title">Upgrading {$ package $}
|
||||
package(s).
|
||||
<img ng-hide="cyberpanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="requestData"
|
||||
class="form-control"
|
||||
rows="12"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
ng-disabled="savingSettings"
|
||||
class="btn btn-default"
|
||||
data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-10"
|
||||
style="padding: 0px; box-shadow: 0px 0px 1px 0px #888888; margin-bottom: 2%">
|
||||
<input placeholder="Search..."
|
||||
ng-model="packSearch" name="packSearch" type="text"
|
||||
class="form-control" required>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<div class="form-group">
|
||||
<select ng-model="recordsToShow" ng-change="fetchPackages('CyberPanel')"
|
||||
class="form-control" id="example-select">
|
||||
<option>10</option>
|
||||
<option>50</option>
|
||||
<option>100</option>
|
||||
<option>500</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
|
||||
<table class="table" style="margin: 0px; padding: 0px">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Package" %}</th>
|
||||
<th>{% trans "Version" %}</th>
|
||||
<th>{% trans "Lock" %}</th>
|
||||
<th>{% trans "Actions" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="record in allPackages | filter:packSearch">
|
||||
<td ng-bind="record.package"></td>
|
||||
<td ng-bind="record.version"></td>
|
||||
<td>
|
||||
<a ng-click="lockStatus(record.package, 0)" href=""><i ng-show="record.lock==1" class="glyph-icon tooltip-button demo-icon icon-lock" title="Packed is locked for upgrade."></i></a>
|
||||
<a ng-click="lockStatus(record.package, 1)" href=""><i ng-show="record.lock==0" class="glyph-icon tooltip-button demo-icon icon-unlock" title="Package is unlocked"></i></a>
|
||||
</td>
|
||||
<td>
|
||||
<a data-toggle="modal" data-target="#packageDetailsCyberPanel"
|
||||
ng-click="fetchPackageDetails(record.package)"
|
||||
class="btn btn-border btn-alt border-blue-alt btn-link font-blue-alt"
|
||||
href="#"
|
||||
title=""><span>Details</span></a>
|
||||
<div id="packageDetailsCyberPanel" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal">
|
||||
×
|
||||
</button>
|
||||
<h4 class="modal-title">Package {$ package $}
|
||||
details.
|
||||
<img ng-hide="cyberpanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="packageDetails"
|
||||
class="form-control"
|
||||
rows="12"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
ng-disabled="savingSettings"
|
||||
class="btn btn-default"
|
||||
data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a ng-click="updatePackage(record.package)" data-toggle="modal"
|
||||
data-target="#updatePackageCyberPanel" style="margin-left: 1%"
|
||||
class="btn btn-border btn-alt border-azure btn-link font-azure"
|
||||
href="#"
|
||||
title=""><span>Update</span></a>
|
||||
<div id="updatePackageCyberPanel" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal">
|
||||
×
|
||||
</button>
|
||||
<h4 class="modal-title">Upgrading {$ package $}
|
||||
package(s).
|
||||
<img ng-hide="cyberpanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="requestData"
|
||||
class="form-control"
|
||||
rows="12"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
ng-disabled="savingSettings"
|
||||
class="btn btn-default"
|
||||
data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 2%" class="row">
|
||||
<div style="margin-top: 2%" class="col-md-12">
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<select ng-model="currentPage" class="form-control"
|
||||
ng-change="fetchPackages('CyberPanel')">
|
||||
<option ng-repeat="page in pagination">{$ $index + 1 $}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end row -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -18,5 +18,10 @@ urlpatterns = [
|
||||
url(r'^topProcesses$', views.topProcesses, name='topProcesses'),
|
||||
url(r'^topProcessesStatus$', views.topProcessesStatus, name='topProcessesStatus'),
|
||||
url(r'^killProcess$', views.killProcess, name='killProcess'),
|
||||
url(r'^packageManager$', views.packageManager, name='packageManager'),
|
||||
url(r'^fetchPackages$', views.fetchPackages, name='fetchPackages'),
|
||||
url(r'^fetchPackageDetails$', views.fetchPackageDetails, name='fetchPackageDetails'),
|
||||
url(r'^updatePackage$', views.updatePackage, name='updatePackage'),
|
||||
url(r'^lockStatus$', views.lockStatus, name='lockStatus'),
|
||||
|
||||
]
|
||||
@@ -6,7 +6,7 @@ from django.http import HttpResponse
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from loginSystem.views import loadLoginPage
|
||||
import json
|
||||
import subprocess
|
||||
import subprocess, shlex
|
||||
import psutil
|
||||
import socket
|
||||
from plogical.acl import ACLManager
|
||||
@@ -93,7 +93,6 @@ def litespeedStatus(request):
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def stopOrRestartLitespeed(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -127,7 +126,6 @@ def stopOrRestartLitespeed(request):
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[stopOrRestartLitespeed]")
|
||||
return HttpResponse("Not Logged in as admin")
|
||||
|
||||
|
||||
def cyberCPMainLogFile(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -145,7 +143,6 @@ def cyberCPMainLogFile(request):
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[cyberCPMainLogFile]")
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def getFurtherDataFromLogFile(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -196,7 +193,6 @@ def services(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def servicesStatus(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -291,7 +287,6 @@ def servicesStatus(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def servicesAction(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -344,7 +339,6 @@ def servicesAction(request):
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
def switchTOLSWS(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -378,7 +372,6 @@ def switchTOLSWS(request):
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def switchTOLSWSStatus(request):
|
||||
try:
|
||||
|
||||
@@ -505,7 +498,6 @@ def topProcesses(request):
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def topProcessesStatus(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -580,17 +572,57 @@ def topProcessesStatus(request):
|
||||
data['Softirqs'] = loadNow[13] + '%'
|
||||
|
||||
## Memory
|
||||
data['totalMemory'] = str(int(float(memory[3]) / 1024)) + 'MB'
|
||||
data['freeMemory'] = str(int(float(memory[5]) / 1024)) + 'MB'
|
||||
data['usedMemory'] = str(int(float(memory[7]) / 1024)) + 'MB'
|
||||
data['buffCache'] = str(int(float(memory[9]) / 1024)) + 'MB'
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(memory))
|
||||
|
||||
if memory[3].find('+') > -1:
|
||||
memoryFinal = memory[3].split('+')[0]
|
||||
else:
|
||||
memoryFinal = memory[3]
|
||||
|
||||
data['totalMemory'] = str(int(float(memoryFinal) / 1024)) + 'MB'
|
||||
|
||||
|
||||
##
|
||||
|
||||
if memory[5].find('free') > -1:
|
||||
data['freeMemory'] = str(int(float(memory[4]) / 1024)) + 'MB'
|
||||
else:
|
||||
data['freeMemory'] = str(int(float(memory[5]) / 1024)) + 'MB'
|
||||
|
||||
|
||||
##
|
||||
|
||||
if memory[7].find('used') > -1:
|
||||
data['usedMemory'] = str(int(float(memory[6]) / 1024)) + 'MB'
|
||||
else:
|
||||
data['usedMemory'] = str(int(float(memory[7]) / 1024)) + 'MB'
|
||||
|
||||
|
||||
try:
|
||||
if memory[9].find('buff') > -1:
|
||||
data['buffCache'] = str(int(float(memory[8]) / 1024)) + 'MB'
|
||||
else:
|
||||
data['buffCache'] = str(int(float(memory[9]) / 1024)) + 'MB'
|
||||
except:
|
||||
logging.CyberCPLogFileWriter.writeToFile(memory[8])
|
||||
data['buffCache'] = str(int(float(memory[8].split('+')[0]) / 1024)) + 'MB'
|
||||
|
||||
|
||||
## Swap
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(swap))
|
||||
|
||||
|
||||
data['swapTotalMemory'] = str(int(float(swap[2]) / 1024)) + 'MB'
|
||||
data['swapFreeMemory'] = str(int(float(swap[4]) / 1024)) + 'MB'
|
||||
data['swapUsedMemory'] = str(int(float(swap[6]) / 1024)) + 'MB'
|
||||
data['swapBuffCache'] = str(int(float(swap[8]) / 1024)) + 'MB'
|
||||
|
||||
if swap[8].find('+') > -1:
|
||||
finalBuffCache = swap[8].split('+')[0]
|
||||
data['swapBuffCache'] = str(int(float(finalBuffCache) / 1024)) + 'MB'
|
||||
else:
|
||||
data['swapBuffCache'] = str(int(float(swap[8]) / 1024)) + 'MB'
|
||||
|
||||
## Processes
|
||||
|
||||
@@ -628,7 +660,6 @@ def topProcessesStatus(request):
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def killProcess(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -656,4 +687,416 @@ def killProcess(request):
|
||||
except KeyError as msg:
|
||||
final_dic = {'status': 0, 'erroMessage': str(msg)}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def packageManager(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
templateName = "serverStatus/packageManager.html"
|
||||
proc = httpProc(request, templateName)
|
||||
return proc.renderPre()
|
||||
|
||||
except KeyError as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[packageManager]")
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def fetchPackages(request):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
data = json.loads(request.body)
|
||||
page = int(str(data['page']).rstrip('\n'))
|
||||
recordsToShow = int(data['recordsToShow'])
|
||||
type = data['type']
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
|
||||
command = 'apt-mark showhold'
|
||||
locked = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
if type == 'CyberPanel':
|
||||
|
||||
command = 'cat /usr/local/CyberCP/AllCPUbuntu.json'
|
||||
packages = json.loads(ProcessUtilities.outputExecutioner(command))
|
||||
|
||||
else:
|
||||
command = 'apt list --installed'
|
||||
packages = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
packages = packages[4:]
|
||||
|
||||
upgradePackages = []
|
||||
|
||||
if type == 'upgrade':
|
||||
for pack in packages:
|
||||
if pack.find('upgradable') > -1:
|
||||
upgradePackages.append(pack)
|
||||
|
||||
packages = upgradePackages
|
||||
|
||||
|
||||
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
|
||||
### Check Package Lock status
|
||||
|
||||
if os.path.exists('/etc/yum.conf'):
|
||||
yumConf = '/etc/yum.conf'
|
||||
elif os.path.exists('/etc/yum/yum.conf'):
|
||||
yumConf = '/etc/yum/yum.conf'
|
||||
|
||||
yumConfData = open(yumConf, 'r').read()
|
||||
locked = []
|
||||
|
||||
if yumConfData.find('exclude') > -1:
|
||||
|
||||
data = open(yumConf, 'r').readlines()
|
||||
|
||||
for items in data:
|
||||
if items.find('exclude') > -1:
|
||||
locked = items.split('=')[1].rstrip('\n').split(' ')
|
||||
break
|
||||
|
||||
if type == 'installed':
|
||||
|
||||
#### Cater for packages that need updates.
|
||||
|
||||
startForUpdate = 1
|
||||
|
||||
command = 'yum check-update'
|
||||
updates = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
for items in updates:
|
||||
if items == '':
|
||||
updates = updates[startForUpdate:]
|
||||
break
|
||||
else:
|
||||
startForUpdate = startForUpdate + 1
|
||||
|
||||
## make list of packages that need update
|
||||
|
||||
updateNeeded = []
|
||||
for items in updates:
|
||||
updateNeeded.append(items.split(' ')[0])
|
||||
|
||||
###
|
||||
|
||||
command = 'yum list installed'
|
||||
packages = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
startFrom = 1
|
||||
|
||||
for items in packages:
|
||||
if items.find('Installed Packages') > -1:
|
||||
packages = packages[startFrom:]
|
||||
break
|
||||
else:
|
||||
startFrom = startFrom + 1
|
||||
elif type == 'upgrade':
|
||||
#### Cater for packages that need updates.
|
||||
|
||||
startForUpdate = 1
|
||||
|
||||
command = 'yum check-update'
|
||||
packages = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
for items in packages:
|
||||
if items == '':
|
||||
packages = packages[startForUpdate:-1]
|
||||
break
|
||||
else:
|
||||
startForUpdate = startForUpdate + 1
|
||||
elif type == 'CyberPanel':
|
||||
command = 'cat /usr/local/CyberCP/CPCent7repo.json'
|
||||
packages = json.loads(ProcessUtilities.outputExecutioner(command))
|
||||
|
||||
## make list of packages that need update
|
||||
|
||||
|
||||
#if os.path.exists(ProcessUtilities.debugPath):
|
||||
# logging.CyberCPLogFileWriter.writeToFile('All packages: %s' % (str(packages)))
|
||||
|
||||
from s3Backups.s3Backups import S3Backups
|
||||
|
||||
pagination = S3Backups.getPagination(len(packages), recordsToShow)
|
||||
endPageNumber, finalPageNumber = S3Backups.recordsPointer(page, recordsToShow)
|
||||
finalPackages = packages[finalPageNumber:endPageNumber]
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
counter = 0
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile('Final packages: %s' % (str(finalPackages)))
|
||||
|
||||
import re
|
||||
for items in finalPackages:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
try:
|
||||
if type == 'CyberPanel':
|
||||
|
||||
packageName = items['Package'].split('/')[0]
|
||||
|
||||
if packageName in locked:
|
||||
lock = 1
|
||||
else:
|
||||
lock = 0
|
||||
|
||||
dic = {'package': packageName,
|
||||
'version': items['Version'], 'lock': lock}
|
||||
|
||||
counter = counter + 1
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
|
||||
else:
|
||||
nowSplitted = items.split('now')
|
||||
|
||||
upgrade = 'Not Needed'
|
||||
|
||||
if nowSplitted[1].split(' ')[3].find('upgradable') > -1:
|
||||
current = nowSplitted[1].split(' ')
|
||||
upgrade = '%s %s %s' % (current[3], current[4], current[5])
|
||||
|
||||
if nowSplitted[0].split('/')[0] in locked:
|
||||
lock = 1
|
||||
else:
|
||||
lock = 0
|
||||
|
||||
dic = {'package': nowSplitted[0].split('/')[0], 'version': '%s %s' % (nowSplitted[1].split(' ')[1], nowSplitted[1].split(' ')[2]), 'upgrade': upgrade, 'lock': lock}
|
||||
|
||||
counter = counter + 1
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile('[ERROR] %s. [fetchPackages:773]' % (str(msg)))
|
||||
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
try:
|
||||
if type == 'installed' or type == 'upgrade':
|
||||
|
||||
###
|
||||
|
||||
details = items.split(' ')
|
||||
details = [a for a in details if a != '']
|
||||
|
||||
if type == 'installed':
|
||||
if details[0] in updateNeeded:
|
||||
upgrade = 'Upgrade available'
|
||||
else:
|
||||
upgrade = 'Not needed.'
|
||||
else:
|
||||
upgrade = 'Upgrade available'
|
||||
|
||||
|
||||
if details[0].split('.')[0] in locked:
|
||||
lock = 1
|
||||
else:
|
||||
lock = 0
|
||||
|
||||
dic = {'package': details[0],
|
||||
'version': details[1],
|
||||
'upgrade': upgrade, 'lock': lock}
|
||||
|
||||
counter = counter + 1
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
elif type == 'CyberPanel':
|
||||
|
||||
packageName = items['Package']
|
||||
|
||||
if packageName.split('.')[0] in locked:
|
||||
lock = 1
|
||||
else:
|
||||
lock = 0
|
||||
|
||||
dic = {'package': packageName,
|
||||
'version': items['Version'], 'lock': lock}
|
||||
|
||||
counter = counter + 1
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
print(str(msg))
|
||||
logging.CyberCPLogFileWriter.writeToFile('[ERROR] %s. [fetchPackages:839]' % (str(msg)))
|
||||
|
||||
json_data = json_data + ']'
|
||||
|
||||
data_ret = {'status': 1, 'packages': json_data, 'pagination': pagination, 'fetchedPackages': counter, 'totalPackages': len(packages)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def fetchPackageDetails(request):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
data = json.loads(request.body)
|
||||
package = data['package']
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'apt-cache show %s' % (package)
|
||||
packageDetails = ProcessUtilities.outputExecutioner(command)
|
||||
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'yum info %s' % (package)
|
||||
packageDetails = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
data_ret = {'status': 1, 'packageDetails': packageDetails}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def updatePackage(request):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
data = json.loads(request.body)
|
||||
package = data['package']
|
||||
|
||||
from serverStatus.serverStatusUtil import ServerStatusUtil
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
'Starting package(s) upgrade..',
|
||||
1)
|
||||
|
||||
extraArgs = {}
|
||||
extraArgs['package'] = package
|
||||
|
||||
from plogical.applicationInstaller import ApplicationInstaller
|
||||
|
||||
background = ApplicationInstaller('updatePackage', extraArgs)
|
||||
background.start()
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
data_ret = {'status': 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def lockStatus(request):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
data = json.loads(request.body)
|
||||
package = data['package']
|
||||
type = data['type']
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
|
||||
if type == 0:
|
||||
command = 'apt-mark unhold %s' % (package)
|
||||
ProcessUtilities.executioner(command)
|
||||
else:
|
||||
command = 'apt-mark hold %s' % (package)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
|
||||
package = package.split('.')[0]
|
||||
|
||||
if os.path.exists('/etc/yum.conf'):
|
||||
yumConf = '/etc/yum.conf'
|
||||
elif os.path.exists('/etc/yum/yum.conf'):
|
||||
yumConf = '/etc/yum/yum.conf'
|
||||
|
||||
yumConfData = open(yumConf, 'r').read()
|
||||
data = open(yumConf, 'r').readlines()
|
||||
|
||||
|
||||
if type == 0:
|
||||
writeToFile = open(yumConf, 'w')
|
||||
|
||||
for items in data:
|
||||
if items.find('exclude') > -1:
|
||||
writeToFile.writelines(items.replace(package, ''))
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
writeToFile.close()
|
||||
else:
|
||||
|
||||
if yumConfData.find('exclude') == -1:
|
||||
|
||||
writeToFile = open(yumConf, 'a')
|
||||
writeToFile.writelines('exclude=%s\n' % (package))
|
||||
writeToFile.close()
|
||||
|
||||
else:
|
||||
writeToFile = open(yumConf, 'w')
|
||||
|
||||
for items in data:
|
||||
if items.find('exclude') > -1:
|
||||
excludeLine = items.strip('\n')
|
||||
writeToFile.writelines('%s %s\n' % (excludeLine, package))
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
writeToFile.close()
|
||||
|
||||
data_ret = {'status': 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
@@ -416,7 +416,7 @@ app.controller('restoreWebsiteControl', function ($scope, $http, $timeout) {
|
||||
});
|
||||
|
||||
|
||||
//*** Resotre site ends here ***///
|
||||
//*** Restore site ends here ***///
|
||||
|
||||
|
||||
///** Backup Destination ***//
|
||||
@@ -448,6 +448,7 @@ app.controller('backupDestinations', function ($scope, $http, $timeout) {
|
||||
var data = {
|
||||
IPAddress: $scope.IPAddress,
|
||||
password: $scope.password,
|
||||
user: $scope.user,
|
||||
backupSSHPort: $scope.backupSSHPort,
|
||||
};
|
||||
|
||||
@@ -1346,6 +1347,7 @@ app.controller('remoteBackupControl', function ($scope, $http, $timeout) {
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.backupProcessStarted = true;
|
||||
|
||||
if (response.data.remoteTransferStatus === 1) {
|
||||
|
||||
@@ -1539,4 +1541,68 @@ app.controller('remoteBackupControl', function ($scope, $http, $timeout) {
|
||||
|
||||
});
|
||||
|
||||
///** Backup site ends **///
|
||||
///** Backup site ends **///
|
||||
|
||||
|
||||
//*** Remote Backup site ****//
|
||||
app.controller('backupLogsScheduled', function ($scope, $http, $timeout) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.logDetails = true;
|
||||
|
||||
$scope.currentPage = 1;
|
||||
$scope.recordsToShow = 10;
|
||||
|
||||
$scope.fetchLogs = function () {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
logFile: $scope.logFile,
|
||||
recordsToShow: $scope.recordsToShow,
|
||||
page: $scope.currentPage
|
||||
};
|
||||
|
||||
dataurl = "/backup/fetchLogs";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.logDetails = false;
|
||||
$scope.logs = JSON.parse(response.data.logs);
|
||||
$scope.pagination = response.data.pagination;
|
||||
$scope.jobSuccessSites = response.data.jobSuccessSites;
|
||||
$scope.jobFailedSites = response.data.jobFailedSites;
|
||||
$scope.location = response.data.location;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
||||
///** Backup site ends **///
|
||||
|
||||
6
static/databases/databases.js
Executable file → Normal file
6
static/databases/databases.js
Executable file → Normal file
@@ -106,7 +106,7 @@ app.controller('createDatabase', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.dbPassword = randomPassword(12);
|
||||
$scope.dbPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -447,7 +447,7 @@ app.controller('listDBs', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.dbPassword = randomPassword(12);
|
||||
$scope.dbPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -493,4 +493,4 @@ app.controller('phpMyAdmin', function ($scope, $http, $window) {
|
||||
}
|
||||
setupPHPMYAdminSession();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1479,7 +1479,6 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader,
|
||||
// Download files
|
||||
|
||||
$scope.downloadFile = function () {
|
||||
|
||||
url = "/filemanager/downloadFile";
|
||||
var downloadURL = $scope.currentPath + "/" + allFilesAndFolders[0];
|
||||
window.location.href = url + '?domainName=' + domainName + '&fileToDownload=' + downloadURL;
|
||||
|
||||
@@ -2171,8 +2171,6 @@ app.controller('installImunify', function ($scope, $http, $timeout, $window) {
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ app.controller('createFTPAccount', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.ftpPassword = randomPassword(12);
|
||||
$scope.ftpPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -451,11 +451,11 @@ app.controller('listFTPAccounts', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.ftpPassword = randomPassword(12);
|
||||
$scope.ftpPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
$scope.generatedPasswordView = true;
|
||||
};
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -110,7 +110,7 @@ app.controller('createEmailAccount', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.emailPassword = randomPassword(12);
|
||||
$scope.emailPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -465,7 +465,7 @@ app.controller('changeEmailPassword', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.emailPassword = randomPassword(12);
|
||||
$scope.emailPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -1124,6 +1124,7 @@ app.controller('listEmails', function ($scope, $http) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.emailsAccounts = true;
|
||||
$scope.mailConfigured = 1;
|
||||
|
||||
$scope.populateCurrentRecords = function () {
|
||||
$scope.cyberpanelLoading = false;
|
||||
@@ -1151,6 +1152,9 @@ app.controller('listEmails', function ($scope, $http) {
|
||||
if (response.data.status === 1) {
|
||||
$scope.emailsAccounts = false;
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.mailConfigured = response.data.mailConfigured;
|
||||
$scope.serverHostname = response.data.serverHostname;
|
||||
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Emails Successfully Fetched.',
|
||||
@@ -1229,6 +1233,55 @@ app.controller('listEmails', function ($scope, $http) {
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.fixMailSSL = function (email) {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
var url = "/email/fixMailSSL";
|
||||
|
||||
var data = {
|
||||
selectedDomain: $scope.selectedDomain,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
if (response.data.status === 1) {
|
||||
$scope.populateCurrentRecords();
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Configurations applied successfully.',
|
||||
type: 'success'
|
||||
});
|
||||
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.changePasswordInitial = function (email) {
|
||||
@@ -1291,4 +1344,4 @@ app.controller('listEmails', function ($scope, $http) {
|
||||
});
|
||||
|
||||
|
||||
/* Java script code for List Emails Ends here */
|
||||
/* Java script code for List Emails Ends here */
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Java script code to start/stop litespeed */
|
||||
app.controller('litespeedStatus', function ($scope, $http) {
|
||||
|
||||
@@ -49,8 +48,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
|
||||
$scope.actionResultBad = true;
|
||||
$scope.serverStatusCouldNotConnect = true;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$scope.restartorStopLoading = true;
|
||||
$scope.actionResult = true;
|
||||
@@ -109,8 +107,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
|
||||
$scope.actionResultBad = true;
|
||||
$scope.serverStatusCouldNotConnect = true;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$scope.restartorStopLoading = true;
|
||||
$scope.actionResult = true;
|
||||
@@ -174,8 +171,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
|
||||
});
|
||||
$scope.lsSerial = response.data.lsSerial;
|
||||
$scope.lsexpiration = response.data.lsexpiration;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.cpLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
@@ -229,8 +225,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
|
||||
text: 'License successfully Updated',
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.cpLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
@@ -292,8 +287,7 @@ app.controller('readCyberCPLogFile', function ($scope, $http) {
|
||||
$scope.logsData = response.data.logsdata;
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$scope.logFileLoading = true;
|
||||
$scope.logsFeteched = true;
|
||||
@@ -347,8 +341,7 @@ app.controller('readCyberCPLogFile', function ($scope, $http) {
|
||||
$scope.logsData = response.data.logsdata;
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$scope.logFileLoading = true;
|
||||
$scope.logsFeteched = true;
|
||||
@@ -409,8 +402,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.olsStart = false;
|
||||
$scope.olsStop = true;
|
||||
$scope.olsMem = Math.round(parseInt(response.data.memUsage.litespeed) / 1048576) + " MB";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.olsStatus = "Stopped";
|
||||
$scope.olsStats = false;
|
||||
$scope.olsStart = true;
|
||||
@@ -421,8 +413,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.dockerStatus = "Running";
|
||||
$scope.dockerStart = false;
|
||||
$scope.dockerStop = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.dockerStatus = "Stopped";
|
||||
$scope.dockerStart = true;
|
||||
$scope.dockerStop = false;
|
||||
@@ -435,8 +426,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.sqlStart = false;
|
||||
$scope.sqlStop = true;
|
||||
$scope.sqlMem = Math.round(parseInt(response.data.memUsage.mysql) / 1048576) + " MB";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.sqlStatus = "Stopped";
|
||||
$scope.sqlStats = false;
|
||||
$scope.sqlStart = true;
|
||||
@@ -451,8 +441,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.dnsStart = false;
|
||||
$scope.dnsStop = true;
|
||||
$scope.dnsMem = Math.round(parseInt(response.data.memUsage.powerdns) / 1048576) + " MB";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.dnsStatus = "Stopped";
|
||||
$scope.dnsStats = false;
|
||||
$scope.dnsStart = true;
|
||||
@@ -467,8 +456,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.ftpStart = false;
|
||||
$scope.ftpStop = true;
|
||||
$scope.ftpMem = Math.round(parseInt(response.data.memUsage.pureftp) / 1048576) + " MB";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.ftpStatus = "Stopped";
|
||||
$scope.ftpStats = false;
|
||||
$scope.ftpStart = true;
|
||||
@@ -487,6 +475,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getServiceStatus();
|
||||
|
||||
$scope.serviceAction = function (serviceName, action) {
|
||||
@@ -524,8 +513,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.actionLoader = false;
|
||||
$scope.btnDisable = false;
|
||||
}, 3000);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setTimeout(function () {
|
||||
getServiceStatus();
|
||||
$scope.ActionSuccessfull = false;
|
||||
@@ -583,8 +571,7 @@ app.controller('lswsSwitch', function ($scope, $http, $timeout, $window) {
|
||||
if (response.data.status === 1) {
|
||||
$scope.installBoxGen = false;
|
||||
getRequestStatus();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
@@ -626,8 +613,7 @@ app.controller('lswsSwitch', function ($scope, $http, $timeout, $window) {
|
||||
if (response.data.abort === 0) {
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
$timeout(getRequestStatus, 1000);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Notifications
|
||||
$scope.cyberPanelLoading = true;
|
||||
$timeout.cancel();
|
||||
@@ -720,8 +706,7 @@ app.controller('topProcesses', function ($scope, $http, $timeout) {
|
||||
$scope.zombieProcesses = response.data.zombieProcesses;
|
||||
|
||||
$timeout($scope.topProcessesStatus, 3000);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
@@ -771,8 +756,7 @@ app.controller('topProcesses', function ($scope, $http, $timeout) {
|
||||
text: 'Process successfully killed.',
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
@@ -793,4 +777,236 @@ app.controller('topProcesses', function ($scope, $http, $timeout) {
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
///
|
||||
|
||||
|
||||
app.controller('listOSPackages', function ($scope, $http, $timeout) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
|
||||
$scope.currentPage = 1;
|
||||
$scope.recordsToShow = 10;
|
||||
var globalType;
|
||||
|
||||
$scope.fetchPackages = function (type = 'installed') {
|
||||
$scope.cyberpanelLoading = false;
|
||||
globalType = type;
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
page: $scope.currentPage,
|
||||
recordsToShow: $scope.recordsToShow,
|
||||
type: type
|
||||
};
|
||||
|
||||
dataurl = "/serverstatus/fetchPackages";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.allPackages = JSON.parse(response.data.packages);
|
||||
$scope.pagination = response.data.pagination;
|
||||
$scope.fetchedPackages = response.data.fetchedPackages;
|
||||
$scope.totalPackages = response.data.totalPackages;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
$scope.fetchPackages('upgrade');
|
||||
|
||||
$scope.fetchPackageDetails = function (packageFetch) {
|
||||
$scope.cyberpanelLoading = false;
|
||||
$scope.package = packageFetch;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
package: packageFetch
|
||||
};
|
||||
|
||||
dataurl = "/serverstatus/fetchPackageDetails";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.packageDetails = response.data.packageDetails;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.updatePackage = function (packageToUpgrade = 'all') {
|
||||
$scope.cyberpanelLoading = false;
|
||||
$scope.package = packageToUpgrade;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
package: packageToUpgrade
|
||||
};
|
||||
|
||||
dataurl = "/serverstatus/updatePackage";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
getRequestStatus();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
function getRequestStatus() {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
url = "/serverstatus/switchTOLSWSStatus";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
if (response.data.abort === 0) {
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
$timeout(getRequestStatus, 1000);
|
||||
} else {
|
||||
// Notifications
|
||||
$timeout.cancel();
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$scope.lockStatus = function (lockPackage, type) {
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
package: lockPackage,
|
||||
type: type,
|
||||
};
|
||||
|
||||
dataurl = "/serverstatus/lockStatus";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Status updated.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.fetchPackages(globalType);
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
@@ -113,7 +113,7 @@ app.controller('createUserCtr', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.password = randomPassword(12);
|
||||
$scope.password = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -342,7 +342,7 @@ app.controller('modifyUser', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.password = randomPassword(12);
|
||||
$scope.password = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -1744,4 +1744,4 @@ app.controller('listTableUsers', function ($scope, $http) {
|
||||
});
|
||||
|
||||
|
||||
/* Java script code to list table users */
|
||||
/* Java script code to list table users */
|
||||
|
||||
@@ -5836,7 +5836,7 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
$scope.autoCommitCurrent = response.data.autoCommitCurrent;
|
||||
$scope.autoPushCurrent = response.data.autoPushCurrent;
|
||||
$scope.emailLogsCurrent = response.data.emailLogsCurrent;
|
||||
$scope.currentCommands = response.data.commands;
|
||||
document.getElementById("currentCommands").value = response.data.commands;
|
||||
$scope.webhookCommandCurrent = response.data.webhookCommandCurrent;
|
||||
} else {
|
||||
$scope.gitTracking = false;
|
||||
@@ -6677,17 +6677,40 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
url = "/websites/saveGitConfigurations";
|
||||
|
||||
|
||||
var data = {
|
||||
domain: $("#domain").text(),
|
||||
folder: $scope.folder,
|
||||
autoCommit: $scope.autoCommit,
|
||||
autoPush: $scope.autoPush,
|
||||
emailLogs: $scope.emailLogs,
|
||||
commands: $scope.commands,
|
||||
commands: document.getElementById("currentCommands").value,
|
||||
webhookCommand: $scope.webhookCommand
|
||||
};
|
||||
|
||||
if ($scope.autoCommit === undefined){
|
||||
$scope.autoCommitCurrent = 'Never';
|
||||
}else{
|
||||
$scope.autoCommitCurrent = $scope.autoCommit;
|
||||
}
|
||||
|
||||
if ($scope.autoPush === undefined){
|
||||
$scope.autoPushCurrent = 'Never';
|
||||
}else{
|
||||
$scope.autoPushCurrent = $scope.autoPush;
|
||||
}
|
||||
|
||||
if ($scope.emailLogs === undefined){
|
||||
$scope.emailLogsCurrent = false;
|
||||
}else{
|
||||
$scope.emailLogsCurrent = $scope.emailLogs;
|
||||
}
|
||||
|
||||
if ($scope.webhookCommand === undefined){
|
||||
$scope.webhookCommandCurrent = false;
|
||||
}else{
|
||||
$scope.webhookCommandCurrent = $scope.webhookCommand;
|
||||
}
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
@@ -6782,4 +6805,5 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
/* Java script code to git tracking ends here */
|
||||
|
||||
@@ -113,7 +113,7 @@ app.controller('createUserCtr', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.password = randomPassword(12);
|
||||
$scope.password = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -342,7 +342,7 @@ app.controller('modifyUser', function ($scope, $http) {
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.password = randomPassword(12);
|
||||
$scope.password = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -1744,4 +1744,4 @@ app.controller('listTableUsers', function ($scope, $http) {
|
||||
});
|
||||
|
||||
|
||||
/* Java script code to list table users */
|
||||
/* Java script code to list table users */
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":"2.0","build":0}
|
||||
{"version":"2.0","build":1}
|
||||
@@ -36,12 +36,17 @@ class StagingSetup(multi.Thread):
|
||||
|
||||
website = Websites.objects.get(domain=masterDomain)
|
||||
|
||||
masterPath = '/home/%s/public_html' % (masterDomain)
|
||||
|
||||
command = 'chmod 755 %s' % (masterPath)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## Creating Child Domain
|
||||
|
||||
path = "/home/" + masterDomain + "/public_html/" + domain
|
||||
|
||||
logging.statusWriter(tempStatusPath, 'Creating domain for staging environment..,5')
|
||||
phpSelection = 'PHP 7.1'
|
||||
phpSelection = 'PHP 7.2'
|
||||
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " createDomain --masterDomain " + masterDomain + " --virtualHostName " + domain + \
|
||||
@@ -57,18 +62,37 @@ class StagingSetup(multi.Thread):
|
||||
if data.find('[200]') > -1:
|
||||
pass
|
||||
else:
|
||||
logging.statusWriter(tempStatusPath, 'Failed to create child-domain for staging enviroment. [404]')
|
||||
logging.statusWriter(tempStatusPath, 'Failed to create child-domain for staging environment. [404]')
|
||||
return 0
|
||||
|
||||
logging.statusWriter(tempStatusPath, 'Domain successfully created..,15')
|
||||
|
||||
## Copying Data
|
||||
|
||||
masterPath = '/home/%s/public_html' % (masterDomain)
|
||||
## Fetch child domain path
|
||||
|
||||
childDomainPaths = []
|
||||
|
||||
for childs in website.childdomains_set.all():
|
||||
childDomainPaths.append(childs.path)
|
||||
|
||||
filesAndFolder = os.listdir(masterPath)
|
||||
|
||||
for items in filesAndFolder:
|
||||
completePath = '%s/%s' % (masterPath, items)
|
||||
|
||||
if completePath in childDomainPaths:
|
||||
continue
|
||||
else:
|
||||
command = 'cp -r %s %s/' % (completePath, path)
|
||||
ProcessUtilities.executioner(command, website.externalApp)
|
||||
|
||||
foldersToBeRemoved = ['%s/.git' % (path), '%s/wp-content/backups' % (path), '%s/wp-content/updraft' % (path), '%s/wp-content/cache' % (path), '%s/wp-content/plugins/litespeed-cache' % (path)]
|
||||
|
||||
for rmv in foldersToBeRemoved:
|
||||
command = 'rm -rf %s' % (rmv)
|
||||
ProcessUtilities.executioner(command, website.externalApp)
|
||||
|
||||
command = 'rsync -avzh --exclude "%s" --exclude ".git" --exclude "wp-content/backups" --exclude "wp-content/updraft" --exclude "wp-content/cache" --exclude "wp-content/plugins/litespeed-cache" %s/ %s' % (
|
||||
domain, masterPath, path)
|
||||
ProcessUtilities.executioner(command, website.externalApp)
|
||||
|
||||
logging.statusWriter(tempStatusPath, 'Data copied..,50')
|
||||
|
||||
@@ -82,14 +106,18 @@ class StagingSetup(multi.Thread):
|
||||
|
||||
configPath = '%s/wp-config.php' % (masterPath)
|
||||
|
||||
if not os.path.exists(configPath):
|
||||
command = 'ls -la %s' % (configPath)
|
||||
output = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if output.find('No such file or') > -1:
|
||||
logging.statusWriter(tempStatusPath, 'WordPress is not detected. [404]')
|
||||
return 0
|
||||
|
||||
data = open(configPath, 'r').readlines()
|
||||
command = 'cat %s' % (configPath)
|
||||
data = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
for items in data:
|
||||
if items.find('DB_NAME') > -1:
|
||||
if items.find('DB_NAME') > -1 and items[0] != '/':
|
||||
try:
|
||||
dbName = items.split("'")[3]
|
||||
if mysqlUtilities.createDatabaseBackup(dbName, '/home/cyberpanel'):
|
||||
@@ -105,11 +133,6 @@ class StagingSetup(multi.Thread):
|
||||
|
||||
databasePath = '%s/%s.sql' % ('/home/cyberpanel', dbName)
|
||||
|
||||
command = "sed -i 's/%s/%s/g' %s" % (masterDomain, domain, databasePath)
|
||||
ProcessUtilities.executioner(command, 'cyberpanel')
|
||||
command = "sed -i 's/%s/%s/g' %s" % ('https', 'http', databasePath)
|
||||
ProcessUtilities.executioner(command, 'cyberpanel')
|
||||
|
||||
if not mysqlUtilities.restoreDatabaseBackup(dbNameRestore, '/home/cyberpanel', None, 1, dbName):
|
||||
try:
|
||||
os.remove(databasePath)
|
||||
@@ -125,22 +148,31 @@ class StagingSetup(multi.Thread):
|
||||
## Update final config file
|
||||
|
||||
pathFinalConfig = '%s/wp-config.php' % (path)
|
||||
data = open(pathFinalConfig, 'r').readlines()
|
||||
|
||||
command = 'cat %s' % (configPath)
|
||||
data = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
tmp = "/tmp/" + str(randint(1000, 9999))
|
||||
writeToFile = open(tmp, 'w')
|
||||
|
||||
for items in data:
|
||||
if items.find('DB_NAME') > -1:
|
||||
writeToFile.write("define( 'DB_NAME', '%s' );\n" % (dbNameRestore))
|
||||
writeToFile.write("\ndefine( 'DB_NAME', '%s' );\n" % (dbNameRestore))
|
||||
elif items.find('DB_USER') > -1:
|
||||
writeToFile.write("define( 'DB_USER', '%s' );\n" % (dbUser))
|
||||
writeToFile.write("\ndefine( 'DB_USER', '%s' );\n" % (dbUser))
|
||||
elif items.find('DB_PASSWORD') > -1:
|
||||
writeToFile.write("define( 'DB_PASSWORD', '%s' );\n" % (dbPassword))
|
||||
writeToFile.write("\ndefine( 'DB_PASSWORD', '%s' );\n" % (dbPassword))
|
||||
elif items.find('WP_SITEURL') > -1:
|
||||
continue
|
||||
elif items.find("table_prefix") > -1:
|
||||
writeToFile.writelines(items)
|
||||
content = """
|
||||
define('WP_HOME','http://%s');
|
||||
define('WP_SITEURL','http://%s');
|
||||
""" % (domain, domain)
|
||||
writeToFile.write(content)
|
||||
else:
|
||||
writeToFile.write(items)
|
||||
writeToFile.write(items + '\n')
|
||||
|
||||
writeToFile.close()
|
||||
|
||||
@@ -157,6 +189,14 @@ class StagingSetup(multi.Thread):
|
||||
except:
|
||||
pass
|
||||
|
||||
from filemanager.filemanager import FileManager
|
||||
|
||||
fm = FileManager(None, None)
|
||||
fm.fixPermissions(masterDomain)
|
||||
|
||||
from plogical.installUtilities import installUtilities
|
||||
installUtilities.reStartLiteSpeed()
|
||||
|
||||
logging.statusWriter(tempStatusPath, 'Data copied..,[200]')
|
||||
|
||||
return 0
|
||||
@@ -174,7 +214,11 @@ class StagingSetup(multi.Thread):
|
||||
|
||||
child = ChildDomains.objects.get(domain=childDomain)
|
||||
|
||||
command = 'chmod 755 /home/%s/public_html' % (child.master.domain)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
configPath = '%s/wp-config.php' % (child.path)
|
||||
|
||||
if not os.path.exists(configPath):
|
||||
logging.statusWriter(tempStatusPath, 'WordPress is not detected. [404]')
|
||||
return 0
|
||||
@@ -189,7 +233,7 @@ class StagingSetup(multi.Thread):
|
||||
data = open(configPath, 'r').readlines()
|
||||
|
||||
for items in data:
|
||||
if items.find('DB_NAME') > -1:
|
||||
if items.find('DB_NAME') > -1 and items[0] != '/':
|
||||
dbName = items.split("'")[3]
|
||||
if mysqlUtilities.createDatabaseBackup(dbName, '/home/cyberpanel'):
|
||||
break
|
||||
@@ -197,8 +241,6 @@ class StagingSetup(multi.Thread):
|
||||
raise BaseException('Failed to create database backup.')
|
||||
|
||||
databasePath = '%s/%s.sql' % ('/home/cyberpanel', dbName)
|
||||
command = "sed -i 's/%s/%s/g' %s" % (child.domain, child.master.domain, databasePath)
|
||||
ProcessUtilities.executioner(command, 'cyberpanel')
|
||||
|
||||
## Restore to master domain
|
||||
|
||||
@@ -209,7 +251,7 @@ class StagingSetup(multi.Thread):
|
||||
data = open(configPath, 'r').readlines()
|
||||
|
||||
for items in data:
|
||||
if items.find('DB_NAME') > -1:
|
||||
if items.find('DB_NAME') > -1 and items[0] != '/':
|
||||
dbNameRestore = items.split("'")[3]
|
||||
if not mysqlUtilities.restoreDatabaseBackup(dbNameRestore, '/home/cyberpanel', None, 1, dbName):
|
||||
try:
|
||||
@@ -222,7 +264,6 @@ class StagingSetup(multi.Thread):
|
||||
os.remove(databasePath)
|
||||
except:
|
||||
pass
|
||||
|
||||
if eraseCheck:
|
||||
sourcePath = child.path
|
||||
destinationPath = '/home/%s/public_html' % (child.master.domain)
|
||||
@@ -236,6 +277,14 @@ class StagingSetup(multi.Thread):
|
||||
command = 'rsync -avzh --exclude "wp-config.php" %s/ %s' % (sourcePath, destinationPath)
|
||||
ProcessUtilities.executioner(command, child.master.externalApp)
|
||||
|
||||
from filemanager.filemanager import FileManager
|
||||
|
||||
fm = FileManager(None, None)
|
||||
fm.fixPermissions(child.master.domain)
|
||||
|
||||
from plogical.installUtilities import installUtilities
|
||||
installUtilities.reStartLiteSpeed()
|
||||
|
||||
logging.statusWriter(tempStatusPath, 'Data copied..,[200]')
|
||||
|
||||
return 0
|
||||
|
||||
@@ -8,7 +8,6 @@ from datetime import datetime
|
||||
|
||||
# Create your models here.
|
||||
|
||||
|
||||
class Websites(models.Model):
|
||||
admin = models.ForeignKey(Administrator, on_delete=models.PROTECT)
|
||||
package = models.ForeignKey(Package, on_delete=models.PROTECT)
|
||||
@@ -26,7 +25,6 @@ class ChildDomains(models.Model):
|
||||
ssl = models.IntegerField()
|
||||
phpSelection = models.CharField(max_length=10,default=None)
|
||||
|
||||
|
||||
class Backups(models.Model):
|
||||
website = models.ForeignKey(Websites,on_delete=models.CASCADE)
|
||||
fileName = models.CharField(max_length=200)
|
||||
@@ -34,16 +32,13 @@ class Backups(models.Model):
|
||||
size = models.CharField(max_length=50)
|
||||
status = models.IntegerField(default=0)
|
||||
|
||||
|
||||
class dest(models.Model):
|
||||
destLoc = models.CharField(unique=True,max_length=18)
|
||||
|
||||
|
||||
class backupSchedules(models.Model):
|
||||
dest = models.ForeignKey(dest, on_delete=models.CASCADE)
|
||||
frequency = models.CharField(max_length=15)
|
||||
|
||||
|
||||
class aliasDomains(models.Model):
|
||||
master = models.ForeignKey(Websites, on_delete=models.CASCADE)
|
||||
aliasDomain = models.CharField(max_length=75)
|
||||
@@ -54,4 +49,15 @@ class GitLogs(models.Model):
|
||||
type = models.CharField(max_length=5)
|
||||
message = models.TextField(max_length=65532)
|
||||
|
||||
class BackupJob(models.Model):
|
||||
logFile = models.CharField(max_length=1000)
|
||||
ipAddress = models.CharField(max_length=50)
|
||||
port = models.CharField(max_length=15)
|
||||
jobSuccessSites = models.IntegerField()
|
||||
jobFailedSites = models.IntegerField()
|
||||
location = models.IntegerField()
|
||||
|
||||
class BackupJobLogs(models.Model):
|
||||
owner = models.ForeignKey(BackupJob, on_delete=models.CASCADE)
|
||||
status = models.IntegerField()
|
||||
message = models.TextField()
|
||||
@@ -5836,7 +5836,7 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
$scope.autoCommitCurrent = response.data.autoCommitCurrent;
|
||||
$scope.autoPushCurrent = response.data.autoPushCurrent;
|
||||
$scope.emailLogsCurrent = response.data.emailLogsCurrent;
|
||||
$scope.currentCommands = response.data.commands;
|
||||
document.getElementById("currentCommands").value = response.data.commands;
|
||||
$scope.webhookCommandCurrent = response.data.webhookCommandCurrent;
|
||||
} else {
|
||||
$scope.gitTracking = false;
|
||||
@@ -6677,17 +6677,40 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
url = "/websites/saveGitConfigurations";
|
||||
|
||||
|
||||
var data = {
|
||||
domain: $("#domain").text(),
|
||||
folder: $scope.folder,
|
||||
autoCommit: $scope.autoCommit,
|
||||
autoPush: $scope.autoPush,
|
||||
emailLogs: $scope.emailLogs,
|
||||
commands: $scope.commands,
|
||||
commands: document.getElementById("currentCommands").value,
|
||||
webhookCommand: $scope.webhookCommand
|
||||
};
|
||||
|
||||
if ($scope.autoCommit === undefined){
|
||||
$scope.autoCommitCurrent = 'Never';
|
||||
}else{
|
||||
$scope.autoCommitCurrent = $scope.autoCommit;
|
||||
}
|
||||
|
||||
if ($scope.autoPush === undefined){
|
||||
$scope.autoPushCurrent = 'Never';
|
||||
}else{
|
||||
$scope.autoPushCurrent = $scope.autoPush;
|
||||
}
|
||||
|
||||
if ($scope.emailLogs === undefined){
|
||||
$scope.emailLogsCurrent = false;
|
||||
}else{
|
||||
$scope.emailLogsCurrent = $scope.emailLogs;
|
||||
}
|
||||
|
||||
if ($scope.webhookCommand === undefined){
|
||||
$scope.webhookCommandCurrent = false;
|
||||
}else{
|
||||
$scope.webhookCommandCurrent = $scope.webhookCommand;
|
||||
}
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
@@ -6782,4 +6805,5 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
/* Java script code to git tracking ends here */
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Path" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input placeholder="Leave empty to install in website home directory. (Without preceding slash)" type="text" class="form-control" ng-model="installPath">
|
||||
<input placeholder="{% trans "Leave empty to install in website home directory. (Without preceding slash)" %}" type="text" class="form-control" ng-model="installPath">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
style="padding: 0px; box-shadow: 0px 0px 1px 0px #888888;">
|
||||
<div class="">
|
||||
<div class="table-responsive no-gutter text-nowrap" style="overflow-x: hidden;">
|
||||
<div style="background-image: url({% static 'images/not-available-preview.png' %});
|
||||
<div style="background-image: url('https://cdn.statically.io/screenshot/{$ web.domain $}?fullPage=true');;
|
||||
height: 160px;
|
||||
width: 200px;
|
||||
background-position: top;
|
||||
|
||||
@@ -41,16 +41,14 @@
|
||||
style="padding: 0px; box-shadow: 0px 0px 1px 0px #888888;">
|
||||
<div class="">
|
||||
<div class="table-responsive no-gutter text-nowrap" style="overflow-x: hidden;">
|
||||
<div
|
||||
style="background-image: url({% static 'images/not-available-preview.png' %});
|
||||
<div style="background-image: url('https://cdn.statically.io/screenshot/{$ web.domain $}?fullPage=true');
|
||||
height: 160px;
|
||||
width: 200px;
|
||||
background-position: top;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
position: relative;"
|
||||
class="col-lg-3 col-md-12"
|
||||
>
|
||||
class="col-lg-3 col-md-12">
|
||||
</div>
|
||||
<div class="col-lg-9" style="text-transform: none">
|
||||
<div style="border-bottom: 1px solid #888888" class="col-md-12">
|
||||
|
||||
@@ -189,8 +189,7 @@
|
||||
<option>Weekly</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="current-pack ng-binding">Currently: {$ autoCommitCurrent
|
||||
$}
|
||||
<div class="current-pack ng-binding">Currently: {$ autoCommitCurrent $}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -234,10 +233,9 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Commands" %}</label>
|
||||
<div class="col-sm-9">
|
||||
<textarea ng-model="$parent.commands"
|
||||
placeholder="Add Commands to run after every commit, each line must contain one command only."
|
||||
<textarea id="currentCommands"
|
||||
rows="4"
|
||||
class="form-control">{$ currentCommands $}</textarea>
|
||||
class="form-control"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1367,7 +1367,7 @@ class WebsiteManager:
|
||||
|
||||
CronUtil.CronPrem(0)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
cronPath = "/var/spool/cron/" + website.externalApp
|
||||
else:
|
||||
cronPath = "/var/spool/cron/crontabs/" + website.externalApp
|
||||
@@ -1586,7 +1586,7 @@ class WebsiteManager:
|
||||
|
||||
website = Websites.objects.get(domain=self.domain)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
cronPath = "/var/spool/cron/" + website.externalApp
|
||||
else:
|
||||
cronPath = "/var/spool/cron/crontabs/" + website.externalApp
|
||||
@@ -1605,7 +1605,7 @@ class WebsiteManager:
|
||||
output = ProcessUtilities.outputExecutioner(execPath, website.externalApp)
|
||||
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'chmod 600 %s' % (cronPath)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
@@ -3222,7 +3222,23 @@ StrictHostKeyChecking no
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
if validators.domain(self.gitHost) and ACLManager.validateInput(self.gitUsername) and ACLManager.validateInput(self.gitReponame):
|
||||
if self.gitHost.find(':') > -1:
|
||||
gitHostDomain = self.gitHost.split(':')[0]
|
||||
gitHostPort = self.gitHost.split(':')[1]
|
||||
|
||||
if not validators.domain(gitHostDomain):
|
||||
return ACLManager.loadErrorJson('status', 'Invalid characters in your input.')
|
||||
|
||||
try:
|
||||
gitHostPort = int(gitHostPort)
|
||||
except:
|
||||
return ACLManager.loadErrorJson('status', 'Invalid characters in your input.')
|
||||
|
||||
else:
|
||||
if not validators.domain(self.gitHost):
|
||||
return ACLManager.loadErrorJson('status', 'Invalid characters in your input.')
|
||||
|
||||
if ACLManager.validateInput(self.gitUsername) and ACLManager.validateInput(self.gitReponame):
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('status', 'Invalid characters in your input.')
|
||||
@@ -3613,11 +3629,25 @@ StrictHostKeyChecking no
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile('hello world 2')
|
||||
if self.gitHost.find(':') > -1:
|
||||
gitHostDomain = self.gitHost.split(':')[0]
|
||||
gitHostPort = self.gitHost.split(':')[1]
|
||||
|
||||
if not validators.domain(gitHostDomain):
|
||||
return ACLManager.loadErrorJson('status', 'Invalid characters in your input.')
|
||||
|
||||
try:
|
||||
gitHostPort = int(gitHostPort)
|
||||
except:
|
||||
return ACLManager.loadErrorJson('status', 'Invalid characters in your input.')
|
||||
else:
|
||||
if not validators.domain(self.gitHost):
|
||||
return ACLManager.loadErrorJson('status', 'Invalid characters in your input.')
|
||||
|
||||
|
||||
## Security check
|
||||
|
||||
if validators.domain(self.gitHost) and ACLManager.validateInput(self.gitUsername) and ACLManager.validateInput(self.gitReponame):
|
||||
if ACLManager.validateInput(self.gitUsername) and ACLManager.validateInput(self.gitReponame):
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('status', 'Invalid characters in your input.')
|
||||
|
||||
Reference in New Issue
Block a user