fix conflict from v2.0.1

This commit is contained in:
Usman Nasir
2020-06-02 18:46:13 +05:00
114 changed files with 9641 additions and 2848 deletions

2984
AllCPUbuntu.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -79,48 +79,51 @@ class CloudLinuxUsers(CLMain):
def fetchJson(self, websites):
users = []
for webs in websites:
itemPackage = webs.package
package = {'name': itemPackage.packageName, 'owner': webs.externalApp}
try:
itemPackage = webs.package
package = {'name': itemPackage.packageName, 'owner': webs.externalApp}
user = {}
user = {}
if self.id:
user['id'] = pwd.getpwnam(webs.externalApp).pw_uid
if self.un:
user['username'] = webs.externalApp
if self.ow:
user['owner'] = webs.externalApp
if self.domain:
user['domain'] = webs.domain
if self.package:
user['package'] = package
if self.email:
user['email'] = webs.adminEmail
if self.localecode:
user['locale_code'] = "EN_us"
if self.packageName != None:
if self.package:
if self.packageName == user['package']['name'] and self.packageOwner == user['package']['owner']:
pass
else:
continue
if self.uid !=None:
if self.id:
if self.uid == user['id']:
user['id'] = pwd.getpwnam(webs.externalApp).pw_uid
if self.un:
user['username'] = webs.externalApp
if self.ow:
user['owner'] = webs.externalApp
if self.domain:
user['domain'] = webs.domain
if self.package:
user['package'] = package
if self.email:
user['email'] = webs.adminEmail
if self.localecode:
user['locale_code'] = "EN_us"
if self.packageName != None:
if self.package:
if self.packageName == user['package']['name'] and self.packageOwner == user['package']['owner']:
pass
else:
continue
if self.uid !=None:
if self.id:
if self.uid == user['id']:
users.append(user)
else:
users.append(user)
else:
users.append(user)
else:
users.append(user)
except BaseException as msg:
pass
final = {'data': users, 'metadata': self.initialMeta}
print(json.dumps(final))

192
CPCent7repo.json Normal file
View File

@@ -0,0 +1,192 @@
[
{
"Package": "MariaDB-client.x86_64",
"Version": "10.1.44-1.el7.centos",
"Repo": "@CyberPanel"
},
{
"Package": "MariaDB-common.x86_64",
"Version": "10.1.44-1.el7.centos",
"Repo": "@CyberPanel"
},
{
"Package": "MariaDB-devel.x86_64",
"Version": "10.1.44-1.el7.centos",
"Repo": "@CyberPanel"
},
{
"Package": "MariaDB-server.x86_64",
"Version": "10.1.44-1.el7.centos",
"Repo": "@CyberPanel"
},
{
"Package": "MariaDB-shared.x86_64",
"Version": "10.1.44-1.el7.centos",
"Repo": "@CyberPanel"
},
{
"Package": "compat-libtidy.x86_64",
"Version": "0.99.0-37.20091203.el7",
"Repo": "@CyberPanel"
},
{
"Package": "dovecot.x86_64",
"Version": "2:2.3.10-2",
"Repo": "@CyberPanel"
},
{
"Package": "dovecot-mysql.x86_64",
"Version": "2:2.3.10-2",
"Repo": "@CyberPanel"
},
{
"Package": "fastlz.x86_64",
"Version": "0.1.0-0.1.20070619svnrev12.el7",
"Repo": "@CyberPanel"
},
{
"Package": "galera.x86_64",
"Version": "25.3.28-1.rhel7.el7.centos",
"Repo": "@CyberPanel"
},
{
"Package": "htop.x86_64",
"Version": "2.2.0-3.el7",
"Repo": "@CyberPanel"
},
{
"Package": "jemalloc.x86_64",
"Version": "3.6.0-1.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libargon2.x86_64",
"Version": "20161029-3.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libbsd.x86_64",
"Version": "0.8.3-1.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libc-client.x86_64",
"Version": "2007f-16.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libdb4.x86_64",
"Version": "4.8.30-13.el7",
"Repo": "@CyberPanel"
},
{
"Package": "liblzf.x86_64",
"Version": "3.6-7.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libmcrypt.x86_64",
"Version": "2.5.8-13.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libopendkim.x86_64",
"Version": "2.11.0-0.1.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libsodium.x86_64",
"Version": "1.0.18-1.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libtidy.x86_64",
"Version": "5.4.0-1.el7",
"Repo": "@CyberPanel"
},
{
"Package": "luajit.x86_64",
"Version": "2.0.4-3.el7",
"Repo": "@CyberPanel"
},
{
"Package": "oniguruma.x86_64",
"Version": "5.9.5-3.el7",
"Repo": "@CyberPanel"
},
{
"Package": "opendbx.x86_64",
"Version": "1.4.6-6.el7",
"Repo": "@CyberPanel"
},
{
"Package": "opendkim.x86_64",
"Version": "2.11.0-0.1.el7",
"Repo": "@CyberPanel"
},
{
"Package": "pdns.x86_64",
"Version": "4.2.2-1pdns.el7",
"Repo": "@CyberPanel"
},
{
"Package": "pdns-backend-mysql.x86_64",
"Version": "4.2.2-1pdns.el7",
"Repo": "@CyberPanel"
},
{
"Package": "postfix3.x86_64",
"Version": "2:3.4.7-1.gf.el7",
"Repo": "@CyberPanel"
},
{
"Package": "postfix3-ldap.x86_64",
"Version": "2:3.4.7-1.gf.el7",
"Repo": "@CyberPanel"
},
{
"Package": "postfix3-mysql.x86_64",
"Version": "2:3.4.7-1.gf.el7",
"Repo": "@CyberPanel"
},
{
"Package": "postfix3-pcre.x86_64",
"Version": "2:3.4.7-1.gf.el7",
"Repo": "@CyberPanel"
},
{
"Package": "pure-ftpd.x86_64",
"Version": "1.0.47-3.el7",
"Repo": "@CyberPanel"
},
{
"Package": "redis.x86_64",
"Version": "3.2.12-2.el7",
"Repo": "@CyberPanel"
},
{
"Package": "restic.x86_64",
"Version": "0.9.6-1.el7",
"Repo": "@CyberPanel"
},
{
"Package": "rsync31u.x86_64",
"Version": "3.1.3-1.ius.el7",
"Repo": "@CyberPanel"
},
{
"Package": "udns.x86_64",
"Version": "0.4-3.el7",
"Repo": "@CyberPanel"
},
{
"Package": "udns-devel.x86_64",
"Version": "0.4-3.el7",
"Repo": "@CyberPanel"
},
{
"Package": "vim-minimal.x86_64",
"Version": "2:8.0.003-1.gf.el7",
"Repo": "@CyberPanel"
}
]

View File

@@ -0,0 +1,360 @@
#!/bin/bash
#systemctl stop firewalld
check_return() {
#check previous command result , 0 = ok , non-0 = something wrong.
if [[ $? -eq "0" ]] ; then
:
else
echo -e "\ncommand failed, exiting..."
exit
fi
}
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
perl -MCPAN -e 'install Encoding::FixLatin'
perl -MCPAN -e 'install Digest::SHA1'
perl -MCPAN -e 'install Geo::IP'
perl -MCPAN -e 'install Razor2::Client::Agent'
perl -MCPAN -e 'install 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
perl -MCPAN -e 'install Encoding::FixLatin'
perl -MCPAN -e 'install Digest::SHA1'
perl -MCPAN -e 'install Geo::IP'
perl -MCPAN -e 'install Razor2::Client::Agent'
perl -MCPAN -e 'install Sys::Hostname::Long'
perl -MCPAN -e 'install 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
if [ "$OS" = "NAME=\"Ubuntu\"" ];then
wget https://github.com/MailScanner/v5/releases/download/5.3.3-1/MailScanner-5.3.3-1.noarch.deb
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
wget https://github.com/MailScanner/v5/releases/download/5.3.3-1/MailScanner-5.3.3-1.rhel.noarch.rpm
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 && systemctl restart mailscanner;
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

View File

@@ -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 \

View File

@@ -113,8 +113,8 @@ DATABASES = {
'NAME': 'cyberpanel',
'USER': 'cyberpanel',
'PASSWORD': 'Bz9gF7Hr7X4RtD',
'HOST': '127.0.0.1',
'PORT':'3307'
'HOST': 'localhost',
'PORT':''
},
'rootdb': {
'ENGINE': 'django.db.backends.mysql',
@@ -187,6 +187,7 @@ LANGUAGES = (
('vi', _('Vietnamese')),
('it', _('Italian')),
('de', _('Deutsch')),
('id', _('Indonesian')),
)
MEDIA_URL = '/home/cyberpanel/media/'

View File

@@ -118,6 +118,24 @@ class IncJobs(multi.Thread):
except BaseException as msg:
logging.writeToFile(str(msg))
## Find restore path
def findRestorePath(self):
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8 \
or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
self.restoreTarget = '/'
return 1
else:
if self.jobid.type[:8] == 'database':
self.restoreTarget = '/home/cyberpanel/'
elif self.jobid.type[:4] == 'data':
self.restoreTarget = '/home/'
elif self.jobid.type[:5] == 'email':
self.restoreTarget = '/home/vmail/'
elif self.jobid.type[:4] == 'meta':
self.restoreTarget = '/home/%s/' % (self.website)
####
def getAWSData(self):
@@ -159,9 +177,9 @@ class IncJobs(multi.Thread):
key, secret = self.getAWSData()
command = 'export RESTIC_PASSWORD=%s AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s restore %s --target /' % (
command = 'export RESTIC_PASSWORD=%s AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s restore %s --target %s' % (
self.passwordFile,
key, secret, self.website, snapshotID)
key, secret, self.website, snapshotID, self.restoreTarget)
result = ProcessUtilities.outputExecutioner(command)
@@ -173,8 +191,8 @@ class IncJobs(multi.Thread):
key, secret = self.getAWSData()
command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s restore %s --password-file %s --target /' % (
key, secret, self.website, snapshotID, self.passwordFile)
command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s restore %s --password-file %s --target %s' % (
key, secret, self.website, snapshotID, self.passwordFile, self.restoreTarget)
result = ProcessUtilities.outputExecutioner(command)
@@ -213,8 +231,8 @@ class IncJobs(multi.Thread):
return 1
else:
repoLocation = '/home/%s/incbackup' % (self.website)
command = 'restic -r %s restore %s --target / --password-file %s' % (
repoLocation, self.jobid.snapshotid, self.passwordFile)
command = 'restic -r %s restore %s --target %s --password-file %s' % (
repoLocation, self.jobid.snapshotid, self.restoreTarget, self.passwordFile)
result = ProcessUtilities.outputExecutioner(command)
@@ -250,17 +268,17 @@ class IncJobs(multi.Thread):
else:
if self.reconstruct == 'remote':
repoLocation = '/home/backup/%s' % (self.website)
command = 'export RESTIC_PASSWORD=%s PATH=${PATH}:/usr/bin && restic -r %s:%s restore %s --target /' % (
command = 'export RESTIC_PASSWORD=%s PATH=${PATH}:/usr/bin && restic -r %s:%s restore %s --target %s' % (
self.passwordFile,
self.backupDestinations, repoLocation, self.jobid)
self.backupDestinations, repoLocation, self.jobid, self.restoreTarget)
result = ProcessUtilities.outputExecutioner(command)
if result.find('restoring') == -1:
logging.statusWriter(self.statusPath, 'Failed: %s. [5009]' % (result), 1)
return 0
else:
repoLocation = '/home/backup/%s' % (self.website)
command = 'export PATH=${PATH}:/usr/bin && restic -r %s:%s restore %s --target / --password-file %s' % (
self.jobid.destination, repoLocation, self.jobid.snapshotid, self.passwordFile)
command = 'export PATH=${PATH}:/usr/bin && restic -r %s:%s restore %s --target %s --password-file %s' % (
self.jobid.destination, repoLocation, self.jobid.snapshotid, self.restoreTarget, self.passwordFile)
result = ProcessUtilities.outputExecutioner(command)
if result.find('restoring') == -1:
logging.statusWriter(self.statusPath, 'Failed: %s. [5009]' % (result), 1)
@@ -448,8 +466,11 @@ class IncJobs(multi.Thread):
message = 'Reconstructed'
logging.statusWriter(self.statusPath, message, 1)
else:
self.jobid = JobSnapshots.objects.get(pk=jobid)
self.findRestorePath()
message = 'Starting restore of %s for %s.' % (self.jobid.snapshotid, self.website)
logging.statusWriter(self.statusPath, message, 1)
self.passwordFile = '/home/%s/%s' % (self.website, self.website)

View File

@@ -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)

View File

@@ -1,19 +1,18 @@
#!/usr/local/CyberCP/bin/python
import tornado.httpserver
import tornado.websocket
import tornado.ioloop
import tornado.web
import sys
import os
import django
sys.path.append('/usr/local/CyberCP')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
import signal
import sys
import ssl
from SimpleWebSocketServer import WebSocket, SimpleSSLWebSocketServer
import paramiko
import os
import json
import threading as multi
import time
import asyncio
class SSHServer(multi.Thread):
@@ -34,7 +33,7 @@ class SSHServer(multi.Thread):
else:
SSHServer.DEFAULT_PORT = int(items.split(' ')[1])
except BaseException as msg:
logging.writeToFile(str(msg))
logging.writeToFile('%s. [SSHServer.findSSHPort]' % (str(msg)))
def loadPublicKey(self):
pubkey = '/root/.ssh/cyberpanel.pub'
@@ -73,79 +72,90 @@ class SSHServer(multi.Thread):
self.color = 0
def recvData(self):
asyncio.set_event_loop(asyncio.new_event_loop())
while True:
try:
if self.websocket.running:
if os.path.exists(self.websocket.verifyPath):
if self.websocket.filePassword == self.websocket.password:
if self.shell.recv_ready():
if self.color == 0:
text = '%sEnjoy your accelerated Internet by CyberPanel and LiteSpeed%s' % (SSHServer.OKGREEN, SSHServer.ENDC)
nText = 'Enjoy your accelerated Internet by CyberPanel'
self.websocket.sendMessage(self.shell.recv(9000).decode("utf-8").replace(nText, text))
self.color = 1
else:
self.websocket.sendMessage(self.shell.recv(9000).decode("utf-8"))
else:
time.sleep(0.01)
if os.path.exists(self.verifyPath) and self.filePassword == self.password:
if self.shell.recv_ready():
self.websocket.write_message(self.shell.recv(9000).decode("utf-8"))
else:
time.sleep(0.001)
else:
return 0
else:
return 0
except BaseException as msg:
time.sleep(0.1)
print('%s. [recvData]' % str(msg))
time.sleep(0.001)
def run(self):
try:
self.recvData()
except BaseException as msg:
print((str(msg)))
print('%s. [SSHServer.run]' % (str(msg)))
class WSHandler(tornado.websocket.WebSocketHandler):
class WebTerminalServer(WebSocket):
def open(self):
print('connected')
self.running = 1
self.sh = SSHServer(self)
self.shell = self.sh.shell
self.sh.start()
self.init = 1
print('connect ok')
def handleMessage(self):
try:
data = json.loads(self.data)
if str(self.data).find('"tp":"init"') > -1:
self.verifyPath = str(data['data']['verifyPath'])
self.password = str(data['data']['password'])
self.filePassword = open(self.verifyPath, 'r').read()
else:
if os.path.exists(self.verifyPath):
if self.filePassword == self.password:
self.shell.send(str(data['data']))
except:
pass
def on_message(self, message):
try:
print('handle message')
data = json.loads(message)
def handleConnected(self):
self.running = 1
self.sh = SSHServer(self)
self.shell = self.sh.shell
self.sh.start()
if self.init:
self.sh.verifyPath = str(data['data']['verifyPath'])
self.sh.password = str(data['data']['password'])
self.sh.filePassword = open(self.sh.verifyPath, 'r').read()
self.init = 0
else:
if os.path.exists(self.sh.verifyPath):
if self.sh.filePassword == self.sh.password:
self.shell.send(str(data['data']))
def handleClose(self):
try:
os.remove(self.verifyPath)
self.running = 0
except:
pass
except BaseException as msg:
print('%s. [WebTerminalServer.handleMessage]' % (str(msg)))
def on_close(self):
print('connection closed')
def check_origin(self, origin):
return True
application = tornado.web.Application([
(r'/', WSHandler),
])
if __name__ == "__main__":
pidfile = '/usr/local/CyberCP/WebTerminal/pid'
writeToFile = open(pidfile, 'w')
writeToFile.write(str(os.getpid()))
writeToFile.close()
pidfile = '/usr/local/CyberCP/WebTerminal/pid'
SSHServer.findSSHPort()
writeToFile = open(pidfile, 'w')
writeToFile.write(str(os.getpid()))
writeToFile.close()
print ('SSH Port is set to: %s' % (str(SSHServer.DEFAULT_PORT)))
http_server = tornado.httpserver.HTTPServer(application, ssl_options={
"certfile": "/usr/local/lscp/conf/cert.pem",
"keyfile": "/usr/local/lscp/conf/key.pem",
}, )
server = SimpleSSLWebSocketServer('0.0.0.0', '5678', WebTerminalServer, '/usr/local/lscp/conf/cert.pem', '/usr/local/lscp/conf/key.pem', version=ssl.PROTOCOL_TLSv1)
ADDR = '0.0.0.0'
http_server.listen(5678, ADDR)
print('*** Websocket Server Started at %s***' % ADDR)
def close_sig_handler(signal, frame):
server.close()
sys.exit()
import signal
def close_sig_handler(signal, frame):
http_server.stop()
sys.exit()
signal.signal(signal.SIGINT, close_sig_handler)
server.serveforever()
signal.signal(signal.SIGINT, close_sig_handler)
tornado.ioloop.IOLoop.instance().start()

View File

@@ -73,16 +73,6 @@ function connect() {
if (remember) {
store(options)
}
// if (check()) {
// openTerminal(options)
// } else {
// for (var key in validResult) {
// if (!validResult[key]) {
// alert(errorMsg[key]);
// break;
// }
// }
// }
openTerminal(options)
}

View File

@@ -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 %}

View File

@@ -622,7 +622,6 @@ def runAWSBackups(request):
except BaseException as msg:
logging.writeToFile(str(msg) + ' [API.runAWSBackups]')
@csrf_exempt
def submitUserCreation(request):
try:

View File

@@ -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
@@ -407,46 +407,65 @@ class BackupManager:
destinations = backupUtil.backupUtilities.destinationsPath
ipAddress = data['IPAddress']
password = data['password']
finalDic = {}
finalDic['ipAddress'] = data['IPAddress']
finalDic['password'] = data['password']
try:
finalDic['port'] = data['backupSSHPort']
except:
finalDic['port'] = "22"
try:
finalDic['user'] = data['user']
except:
finalDic['user'] = "root"
if dest.objects.all().count() == 2:
final_dic = {'destStatus': 0,
'error_message': "Currently only one remote destination is allowed."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
try:
d = dest.objects.get(destLoc=ipAddress)
d = dest.objects.get(destLoc=finalDic['password'])
final_dic = {'destStatus': 0, 'error_message': "This destination already exists."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except:
try:
port = data['backupSSHPort']
except:
port = "22"
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
execPath = execPath + " submitDestinationCreation --ipAddress " + ipAddress + " --password " \
+ password + " --port " + port
execPath = execPath + " submitDestinationCreation --ipAddress " + finalDic['ipAddress'] + " --password " \
+ finalDic['password'] + " --port " + finalDic['port'] + ' --user %s' % (finalDic['user'])
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(execPath)
output = ProcessUtilities.outputExecutioner(execPath)
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(output)
if output.find('1,') > -1:
try:
writeToFile = open(destinations, "w")
writeToFile.writelines(ipAddress + "\n")
writeToFile.writelines(data['backupSSHPort'] + "\n")
writeToFile.write(json.dumps(finalDic))
writeToFile.close()
newDest = dest(destLoc=ipAddress)
newDest = dest(destLoc=finalDic['ipAddress'])
newDest.save()
final_dic = {'destStatus': 1, 'error_message': "None"}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except:
writeToFile = open(destinations, "w")
writeToFile.writelines(ipAddress + "\n")
writeToFile.writelines("22" + "\n")
writeToFile.write(json.dumps(finalDic))
writeToFile.close()
newDest = dest(destLoc=ipAddress)
newDest = dest(destLoc=finalDic['ipAddress'])
newDest.save()
final_dic = {'destStatus': 1, 'error_message': "None"}
@@ -1096,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)
@@ -1172,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)

View File

@@ -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 **///

View File

@@ -33,6 +33,13 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "User" %}</label>
<div class="col-sm-6">
<input placeholder="{% trans "Backup server SSH User, leave empty for root." %}" type="text" class="form-control" ng-model="user" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
@@ -48,7 +55,6 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">

View 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 %}

View File

@@ -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">

View File

@@ -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'),
]

View File

@@ -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):

View File

@@ -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 -->
@@ -874,6 +877,9 @@
<li><a href="{% url 'emailMarketing' %}"
title="{% trans 'Email Marketing' %}"><span>{% trans "Email Marketing" %}</span></a>
</li>
<li><a href="{% url 'MailScanner' %}"
title="{% trans 'MailScanner' %}"><span>{% trans "MailScanner" %}</span></a>
</li>
</ul>
</div><!-- .sidebar-submenu -->

View File

@@ -13,6 +13,4 @@ urlpatterns = [
url(r'^UpgradeStatus',views.upgradeStatus, name='UpgradeStatus'),
url(r'^upgradeVersion',views.upgradeVersion, name='upgradeVersion'),
]

View File

@@ -19,7 +19,7 @@ from plogical.processUtilities import ProcessUtilities
# Create your views here.
VERSION = '2.0'
BUILD = 0
BUILD = 1
@ensure_csrf_cookie
def renderBase(request):
@@ -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'

View File

@@ -54,4 +54,13 @@ class cliParser:
parser.add_argument('--userName', help='Email Username.')
parser.add_argument('--password', help='Email password.')
### Additional Arguments for user manager
parser.add_argument('--firstName', help='First name while creating user.')
parser.add_argument('--lastName', help='First name while creating user.')
parser.add_argument('--websitesLimit', help='Website limit while creating user.')
parser.add_argument('--selectedACL', help='Select ACL while creating user.')
parser.add_argument('--securityLevel', help='Set security level while creating user.')
parser.add_argument('--state', help='State value used in user suspension.')
return parser.parse_args()

View File

@@ -1323,6 +1323,155 @@ def main():
currentversion = version + '.' + build
print (currentversion)
### User Functions
elif args.function == "createUser":
completeCommandExample = 'cyberpanel createUser --firstName Cyber --lastName Panel --email email@cyberpanel.net --userName cyberpanel --password securepassword --websitesLimit 10 --selectedACL user --securityLevel HIGH'
if not args.firstName:
print("\n\nPlease enter First Name. For example:\n\n" + completeCommandExample + "\n\n")
return
if not args.lastName:
print("\n\nPlease enter Last Name. For example:\n\n" + completeCommandExample + "\n\n")
return
if not args.email:
print("\n\nPlease enter Email. For example:\n\n" + completeCommandExample + "\n\n")
return
if not args.userName:
print("\n\nPlease enter User name. For example:\n\n" + completeCommandExample + "\n\n")
return
if not args.password:
print("\n\nPlease enter password. For example:\n\n" + completeCommandExample + "\n\n")
return
if not args.websitesLimit:
print("\n\nPlease enter website limit. For example:\n\n" + completeCommandExample + "\n\n")
return
if not args.selectedACL:
print("\n\nPlease enter select acl. For example:\n\n" + completeCommandExample + "\n\n")
return
if not args.securityLevel:
print("\n\nPlease set security level. For example:\n\n" + completeCommandExample + "\n\n")
return
from userManagment.views import submitUserCreation
data = {}
data['firstName'] = args.firstName
data['lastName'] = args.lastName
data['email'] = args.email
data['userName'] = args.userName
data['password'] = args.password
data['websitesLimit'] = args.websitesLimit
data['selectedACL'] = args.selectedACL
data['securityLevel'] = args.securityLevel
data['userID'] = 1
response = submitUserCreation(data)
print(response.content.decode())
elif args.function == "deleteUser":
completeCommandExample = 'cyberpanel deleteUser --userName cyberpanel'
if not args.userName:
print("\n\nPlease enter User Name. For example:\n\n" + completeCommandExample + "\n\n")
return
from userManagment.views import submitUserDeletion
data = {}
data['accountUsername'] = args.userName
data['userID'] = 1
response = submitUserDeletion(data)
print(response.content.decode())
elif args.function == "listUsers":
from userManagment.views import fetchTableUsers
data = {}
data['userID'] = 1
response = fetchTableUsers(data)
print(response.content.decode())
elif args.function == "suspendUser":
completeCommandExample = 'cyberpanel suspendUser --userName cyberpanel --state SUSPEND'
if not args.userName:
print("\n\nPlease enter User Name. For example:\n\n" + completeCommandExample + "\n\n")
return
if not args.state:
print("\n\nPlease enter state value i.e SUSPEND/UnSuspend. For example:\n\n" + completeCommandExample + "\n\n")
return
from userManagment.views import controlUserState
data = {}
data['accountUsername'] = args.userName
data['state'] = args.state
data['userID'] = 1
response = controlUserState(data)
print(response.content.decode())
elif args.function == "editUser":
completeCommandExample = 'cyberpanel editUser --userName cyberpanel --firstName Cyber --lastName Panel --email email@cyberpanel.net --password securepassword --securityLevel HIGH'
if not args.firstName:
print("\n\nPlease enter First Name. For example:\n\n" + completeCommandExample + "\n\n")
return
if not args.lastName:
print("\n\nPlease enter Last Name. For example:\n\n" + completeCommandExample + "\n\n")
return
if not args.email:
print("\n\nPlease enter Email. For example:\n\n" + completeCommandExample + "\n\n")
return
if not args.userName:
print("\n\nPlease enter User name. For example:\n\n" + completeCommandExample + "\n\n")
return
if not args.password:
print("\n\nPlease enter password. For example:\n\n" + completeCommandExample + "\n\n")
return
if not args.securityLevel:
print("\n\nPlease set security level. For example:\n\n" + completeCommandExample + "\n\n")
return
from userManagment.views import saveModifications
data = {}
data['accountUsername'] = args.userName
data['firstName'] = args.firstName
data['lastName'] = args.lastName
data['email'] = args.email
data['passwordByPass'] = args.password
data['securityLevel'] = args.securityLevel
data['userID'] = 1
response = saveModifications(data)
print(response.content.decode())
if __name__ == "__main__":

View File

@@ -948,6 +948,7 @@ class CloudManager:
def systemStatus(self, request):
try:
request.session['userID'] = self.admin.pk
return topProcessesStatus(request)
except BaseException as msg:
return self.ajaxPre(0, str(msg))
@@ -1079,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')

View File

@@ -3,4 +3,5 @@ from . import views
urlpatterns = [
url(r'^$', views.router, name='router'),
url(r'^access$', views.access, name='access'),
]

View File

@@ -4,8 +4,8 @@
from .cloudManager import CloudManager
import json
from loginSystem.models import Administrator
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import HttpResponse
@csrf_exempt
def router(request):
@@ -310,3 +310,26 @@ def router(request):
except BaseException as msg:
cm = CloudManager(None)
return cm.ajaxPre(0, str(msg))
@csrf_exempt
def access(request):
try:
serverUserName = request.GET.get('serverUserName')
token = request.GET.get('token')
admin = Administrator.objects.get(userName=serverUserName)
if admin.api == 0:
return HttpResponse('API Access Disabled.')
if token == admin.token.lstrip('Basic ').rstrip('='):
request.session['userID'] = admin.pk
from django.shortcuts import redirect
from baseTemplate.views import renderBase
return redirect(renderBase)
else:
return HttpResponse('Unauthorized access.')
except BaseException as msg:
cm = CloudManager(None)
return cm.ajaxPre(0, str(msg))

View File

@@ -1,11 +1,10 @@
#!/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)
DEV="OFF"
BRANCH="stable"
POSTFIX_VARIABLE="ON"
POWERDNS_VARIABLE="ON"
PUREFTPD_VARIABLE="ON"
@@ -22,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.
@@ -46,22 +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
#BASH_PATH="/root/.bashrc"
#if ! cat $BASH_PATH | grep -q cyberpanel_utility ; then
#echo -e "\n\ncyberpanel() {
#if [[ \$1 == \"utility\" ]] ; then
#/usr/bin/cyberpanel_utility \${@:2:99}
#elif [[ \$1 == \"help\" ]] ; then
#/usr/bin/cyberpanel_utility --help
#elif [[ \$1 == \"upgrade\" ]] || [[ \$1 == \"update\" ]] ; then
#/usr/bin/cyberpanel_utility --upgrade
#else
#/usr/bin/cyberpanel \"\$@\"
#fi
#}" >> $BASH_PATH
#fi
}
watchdog_setup() {
@@ -193,6 +190,7 @@ special_change(){
sed -i 's|cyberpanel.sh|'$DOWNLOAD_SERVER'|g' install.py
sed -i 's|mirror.cyberpanel.net|'$DOWNLOAD_SERVER'|g' install.py
sed -i 's|git clone https://github.com/usmannasir/cyberpanel|echo downloaded|g' install.py
#change to CDN first, regardless country
#sed -i 's|http://|https://|g' install.py
@@ -257,44 +255,17 @@ if [[ $SERVER_COUNTRY == "CN" ]] ; then
sed -i 's|wget -O - https://get.acme.sh \| sh|git clone https://gitee.com/qtwrk/acme.sh.git ; cd acme.sh ; ./acme.sh --install ; cd - ; rm -rf acme.sh|g' install.py
sed -i 's|composer.sh|composer_cn.sh|g' install.py
sed -i 's|yum -y install http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm|wget -O /etc/yum.repos.d/lux.repo https://'$DOWNLOAD_SERVER'/lux/lux.repo|g' install.py
# global change for CN , regardless provider and system
if [[ $SERVER_OS == "CentOS" ]] ; then
DIR=$(pwd)
cd $DIR/mysql
echo "[mariadb-tsinghua]
name = MariaDB
baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/10.1/centos7-amd64
gpgkey = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum//RPM-GPG-KEY-MariaDB
gpgcheck = 1" > MariaDB.repo
#above to set mariadb db to Tsinghua repo
cd $DIR
sed -i 's|https://www.litespeedtech.com/packages/5.0/lsws-5.3.5-ent-x86_64-linux.tar.gz|https://cyberpanel.sh/packages/5.0/lsws-5.3.5-ent-x86_64-linux.tar.gz|g' installCyberPanel.py
mkdir /root/.config
mkdir /root/.config/pip
cat << EOF > /root/.config/pip/pip.conf
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn
EOF
echo -e "\nSet to Aliyun pip repo..."
fi
if [[ $SERVER_OS == "Ubuntu" ]] ; then
echo $'\n89.208.248.38 rpms.litespeedtech.com\n' >> /etc/hosts
echo -e "Mirror server set..."
pip config set global.index-url https://pypi.python.org/simple/
mkdir /root/.config
mkdir /root/.config/pip
cat << EOF > /root/.config/pip/pip.conf
[global]
index-url = https://pypi.python.org/simple/
[install]
trusted-host=pypi.python.org
EOF
echo -e "\nSet to Aliyun pip repo..."
if [[ $PROVIDER == "Tencent Cloud" ]] ; then
#tencent cloud and ubuntu system
echo -e "\n Tencent Cloud detected ... bypass default repository"
@@ -313,7 +284,6 @@ deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted univer
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
EOF
DEBIAN_FRONTEND=noninteractive apt update -y
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
fi
fi
fi
@@ -398,19 +368,17 @@ fi
install_required() {
if [[ $SERVER_COUNTRY == "CN" ]] ; then
mkdir /root/.config
mkdir /root/.config/pip
cat << EOF > /root/.config/pip/pip.conf
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn
EOF
if [[ $CENTOS_8 == "True" ]] ; then
curl https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.0.1/install/CyberPanel8.repo > /etc/yum.repos.d/CyberPanel.repo
dnf install zip -y
elif [[ $CENTOS_8 == "False" ]] ; then
curl https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.0.1/install/CyberPanel.repo > /etc/yum.repos.d/CyberPanel.repo
fi
echo -e "\nInstalling necessary components..."
if [[ $SERVER_OS == "CentOS" ]] ; then
timeout 10 rpm --import https://$DOWNLOAD_SERVER/mariadb/RPM-GPG-KEY-MariaDB
timeout 10 rpm --import https://$DOWNLOAD_SERVER/litespeed/RPM-GPG-KEY-litespeed
timeout 10 rpm --import https://$DOWNLOAD_SERVER/powerdns/FD380FBB-pub.asc
@@ -420,63 +388,60 @@ if [[ $SERVER_OS == "CentOS" ]] ; then
timeout 10 rpm --import https://$DOWNLOAD_SERVER/ius/RPM-GPG-KEY-IUS-7
timeout 10 rpm --import https://repo.dovecot.org/DOVECOT-REPO-GPG
timeout 10 rpm --import https://copr-be.cloud.fedoraproject.org/results/copart/restic/pubkey.gpg
timeout 10 rpm --import https://rep8.cyberpanel.net/RPM-GPG-KEY-CP-EP-8
timeout 10 rpm --import https://rep8.cyberpanel.net/RPM-GPG-KEY-CP-GF-8
timeout 10 rpm --import https://rep8.cyberpanel.net/RPM-GPG-KEY-centosofficialcp
curl https://getfedora.org/static/fedora.gpg | gpg --import
yum clean all
yum update -y
yum autoremove epel-release -y
rm -f /etc/yum.repos.d/epel.repo
rm -f /etc/yum.repos.d/epel.repo.rpmsave
yum install epel-release -y
if [[ $CENTOS_8 == "False" ]] ; then
yum install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc python-devel libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel python-pip git socat
yum --enablerepo=CyberPanel install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel gpgme-devel curl-devel git socat openssl-devel MariaDB-shared mariadb-devel yum-utils python36u python36u-pip python36u-devel
check_return
yum -y groupinstall development
check_return
fi
if [[ $CENTOS_8 == "True" ]] ; then
yum install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel mariadb-devel curl-devel git platform-python-devel tar socat
dnf install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel mariadb-devel curl-devel git platform-python-devel tar socat python3
check_return
dnf --enablerepo=PowerTools install gpgme-devel -y
check_return
fi
if [[ $DEV == "ON" ]] ; then
if [[ $CENTOS_8 == "False" ]] ; then
yum -y install yum-utils
yum -y groupinstall development
if [[ $SERVER_COUNTRY == "CN" ]] ; then
wget -O /etc/yum.repos.d/ius.repo https://$DOWNLOAD_SERVER/ius/ius.repo
else
yum -y install https://repo.ius.io/ius-release-el7.rpm
fi
yum -y install python36u python36u-pip python36u-devel
check_return
fi
if [[ $CENTOS_8 == "True" ]] ; then
dnf install python3 -y
check_return
fi
if [[ $SERVER_OS == "CentOS" ]] ; then
pip3.6 install virtualenv==16.7.9
else
pip3.6 install virtualenv
fi
check_return
fi
if [[ $SERVER_OS == "CentOS" ]] ; then
pip3.6 install virtualenv==16.7.9
else
pip3.6 install virtualenv
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 python-mysqldb python-dev 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 python-gpg python python-minimal python-setuptools virtualenv python-dev python-pip 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
if [[ $DEV == "ON" ]] ; then
DEBIAN_FRONTEND=noninteractive apt install -y python3-pip
check_return
ln -s /usr/bin/pip3 /usr/bin/pip3.6
DEBIAN_FRONTEND=noninteractive apt install -y build-essential libssl-dev libffi-dev python3-dev
check_return
DEBIAN_FRONTEND=noninteractive apt install -y python3-venv
check_return
fi
DEBIAN_FRONTEND=noninteractive apt install -y python3-pip
check_return
ln -s /usr/bin/pip3 /usr/bin/pip3.6
DEBIAN_FRONTEND=noninteractive apt install -y build-essential libssl-dev libffi-dev python3-dev
check_return
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
}
@@ -600,6 +565,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"
@@ -618,12 +584,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() {
@@ -1041,11 +1018,14 @@ if [[ $debug == "0" ]] ; then
exit
fi
if [[ $debug == "1" ]] ; then
wget -O requirements.txt https://$GIT_CONTENT_URL/${BRANCH_NAME}/requirments.txt
check_return
/usr/local/CyberPanel/bin/pip3 install --ignore-installed -r requirements.txt
rm -f requirements.txt
if [[ $UBUNTU_20 == "False" ]] ; then
pip3.6 install --ignore-installed /usr/local/pip-packs/*
else
pip3.6 install --ignore-installed /usr/local/packages/*
fi
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
@@ -1068,6 +1048,7 @@ if [[ $REDIS == "ON" ]] ; then
fi
after_install
fi
}
pip_virtualenv() {
@@ -1084,14 +1065,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 requirements.txt https://$GIT_CONTENT_URL/${BRANCH_NAME}/requirments.txt
check_return
pip3.6 install --ignore-installed -r requirements.txt
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
@@ -1179,15 +1171,24 @@ trusted-host=pypi.python.org
EOF
fi
virtualenv -p /usr/bin/python3 /usr/local/CyberCP
source /usr/local/CyberCP/bin/activate
wget -O requirements.txt https://$GIT_CONTENT_URL/${BRANCH_NAME}/requirments.txt
check_return
pip3.6 install --ignore-installed -r requirements.txt
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)
@@ -1310,7 +1311,11 @@ fi
fi
#fix php.ini &amp; issue
clear
if [[ $UBUNTU_20 == "True" ]] ; then
cp /usr/local/lsws/lsphp73/bin/php /usr/bin
fi
#clear
echo "###################################################################"
echo " CyberPanel Successfully Installed "
echo " "
@@ -1441,6 +1446,8 @@ else
fi
}
##START
if [ $# -eq 0 ] ; then
echo -e "\nInitializing...\n"
else
@@ -1539,6 +1546,8 @@ else
DOWNLOAD_SERVER="cdn.cyberpanel.sh"
fi
##END
check_OS
check_virtualization
check_root
@@ -1547,9 +1556,6 @@ check_process
check_provider
if [[ $SILENT = "ON" ]] ; then
argument_mode
else
@@ -1566,3 +1572,8 @@ pip_virtualenv
system_tweak
main_install
### Disable Centos Default Repos
disable_repos

View File

@@ -1,4 +1,5 @@
#!/bin/bash
#CyberPanel Upgrade script
export LC_CTYPE=en_US.UTF-8
@@ -11,6 +12,27 @@ 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
rm -f /etc/yum.repos.d/ius-archive.repo
rm -f /etc/yum.repos.d/copart-restic-epel-7.repo
rm -f /etc/yum.repos.d/dovecot.repo
rm -f /etc/yum.repos.d/epel.repo
rm -f /etc/yum.repos.d/epel-testing.repo
rm -f /etc/yum.repos.d/frank.repo
rm -f /etc/yum.repos.d/ius.repo
rm -f /etc/yum.repos.d/ius-testing.repo
rm -f /etc/yum.repos.d/MariaDB.repo
rm -f /etc/yum.repos.d/lux.repo
rm -f /etc/yum.repos.d/gf.repo
rm -f /etc/yum.repos.d/powerdns-auth-42.repo
rm -rf /etc/yum.repos.d/powerdns-auth-master.repo
rm -rf /etc/yum.repos.d/gf.repo.rpmnew
##
if [[ ${#SERVER_COUNTRY} == "2" ]] || [[ ${#SERVER_COUNTRY} == "6" ]] ; then
echo -e "\nChecking server..."
else
@@ -138,24 +160,41 @@ 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"
curl https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.0.1/install/CyberPanel.repo > /etc/yum.repos.d/CyberPanel.repo
yum clean all
yum update -y
yum autoremove epel-release -y
rm -f /etc/yum.repos.d/epel.repo
rm -f /etc/yum.repos.d/epel.repo.rpmsave
elif echo $OUTPUT | grep -q "CloudLinux 7" ; then
echo -e "\nDetecting CloudLinux 7.X...\n"
SERVER_OS="CentOS7"
curl https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.0.1/install/CyberPanel.repo > /etc/yum.repos.d/CyberPanel.repo
yum clean all
yum update -y
yum autoremove epel-release -y
rm -f /etc/yum.repos.d/epel.repo
rm -f /etc/yum.repos.d/epel.repo.rpmsave
elif echo $OUTPUT | grep -q "CentOS Linux 8" ; then
curl https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.0.1/install/CyberPanel8.repo > /etc/yum.repos.d/CyberPanel.repo
echo -e "\nDetecting CentOS 8.X...\n"
SERVER_OS="CentOS8"
yum clean all
yum update -y
yum autoremove epel-release -y
rm -f /etc/yum.repos.d/epel.repo
rm -f /etc/yum.repos.d/epel.repo.rpmsave
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"
@@ -166,16 +205,15 @@ fi
if [ $SERVER_OS = "CentOS7" ] ; then
yum -y install yum-utils
yum -y groupinstall development
yum -y install https://centos7.iuscommunity.org/ius-release.rpm
yum -y install python36u python36u-pip python36u-devel
yum --enablerepo=CyberPanel install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel gpgme-devel curl-devel git socat openssl-devel MariaDB-shared mariadb-devel python36u python36u-pip python36u-devel
elif [ $SERVER_OS = "CentOS8" ] ; then
yum install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel mariadb-devel curl-devel git platform-python-devel tar
dnf install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel mariadb-devel curl-devel git platform-python-devel tar socat
dnf --enablerepo=PowerTools install gpgme-devel -y
dnf install python3 -y
else
apt update -y
DEBIAN_FRONTEND=noninteractive apt upgrade -y
DEBIAN_FRONTEND=noninteracitve apt install -y htop telnet python-mysqldb python-dev 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 python-gpg python python-minimal python-setuptools virtualenv python-dev python-pip git
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
DEBIAN_FRONTEND=noninteractive apt install -y python3-pip
DEBIAN_FRONTEND=noninteractive apt install -y build-essential libssl-dev libffi-dev python3-dev
DEBIAN_FRONTEND=noninteractive apt install -y python3-venv
@@ -189,65 +227,114 @@ else
check_return
fi
rm -rf /usr/local/CyberPanel
virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel
check_return
if [[ -f /usr/local/CyberPanel/bin/python2 ]] ; then
echo -e "\nPython 2 dectected, doing resetup...\n"
rm -rf /usr/local/CyberPanel/bin
virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel
check_return
elif [[ -d /usr/local/CyberPanel/bin/ ]] ; then
echo -e "\nNo need to resetup virtualenv at /usr/local/CyberPanel...\n"
else
echo -e "\nNothing found, need fresh setup...\n"
virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel
check_return
fi
rm -f requirments.txt
wget -O requirements.txt https://$GIT_CONTENT_URL/${BRANCH_NAME}/requirments.txt
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
check_return
if [ $SERVER_OS = "Ubuntu" ] ; then
. /usr/local/CyberPanel/bin/activate
check_return
pip3 install --ignore-installed -r requirements.txt
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
check_return
pip3.6 install --ignore-installed -r requirements.txt
pip3.6 install --ignore-installed /usr/local/pip-packs/*
check_return
fi
## Doing again to prevent an error - dont confuse later
virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel
check_return
##
rm -rf upgrade.py
wget https://$GIT_CONTENT_URL/${BRANCH_NAME}/plogical/upgrade.py
if [[ $SERVER_COUNTRY == "CN" ]] ; then
sed -i 's|wget https://raw.githubusercontent.com/usmannasir/cyberpanel/v1.9.4/lscpd-0.2.4 -P /usr/local/lscp/bin/|cp -f /usr/local/CyberCP/lscpd-0.2.4 /usr/local/lscp/bin/lscpd-0.2.4|g' upgrade.py
sed -i 's|wget https://raw.githubusercontent.com/usmannasir/cyberpanel/%s/lscpd-0.2.4 -P /usr/local/lscp/bin/|cp -f /usr/local/CyberCP/lscpd-0.2.4 /usr/local/lscp/bin/lscpd-0.2.4|g' upgrade.py
sed -i $'s/0.2.4\' % (branch)/0.2.4\'/' upgrade.py
#sed -i $'s/0.2.4\' % (branch)/0.2.4\'/' upgrade.py
sed -i 's|raw.githubusercontent.com/usmannasir/cyberpanel|'${GIT_CONTENT_URL}'|g' upgrade.py
sed -i 's|git clone https://github.com/usmannasir/cyberpanel|git clone https://'${GIT_URL}'|g' upgrade.py
fi
/usr/local/CyberPanel/bin/python upgrade.py $BRANCH_NAME
check_return
virtualenv -p /usr/bin/python3 /usr/local/CyberCP
if [[ -f /usr/local/CyberCP/bin/python2 ]] ; then
rm -rf /usr/local/CyberCP/bin
virtualenv -p /usr/bin/python3 /usr/local/CyberCP
elif [[ -d /usr/local/CyberCP/bin/ ]] ; then
echo -e "\nNo need to resetup virtualenv at /usr/local/CyberCP...\n"
else
virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberCP
check_return
fi
check_return
wget -O requirements.txt https://$GIT_CONTENT_URL/${BRANCH_NAME}/requirments.txt
if [ $SERVER_OS = "Ubuntu" ] ; then
. /usr/local/CyberCP/bin/activate
check_return
pip3 install --ignore-installed -r requirements.txt
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
check_return
pip3.6 install --ignore-installed -r requirements.txt
pip3.6 install --ignore-installed /usr/local/pip-packs/*
check_return
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
@@ -341,6 +428,25 @@ rm -f /usr/local/composer.sh
# clean up
### 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
echo "###################################################################"
echo " CyberPanel Upgraded "
echo "###################################################################"

View File

@@ -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'

View File

@@ -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'

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,107 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "MailScanner - 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 "MailScanner" %}</h2>
<p>{% trans "Install/Access MailScanner" %}</p>
</div>
<div ng-controller="MailScanner" class="example-box-wrapper">
<div class="panel panel-body">
<h3 class="content-box-header">
{% trans "MailScanner" %} <img ng-hide="SpamAssassinLoading" src="/static/images/loading.gif">
</h3>
<div class="content-box-wrapper">
<div class="row">
{% if checkIfMailScannerInstalled == 0 %}
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
<h4 class="mb-10">{% trans "MailScanner is not installed " %}
</h4>
<button ng-click="installSpamAssassin()" class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans "Install Now." %}</span>
<i class="glyph-icon icon-arrow-right"></i>
</button>
</div>
<!------ SpamAssassin Install Log box ----------------->
<div ng-hide="SpamAssassinNotifyBox" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-6">
<div ng-hide="failedToStartInallation" class="alert alert-danger">
<p>{% trans "Failed to start installation, Error message: " %} {$ errorMessage
$}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect. Please refresh this page." %} </p>
</div>
<div ng-hide="installationFailed" class="alert alert-danger">
<p>{% trans "Installation failed." %} {$ errorMessage $}</p>
</div>
<div ng-hide="SpamAssassinSuccessfullyInstalled" class="alert alert-success">
<p>{% trans "MailScanner successfully installed, refreshing page in 3 seconds.." %}</p>
</div>
</div>
</div>
<div ng-hide="SpamAssassinInstallBox" class="col-md-12">
<form action="/" id="" class="form-horizontal bordered-row">
<div class="form-group">
<div class="col-sm-12 text-center">
<h3><img
src="{% static 'firewall/icons/firewall.png' %}"> {% trans "Winter is coming, but so is MailScanner." %}
<img ng-hide="SpamAssassinLoading" src="/static/images/loading.gif">
</h3>
</div>
<div style="margin-top: 2%;" class="col-sm-12">
<textarea ng-model="requestData" rows="15"
class="form-control">{{ requestData }}</textarea>
</div>
</div>
</form>
</div>
<!----- SpamAssassin Install Log box ----------------->
{% else %}
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
<h4 class="mb-10">{% trans "MailScanner is installed. " %}
</h4>
<a target="_blank" href="https://{{ ipAddress }}:8090/mailwatch/mailscanner/">
<button class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans "Access Now." %}</span>
<i class="glyph-icon icon-arrow-right"></i>
</button></a>
</div>
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -38,6 +38,9 @@ urlpatterns = [
url(r'^fetchMessage$', views.fetchMessage, name='fetchMessage'),
url(r'^flushQueue$', views.flushQueue, name='flushQueue'),
url(r'^delete$', views.delete, name='delete'),
url(r'^MailScanner$', views.MailScanner, name='MailScanner'),
url(r'^installMailScanner$', views.installMailScanner, name='installMailScanner'),
url(r'^installStatusMailScanner$', views.installStatusMailScanner, name='installStatusMailScanner'),
url(r'^(?P<domain>(.*))$', views.emailLimits, name='emailLimits'),

View File

@@ -832,6 +832,11 @@ def installStatusSpamAssassin(request):
output = ProcessUtilities.outputExecutioner(execPath, 'root')
if output.find("1,None") > -1:
import os
if os.path.exists(mailUtilities.mailScannerInstallLogPath):
os.remove(mailUtilities.mailScannerInstallLogPath)
final_json = json.dumps({
'error_message': "None",
'requestStatus': installStatus,
@@ -1166,4 +1171,111 @@ def delete(request):
except KeyError as msg:
dic = {'status': 0, 'error_message': str(msg)}
json_data = json.dumps(dic)
return HttpResponse(json_data)
return HttpResponse(json_data)
## MailScanner
def MailScanner(request):
try:
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()
checkIfMailScannerInstalled = 0
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
if mailUtilities.checkIfMailScannerInstalled() == 1:
checkIfMailScannerInstalled = 1
return render(request, 'emailPremium/MailScanner.html',{'checkIfMailScannerInstalled': checkIfMailScannerInstalled, 'ipAddress': ipAddress})
except KeyError:
return redirect(loadLoginPage)
def installMailScanner(request):
try:
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadErrorJson()
try:
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
execPath = execPath + " installMailScanner"
ProcessUtilities.popenExecutioner(execPath)
final_json = json.dumps({'status': 1, 'error_message': "None"})
return HttpResponse(final_json)
except BaseException as msg:
final_dic = {'status': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError:
final_dic = {'status': 0, 'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
def installStatusMailScanner(request):
try:
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadErrorJson()
try:
if request.method == 'POST':
command = "sudo cat " + mailUtilities.mailScannerInstallLogPath
installStatus = ProcessUtilities.outputExecutioner(command)
if installStatus.find("[200]")>-1:
final_json = json.dumps({
'error_message': "None",
'requestStatus': installStatus,
'abort': 1,
'installed': 1,
})
return HttpResponse(final_json)
elif installStatus.find("[404]") > -1:
final_json = json.dumps({
'abort':1,
'installed':0,
'error_message': "None",
'requestStatus': installStatus,
})
return HttpResponse(final_json)
else:
final_json = json.dumps({
'abort':0,
'error_message': "None",
'requestStatus': installStatus,
})
return HttpResponse(final_json)
except BaseException as msg:
final_dic = {'abort':1,'installed':0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError:
final_dic = {'abort':1,'installed':0, 'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)

View File

@@ -5,7 +5,6 @@ from plogical.processUtilities import ProcessUtilities
from websiteFunctions.models import Websites
from random import randint
from django.core.files.storage import FileSystemStorage
import html.parser
from plogical.acl import ACLManager
class FileManager:
@@ -540,5 +539,5 @@ class FileManager:
command = 'chmod 755 %s' % (childs.path)
ProcessUtilities.popenExecutioner(command)
command = 'chmod %s:%s %s' % (externalApp, groupName, childs.path)
command = 'chown %s:%s %s' % (externalApp, groupName, childs.path)
ProcessUtilities.popenExecutioner(command)

View File

@@ -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;

View File

@@ -64,8 +64,12 @@ def downloadFile(request):
try:
userID = request.session['userID']
admin = Administrator.objects.get(pk=userID)
from urllib.parse import quote
from django.utils.encoding import iri_to_uri
fileToDownload = request.build_absolute_uri().split('fileToDownload')[1][1:]
fileToDownload = iri_to_uri(fileToDownload)
fileToDownload = request.GET.get('fileToDownload')
domainName = request.GET.get('domainName')
currentACL = ACLManager.loadedACL(userID)

View File

@@ -2171,8 +2171,6 @@ app.controller('installImunify', function ($scope, $http, $timeout, $window) {
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
}

View File

@@ -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

5
install/CyberPanel.repo Normal file
View File

@@ -0,0 +1,5 @@
[CyberPanel]
name=CyberPanel
baseurl=https://rep.cyberpanel.net/
gpgkey=https://rep.cyberpanel.net/RPM-GPG-KEY-cyberpanel
gpgcheck=1

5
install/CyberPanel8.repo Normal file
View File

@@ -0,0 +1,5 @@
[CyberPanel]
name=CyberPanel
baseurl=https://rep8.cyberpanel.net/
gpgkey=https://rep.cyberpanel.net/RPM-GPG-KEY-cyberpanel
gpgcheck=1

View File

@@ -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

View File

@@ -25,6 +25,9 @@ class FirewallUtilities:
@staticmethod
def addRule(proto,port):
print('Adding port: %s' % (port))
if port == "21":
command = "sudo firewall-cmd --add-service=ftp --permanent"
else:
@@ -56,6 +59,7 @@ class FirewallUtilities:
@staticmethod
def deleteRule(proto, port):
if port=="21":
command = "sudo firewall-cmd --remove-service=ftp --permanent"
else:

View File

@@ -15,7 +15,7 @@ from stat import *
import stat
VERSION = '2.0'
BUILD = 0
BUILD = 1
char_set = {'small': 'abcdefghijklmnopqrstuvwxyz',
'nums': '0123456789',
@@ -304,10 +304,6 @@ class preFlightsChecks:
except BaseException as msg:
logging.InstallLog.writeToFile("[ERROR] setup_account_cyberpanel. " + str(msg))
def yum_update(self):
command = 'yum update -y'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
def installCyberPanelRepo(self):
self.stdOut("Install Cyberpanel repo")
@@ -333,60 +329,6 @@ class preFlightsChecks:
command = 'rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm'
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
def enableEPELRepo(self):
command = 'yum -y install epel-release'
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
def install_pip(self):
self.stdOut("Install pip")
if self.distro == ubuntu:
command = "apt-get -y install python-pip"
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
elif self.distro == centos:
command = "yum -y install python-pip"
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
def install_python_dev(self):
self.stdOut("Install python development environment")
if self.distro == centos:
command = "yum -y install python-devel"
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
elif self.distro == ubuntu:
command = "apt-get -y install python-dev"
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
def install_gcc(self):
self.stdOut("Install gcc")
if self.distro == centos:
command = "yum -y install gcc"
else:
command = "apt-get -y install gcc"
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
def install_python_setup_tools(self):
command = "yum -y install python-setuptools"
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
def install_python_mysql_library(self):
self.stdOut("Install MySQL python library")
if self.distro == centos:
command = "yum install mariadb-devel gcc python36u-devel -y"
else:
command = "apt-get -y install libmysqlclient-dev"
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
if self.distro == ubuntu:
command = "pip install MySQL-python"
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
def fix_selinux_issue(self):
try:
cmd = []
@@ -415,24 +357,11 @@ class preFlightsChecks:
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
def installGit(self):
if os.path.exists("/etc/lsb-release"):
command = 'apt -y install git'
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
else:
command = 'yum -y install http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
command = 'yum install git -y'
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
def download_install_CyberPanel(self, mysqlPassword, mysql):
##
os.chdir(self.path)
self.installGit()
os.chdir('/usr/local')
command = "git clone https://github.com/usmannasir/cyberpanel"
@@ -748,24 +677,8 @@ class preFlightsChecks:
def install_postfix_davecot(self):
self.stdOut("Install dovecot - first remove postfix")
if self.distro == centos:
path = '/etc/yum.repos.d/dovecot.repo'
content = """[dovecot-2.3-latest]
name=Dovecot 2.3 CentOS $releasever - $basearch
baseurl=http://repo.dovecot.org/ce-2.3-latest/centos/$releasever/RPMS/$basearch
gpgkey=https://repo.dovecot.org/DOVECOT-REPO-GPG
gpgcheck=1
enabled=1"""
writeToFile = open(path, 'w')
writeToFile.write(content)
writeToFile.close()
try:
if self.distro == centos:
command = 'yum -y install http://cyberpanel.sh/gf-release-latest.gf.el7.noarch.rpm'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
command = 'yum remove postfix -y'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
elif self.distro == ubuntu:
@@ -773,13 +686,12 @@ enabled=1"""
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
self.stdOut("Install dovecot - do the install")
if self.distro == centos:
command = 'yum install --enablerepo=gf-plus -y postfix3 postfix3-ldap postfix3-mysql postfix3-pcre'
command = 'yum install --enablerepo=CyberPanel -y postfix3 postfix3-ldap postfix3-mysql postfix3-pcre'
elif self.distro == cent8:
command = 'dnf install postfix postfix-mysql -y'
command = 'dnf --enablerepo=CyberPanel install postfix3 postfix3-mysql -y '
else:
command = 'apt-get -y debconf-utils'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
@@ -805,8 +717,10 @@ enabled=1"""
##
if self.distro == centos or self.distro == cent8:
command = 'yum -y install dovecot dovecot-mysql'
if self.distro == centos:
command = 'yum --enablerepo=CyberPanel -y install dovecot dovecot-mysql'
elif self.distro == cent8:
command = 'dnf --enablerepo=CyberPanel install dovecot23 dovecot23-mysql -y'
else:
command = 'apt-get -y install dovecot-mysql'
@@ -1330,8 +1244,6 @@ imap_folder_list_limit = 0
def installFirewalld(self):
if self.distro == cent8:
return 0
if self.distro == ubuntu:
self.removeUfw()
@@ -1346,7 +1258,7 @@ imap_folder_list_limit = 0
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
######
if self.distro == centos or self.distro == cent8:
if self.distro == centos:
# Not available in ubuntu
command = 'systemctl restart dbus'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
@@ -1416,7 +1328,25 @@ imap_folder_list_limit = 0
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
command = 'tar zxf lscp.tar.gz -C /usr/local/'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
###
lscpdPath = '/usr/local/lscp/bin/lscpd'
command = 'cp -f /usr/local/CyberCP/lscpd-0.2.5 /usr/local/lscp/bin/lscpd-0.2.5'
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
command = 'rm -f /usr/local/lscp/bin/lscpd'
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
command = 'mv /usr/local/lscp/bin/lscpd-0.2.5 /usr/local/lscp/bin/lscpd'
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
command = 'chmod 755 %s' % (lscpdPath)
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
##
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 /usr/local/lscp/conf/key.pem -out /usr/local/lscp/conf/cert.pem'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
@@ -1562,13 +1492,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)
@@ -1789,8 +1719,10 @@ imap_folder_list_limit = 0
def installOpenDKIM(self):
try:
if self.distro == centos or self.distro == cent8:
if self.distro == centos:
command = 'yum -y install opendkim'
elif self.distro == cent8:
command = 'dnf --enablerepo=CyberPanel install opendkim -y'
else:
command = 'apt-get -y install opendkim'
@@ -1919,60 +1851,6 @@ milter_default_action = accept
return res # Though probably not used
def setupVirtualEnv(self, distro):
try:
##
count = 0
if distro == ubuntu:
# You can't install all at once! So install one at a time.
preFlightsChecks.stdOut("Installing python prerequisites", 1)
preFlightsChecks.installOne('libcurl4-gnutls-dev')
preFlightsChecks.installOne('libgnutls-dev')
preFlightsChecks.installOne('libgcrypt20-dev')
preFlightsChecks.installOne('libattr1')
preFlightsChecks.installOne('libattr1-dev')
preFlightsChecks.installOne('liblzma-dev')
preFlightsChecks.installOne('libgpgme-dev')
preFlightsChecks.installOne('libmariadbclient-dev')
preFlightsChecks.installOne('libcurl4-gnutls-dev')
preFlightsChecks.installOne('libssl-dev')
preFlightsChecks.installOne('nghttp2')
preFlightsChecks.installOne('libnghttp2-dev')
preFlightsChecks.installOne('idn2')
preFlightsChecks.installOne('libidn2-dev')
preFlightsChecks.installOne('libidn2-0-dev')
preFlightsChecks.installOne('librtmp-dev')
preFlightsChecks.installOne('libpsl-dev')
preFlightsChecks.installOne('nettle-dev')
preFlightsChecks.installOne('libgnutls28-dev')
preFlightsChecks.installOne('libldap2-dev')
preFlightsChecks.installOne('libgssapi-krb5-2')
preFlightsChecks.installOne('libk5crypto3')
preFlightsChecks.installOne('libkrb5-dev')
preFlightsChecks.installOne('libcomerr2')
preFlightsChecks.installOne('libldap2-dev')
preFlightsChecks.installOne('python-gpg')
preFlightsChecks.installOne('python-gpgme')
else:
command = "yum install -y libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel"
preFlightsChecks.call(command, distro, command, command, 1, 1, os.EX_OSERR)
##
os.chdir(self.cwd)
command = "chmod +x venvsetup.sh"
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
command = "./venvsetup.sh"
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
except OSError as msg:
logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setupVirtualEnv]")
return 0
@staticmethod
def enableDisableDNS(state):
try:
@@ -2059,62 +1937,6 @@ milter_default_action = accept
except:
pass
@staticmethod
def p3(distro):
### Virtual Env 3
if distro == centos:
command = 'yum -y install python36 -y'
preFlightsChecks.call(command, distro, '[install python36]',
'install python36',
1, 0, os.EX_OSERR)
command = 'virtualenv -p python3 /usr/local/CyberPanel/p3'
preFlightsChecks.call(command, distro, '[install python36]',
'install python36',
1, 0, os.EX_OSERR)
env_path = '/usr/local/CyberPanel/p3'
subprocess.call(['virtualenv', env_path])
activate_this = os.path.join(env_path, 'bin', 'activate_this.py')
exec(compile(open(activate_this, "rb").read(), activate_this, 'exec'), dict(__file__=activate_this))
command = "pip3 install --ignore-installed -r %s" % ('/usr/local/CyberCP/WebTerminal/requirments.txt')
preFlightsChecks.call(command, distro, '[install python36]',
'install python36',
1, 0, os.EX_OSERR)
else:
command = 'apt install -y python3-pip'
preFlightsChecks.call(command, distro, '[install python36]',
'install python36',
1, 0, os.EX_OSERR)
command = 'apt install build-essential libssl-dev libffi-dev python3-dev -y'
preFlightsChecks.call(command, distro, '[install python36]',
'install python36',
1, 0, os.EX_OSERR)
command = 'apt install -y python3-venv'
preFlightsChecks.call(command, distro, '[install python36]',
'install python36',
1, 0, os.EX_OSERR)
command = 'virtualenv -p python3 /usr/local/CyberPanel/p3'
preFlightsChecks.call(command, distro, '[install python36]',
'install python36',
1, 0, os.EX_OSERR)
env_path = '/usr/local/CyberPanel/p3'
subprocess.call(['virtualenv', env_path])
activate_this = os.path.join(env_path, 'bin', 'activate_this.py')
exec(compile(open(activate_this, "rb").read(), activate_this, 'exec'), dict(__file__=activate_this))
command = "pip3 install --ignore-installed -r %s" % ('/usr/local/CyberCP/WebTerminal/requirments.txt')
preFlightsChecks.call(command, distro, '[install python36]',
'install python36',
1, 0, os.EX_OSERR)
def installRestic(self):
try:
@@ -2122,13 +1944,11 @@ milter_default_action = accept
if os.path.exists(CentOSPath):
command = 'yum install yum-utils -y'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
if self.distro == centos:
command = 'yum --enablerepo=CyberPanel install restic -y'
else:
command = 'dnf --enablerepo=CyberPanel install restic -y --nogpgcheck'
command = 'yum-config-manager --add-repo https://copr.fedorainfracloud.org/coprs/copart/restic/repo/epel-7/copart-restic-epel-7.repo'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
command = 'yum install restic -y'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
else:
command = 'apt-get update -y'
@@ -2137,10 +1957,6 @@ milter_default_action = accept
command = 'apt-get install restic -y'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
cronTab = '/etc/crontab'
data = open(cronTab, 'r').read()
except:
pass
@@ -2236,8 +2052,17 @@ vmail
command = 'systemctl enable redis'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
def disablePackegeUpdates(self):
if self.distro == centos:
mainConfFile = '/etc/yum.conf'
content = 'exclude=MariaDB-client MariaDB-common MariaDB-devel MariaDB-server MariaDB-shared ' \
'pdns pdns-backend-mysql dovecot dovecot-mysql postfix3 postfix3-ldap postfix3-mysql ' \
'postfix3-pcre restic opendkim libopendkim pure-ftpd ftp\n'
writeToFile = open(mainConfFile, 'a')
writeToFile.write(content)
writeToFile.close()
def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer')
@@ -2307,10 +2132,6 @@ def main():
checks.checkPythonVersion()
checks.setup_account_cyberpanel()
checks.installCyberPanelRepo()
#checks.install_gcc()
if distro == centos:
checks.install_python_setup_tools()
#checks.install_python_mysql_library()
import installCyberPanel
@@ -2348,7 +2169,6 @@ def main():
checks.setup_cron()
checks.installRestic()
checks.installAcme()
# checks.installdnsPython()
## Install and Configure OpenDKIM.
@@ -2390,6 +2210,7 @@ def main():
checks.enableDisableFTP('on', distro)
checks.installCLScripts()
#checks.disablePackegeUpdates()
logging.InstallLog.writeToFile("CyberPanel installation successfully completed!")

View File

@@ -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 = ""
@@ -165,16 +185,14 @@ class InstallCyberPanel:
if res != 0:
InstallCyberPanel.stdOut("Failed to install PHP on Ubuntu.", 1, 1)
elif self.distro == cent8 or self.distro == centos:
elif self.distro == centos:
command = 'yum -y groupinstall lsphp-all'
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
InstallCyberPanel.stdOut("LiteSpeed PHPs successfully installed!", 1)
## only php 71
if self.distro == centos or self.distro == cent8:
if self.distro == centos:
command = 'yum install lsphp71 lsphp71-json lsphp71-xmlrpc lsphp71-xml lsphp71-soap lsphp71-snmp ' \
'lsphp71-recode lsphp71-pspell lsphp71-process lsphp71-pgsql lsphp71-pear lsphp71-pdo lsphp71-opcache ' \
@@ -207,27 +225,9 @@ class InstallCyberPanel:
install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
def setup_mariadb_repo(self):
try:
if self.distro == ubuntu:
# Only needed if the repo is broken or we need the latest version.
# command = "apt-get -y install software-properties-common"
# command = "apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8"
# command = "add-apt-repository 'deb [arch=amd64] http://mirror.zol.co.zw/mariadb/repo/10.3/ubuntu bionic main'"
return
InstallCyberPanel.stdOut("Setting up MariaDB Repo..", 1)
os.chdir(self.cwd)
shutil.copy("mysql/MariaDB.repo","/etc/yum.repos.d/MariaDB.repo")
InstallCyberPanel.stdOut("MariaDB repo set!", 1)
except BaseException as msg:
logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [setup_mariadb_repo]")
return 0
if self.distro == cent8:
command = 'dnf install lsphp71* lsphp72* lsphp73* lsphp74* --exclude lsphp73-pecl-zip -y'
subprocess.call(command, shell=True)
def installMySQL(self, mysql):
@@ -235,8 +235,10 @@ class InstallCyberPanel:
if self.distro == ubuntu:
command = "apt-get -y install mariadb-server"
else:
command = 'yum -y install mariadb-server'
elif self.distro == centos:
command = 'yum --enablerepo=CyberPanel -y install mariadb-server'
elif self.distro == cent8:
command = 'dnf --enablerepo=CyberPanel -y install mariadb-server'
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
@@ -326,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()
@@ -351,21 +356,26 @@ 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)
else:
elif self.distro == centos:
command = "yum install -y pure-ftpd"
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
elif self.distro == cent8:
command = 'dnf --enablerepo=CyberPanel install pure-ftpd -y'
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
####### Install pureftpd to system startup
@@ -399,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)
@@ -463,6 +476,7 @@ class InstallCyberPanel:
command = 'echo "/etc/pure-ftpd/db/mysql.conf" > /etc/pure-ftpd/conf/MySQLConfigFile'
subprocess.call(command, shell=True)
command = 'ln -s /etc/pure-ftpd/conf/MySQLConfigFile /etc/pure-ftpd/auth/30mysql'
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
@@ -511,17 +525,12 @@ class InstallCyberPanel:
# ". This may need to be fixed manually as 'echo \"nameserver 8.8.8.8\"> "
# "/etc/resolv.conf'", 1, 1, os.EX_OSERR)
if self.distro == centos:
command = 'curl -o /etc/yum.repos.d/powerdns-auth-42.repo ' \
'https://repo.powerdns.com/repo-files/centos-auth-42.repo'
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
if self.distro == cent8:
command = 'dnf config-manager --set-enabled PowerTools'
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
command = 'curl -o /etc/yum.repos.d/powerdns-auth-master.repo https://repo.powerdns.com/repo-files/centos-auth-master.repo'
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
# if self.distro == cent8:
# command = 'dnf config-manager --set-enabled PowerTools'
# install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
#
# command = 'curl -o /etc/yum.repos.d/powerdns-auth-master.repo https://repo.powerdns.com/repo-files/centos-auth-master.repo'
# install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
if self.distro == ubuntu:
command = "DEBIAN_FRONTEND=noninteractive apt-get -y install pdns-server pdns-backend-mysql"
@@ -636,8 +645,6 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns
if ent == 0:
installer.fix_ols_configs()
installer.setup_mariadb_repo()
installer.installMySQL(mysql)
installer.changeMYSQLRootPassword()
#installer.changeMYSQLRootPasswordCyberPanel(mysql)

View File

@@ -18,7 +18,7 @@ MaxLoad 4
AntiWarez yes
Umask 133:022
MinUID 1000
UseFtpUsers no
#UseFtpUsers no
AllowUserFXP no
AllowAnonymousFXP no
ProhibitDotFilesWrite no

View File

@@ -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.

View File

@@ -3,28 +3,20 @@
# This file is distributed under the same license as the CyberPanel package.
# FIRST AUTHOR <unasir@litespeedtech.com>, 2017.
#
#: baseTemplate/templates/baseTemplate/index.html:219
#: baseTemplate/templates/baseTemplate/index.html:272
#: baseTemplate/templates/baseTemplate/index.html:279
#: baseTemplate/templates/baseTemplate/index.html:286
#: baseTemplate/templates/baseTemplate/index.html:293
#: baseTemplate/templates/baseTemplate/index.html:300
#: baseTemplate/templates/baseTemplate/index.html:307
#: emailMarketing/templates/emailMarketing/sendEmails.html:93
msgid ""
msgstr ""
"Project-Id-Version: CyberPanel\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-21 19:54+0500\n"
"PO-Revision-Date: 2019-08-14 18:39+0200\n"
"Last-Translator: \n"
"Language-Team: GERMAN <german@cyberpanel.ch>\n"
"PO-Revision-Date: 2020-05-26 08:47+0200\n"
"Last-Translator: Linunaut <linunaut@protonmail.com>\n"
"Language-Team: Linunaut <linunaut@protonmail.com>\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.2.3\n"
"X-Generator: Poedit 2.3.1\n"
#: CLManager/templates/CLManager/createPackage.html:3
msgid "Create Cloud Linux Package - CyberPanel"
@@ -110,12 +102,12 @@ msgstr "NPROC"
#: CLManager/templates/CLManager/createPackage.html:105
#: CLManager/templates/CLManager/listPackages.html:164
msgid "INODES soft"
msgstr "INODES weich"
msgstr "INODES soft"
#: CLManager/templates/CLManager/createPackage.html:113
#: CLManager/templates/CLManager/listPackages.html:175
msgid "INODES hard"
msgstr "INODES hart"
msgstr "INODES hard"
#: CLManager/templates/CLManager/listPackages.html:3
msgid "Manage CloudLinux Packages - CyberPanel"
@@ -328,7 +320,7 @@ msgstr "Italienisch"
#: CyberCP/settings.py:189
msgid "Deutsch"
msgstr ""
msgstr "Deutsch"
#: IncBackups/templates/IncBackups/backupSchedule.html:3
#: backup/templates/backup/backupSchedule.html:3
@@ -376,10 +368,8 @@ msgstr "Frequenz bestimmen"
#: IncBackups/templates/IncBackups/backupSchedule.html:54
#: IncBackups/templates/IncBackups/createBackup.html:56
#, fuzzy
#| msgid "Backup Management"
msgid "Backup Content"
msgstr "Sicherungsverwaltung"
msgstr "Backup-Inhalt"
#: IncBackups/templates/IncBackups/backupSchedule.html:98
#: IncBackups/templates/IncBackups/incrementalDestinations.html:72
@@ -398,6 +388,7 @@ msgstr "Suche Konten..."
#: IncBackups/templates/IncBackups/backupSchedule.html:124
msgid "Select sites to be included in this job"
msgstr ""
"Wähle die Webseiten aus, die in diesen Auftrag einbezogen werden sollen"
#: IncBackups/templates/IncBackups/backupSchedule.html:150
#: IncBackups/templates/IncBackups/createBackup.html:127
@@ -460,10 +451,8 @@ msgid "Delete"
msgstr "Löschen"
#: IncBackups/templates/IncBackups/createBackup.html:3
#, fuzzy
#| msgid "Cancel Backup"
msgid "Create Incremental Backup"
msgstr "Sicherung abbrechen"
msgstr "Erstellen einer inkrementellen Sicherung"
#: IncBackups/templates/IncBackups/createBackup.html:13
#: IncBackups/templates/IncBackups/createBackup.html:23
@@ -481,10 +470,10 @@ msgid "Backup Docs"
msgstr "Sicherung Docs"
#: IncBackups/templates/IncBackups/createBackup.html:17
#, fuzzy
#| msgid "This page can be used to Back up your websites"
msgid "This page can be used to create incremental backups for your websites."
msgstr "Diese Seite kann zum sichern der Webseite benutzt werden"
msgstr ""
"Diese Seite kann verwendet werden, um inkrementelle Sicherungen für deine "
"Webseiten zu erstellen."
#: IncBackups/templates/IncBackups/createBackup.html:33
#: IncBackups/templates/IncBackups/restoreRemoteBackups.html:35
@@ -538,13 +527,13 @@ msgstr "Job ID"
#: IncBackups/templates/IncBackups/createBackup.html:162
#: IncBackups/templates/IncBackups/restoreRemoteBackups.html:97
msgid "Snapshot ID"
msgstr ""
msgstr "Snapshot ID"
#: IncBackups/templates/IncBackups/createBackup.html:163
#: dns/templates/dns/addDeleteDNSRecords.html:327
#: pluginHolder/templates/pluginHolder/plugins.html:29
msgid "Type"
msgstr "Art"
msgstr "Typ"
#: IncBackups/templates/IncBackups/createBackup.html:165
#: websiteFunctions/templates/websiteFunctions/listCron.html:52
@@ -558,30 +547,22 @@ msgid "Set up Back up Destinations"
msgstr "Zielort der Sicherung"
#: IncBackups/templates/IncBackups/incrementalDestinations.html:14
#, fuzzy
#| msgid "Set up Back up Destinations"
msgid "Set up Incremental Back up Destinations"
msgstr "Zielort der Sicherung"
msgstr "Zielort der inkrementellen Sicherung"
#: IncBackups/templates/IncBackups/incrementalDestinations.html:20
#, fuzzy
#| msgid "On this page you can set up your Back up destinations. (SFTP)"
msgid "On this page you can set up your Back up destinations. (SFTP and AWS)"
msgstr ""
"Auf dieser Seite kannst du die Zielorte für deine Sicherungen definieren. "
"(SFTP)"
"(SFTP und AWS)"
#: IncBackups/templates/IncBackups/incrementalDestinations.html:26
#, fuzzy
#| msgid "Set up Back up Destinations"
msgid "Set up Back up Destinations."
msgstr "Zielort der Sicherung"
msgstr "Zielort der Sicherung definieren."
#: IncBackups/templates/IncBackups/incrementalDestinations.html:35
#, fuzzy
#| msgid "Select Template"
msgid "Select Type"
msgstr "Template auswählen"
msgstr "Typ auswählen"
#: IncBackups/templates/IncBackups/incrementalDestinations.html:47
#: backup/templates/backup/backupDestinations.html:30
@@ -635,30 +616,28 @@ msgstr "IP"
#: IncBackups/templates/IncBackups/incrementalDestinations.html:117
#: IncBackups/templates/IncBackups/incrementalDestinations.html:153
msgid "AWS_ACCESS_KEY_ID"
msgstr ""
msgstr "AWS_ACCESS_KEY_ID"
#: IncBackups/templates/IncBackups/incrementalDestinations.html:124
msgid "AWS_SECRET_ACCESS_KEY"
msgstr ""
msgstr "AWS_SECRET_ACCESS_KEY"
#: IncBackups/templates/IncBackups/restoreRemoteBackups.html:3
#: IncBackups/templates/IncBackups/restoreRemoteBackups.html:13
#, fuzzy
#| msgid "Cancel Backup"
msgid "Restore Remote Incremental Backups"
msgstr "Sicherung abbrechen"
msgstr "Wiederherstellen von inkrementellen Remotesicherungen"
#: IncBackups/templates/IncBackups/restoreRemoteBackups.html:19
#, fuzzy
#| msgid "This page can be used to Back up your websites"
msgid ""
"This page can be used to restore remote incremental backups for your "
"websites."
msgstr "Diese Seite kann zum sichern der Webseite benutzt werden"
msgstr ""
"Diese Seite kann verwendet werden, um inkrementelle Remotesicherungen für "
"deine Webseiten wiederherzustellen."
#: IncBackups/templates/IncBackups/restoreRemoteBackups.html:69
msgid "Fetch Restore Points"
msgstr ""
msgstr "Abrufen von Wiederherstellungspunkten"
#: IncBackups/templates/IncBackups/restoreRemoteBackups.html:99
#: emailMarketing/templates/emailMarketing/manageSMTPHosts.html:76
@@ -692,33 +671,31 @@ msgid "Actions"
msgstr "Aktionen"
#: WebTerminal/templates/WebTerminal/WebTerminal.html:3
#, fuzzy
#| msgid "Domains - CyberPanel"
msgid "Terminal - CyberPanel"
msgstr "Domains - CyberPanel"
msgstr "Terminal - CyberPanel"
#: WebTerminal/templates/WebTerminal/WebTerminal.html:16
#: baseTemplate/templates/baseTemplate/index.html:641
#: baseTemplate/templates/baseTemplate/index.html:650
msgid "Terminal"
msgstr ""
msgstr "Terminal"
#: WebTerminal/templates/WebTerminal/WebTerminal.html:18
msgid "Web Terminal Docs"
msgstr ""
msgstr "Web Terminal Docs"
#: WebTerminal/templates/WebTerminal/WebTerminal.html:19
msgid "Execute your terminal commands."
msgstr ""
msgstr "Führen deine Terminalbefehle aus."
#: WebTerminal/templates/WebTerminal/WebTerminal.html:26
#: baseTemplate/templates/baseTemplate/index.html:643
msgid "Web Terminal"
msgstr ""
msgstr "Web Terminal"
#: WebTerminal/templates/WebTerminal/WebTerminal.html:28
msgid "Reboot SSH Server"
msgstr ""
msgstr "SSH Server neu starten"
#: backup/templates/backup/backup.html:15
msgid "This page can be used to Back up your websites"
@@ -872,11 +849,13 @@ msgstr "Verbindung überprüfen"
#: backup/templates/backup/backupSchedule.html:54
msgid "Local Path"
msgstr ""
msgstr "Lokaler Pfad"
#: backup/templates/backup/backupSchedule.html:57
msgid "Local directory where backups will be moved after creation."
msgstr ""
"Lokales Verzeichnis, in dem Sicherungen nach der Erstellung verschoben "
"werden."
#: backup/templates/backup/backupSchedule.html:82
msgid "Cannot add schedule. Error message:"
@@ -1501,16 +1480,12 @@ msgid "Create Nameserver"
msgstr "Nameserver erstellen"
#: baseTemplate/templates/baseTemplate/index.html:488
#, fuzzy
#| msgid "Create Nameserver"
msgid "Configure Default Nameservers"
msgstr "Nameserver erstellen"
msgstr "Konfigurieren von Standardnameservern"
#: baseTemplate/templates/baseTemplate/index.html:488
#, fuzzy
#| msgid "Create Nameserver"
msgid "Config Default Nameservers"
msgstr "Nameserver erstellen"
msgstr "Konfiguriere Standardnameserver"
#: baseTemplate/templates/baseTemplate/index.html:491
#: dns/templates/dns/createDNSZone.html:12
@@ -1647,43 +1622,31 @@ msgstr "Zielorte hinzufügen/löschen"
#: baseTemplate/templates/baseTemplate/index.html:590
msgid "Incremental Back up - Beta"
msgstr ""
msgstr "Inkrementelles Sichern - Beta"
#: baseTemplate/templates/baseTemplate/index.html:592
#, fuzzy
#| msgid "Cancel Backup"
msgid "Incremental Back up"
msgstr "Sicherung abbrechen"
msgstr "Inkrementelles Sichern"
#: baseTemplate/templates/baseTemplate/index.html:598
#, fuzzy
#| msgid "Restore Back up"
msgid "Create/Restore Back up"
msgstr "Sicherung wiederherstellen"
msgstr "Sicherung erstellen/wiederherstellen"
#: baseTemplate/templates/baseTemplate/index.html:601
#, fuzzy
#| msgid "Add/Delete Destinations"
msgid "Add/Remove Destinations"
msgstr "Hinzufügen/Löschen von Zielorten"
#: baseTemplate/templates/baseTemplate/index.html:604
#, fuzzy
#| msgid "Schedule Back up"
msgid "Schedule Back ups"
msgstr "Sicherung planen"
#: baseTemplate/templates/baseTemplate/index.html:607
#, fuzzy
#| msgid "Transfer Websites from Remote Server - CyberPanel"
msgid "Restore from Remote Server"
msgstr "Webseiten vom Remote-Server übertragen - CybaerPanel"
msgstr "Wiederherstellen vom Remote-Server"
#: baseTemplate/templates/baseTemplate/index.html:607
#, fuzzy
#| msgid "Restore Website"
msgid "Restore from Remote"
msgstr "Webseite wiederherstellen"
msgstr "Wiederherstellen von Remote"
#: baseTemplate/templates/baseTemplate/index.html:624
#: manageSSL/templates/manageSSL/index.html:29
@@ -1725,7 +1688,7 @@ msgstr "NEU"
#: baseTemplate/templates/baseTemplate/index.html:650
msgid "Web Based Terminal"
msgstr ""
msgstr "Web Basiertes Terminal"
#: baseTemplate/templates/baseTemplate/index.html:657
#: baseTemplate/templates/baseTemplate/index.html:659
@@ -2408,16 +2371,12 @@ msgid "Record Successfully Added."
msgstr "Record erfolgreich hinzugefügt."
#: dns/templates/dns/configureDefaultNameServers.html:3
#, fuzzy
#| msgid "Create Nameserver - CyberPanel"
msgid "Configure Default Nameserver - CyberPanel"
msgstr "Nameserver erstellen - CyberPanel"
msgstr "Konfigurieren von Standardnameserver - CyberPanel"
#: dns/templates/dns/configureDefaultNameServers.html:12
#, fuzzy
#| msgid "Create Nameserver"
msgid "Configure Default Nameserver"
msgstr "Nameserver erstellen"
msgstr "Konfigurieren von Standardnameserver"
#: dns/templates/dns/configureDefaultNameServers.html:13
#: dns/templates/dns/createNameServer.html:13
@@ -2439,22 +2398,16 @@ msgid "First Nameserver"
msgstr "Erster Nameserver"
#: dns/templates/dns/configureDefaultNameServers.html:45
#, fuzzy
#| msgid "Second Nameserver (Back up)"
msgid "Second Nameserver"
msgstr "Zweiter Nameserver (ersatz)"
msgstr "Zweiter Nameserver"
#: dns/templates/dns/configureDefaultNameServers.html:52
#, fuzzy
#| msgid "First Nameserver"
msgid "Third Nameserver"
msgstr "Erster Nameserver"
msgstr "Dritter Nameserver"
#: dns/templates/dns/configureDefaultNameServers.html:59
#, fuzzy
#| msgid "First Nameserver"
msgid "Forth Nameserver"
msgstr "Erster Nameserver"
msgstr "Vierter Nameserver"
#: dns/templates/dns/configureDefaultNameServers.html:68
#: emailMarketing/templates/emailMarketing/website.html:656
@@ -3759,10 +3712,8 @@ msgstr "SpamAssassin Konfigurationen erfolgreich gespeichert."
#: emailPremium/templates/emailPremium/emailLimits.html:13
#: emailPremium/templates/emailPremium/listDomains.html:14
#: emailPremium/templates/emailPremium/policyServer.html:13
#, fuzzy
#| msgid "Emai Limits Docs"
msgid "Email Limits Docs"
msgstr "E-Mai Limits Docs"
msgstr "E-Mail Limits Docs"
#: emailPremium/templates/emailPremium/emailLimits.html:14
msgid "View and change email limits for a domain name."
@@ -3832,7 +3783,7 @@ msgstr "Verwalten"
#: emailPremium/templates/emailPremium/emailPage.html:13
msgid "Emai Limits Docs"
msgstr "E-Mai Limits Docs"
msgstr "E-Mai Grenzwerte Docs"
#: emailPremium/templates/emailPremium/emailPage.html:14
msgid "View and change limits for an Email Address."
@@ -4789,10 +4740,8 @@ msgstr ""
"Mails."
#: mailServer/templates/mailServer/emailForwarding.html:61
#, fuzzy
#| msgid "Forwarding Docs"
msgid "Forwarding Options"
msgstr "Weiterleitung Docs"
msgstr "Weiterleitungsoptionen"
#: mailServer/templates/mailServer/emailForwarding.html:97
#: mailServer/templates/mailServer/emailForwarding.html:118
@@ -4801,7 +4750,7 @@ msgstr "Quelle"
#: mailServer/templates/mailServer/emailForwarding.html:101
msgid "or path to the program"
msgstr ""
msgstr "oder Pfad zum Programm"
#: mailServer/templates/mailServer/emailForwarding.html:106
msgid "Forward Email"
@@ -5442,10 +5391,8 @@ msgid "Switch to LiteSpeed Enterprise Web Server"
msgstr "Wechseln zu LiteSpeed Enterprise Web Server"
#: serverStatus/templates/serverStatus/litespeedStatus.html:149
#, fuzzy
#| msgid "LiteSpeed Processes"
msgid "LiteSpeed Serial No. (License Key)"
msgstr "LiteSpeed Prozesse"
msgstr "LiteSpeed Seriennummer (Lizenzschlüssel)"
#: serverStatus/templates/serverStatus/litespeedStatus.html:160
msgid "Switch"
@@ -5453,7 +5400,7 @@ msgstr "Wechseln"
#: serverStatus/templates/serverStatus/litespeedStatus.html:162
msgid "Get 15 Days Trial"
msgstr ""
msgstr "Erhalte eine 15 Tage Testversion"
#: serverStatus/templates/serverStatus/litespeedStatus.html:175
msgid ""
@@ -5461,6 +5408,9 @@ msgid ""
"CyberPanel will auto fetch 15 days trial key for you. Make sure this server "
"have not used trial already."
msgstr ""
"Hinweis: Wenn die 15 Tage Testversion ausgewählt wird, muss der Serial key "
"nicht eingegeben werden, CyberPanel ruft automatisch den 15-Tage-Testkey ab. "
"Stelle sicher, dass dieser Server noch keine Testversion verwendet hat."
#: serverStatus/templates/serverStatus/litespeedStatus.html:193
msgid "With great wisdom comes great responsibility."
@@ -5970,10 +5920,8 @@ msgstr "Webseiten Grenzwerte"
#: userManagment/templates/userManagment/createUser.html:107
#: userManagment/templates/userManagment/modifyUser.html:85
#, fuzzy
#| msgid "Security"
msgid "Security Level"
msgstr "Sicherheit"
msgstr "Sicherheitsstufe"
#: userManagment/templates/userManagment/createUser.html:120
#: userManagment/templates/userManagment/index.html:49
@@ -6309,38 +6257,32 @@ msgid "Installation successful. Visit:"
msgstr "Installation erfolgreich. Besuche:"
#: websiteFunctions/templates/websiteFunctions/installMagento.html:3
#, fuzzy
#| msgid "Install PrestaShop - CyberPanel"
msgid "Install Magento - CyberPanel"
msgstr "PrestaShop installieren - CyberPanel"
msgstr "Magento installieren - CyberPanel"
#: websiteFunctions/templates/websiteFunctions/installMagento.html:12
#: websiteFunctions/templates/websiteFunctions/launchChild.html:724
#: websiteFunctions/templates/websiteFunctions/launchChild.html:728
#: websiteFunctions/templates/websiteFunctions/website.html:1029
#: websiteFunctions/templates/websiteFunctions/website.html:1033
#, fuzzy
#| msgid "Install Packages"
msgid "Install Magento"
msgstr "Pakete installieren"
msgstr "Magento installieren"
#: websiteFunctions/templates/websiteFunctions/installMagento.html:13
#, fuzzy
#| msgid "One-click PrestaShop Install!"
msgid "One-click Magento Install!"
msgstr "1-Klick PrestaShop Installation!"
msgstr "1-Klick Magento Installation!"
#: websiteFunctions/templates/websiteFunctions/installMagento.html:51
#, fuzzy
#| msgid "Username"
msgid "Admin Username"
msgstr "用户名"
msgstr "Admin Benutzername"
#: websiteFunctions/templates/websiteFunctions/installMagento.html:93
msgid ""
"does not work on OpenLiteSpeed. It is highly recommended to use this "
"installer with LiteSpeed Enterprise only."
msgstr ""
"funktioniert nicht mit OpenLiteSpeed. Es wird dringend empfohlen, dieses "
"Installationsprogramm nur mit LiteSpeed Enterprise zu verwenden."
#: websiteFunctions/templates/websiteFunctions/installPrestaShop.html:3
msgid "Install PrestaShop - CyberPanel"
@@ -6387,7 +6329,7 @@ msgstr "WP + LSCache"
#: websiteFunctions/templates/websiteFunctions/launchChild.html:729
#: websiteFunctions/templates/websiteFunctions/website.html:1034
msgid "Magento"
msgstr ""
msgstr "Magento"
#: websiteFunctions/templates/websiteFunctions/listCron.html:3
msgid "Cron Management - CyberPanel"

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -204,6 +204,7 @@
<option>German</option>
<option>Greek</option>
<option>Italian</option>
<option>Indonesian</option>
<option>Japanese</option>
<option>Polish</option>
<option>Portuguese</option>

View File

@@ -19,7 +19,7 @@ from django.utils import translation
# Create your views here.
VERSION = '2.0'
BUILD = 0
BUILD = 1
def verifyLogin(request):
try:
@@ -69,6 +69,8 @@ def verifyLogin(request):
user_Language = "it"
elif data['languageSelection'] == "German":
user_Language = "de"
elif data['languageSelection'] == "Indonesian":
user_Language = "id"
translation.activate(user_Language)
response = HttpResponse()

BIN
lscpd-0.2.4 → lscpd-0.2.5 Normal file → Executable file

Binary file not shown.

View File

@@ -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"}

View File

@@ -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) {

View File

@@ -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 --->

View File

@@ -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

View File

@@ -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)

View File

@@ -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]

View File

@@ -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:

View File

@@ -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)

View File

@@ -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>

View File

@@ -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.")

View 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

View File

@@ -13,7 +13,7 @@ from packages.models import Package
from baseTemplate.models import version
VERSION = '2.0'
BUILD = 0
BUILD = 1
if not os.geteuid() == 0:
sys.exit("\nOnly root can run this script\n")

View File

@@ -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:
@@ -123,10 +169,10 @@ class ApplicationInstaller(multi.Thread):
command = 'mv %s /home/%s/public_html' % (path, domainName)
ProcessUtilities.executioner(command)
website = Websites.objects.get(domain=domainName)
from filemanager.filemanager import FileManager
command = 'chown %s:%s /home/%s/public_html' % (website.externalApp, website.externalApp, domainName)
ProcessUtilities.executioner(command)
fm = FileManager(None, None)
fm.fixPermissions(domainName)
statusFile = open(self.tempStatusPath, 'w')
statusFile.writelines('Successfully converted. [200]')
@@ -166,8 +212,6 @@ class ApplicationInstaller(multi.Thread):
command = 'apt -y install git'
ProcessUtilities.executioner(command)
else:
command = 'yum -y install http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm'
ProcessUtilities.executioner(command)
command = 'yum install git -y'
ProcessUtilities.executioner(command)
@@ -266,7 +310,7 @@ class ApplicationInstaller(multi.Thread):
statusFile.close()
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
self.permPath = '/home/%s/public_html' % (website.master.domain)
self.permPath = website.path
except:
website = Websites.objects.get(domain=domainName)
@@ -370,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'
@@ -442,7 +486,7 @@ class ApplicationInstaller(multi.Thread):
statusFile.close()
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
self.permPath = '/home/%s/public_html' % (website.master.domain)
self.permPath = website.path
except:
website = Websites.objects.get(domain=domainName)
@@ -546,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'
@@ -706,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'
@@ -732,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'
@@ -804,7 +848,7 @@ class ApplicationInstaller(multi.Thread):
statusFile.close()
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
self.permPath = '/home/%s/public_html' % (website.master.domain)
self.permPath = website.path
except:
website = Websites.objects.get(domain=domainName)
@@ -920,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'

View File

@@ -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,22 +163,29 @@ 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
def createBackup(virtualHost, ipAddress, backupLogPath , port):
def createBackup(virtualHost, ipAddress, backupLogPath , port='22', user='root'):
try:
backupSchedule.remoteBackupLogging(backupLogPath, "Preparing to create backup for: " + virtualHost)
@@ -152,7 +202,7 @@ class backupSchedule:
backupSchedule.remoteBackupLogging(backupLogPath, "Preparing to send backup for: " + virtualHost +" to " + ipAddress)
backupSchedule.sendBackup(backupPath+".tar.gz", ipAddress, backupLogPath, port)
backupSchedule.sendBackup(backupPath+".tar.gz", ipAddress, backupLogPath, port, user)
backupSchedule.remoteBackupLogging(backupLogPath, "Backup for: " + virtualHost + " is sent to " + ipAddress)
@@ -166,8 +216,11 @@ class backupSchedule:
backupSchedule.remoteBackupLogging(backupLogPath, "")
backupSchedule.remoteBackupLogging(backupLogPath, "")
return 1
else:
backupSchedule.remoteBackupLogging(backupLogPath, 'Remote backup creation failed for %s.' % (virtualHost) )
backupSchedule.remoteBackupLogging(backupLogPath, "")
backupSchedule.remoteBackupLogging(backupLogPath, "")
@@ -175,12 +228,13 @@ class backupSchedule:
backupSchedule.remoteBackupLogging(backupLogPath, "")
backupSchedule.remoteBackupLogging(backupLogPath, "")
return 0
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupSchedule.createBackup]")
@staticmethod
def sendBackup(backupPath, IPAddress, backupLogPath , port):
def sendBackup(backupPath, IPAddress, backupLogPath , port='22', user='root'):
try:
## IPAddress of local server
@@ -193,9 +247,12 @@ class backupSchedule:
##
writeToFile = open(backupLogPath, "a")
command = "sudo scp -o StrictHostKeyChecking=no -P "+port+" -i /root/.ssh/cyberpanel " + backupPath + " root@"+IPAddress+":/home/backup/" + ipAddressLocal + "/" + time.strftime("%a-%b") + "/"
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,9 +263,51 @@ class backupSchedule:
@staticmethod
def prepare():
try:
if os.path.exists(backupSchedule.runningPath):
pid = open(backupSchedule.runningPath, 'r').read()
output = ProcessUtilities.outputExecutioner('ps aux')
if output.find('/usr/local/CyberCP/plogical/backupSchedule.py') > -1 and output.find(pid) > -1:
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
else:
os.remove(backupSchedule.runningPath)
writeToFile = open(backupSchedule.runningPath, 'w')
writeToFile.write(str(os.getpid()))
writeToFile.close()
## IP of Remote server.
destinations = backupUtilities.destinationsPath
data = json.loads(open(destinations, 'r').read())
port = data['port']
try:
user = data['user']
except:
user = 'root'
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
backupLogPath = "/usr/local/lscp/logs/backup_log."+time.strftime("%m.%d.%Y_%H-%M-%S")
backupSchedule.remoteBackupLogging(backupLogPath,"#################################################")
backupSchedule.remoteBackupLogging(backupLogPath," Backup log for: " +time.strftime("%m.%d.%Y_%H-%M-%S"))
@@ -217,12 +316,6 @@ class backupSchedule:
backupSchedule.remoteBackupLogging(backupLogPath, "")
backupSchedule.remoteBackupLogging(backupLogPath, "")
## IP of Remote server.
data = open(destinations,'r').readlines()
ipAddress = data[0].strip("\n")
port = data[1].strip("\n")
## IPAddress of local server
ipFile = "/etc/cyberpanel/machineIP"
@@ -241,21 +334,28 @@ class backupSchedule:
"Connection to: " + ipAddress + " Failed, please resetup this destination from CyberPanel, aborting.")
return 0
else:
## Create backup dir on remote server
## Create backup dir on remote server in ~/backup
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel root@" + ipAddress + " mkdir -p /home/backup/" + ipAddressLocal + "/" + time.strftime(
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel " + user + "@" + ipAddress + " mkdir -p ~/backup/" + ipAddressLocal + "/" + time.strftime(
"%a-%b")
subprocess.call(shlex.split(command))
pass
for virtualHost in os.listdir("/home"):
if match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', virtualHost, M | I):
backupSchedule.createBackup(virtualHost, ipAddress, backupLogPath, port)
if backupSchedule.createBackup(virtualHost, ipAddress, backupLogPath, port, user):
jobSuccessSites = jobSuccessSites + 1
else:
jobFailedSites = jobFailedSites + 1
backupSchedule.backupLog.jobFailedSites = jobFailedSites
backupSchedule.backupLog.jobSuccessSites = jobSuccessSites
backupSchedule.backupLog.save()
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]")

View File

@@ -17,18 +17,40 @@ 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):
output = ProcessUtilities.outputExecutioner('ps aux')
pid = open(backupScheduleLocal.runningPath, 'r').read()
if output.find('/usr/local/CyberCP/plogical/backupScheduleLocal.py') > -1 and output.find(pid) > -1:
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
else:
os.remove(backupScheduleLocal.runningPath)
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 +65,11 @@ 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)
jobFailedSites = jobFailedSites + 1
continue
if os.path.exists(backupScheduleLocal.localBackupPath):
backupPath = retValues[1] + ".tar.gz"
localBackupPath = '%s/%s' % (open(backupScheduleLocal.localBackupPath, 'r').read().rstrip('/'), backupRunTime)
@@ -52,12 +79,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 +100,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]")

View File

@@ -1,6 +1,8 @@
import os,sys
import os, sys
sys.path.append('/usr/local/CyberCP')
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
try:
django.setup()
@@ -10,13 +12,14 @@ import pexpect
from plogical import CyberCPLogFileWriter as logging
import subprocess
import shlex
from shutil import make_archive,rmtree
from shutil import make_archive, rmtree
from plogical import mysqlUtilities
import tarfile
from multiprocessing import Process
import signal
from plogical.installUtilities import installUtilities
import argparse
try:
from plogical.virtualHostUtilities import virtualHostUtilities
from plogical.sslUtilities import sslUtilities
@@ -29,8 +32,10 @@ from xml.etree import ElementTree
from xml.dom import minidom
import time
from shutil import copy
from distutils.dir_util import copy_tree
from random import randint
from plogical.processUtilities import ProcessUtilities
try:
from websiteFunctions.models import Websites, ChildDomains, Backups
from databases.models import Databases
@@ -41,12 +46,16 @@ try:
except:
pass
VERSION = '2.0'
BUILD = 1
## I am not the monster that you think I am..
class backupUtilities:
Server_root = "/usr/local/lsws"
completeKeyPath = "/home/cyberpanel/.ssh"
completeKeyPath = "/home/cyberpanel/.ssh"
destinationsPath = "/home/cyberpanel/destinations"
licenseKey = '/usr/local/lsws/conf/license.key'
@@ -66,6 +75,12 @@ class backupUtilities:
metaFileXML = Element('metaFile')
child = SubElement(metaFileXML, 'VERSION')
child.text = VERSION
child = SubElement(metaFileXML, 'BUILD')
child.text = str(BUILD)
child = SubElement(metaFileXML, 'masterDomain')
child.text = backupDomain
@@ -180,11 +195,9 @@ class backupUtilities:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
'While creating backup for %s, we failed to backup database %s. Error message: %s' % (
backupDomain, items.dbName, str(msg)))
backupDomain, items.dbName, str(msg)))
continue
databaseXML = Element('database')
child = SubElement(databaseXML, 'dbName')
@@ -266,7 +279,6 @@ class backupUtilities:
## Email meta generated!
def prettify(elem):
"""Return a pretty-printed XML string for the Element.
"""
@@ -274,8 +286,6 @@ class backupUtilities:
reparsed = minidom.parseString(rough_string)
return reparsed.toprettyxml(indent=" ")
## /home/example.com/backup/backup-example.com-02.13.2018_10-24-52/meta.xml -- metaPath
metaPath = '/tmp/%s' % (str(randint(1000, 9999)))
@@ -288,22 +298,21 @@ class backupUtilities:
## meta generated
newBackup = Backups(website=website, fileName=backupName, date=time.strftime("%m.%d.%Y_%H-%M-%S"),
size=0, status=1)
newBackup.save()
logging.CyberCPLogFileWriter.statusWriter(status, 'Meta data is ready..')
return 1,'None', metaPath
return 1, 'None', metaPath
except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(status, "%s [207][5009]" % (str(msg)))
return 0,str(msg)
return 0, str(msg)
@staticmethod
def startBackup(tempStoragePath, backupName, backupPath, metaPath = None):
def startBackup(tempStoragePath, backupName, backupPath, metaPath=None):
try:
## /home/example.com/backup/backup-example.com-02.13.2018_10-24-52 -- tempStoragePath
@@ -317,12 +326,12 @@ class backupUtilities:
writeToFile.writelines(str(os.getpid()))
writeToFile.close()
backupFileNamePath = os.path.join(backupPath,"backupFileName")
backupFileNamePath = os.path.join(backupPath, "backupFileName")
logging.CyberCPLogFileWriter.statusWriter(backupFileNamePath, backupName)
#####
status = os.path.join(backupPath,'status')
status = os.path.join(backupPath, 'status')
logging.CyberCPLogFileWriter.statusWriter(status, "Making archive of home directory.\n")
@@ -330,7 +339,7 @@ class backupUtilities:
## /home/example.com/backup/backup-example.com-02.13.2018_10-24-52 -- tempStoragePath
metaPathInBackup = os.path.join(tempStoragePath,'meta.xml')
metaPathInBackup = os.path.join(tempStoragePath, 'meta.xml')
if metaPath != None:
writeToFile = open(metaPathInBackup, 'w')
@@ -339,7 +348,6 @@ class backupUtilities:
backupMetaData = ElementTree.parse(metaPathInBackup)
##### Making archive of home directory
domainName = backupMetaData.find('masterDomain').text
@@ -354,14 +362,20 @@ class backupUtilities:
## /home/example.com/backup/backup-example.com-02.13.2018_10-24-52 -- tempStoragePath
## shutil.make_archive
make_archive(os.path.join(tempStoragePath,"public_html"), 'gztar', os.path.join("/home",domainName,"public_html"))
## Stop making archive of document_root and copy instead
copy_tree('/home/%s/public_html' % domainName, '%s/%s' % (tempStoragePath, 'public_html'))
# make_archive(os.path.join(tempStoragePath,"public_html"), 'gztar', os.path.join("/home",domainName,"public_html"))
##
logging.CyberCPLogFileWriter.statusWriter(status, "Backing up databases..")
print('1,None')
except BaseException as msg:
try:
os.remove(os.path.join(backupPath,backupName+".tar.gz"))
os.remove(os.path.join(backupPath, backupName + ".tar.gz"))
except:
pass
@@ -371,8 +385,8 @@ class backupUtilities:
pass
status = os.path.join(backupPath, 'status')
logging.CyberCPLogFileWriter.statusWriter(status, "Aborted, "+ str(msg) + ".[365] [5009]")
print(("Aborted, "+ str(msg) + ".[365] [5009]"))
logging.CyberCPLogFileWriter.statusWriter(status, "Aborted, " + str(msg) + ".[365] [5009]")
print(("Aborted, " + str(msg) + ".[365] [5009]"))
os.remove(pidFile)
@@ -412,6 +426,7 @@ class backupUtilities:
for childDomain in childDomains:
actualChildDomain = childDomain.find('domain').text
childPath = childDomain.find('path').text
if os.path.exists(backupUtilities.licenseKey):
completPathToConf = backupUtilities.Server_root + '/conf/vhosts/' + actualChildDomain + '/vhost.conf'
@@ -433,6 +448,10 @@ class backupUtilities:
sslStoragePath)
except:
pass
if childPath.find('/home/%s/public_html' % domainName) == -1:
copy_tree(childPath, '%s/%s-docroot' % (tempStoragePath, actualChildDomain))
except BaseException as msg:
pass
@@ -440,7 +459,8 @@ class backupUtilities:
domainName = backupMetaData.find('masterDomain').text
if os.path.islink(status) or os.path.islink(tempStoragePath or os.path.islink(backupPath)) or os.path.islink(metaPath):
if os.path.islink(status) or os.path.islink(tempStoragePath or os.path.islink(backupPath)) or os.path.islink(
metaPath):
logging.CyberCPLogFileWriter.writeToFile('symlinked.')
logging.CyberCPLogFileWriter.statusWriter(status, 'Symlink attack. [365][5009]')
return 0
@@ -449,11 +469,10 @@ class backupUtilities:
logging.CyberCPLogFileWriter.statusWriter(status, "Backing up email accounts..\n")
try:
make_archive(os.path.join(tempStoragePath, domainName), 'gztar', os.path.join("/home", "vmail", domainName))
except BaseException as msg:
pass
emailPath = '/home/vmail/%s' % (domainName)
if os.path.exists(emailPath):
copy_tree(emailPath, '%s/vmail' % (tempStoragePath))
## shutil.make_archive. Creating final package.
@@ -461,37 +480,36 @@ class backupUtilities:
rmtree(tempStoragePath)
###
backupFileNamePath = os.path.join(backupPath,"backupFileName")
fileName = open(backupFileNamePath, 'r').read()
backupObs = Backups.objects.filter(fileName=fileName)
backupObs = Backups.objects.filter(fileName=backupName)
## adding backup data to database.
filePath = '%s/%s.tar.gz' % (backupPath, backupName)
totalSize = '%sMB' % (str(int(os.path.getsize(filePath) / 1048576)))
try:
for items in backupObs:
items.status = 1
items.size = str(int(float(
os.path.getsize(os.path.join(backupPath,backupName+".tar.gz"))) / (
1024.0 * 1024.0))) + "MB"
items.size = totalSize
items.save()
except:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile('%s. [backupRoot:499]' % str(msg))
for items in backupObs:
items.status = 1
items.size = str(int(float(
os.path.getsize(os.path.join(backupPath,backupName+".tar.gz"))) / (
1024.0 * 1024.0))) + "MB"
items.size = totalSize
items.save()
command = 'chmod 600 %s' % (os.path.join(backupPath,backupName+".tar.gz"))
command = 'chmod 600 %s' % (os.path.join(backupPath, backupName + ".tar.gz"))
ProcessUtilities.executioner(command)
logging.CyberCPLogFileWriter.statusWriter(status, "Completed\n")
os.remove(pidFile)
@staticmethod
def initiateBackup(tempStoragePath,backupName,backupPath):
def initiateBackup(tempStoragePath, backupName, backupPath):
try:
p = Process(target=backupUtilities.startBackup, args=(tempStoragePath,backupName,backupPath,))
p = Process(target=backupUtilities.startBackup, args=(tempStoragePath, backupName, backupPath,))
p.start()
pid = open(backupPath + 'pid', "w")
pid.write(str(p.pid))
@@ -560,14 +578,11 @@ class backupUtilities:
if Websites.objects.filter(domain=domain).count() > 0:
raise BaseException('This website already exists.')
if ChildDomains.objects.filter(domain=domain).count() > 0:
raise BaseException("This website already exists as child domain.")
####### Pre-creation checks ends
## Create Configurations
result = virtualHostUtilities.createVirtualHost(domain, siteUser.email, phpSelection, externalApp, 0, 1, 0,
@@ -602,7 +617,6 @@ class backupUtilities:
zone = DNS.getZoneObject(domain)
for dnsrecord in dnsrecords:
recordType = dnsrecord.find('type').text
value = dnsrecord.find('name').text
content = dnsrecord.find('content').text
@@ -610,8 +624,7 @@ class backupUtilities:
DNS.createDNSRecord(zone, value, recordType, content, prio, 3600)
return 1,'None'
return 1, 'None'
except BaseException as msg:
return 0, str(msg)
@@ -622,30 +635,28 @@ class backupUtilities:
if dir == "CyberPanelRestore":
backupFileName = backupName.strip(".tar.gz")
completPath = os.path.join("/home","backup",backupFileName) ## without extension
originalFile = os.path.join("/home","backup",backupName) ## with extension
completPath = os.path.join("/home", "backup", backupFileName) ## without extension
originalFile = os.path.join("/home", "backup", backupName) ## with extension
elif dir == 'CLI':
completPath = backupName.strip(".tar.gz") ## without extension
originalFile = backupName ## with extension
else:
backupFileName = backupName.strip(".tar.gz")
completPath = "/home/backup/transfer-"+str(dir)+"/"+backupFileName ## without extension
originalFile = "/home/backup/transfer-"+str(dir)+"/"+backupName ## with extension
completPath = "/home/backup/transfer-" + str(dir) + "/" + backupFileName ## without extension
originalFile = "/home/backup/transfer-" + str(dir) + "/" + backupName ## with extension
pathToCompressedHome = os.path.join(completPath,"public_html.tar.gz")
pathToCompressedHome = os.path.join(completPath, "public_html.tar.gz")
if not os.path.exists(completPath):
os.mkdir(completPath)
## Writing pid of restore process
pid = os.path.join(completPath,'pid')
pid = os.path.join(completPath, 'pid')
logging.CyberCPLogFileWriter.statusWriter(pid, str(os.getpid()))
status = os.path.join(completPath,'status')
status = os.path.join(completPath, 'status')
logging.CyberCPLogFileWriter.statusWriter(status, "Extracting Main Archive!")
## Converting /home/backup/backup-example.com-02.13.2018_10-24-52.tar.gz -> /home/backup/backup-example.com-02.13.2018_10-24-52
@@ -654,7 +665,6 @@ class backupUtilities:
tar.extractall(completPath)
tar.close()
logging.CyberCPLogFileWriter.statusWriter(status, "Creating Accounts,Databases and DNS records!")
########### Creating website and its dabases
@@ -663,6 +673,14 @@ class backupUtilities:
backupMetaData = ElementTree.parse(os.path.join(completPath, "meta.xml"))
masterDomain = backupMetaData.find('masterDomain').text
twoPointO = 0
try:
version = backupMetaData.find('VERSION').text
build = backupMetaData.find('BUILD').text
twoPointO = 1
except:
twoPointO = 0
result = backupUtilities.createWebsiteFromBackup(backupName, dir)
if result[0] == 1:
@@ -686,7 +704,8 @@ class backupUtilities:
logging.CyberCPLogFileWriter.writeToFile('%s. [555:startRestore]' % (str(msg)))
else:
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + result[1] + ". Not able to create Account, Databases and DNS Records, aborting. [575][5009]")
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + result[
1] + ". Not able to create Account, Databases and DNS Records, aborting. [575][5009]")
return 0
########### Creating child/sub/addon/parked domains
@@ -696,7 +715,7 @@ class backupUtilities:
## Reading meta file to create subdomains
externalApp = backupMetaData.find('externalApp').text
websiteHome = os.path.join("/home",masterDomain,"public_html")
websiteHome = os.path.join("/home", masterDomain, "public_html")
### Restoring Child Domains if any.
@@ -719,7 +738,8 @@ class backupUtilities:
phpSelection = childDomain.find('phpSelection').text
path = childDomain.find('path').text
retValues = virtualHostUtilities.createDomain(masterDomain, domain, phpSelection, path, 0, 0, 0, 'admin', 0)
retValues = virtualHostUtilities.createDomain(masterDomain, domain, phpSelection, path, 0, 0, 0,
'admin', 0)
if retValues[0] == 1:
if os.path.exists(websiteHome):
@@ -752,16 +772,22 @@ class backupUtilities:
except:
pass
except:
logging.CyberCPLogFileWriter.writeToFile('While restoring backup we had minor issues for rebuilding vhost conf for: ' + domain + '. However this will be auto healed.')
logging.CyberCPLogFileWriter.writeToFile(
'While restoring backup we had minor issues for rebuilding vhost conf for: ' + domain + '. However this will be auto healed.')
if float(version) > 2.0 or float(build) > 0:
if path.find('/home/%s/public_html' % masterDomain) == -1:
copy_tree('%s/%s-docroot' % (completPath, domain), path)
continue
else:
logging.CyberCPLogFileWriter.writeToFile('Error domain %s' % (domain))
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + retValues[1] + ". Not able to create child domains, aborting. [635][5009]")
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + retValues[
1] + ". Not able to create child domains, aborting. [635][5009]")
return 0
except BaseException as msg:
status = open(os.path.join(completPath,'status'), "w")
status.write("Error Message: " + str(msg) +". Not able to create child domains, aborting. [638][5009]")
status = open(os.path.join(completPath, 'status'), "w")
status.write("Error Message: " + str(msg) + ". Not able to create child domains, aborting. [638][5009]")
status.close()
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startRestore]")
return 0
@@ -791,9 +817,9 @@ class backupUtilities:
result = mailUtilities.createEmailAccount(masterDomain, username, password, 'restore')
if result[0] == 0:
raise BaseException(result[1])
except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + str(msg) +". Not able to create email accounts, aborting. [671][5009]")
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + str(
msg) + ". Not able to create email accounts, aborting. [671][5009]")
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startRestore]")
return 0
@@ -816,30 +842,46 @@ class backupUtilities:
logging.CyberCPLogFileWriter.statusWriter(status, "Extracting web home data!")
# /home/backup/backup-example.com-02.13.2018_10-24-52/public_html.tar.gz
## Moving above v2.0.0 extracting webhome data is not required, thus commenting below lines
tar = tarfile.open(pathToCompressedHome)
tar.extractall(websiteHome)
tar.close()
if not twoPointO:
tar = tarfile.open(pathToCompressedHome)
tar.extractall(websiteHome)
tar.close()
else:
if float(version) > 2.0 or float(build) > 0:
copy_tree('%s/public_html' % (completPath), websiteHome)
## extracting email accounts
logging.CyberCPLogFileWriter.statusWriter(status, "Extracting email accounts!")
try:
pathToCompressedEmails = os.path.join(completPath, masterDomain + ".tar.gz")
emailHome = os.path.join("/home","vmail",masterDomain)
if not twoPointO:
tar = tarfile.open(pathToCompressedEmails)
tar.extractall(emailHome)
tar.close()
try:
pathToCompressedEmails = os.path.join(completPath, masterDomain + ".tar.gz")
emailHome = os.path.join("/home", "vmail", masterDomain)
## Change permissions
tar = tarfile.open(pathToCompressedEmails)
tar.extractall(emailHome)
tar.close()
command = "chmod -r vmail:vmail " + emailHome
subprocess.call(shlex.split(command))
## Change permissions
except:
pass
command = "chown -R vmail:vmail " + emailHome
subprocess.call(shlex.split(command))
except:
pass
else:
emailsPath = '%s/vmail' % (completPath)
if os.path.exists(emailsPath):
copy_tree(emailsPath, '/home/vmail/%s' % (masterDomain))
command = "chown -R vmail:vmail /home/vmail/%s" % (masterDomain)
ProcessUtilities.executioner(command)
## emails extracted
@@ -852,18 +894,12 @@ class backupUtilities:
installUtilities.reStartLiteSpeed()
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
## Fix permissions
command = "chown -R " + externalApp + ":%s " % (groupName) + websiteHome
cmd = shlex.split(command)
subprocess.call(cmd)
from filemanager.filemanager import FileManager
command = 'chmod 750 %s' % (websiteHome)
cmd = shlex.split(command)
subprocess.call(cmd)
fm = FileManager(None, None)
fm.fixPermissions(masterDomain)
except BaseException as msg:
status = os.path.join(completPath, 'status')
@@ -871,7 +907,7 @@ class backupUtilities:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startRestore]")
@staticmethod
def initiateRestore(backupName,dir):
def initiateRestore(backupName, dir):
try:
p = Process(target=backupUtilities.startRestore, args=(backupName, dir,))
p.start()
@@ -879,7 +915,7 @@ class backupUtilities:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateRestore]")
@staticmethod
def sendKey(IPAddress, password,port):
def sendKey(IPAddress, password, port='22', user='root'):
try:
expectation = []
@@ -888,9 +924,17 @@ class backupUtilities:
expectation.append("Permission denied")
expectation.append("100%")
command = "scp -o StrictHostKeyChecking=no -P "+ port +" /root/.ssh/cyberpanel.pub root@" + IPAddress + ":/root/.ssh/authorized_keys"
## 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)
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(command)
index = setupKeys.expect(expectation)
## on first login attempt send password
@@ -910,20 +954,37 @@ 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]"]
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]"]
@staticmethod
def setupSSHKeys(IPAddress, password,port):
def setupSSHKeys(IPAddress, password, port='22', user='root'):
try:
## Checking for host verification
@@ -933,7 +994,7 @@ class backupUtilities:
pass
else:
logging.CyberCPLogFileWriter.writeToFile("Host is Down.")
#return [0,"Host is Down."]
# return [0,"Host is Down."]
expectation = []
expectation.append("password:")
@@ -941,9 +1002,12 @@ class backupUtilities:
expectation.append("Permission denied")
expectation.append("File exists")
command = "ssh -o StrictHostKeyChecking=no -p "+ port +" root@"+IPAddress+' "mkdir /root/.ssh || rm -f /root/.ssh/temp && rm -f /root/.ssh/authorized_temp && cp /root/.ssh/authorized_keys /root/.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):
logging.CyberCPLogFileWriter.writeToFile(command)
index = setupKeys.expect(expectation)
## on first login attempt send password
@@ -969,18 +1033,18 @@ class backupUtilities:
index = setupKeys.expect(expectation)
if index == 0:
return [0,"Wrong Password!"]
return [0, "Wrong Password!"]
elif index == 1:
return [0, "Wrong Password!"]
elif index == 2:
setupKeys.wait()
sendKey = backupUtilities.sendKey(IPAddress, password, port)
sendKey = backupUtilities.sendKey(IPAddress, password, port, user)
if sendKey[0] == 1:
return [1, "None"]
else:
return [0,sendKey[1]]
return [0, sendKey[1]]
except pexpect.TIMEOUT as msg:
@@ -999,13 +1063,15 @@ class backupUtilities:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[checkIfHostIsUp]")
@staticmethod
def checkConnection(IPAddress):
def checkConnection(IPAddress, port='22', user='root'):
try:
try:
import json
destinations = backupUtilities.destinationsPath
data = open(destinations, 'r').readlines()
port = data[1].strip("\n")
data = json.loads(open(destinations, 'r').read())
port = data['port']
user = data['user']
except:
port = "22"
@@ -1016,13 +1082,19 @@ class backupUtilities:
expectation.append(pexpect.EOF)
expectation.append(pexpect.TIMEOUT)
checkConn = pexpect.spawn("sudo ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no -p "+ port+" root@"+IPAddress, timeout=3)
command = "sudo ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no -p " + port + ' ' + user + "@" + IPAddress
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(command)
checkConn = pexpect.spawn(command,timeout=3)
index = checkConn.expect(expectation)
if index == 0:
subprocess.call(['kill', str(checkConn.pid)])
logging.CyberCPLogFileWriter.writeToFile("Remote Server is not able to authenticate for transfer to initiate, IP Address:" + IPAddress)
return [0,"Remote Server is not able to authenticate for transfer to initiate."]
logging.CyberCPLogFileWriter.writeToFile(
"Remote Server is not able to authenticate for transfer to initiate, IP Address:" + IPAddress)
return [0, "Remote Server is not able to authenticate for transfer to initiate."]
elif index == 1:
subprocess.call(['kill', str(checkConn.pid)])
logging.CyberCPLogFileWriter.writeToFile(
@@ -1039,28 +1111,28 @@ class backupUtilities:
return [1, "None"]
except pexpect.TIMEOUT as msg:
logging.CyberCPLogFileWriter.writeToFile("Timeout "+IPAddress+ " [checkConnection]")
logging.CyberCPLogFileWriter.writeToFile("Timeout " + IPAddress + " [checkConnection]")
return [0, "371 Timeout while making connection to this server [checkConnection]"]
except pexpect.EOF as msg:
logging.CyberCPLogFileWriter.writeToFile("EOF "+IPAddress+ "[checkConnection]")
logging.CyberCPLogFileWriter.writeToFile("EOF " + IPAddress + "[checkConnection]")
return [0, "374 Remote Server is not able to authenticate for transfer to initiate. [checkConnection]"]
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg)+" " +IPAddress+ " [checkConnection]")
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " " + IPAddress + " [checkConnection]")
return [0, "377 Remote Server is not able to authenticate for transfer to initiate. [checkConnection]"]
@staticmethod
def verifyHostKey(IPAddress):
def verifyHostKey(IPAddress, port='22', user='root'):
try:
backupUtilities.host_key_verification(IPAddress)
password = "hello" ## dumb password, not used anywhere.
password = "hello" ## dumb password, not used anywhere.
expectation = []
expectation.append("continue connecting (yes/no)?")
expectation.append("password:")
setupSSHKeys = pexpect.spawn("ssh cyberpanel@" + IPAddress, timeout=3)
setupSSHKeys = pexpect.spawn("ssh -p " + port + user + "@" + IPAddress, timeout=3)
index = setupSSHKeys.expect(expectation)
@@ -1075,7 +1147,6 @@ class backupUtilities:
expectation.append("password:")
expectation.append(pexpect.EOF)
innerIndex = setupSSHKeys.expect(expectation)
if innerIndex == 0:
@@ -1107,25 +1178,38 @@ class backupUtilities:
except pexpect.TIMEOUT as msg:
logging.CyberCPLogFileWriter.writeToFile("Timeout [verifyHostKey]")
return [0,"Timeout [verifyHostKey]"]
return [0, "Timeout [verifyHostKey]"]
except pexpect.EOF as msg:
logging.CyberCPLogFileWriter.writeToFile("EOF [verifyHostKey]")
return [0,"EOF [verifyHostKey]"]
return [0, "EOF [verifyHostKey]"]
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [verifyHostKey]")
return [0,str(msg)+" [verifyHostKey]"]
return [0, str(msg) + " [verifyHostKey]"]
@staticmethod
def createBackupDir(IPAddress,port):
def createBackupDir(IPAddress, port='22', user='root'):
try:
command = "sudo ssh -o StrictHostKeyChecking=no -p "+ port +" -i /root/.ssh/cyberpanel root@"+IPAddress+" mkdir /home/backup"
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel " + user + "@" + IPAddress + " mkdir ~/backup"
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(command)
subprocess.call(shlex.split(command))
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel root@" + IPAddress + ' "cat /root/.ssh/authorized_keys /root/.ssh/temp > /root/.ssh/authorized_temp"'
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel " + user + "@" + IPAddress + ' "cat ~/.ssh/authorized_keys ~/.ssh/temp > ~/.ssh/authorized_temp"'
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(command)
subprocess.call(shlex.split(command))
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel root@" + IPAddress + ' "cat /root/.ssh/authorized_temp > /root/.ssh/authorized_keys"'
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):
logging.CyberCPLogFileWriter.writeToFile(command)
subprocess.call(shlex.split(command))
except BaseException as msg:
@@ -1230,10 +1314,8 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
writeToFile.close()
return 0
result = backupUtilities.prepareBackupMeta(backupDomain, backupName, tempStoragePath, backupPath)
if result[0] == 0:
writeToFile = open(schedulerPath, 'w')
writeToFile.writelines('error')
@@ -1246,7 +1328,8 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
execPath = "sudo nice -n 10 /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
execPath = execPath + " startBackup --tempStoragePath " + tempStoragePath + " --backupName " \
+ backupName + " --backupPath " + backupPath + ' --backupDomain ' + backupDomain + ' --metaPath %s' % (result[2])
+ backupName + " --backupPath " + backupPath + ' --backupDomain ' + backupDomain + ' --metaPath %s' % (
result[2])
output = ProcessUtilities.outputExecutioner(execPath, website.externalApp)
if output.find('[5009') > -1:
@@ -1283,7 +1366,7 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
execPath = "sudo nice -n 10 /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
execPath = execPath + " BackupRoot --tempStoragePath " + tempStoragePath + " --backupName " \
+ backupName + " --backupPath " + backupPath + ' --backupDomain ' + backupDomain + ' --metaPath %s' % (
result[2])
result[2])
ProcessUtilities.executioner(execPath, 'root')
else:
@@ -1299,7 +1382,8 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [submitBackupCreation]")
def cancelBackupCreation(backupCancellationDomain,fileName):
def cancelBackupCreation(backupCancellationDomain, fileName):
try:
path = "/home/" + backupCancellationDomain + "/backup/pid"
@@ -1331,9 +1415,10 @@ def cancelBackupCreation(backupCancellationDomain,fileName):
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [cancelBackupCreation]")
print("0,"+str(msg))
print("0," + str(msg))
def submitRestore(backupFile,dir):
def submitRestore(backupFile, dir):
try:
p = Process(target=backupUtilities.startRestore, args=(backupFile, dir,))
@@ -1344,13 +1429,14 @@ def submitRestore(backupFile,dir):
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [cancelBackupCreation]")
print("0,"+str(msg))
print("0," + str(msg))
def submitDestinationCreation(ipAddress, password, port):
setupKeys = backupUtilities.setupSSHKeys(ipAddress, password, port)
def submitDestinationCreation(ipAddress, password, port='22', user='root'):
setupKeys = backupUtilities.setupSSHKeys(ipAddress, password, port, user)
if setupKeys[0] == 1:
backupUtilities.createBackupDir(ipAddress, port)
backupUtilities.createBackupDir(ipAddress, port, user)
print("1,None")
else:
print(setupKeys[1])
@@ -1368,8 +1454,8 @@ def getConnectionStatus(ipAddress):
except BaseException as msg:
print(str(msg))
def main():
def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer')
parser.add_argument('function', help='Specific a function to call!')
parser.add_argument('--tempStoragePath', help='')
@@ -1383,6 +1469,7 @@ def main():
parser.add_argument('--ipAddress', help='')
parser.add_argument('--password', help='')
parser.add_argument('--port', help='')
parser.add_argument('--user', help='')
## backup cancellation arguments
@@ -1394,19 +1481,16 @@ def main():
parser.add_argument('--backupFile', help='')
parser.add_argument('--dir', help='')
args = parser.parse_args()
if args.function == "submitBackupCreation":
submitBackupCreation(args.tempStoragePath,args.backupName,args.backupPath, args.backupDomain)
submitBackupCreation(args.tempStoragePath, args.backupName, args.backupPath, args.backupDomain)
elif args.function == "cancelBackupCreation":
cancelBackupCreation(args.backupCancellationDomain,args.fileName)
cancelBackupCreation(args.backupCancellationDomain, args.fileName)
elif args.function == "submitRestore":
submitRestore(args.backupFile,args.dir)
submitRestore(args.backupFile, args.dir)
elif args.function == "submitDestinationCreation":
submitDestinationCreation(args.ipAddress, args.password, args.port)
submitDestinationCreation(args.ipAddress, args.password, args.port, args.user)
elif args.function == "getConnectionStatus":
getConnectionStatus(args.ipAddress)
elif args.function == "startBackup":
@@ -1414,5 +1498,6 @@ def main():
elif args.function == "BackupRoot":
backupUtilities.BackupRoot(args.tempStoragePath, args.backupName, args.backupPath, args.metaPath)
if __name__ == "__main__":
main()
main()

View File

@@ -715,23 +715,9 @@ class cPanelImporter:
return 0
def FixPermissions(self):
externalApp = self.externalApp
command = "sudo chown -R " + externalApp + ":" + externalApp + " /home/" + self.mainDomain
ProcessUtilities.normalExecutioner(command)
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
groupName = 'nobody'
else:
groupName = 'nogroup'
command = "sudo chown -R root:%s /home/" % (groupName) + self.mainDomain + "/logs"
ProcessUtilities.normalExecutioner(command)
command = "sudo find %s -type d -exec chmod 0755 {} \;" % ("/home/" + self.mainDomain + "/public_html")
ProcessUtilities.normalExecutioner(command)
command = "sudo find %s -type f -exec chmod 0644 {} \;" % ("/home/" + self.mainDomain + "/public_html")
ProcessUtilities.normalExecutioner(command)
from filemanager.filemanager import FileManager
fm = FileManager(None, None)
fm.fixPermissions(self.mainDomain)
def MainController(self):

View File

@@ -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)

View File

@@ -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')

View File

@@ -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)

View File

@@ -1,40 +0,0 @@
from plogical import CyberCPLogFileWriter as logging
import argparse
from random import randint
class filemanager:
@staticmethod
def createTemporaryFile(domainName):
try:
path = "/home/" + domainName + "/..filemanagerkey"
fileKey = str(randint(1000, 9999))
filemanager = open(path,'w')
filemanager.write(fileKey)
filemanager.close()
print(fileKey)
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [createTemporaryFile]")
print("0," + str(msg))
def main():
parser = argparse.ArgumentParser(description='CyberPanel Filemanager')
parser.add_argument('function', help='Specific a function to call!')
parser.add_argument('--domainName', help='Domain name!')
args = parser.parse_args()
if args.function == "createTemporaryFile":
filemanager.createTemporaryFile(args.domainName)
if __name__ == "__main__":
main()

View File

@@ -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

View File

@@ -30,6 +30,7 @@ class mailUtilities:
installLogPath = "/home/cyberpanel/openDKIMInstallLog"
spamassassinInstallLogPath = "/home/cyberpanel/spamassassinInstallLogPath"
cyberPanelHome = "/home/cyberpanel"
mailScannerInstallLogPath = "/home/cyberpanel/mailScannerInstallLogPath"
@staticmethod
def SendEmail(sender, receivers, message):
@@ -214,41 +215,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 +256,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 +265,7 @@ class mailUtilities:
## Trusted hosts
trustedHosts = "/etc/opendkim/TrustedHosts"
configToWrite = virtualHostName + "\n"
configToWrite = actualDomain + "\n"
writeToFile = open(trustedHosts, 'a')
writeToFile.write(configToWrite)
@@ -451,7 +450,10 @@ milter_default_action = accept
def installSpamAssassin(install, SpamAssassin):
try:
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
if os.path.exists(mailUtilities.spamassassinInstallLogPath):
os.remove(mailUtilities.spamassassinInstallLogPath)
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'
@@ -479,6 +481,51 @@ milter_default_action = accept
writeToFile.close()
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installSpamAssassin]")
@staticmethod
def installMailScanner(install, SpamAssassin):
try:
if os.path.exists(mailUtilities.mailScannerInstallLogPath):
os.remove(mailUtilities.mailScannerInstallLogPath)
if mailUtilities.checkIfSpamAssassinInstalled():
command = 'chmod +x /usr/local/CyberCP/CPScripts/mailscannerinstaller.sh'
ProcessUtilities.executioner(command)
command = '/usr/local/CyberCP/CPScripts/mailscannerinstaller.sh'
cmd = shlex.split(command)
with open(mailUtilities.mailScannerInstallLogPath, 'w') as f:
res = subprocess.call(cmd, stdout=f, shell=True)
if res == 1:
writeToFile = open(mailUtilities.mailScannerInstallLogPath, 'a')
writeToFile.writelines("Can not be installed.[404]\n")
writeToFile.close()
logging.CyberCPLogFileWriter.writeToFile("[Could not Install MailScanner.]")
return 0
else:
writeToFile = open(mailUtilities.mailScannerInstallLogPath, 'a')
writeToFile.writelines("MailScanner Installed.[200]\n")
writeToFile.close()
return 1
else:
writeToFile = open(mailUtilities.mailScannerInstallLogPath, 'a')
writeToFile.writelines("Please install SpamAssassin from CyberPanel before installing MailScanner.[404]\n")
writeToFile.close()
except BaseException as msg:
writeToFile = open(mailUtilities.mailScannerInstallLogPath, 'a')
writeToFile.writelines("Can not be installed.[404]\n")
writeToFile.close()
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installSpamAssassin]")
@staticmethod
def checkIfSpamAssassinInstalled():
try:
@@ -502,7 +549,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()
@@ -668,6 +715,22 @@ milter_default_action = accept
str(msg) + " [savePolicyServerStatus]")
print("0," + str(msg))
@staticmethod
def checkIfMailScannerInstalled():
try:
path = "/usr/local/CyberCP/public/mailwatch"
if os .path.exists(path):
return 1
else:
return 0
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [checkIfMailScannerInstalled]")
return 0
def main():
@@ -697,6 +760,8 @@ def main():
mailUtilities.savePolicyServerStatus(args.install)
elif args.function == 'installSpamAssassin':
mailUtilities.installSpamAssassin("install", "SpamAssassin")
elif args.function == 'installMailScanner':
mailUtilities.installMailScanner("install", "installMailScanner")
elif args.function == 'AfterEffects':
mailUtilities.AfterEffects(args.domain)

View File

@@ -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'

View File

@@ -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'

View File

@@ -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]

View File

@@ -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,7 +193,6 @@ class ProcessUtilities(multi.Thread):
sock = ret[0]
if user == None:
if command.find('export') > -1:
pass
elif command.find('sudo') == -1:
@@ -268,12 +270,17 @@ class ProcessUtilities(multi.Thread):
def customPoen(self):
try:
if type(self.extraArgs['command']) == str or type(self.extraArgs['command']) == bytes:
command = self.extraArgs['command']
else:
command = " ".join(self.extraArgs['command'])
ProcessUtilities.sendCommand(command, self.extraArgs['user'])
if getpass.getuser() == 'root':
subprocess.call(command, shell=True)
else:
ProcessUtilities.sendCommand(command, self.extraArgs['user'])
return 1
except BaseException as msg:

View File

@@ -14,11 +14,13 @@ import random
import string
VERSION = '2.0'
BUILD = 0
BUILD = 1
class Upgrade:
logPath = "/usr/local/lscp/logs/upgradeLog"
cdn = 'cdn.cyberpanel.sh'
installedOutput = ''
CentOSPath = '/etc/redhat-release'
@staticmethod
def stdOut(message, do_exit=0):
@@ -123,7 +125,6 @@ class Upgrade:
except BaseException as msg:
Upgrade.stdOut(str(msg) + " [mountTemp]", 0)
@staticmethod
def dockerUsers():
### Docker User/group
@@ -408,25 +409,6 @@ class Upgrade:
Upgrade.stdOut(str(msg) + ' [downloadLink]')
os._exit(0)
@staticmethod
def fileManager():
## Copy File manager files
command = "rm -rf /usr/local/lsws/Example/html/FileManager"
Upgrade.executioner(command, 'Remove old Filemanager', 0)
if os.path.exists('/usr/local/lsws/bin/openlitespeed'):
command = "mv /usr/local/CyberCP/install/FileManager /usr/local/lsws/Example/html"
Upgrade.executioner(command, 'Setup new Filemanager', 0)
else:
command = "mv /usr/local/CyberCP/install/FileManager /usr/local/lsws"
Upgrade.executioner(command, 'Setup new Filemanager', 0)
##
command = "chmod -R 777 /usr/local/lsws/Example/html/FileManager"
Upgrade.executioner(command, 'Filemanager permissions change', 0)
@staticmethod
def setupCLI():
try:
@@ -597,6 +579,11 @@ class Upgrade:
except:
pass
try:
cursor.execute("ALTER TABLE websiteFunctions_backups MODIFY fileName varchar(200)")
except:
pass
try:
cursor.execute("ALTER TABLE loginSystem_acl ADD COLUMN listUsers INT DEFAULT 0;")
@@ -1246,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
query = """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:
@@ -1275,232 +1293,122 @@ class Upgrade:
except:
pass
@staticmethod
def installGit():
try:
if os.path.exists("/etc/lsb-release"):
command = 'apt -y install git'
Upgrade.executioner(command, 'installGit', 0)
else:
command = 'sudo yum -y install http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm'
Upgrade.executioner(command, 'installGit', 0)
command = 'sudo yum install git -y'
Upgrade.executioner(command, 'installGit', 0)
except BaseException as msg:
pass
@staticmethod
def downloadAndUpgrade(versionNumbring, branch):
try:
## Download latest version.
Upgrade.installGit()
## Backup settings file.
Upgrade.stdOut("Backing up settings file.")
shutil.copy("/usr/local/CyberCP/CyberCP/settings.py", "/usr/local/settings.py")
## CyberPanel DB Creds
dbName = settings.DATABASES['default']['NAME']
dbUser = settings.DATABASES['default']['USER']
password = settings.DATABASES['default']['PASSWORD']
## Root DB Creds
rootdbName = settings.DATABASES['rootdb']['NAME']
rootdbdbUser = settings.DATABASES['rootdb']['USER']
rootdbpassword = settings.DATABASES['rootdb']['PASSWORD']
## Complete db string
completDBString = """\nDATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '%s',
'USER': '%s',
'PASSWORD': '%s',
'HOST': 'localhost',
'PORT':''
},
'rootdb': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '%s',
'USER': '%s',
'PASSWORD': '%s',
'HOST': 'localhost',
'PORT': '',
},
}\n""" % (dbName, dbUser, password, rootdbName, rootdbdbUser, rootdbpassword)
settingsFile = '/usr/local/CyberCP/CyberCP/settings.py'
Upgrade.stdOut("Settings file backed up.")
## Extract Latest files
## Check git branch status
os.chdir('/usr/local')
os.chdir('/usr/local/CyberCP')
if os.path.exists('cyberpanel'):
shutil.rmtree('cyberpanel')
command = 'git config --global user.email "support@cyberpanel.met"'
Upgrade.executioner(command, command, 1)
### check if imunify exists
command = 'git config --global user.name "CyberPanel"'
Upgrade.executioner(command, command, 1)
imunifyPublic = '/usr/local/CyberCP/public/imunify'
imunifyPublicBackup = '/usr/local'
command = 'git status'
currentBranch = subprocess.check_output(shlex.split(command)).decode()
try:
if currentBranch.find('On branch %s' % (branch)) > -1:
if os.path.exists(imunifyPublic):
shutil.move(imunifyPublic, imunifyPublicBackup)
command = 'git stash'
Upgrade.executioner(command, command, 1)
except:
pass
command = 'git pull'
Upgrade.executioner(command, command, 1)
if os.path.exists('CyberCP'):
shutil.rmtree('CyberCP')
elif currentBranch.find('not a git repository') > -1:
command = 'git clone https://github.com/usmannasir/cyberpanel'
Upgrade.executioner(command, 'Download CyberPanel', 1)
os.chdir('/usr/local')
shutil.move('cyberpanel', 'CyberCP')
command = 'git clone https://github.com/usmannasir/cyberpanel'
Upgrade.executioner(command, 'Download CyberPanel', 1)
if os.path.exists('CyberCP'):
shutil.rmtree('CyberCP')
shutil.move('cyberpanel', 'CyberCP')
else:
command = 'git fetch'
Upgrade.executioner(command, command, 1)
command = 'git stash'
Upgrade.executioner(command, command, 1)
if branch != 'stable':
os.chdir('CyberCP')
command = 'git checkout %s' % (branch)
Upgrade.executioner(command, command, 1)
os.chdir('/usr/local')
command = 'git pull'
Upgrade.executioner(command, command, 1)
## Copy settings file
data = open("/usr/local/settings.py", 'r').readlines()
settingsData = open(settingsFile, 'r').readlines()
csrfCheck = 1
for items in data:
if items.find('CsrfViewMiddleware') > -1:
csrfCheck = 0
DATABASESCHECK = 0
writeToFile = open(settingsFile, 'w')
pluginCheck = 1
for items in data:
if items.find('pluginHolder') > -1:
pluginCheck = 0
for items in settingsData:
if items.find('DATABASES = {') > -1:
DATABASESCHECK = 1
emailMarketing = 1
for items in data:
if items.find('emailMarketing') > -1:
emailMarketing = 0
if DATABASESCHECK == 0:
writeToFile.write(items)
emailPremium = 1
for items in data:
if items.find('emailPremium') > -1:
emailPremium = 0
s3Backups = 1
for items in data:
if items.find('s3Backups') > -1:
s3Backups = 0
dockerManager = 1
for items in data:
if items.find('dockerManager') > -1:
dockerManager = 0
containerization = 1
for items in data:
if items.find('containerization') > -1:
containerization = 0
manageServices = 1
for items in data:
if items.find('manageServices') > -1:
manageServices = 0
CLManager = 1
for items in data:
if items.find('CLManager') > -1:
CLManager = 0
IncBackups = 1
for items in data:
if items.find('IncBackups') > -1:
IncBackups = 0
WebTerminal = 1
for items in data:
if items.find('WebTerminal') > -1:
WebTerminal = 0
SESSION_COOKIE_SECURE = 0
for items in data:
if items.find('SESSION_COOKIE_SECURE') > -1:
SESSION_COOKIE_SECURE = 0
DATABASE_ROUTERS = 1
for items in data:
if items.find('DATABASE_ROUTERS') > -1:
DATABASE_ROUTERS = 0
Upgrade.stdOut('Restoring settings file!')
writeToFile = open("/usr/local/CyberCP/CyberCP/settings.py", 'w')
for items in data:
if items.find('csf') > -1 or items.find('SESSION_COOKIE_SECURE') > -1 or items.find('CSRF_COOKIE_SECURE') > -1:
continue
if items.find("CommonMiddleware") > -1:
if csrfCheck == 1:
writeToFile.writelines(" 'django.middleware.csrf.CsrfViewMiddleware',\n")
if items.find('DATABASE_ROUTERS') > -1:
writeToFile.writelines(items)
if SESSION_COOKIE_SECURE == 1:
con = """SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
"""
writeToFile.writelines(con)
elif items.find("'filemanager',") > -1:
writeToFile.writelines(items)
if pluginCheck == 1:
writeToFile.writelines(" 'pluginHolder',\n")
if emailMarketing == 1:
writeToFile.writelines(" 'emailMarketing',\n")
if emailPremium == 1:
writeToFile.writelines(" 'emailPremium',\n")
if s3Backups == 1:
writeToFile.writelines(" 's3Backups',\n")
if dockerManager == 1:
writeToFile.writelines(" 'dockerManager',\n")
if containerization == 1:
writeToFile.writelines(" 'containerization',\n")
if manageServices == 1:
writeToFile.writelines(" 'manageServices',\n")
if CLManager == 1:
writeToFile.writelines(" 'CLManager',\n")
if IncBackups == 1:
writeToFile.writelines(" 'IncBackups',\n")
if WebTerminal == 1:
writeToFile.writelines(" 'WebTerminal',\n")
else:
writeToFile.writelines(items)
##
DATA_UPLOAD_MAX_MEMORY_SIZE = 1
for items in data:
if items.find('DATA_UPLOAD_MAX_MEMORY_SIZE') > -1:
DATA_UPLOAD_MAX_MEMORY_SIZE = 0
writeToFile.writelines("\nDATA_UPLOAD_MAX_MEMORY_SIZE = 52428800\n")
if DATA_UPLOAD_MAX_MEMORY_SIZE == 1:
writeToFile.writelines("\nDATA_UPLOAD_MAX_MEMORY_SIZE = 52428800\n")
##
MEDIA_URL = 1
for items in data:
if items.find('MEDIA_URL') > -1:
MEDIA_URL = 0
if MEDIA_URL == 1:
writeToFile.writelines("MEDIA_URL = '/home/cyberpanel/media/'\n")
writeToFile.writelines('MEDIA_ROOT = MEDIA_URL\n')
if items.find('MEDIA_ROOT = MEDIA_URLDATA_UPLOAD_MAX_MEMORY_SIZE') > -1:
writeToFile.writelines('MEDIA_ROOT = MEDIA_URL\n')
##
if DATABASE_ROUTERS == 1:
writeToFile.writelines("\nDATABASE_ROUTERS = ['backup.backupRouter.backupRouter']\n")
if items.find('DATABASE_ROUTERS = [') > -1:
DATABASESCHECK = 0
writeToFile.write(completDBString)
writeToFile.write(items)
writeToFile.close()
Upgrade.stdOut('Settings file restored!')
## Move static files
Upgrade.staticContent()
except:
@@ -1526,13 +1434,13 @@ CSRF_COOKIE_SECURE = True
if os.path.exists(lscpdPath):
os.remove(lscpdPath)
command = 'cp -f /usr/local/CyberCP/lscpd-0.2.4 /usr/local/lscp/bin/lscpd-0.2.4'
command = 'cp -f /usr/local/CyberCP/lscpd-0.2.5 /usr/local/lscp/bin/lscpd-0.2.5'
Upgrade.executioner(command, command, 0)
command = 'rm -f /usr/local/lscp/bin/lscpd'
Upgrade.executioner(command, command, 0)
command = 'mv /usr/local/lscp/bin/lscpd-0.2.4 /usr/local/lscp/bin/lscpd'
command = 'mv /usr/local/lscp/bin/lscpd-0.2.5 /usr/local/lscp/bin/lscpd'
Upgrade.executioner(command, command, 0)
command = 'chmod 755 %s' % (lscpdPath)
@@ -1724,18 +1632,22 @@ CSRF_COOKIE_SECURE = True
@staticmethod
def installPHP73():
try:
command = 'yum install -y lsphp73 lsphp73-json lsphp73-xmlrpc lsphp73-xml lsphp73-tidy lsphp73-soap lsphp73-snmp ' \
'lsphp73-recode lsphp73-pspell lsphp73-process lsphp73-pgsql lsphp73-pear lsphp73-pdo lsphp73-opcache ' \
'lsphp73-odbc lsphp73-mysqlnd lsphp73-mcrypt lsphp73-mbstring lsphp73-ldap lsphp73-intl lsphp73-imap ' \
'lsphp73-gmp lsphp73-gd lsphp73-enchant lsphp73-dba lsphp73-common lsphp73-bcmath'
Upgrade.executioner(command, 'Install PHP 73, 0')
command = 'yum install -y lsphp74 lsphp74-json lsphp74-xmlrpc lsphp74-xml lsphp74-tidy lsphp74-soap lsphp74-snmp ' \
'lsphp74-recode lsphp74-pspell lsphp74-process lsphp74-pgsql lsphp74-pear lsphp74-pdo lsphp74-opcache ' \
'lsphp74-odbc lsphp74-mysqlnd lsphp74-mcrypt lsphp74-mbstring lsphp74-ldap lsphp74-intl lsphp74-imap ' \
'lsphp74-gmp lsphp74-gd lsphp74-enchant lsphp74-dba lsphp74-common lsphp74-bcmath'
if Upgrade.installedOutput.find('lsphp73') == -1:
command = 'yum install -y lsphp73 lsphp73-json lsphp73-xmlrpc lsphp73-xml lsphp73-tidy lsphp73-soap lsphp73-snmp ' \
'lsphp73-recode lsphp73-pspell lsphp73-process lsphp73-pgsql lsphp73-pear lsphp73-pdo lsphp73-opcache ' \
'lsphp73-odbc lsphp73-mysqlnd lsphp73-mcrypt lsphp73-mbstring lsphp73-ldap lsphp73-intl lsphp73-imap ' \
'lsphp73-gmp lsphp73-gd lsphp73-enchant lsphp73-dba lsphp73-common lsphp73-bcmath'
Upgrade.executioner(command, 'Install PHP 73, 0')
if Upgrade.installedOutput.find('lsphp74') == -1:
command = 'yum install -y lsphp74 lsphp74-json lsphp74-xmlrpc lsphp74-xml lsphp74-tidy lsphp74-soap lsphp74-snmp ' \
'lsphp74-recode lsphp74-pspell lsphp74-process lsphp74-pgsql lsphp74-pear lsphp74-pdo lsphp74-opcache ' \
'lsphp74-odbc lsphp74-mysqlnd lsphp74-mcrypt lsphp74-mbstring lsphp74-ldap lsphp74-intl lsphp74-imap ' \
'lsphp74-gmp lsphp74-gd lsphp74-enchant lsphp74-dba lsphp74-common lsphp74-bcmath'
Upgrade.executioner(command, 'Install PHP 74, 0')
Upgrade.executioner(command, 'Install PHP 74, 0')
except:
command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install ' \
'lsphp7? lsphp7?-common lsphp7?-curl lsphp7?-dev lsphp7?-imap lsphp7?-intl lsphp7?-json ' \
@@ -1757,11 +1669,6 @@ CSRF_COOKIE_SECURE = True
command = "mkdir -p /usr/local/lscp/cyberpanel/logs"
Upgrade.executioner(command, 0)
@staticmethod
def upgradePDNS():
command = "yum install epel-release && curl -o /etc/yum.repos.d/powerdns-auth-42.repo https://repo.powerdns.com/repo-files/centos-auth-42.repo && yum --enablerepo=epel install pdns"
subprocess.call(command, shell=True)
@staticmethod
def upgradeDovecot():
try:
@@ -1769,40 +1676,28 @@ CSRF_COOKIE_SECURE = True
CentOSPath = '/etc/redhat-release'
if os.path.exists(CentOSPath):
path = '/etc/yum.repos.d/dovecot.repo'
content = """[dovecot-2.3-latest]
name=Dovecot 2.3 CentOS $releasever - $basearch
baseurl=http://repo.dovecot.org/ce-2.3-latest/centos/$releasever/RPMS/$basearch
gpgkey=https://repo.dovecot.org/DOVECOT-REPO-GPG
gpgcheck=1
enabled=1"""
writeToFile = open(path, 'w')
writeToFile.write(content)
writeToFile.close()
command = "yum makecache -y"
Upgrade.executioner(command, 0)
if Upgrade.installedOutput.find('2:2.3.10-2') == -1:
command = "yum makecache -y"
Upgrade.executioner(command, 0)
command = "yum update -y"
Upgrade.executioner(command, 0)
command = "yum update -y"
Upgrade.executioner(command, 0)
## Remove Default Password Scheme
## Remove Default Password Scheme
path = '/etc/dovecot/dovecot-sql.conf.ext'
path = '/etc/dovecot/dovecot-sql.conf.ext'
data = open(path, 'r').readlines()
data = open(path, 'r').readlines()
updatePasswords = 1
writeToFile = open(path, 'w')
for items in data:
if items.find('default_pass_scheme') > -1:
continue
else:
writeToFile.writelines(items)
writeToFile = open(path, 'w')
for items in data:
if items.find('default_pass_scheme') > -1:
updatePasswords = 0
continue
else:
writeToFile.writelines(items)
writeToFile.close()
writeToFile.close()
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
@@ -1821,101 +1716,80 @@ enabled=1"""
Upgrade.executioner(command, 0)
### Postfix Upgrade
try:
shutil.copy('/etc/postfix/master.cf', '/etc/master.cf')
except:
pass
if Upgrade.installedOutput.find('2:3.4.7-1.gf.el7') == -1:
try:
shutil.copy('/etc/postfix/master.cf', '/etc/master.cf')
except:
pass
try:
shutil.copy('/etc/postfix/main.cf', '/etc/main.cf')
except:
pass
try:
shutil.copy('/etc/postfix/main.cf', '/etc/main.cf')
except:
pass
gf = '/etc/yum.repos.d/gf.repo'
gfContent = """[gf]
name=Ghettoforge packages that won't overwrite core distro packages.
mirrorlist=http://mirrorlist.ghettoforge.org/el/7/gf/$basearch/mirrorlist
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-gf.el7
failovermethod=priority
[gf-plus]
name=Ghettoforge packages that will overwrite core distro packages.
mirrorlist=http://mirrorlist.ghettoforge.org/el/7/plus/$basearch/mirrorlist
# Please read http://ghettoforge.org/index.php/Usage *before* enabling this repository!
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-gf.el7
failovermethod=priority
"""
writeToFile = open(gf, 'w')
writeToFile.write(gfContent)
writeToFile.close()
command = 'yum remove postfix -y'
Upgrade.executioner(command, 0)
command = 'yum remove postfix -y'
Upgrade.executioner(command, 0)
command = 'yum clean all'
Upgrade.executioner(command, 0)
command = 'rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm'
Upgrade.executioner(command, 0)
command = 'yum makecache fast'
Upgrade.executioner(command, 0)
command = 'yum clean all'
Upgrade.executioner(command, 0)
command = 'yum install --enablerepo=CyberPanel -y postfix3 postfix3-mysql'
Upgrade.executioner(command, 0)
command = 'yum makecache fast'
Upgrade.executioner(command, 0)
try:
shutil.move('/etc/master.cf', '/etc/postfix/master.cf')
except:
pass
try:
shutil.move('/etc/main.cf', '/etc/postfix/main.cf')
except:
pass
command = 'yum install -y postfix3 postfix3-mysql'
Upgrade.executioner(command, 0)
try:
shutil.move('/etc/master.cf', '/etc/postfix/master.cf')
except:
pass
try:
shutil.move('/etc/main.cf', '/etc/postfix/main.cf')
except:
pass
command = 'systemctl restart postfix'
Upgrade.executioner(command, 0)
command = 'systemctl restart postfix'
Upgrade.executioner(command, 0)
else:
command = 'curl https://repo.dovecot.org/DOVECOT-REPO-GPG | gpg --import'
subprocess.call(command, shell=True)
command = 'gpg --export ED409DA1 > /etc/apt/trusted.gpg.d/dovecot.gpg'
subprocess.call(command, shell=True)
if Upgrade.installedOutput.find('dovecot-mysql/bionic,now 2:2.3.10-2') == -1:
debPath = '/etc/apt/sources.list.d/dovecot.list'
writeToFile = open(debPath, 'w')
writeToFile.write('deb https://repo.dovecot.org/ce-2.3-latest/ubuntu/bionic bionic main\n')
writeToFile.close()
try:
command = 'apt update -y'
Upgrade.executioner(command, 0)
except:
pass
try:
command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
command = 'curl https://repo.dovecot.org/DOVECOT-REPO-GPG | gpg --import'
subprocess.call(command, shell=True)
command = 'dpkg --configure -a'
Upgrade.executioner(command, 0)
command = 'apt --fix-broken install -y'
Upgrade.executioner(command, 0)
command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
command = 'gpg --export ED409DA1 > /etc/apt/trusted.gpg.d/dovecot.gpg'
subprocess.call(command, shell=True)
except:
pass
debPath = '/etc/apt/sources.list.d/dovecot.list'
writeToFile = open(debPath, 'w')
writeToFile.write('deb https://repo.dovecot.org/ce-2.3-latest/ubuntu/bionic bionic main\n')
writeToFile.close()
try:
command = 'apt update -y'
Upgrade.executioner(command, 0)
except:
pass
try:
command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
subprocess.call(command, shell=True)
command = 'dpkg --configure -a'
Upgrade.executioner(command, 0)
command = 'apt --fix-broken install -y'
Upgrade.executioner(command, 0)
command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
subprocess.call(command, shell=True)
except:
pass
## Remove Default Password Scheme
@@ -1989,18 +1863,17 @@ failovermethod=priority
CentOSPath = '/etc/redhat-release'
if os.path.exists(CentOSPath):
command = 'yum-config-manager --add-repo https://copr.fedorainfracloud.org/coprs/copart/restic/repo/epel-7/copart-restic-epel-7.repo'
Upgrade.executioner(command, 'Add restic repo.')
command = 'yum install restic -y'
Upgrade.executioner(command, 'Install Restic')
if Upgrade.installedOutput.find('restic') == -1:
command = 'yum install restic -y'
Upgrade.executioner(command, 'Install Restic')
else:
command = 'apt-get update -y'
Upgrade.executioner(command, 'Install Restic')
command = 'apt-get install restic -y'
Upgrade.executioner(command, 'Install Restic')
if Upgrade.installedOutput.find('restic/bionic,now 0.8') == -1:
command = 'apt-get update -y'
Upgrade.executioner(command, 'Install Restic')
command = 'apt-get install restic -y'
Upgrade.executioner(command, 'Install Restic')
@staticmethod
def UpdateMaxSSLCons():
@@ -2138,6 +2011,14 @@ vmail
# Upgrade.stdOut("Upgrades are currently disabled")
# return 0
if os.path.exists(Upgrade.CentOSPath):
command = 'yum list installed'
Upgrade.installedOutput = subprocess.check_output(shlex.split(command)).decode()
else:
command = 'apt list'
Upgrade.installedOutput = subprocess.check_output(shlex.split(command)).decode()
command = 'systemctl stop cpssh'
Upgrade.executioner(command, 'fix csf if there', 0)
@@ -2145,6 +2026,10 @@ vmail
## Add LSPHP7.4 TO LSWS Ent configs
if not os.path.exists('/usr/local/lsws/bin/openlitespeed'):
if os.path.exists('httpd_config.xml'):
os.remove('httpd_config.xml')
command = 'wget https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/install/litespeed/httpd_config.xml'
Upgrade.executioner(command, command, 0)
#os.remove('/usr/local/lsws/conf/httpd_config.xml')
@@ -2220,18 +2105,9 @@ vmail
time.sleep(3)
## Upgrade version
Upgrade.fixPermissions()
### get back imunify
imunifyPublicBackup = '/usr/local'
imunifyPublicBackup = '%s/imunify' % (imunifyPublicBackup)
try:
shutil.move(imunifyPublicBackup, '/usr/local/CyberCP/public')
except:
pass
##
Upgrade.upgradeVersion()
@@ -2265,6 +2141,14 @@ vmail
Upgrade.installCLScripts()
Upgrade.runSomeImportantBash()
## Move static files
imunifyPath = '/usr/local/CyberCP/public/imunify'
if os.path.exists(imunifyPath):
command = "yum reinstall imunify360-firewall-generic -y"
Upgrade.executioner(command, command, 1)
Upgrade.stdOut("Upgrade Completed.")

View File

@@ -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'
@@ -857,7 +857,7 @@ class vhost:
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
command = "chmod 755 %s" % (path)
command = "chmod 750 %s" % (path)
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)

View File

@@ -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":

View File

@@ -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
@@ -33,7 +31,7 @@ jsonpointer==1.9
MarkupSafe==0.19
mock==2.0.0
mysqlclient==1.4.6
paramiko==2.6.0
paramiko==2.7.1
parsedatetime==2.4
pbr==4.0.4
pexpect==4.4.0
@@ -54,7 +52,7 @@ PyYAML==3.10
requests==2.18.4
requests-file==1.4.3
s3transfer==0.1.13
SimpleWebSocketServer==0.1.1
tornado==6.0.4
six==1.13.0
sqlparse==0.3.0
tldextract==2.2.0

View File

@@ -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"

View File

@@ -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'
});
}
};
});

View 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">
&times;
</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">
&times;
</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">
&times;
</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">
&times;
</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">
&times;
</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">
&times;
</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">
&times;
</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 %}

View File

@@ -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'),
]

View File

@@ -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,420 @@ 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 = ProcessUtilities.outputExecutioner('cat %s' % (yumConf))
data = yumConfData.splitlines()
yumConfTmp = '/home/cyberpanel/yumTemp'
if type == 0:
writeToFile = open(yumConfTmp, '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(yumConfTmp, 'a')
writeToFile.writelines('exclude=%s\n' % (package))
writeToFile.close()
else:
writeToFile = open(yumConfTmp, '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()
command = 'mv %s %s' % (yumConfTmp, yumConf)
ProcessUtilities.executioner(command)
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)

View File

@@ -73,16 +73,6 @@ function connect() {
if (remember) {
store(options)
}
// if (check()) {
// openTerminal(options)
// } else {
// for (var key in validResult) {
// if (!validResult[key]) {
// alert(errorMsg[key]);
// break;
// }
// }
// }
openTerminal(options)
}

View File

@@ -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
View 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();
});
});

File diff suppressed because it is too large Load Diff

View File

@@ -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;

View File

@@ -2171,8 +2171,6 @@ app.controller('installImunify', function ($scope, $http, $timeout, $window) {
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
}

View File

@@ -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;
};
});
});

View File

@@ -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 */

Some files were not shown because too many files have changed in this diff Show More