resolve merge conflicts
This commit is contained in:
commit
f0f77e2f1e
|
|
@ -2,22 +2,21 @@
|
|||
#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
|
||||
#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');
|
||||
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
|
||||
|
|
@ -27,167 +26,131 @@ 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
|
||||
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)
|
||||
CLNVERSION=$(sed '3q;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
|
||||
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
|
||||
### Check SpamAssasin before moving forward
|
||||
|
||||
DIR=/etc/mail/spamassassin
|
||||
|
||||
if [ -d "$DIR" ]; then
|
||||
sa-update
|
||||
|
||||
if [ -d "$DIR" ]; then
|
||||
sa-update
|
||||
else
|
||||
|
||||
echo "Please install spamassassin through the CyberPanel interface before proceeding"
|
||||
|
||||
exit
|
||||
echo "Please install spamassassin through the CyberPanel interface before proceeding"
|
||||
exit
|
||||
fi
|
||||
|
||||
elif [ "$CLNVERSION" = "ID=\"cloudlinux\"" ];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
|
||||
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)
|
||||
CLNVERSION=$(sed '3q;d' /etc/os-release)
|
||||
fi
|
||||
|
||||
elif [ "$OS" = "NAME=\"Ubuntu\"" ];then
|
||||
if [ "$CENTOSVERSION" = "VERSION_ID=\"7\"" ]; then
|
||||
|
||||
apt-get install -y libmysqlclient-dev
|
||||
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)"
|
||||
|
||||
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
|
||||
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'
|
||||
|
||||
cpanm Encoding::FixLatin
|
||||
cpanm Digest::SHA1
|
||||
cpanm Geo::IP
|
||||
cpanm Razor2::Client::Agent
|
||||
cpanm Net::Patricia
|
||||
cpanm Net::CIDR
|
||||
freshclam -v
|
||||
|
||||
sudo systemctl stop clamav-freshclam.service
|
||||
elif [ "$CENTOSVERSION" = "VERSION_ID=\"8\"" ]; then
|
||||
|
||||
freshclam
|
||||
setenforce 0
|
||||
yum install -y perl yum-utils perl-CPAN
|
||||
dnf --enablerepo=powertools install -y perl-IO-stringy
|
||||
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)"
|
||||
|
||||
sudo systemctl start clamav-freshclam.service
|
||||
rpm -Uvh https://forensics.cert.org/centos/cert/8/x86_64/unrar-5.4.0-1.el8.x86_64.rpm
|
||||
|
||||
DIR=/etc/spamassassin
|
||||
if [ -d "$DIR" ]; then
|
||||
export PERL_MM_USE_DEFAULT=1
|
||||
curl -L https://cpanmin.us | perl - App::cpanminus
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
elif [ "$CLNVERSION" = "ID=\"cloudlinux\"" ]; 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
|
||||
|
||||
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
|
||||
|
||||
fi
|
||||
|
||||
echo "header_checks = regexp:/etc/postfix/header_checks" >> /etc/postfix/main.cf
|
||||
echo "/^Received:/ HOLD" >> /etc/postfix/header_checks
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
|
||||
elif [ "$OS" = "NAME=\"CloudLinux\"" ];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
|
||||
elif [ "$OS" = "NAME=\"CloudLinux\"" ]; 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
|
||||
|
|
@ -234,8 +197,15 @@ 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";
|
||||
|
||||
### Fix a bug in MailWatch SQL File
|
||||
|
||||
sed -i 's/char(512)/char(255)/g' /usr/local/CyberCP/public/mailwatch/create.sql
|
||||
|
||||
##
|
||||
|
||||
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';"
|
||||
|
|
@ -247,11 +217,11 @@ sed -i "s/^define('DB_PASS',.*/define('DB_PASS','${PASSWORD}');/" /usr/local/Cyb
|
|||
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
|
||||
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/
|
||||
|
|
@ -268,125 +238,121 @@ systemctl restart mailscanner
|
|||
|
||||
IPADDRESS=$(cat /etc/cyberpanel/machineIP)
|
||||
|
||||
### Furhter onwards is sieve configurations
|
||||
|
||||
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
|
||||
|
||||
elif [ "$CLNVERSION" = "ID=\"cloudlinux\"" ];then
|
||||
|
||||
yum install -y nano net-tools dovecot-pigeonhole 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
|
||||
|
||||
elif [ "$OS" = "NAME=\"CloudLinux\"" ];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 '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
|
||||
#
|
||||
#elif [ "$CLNVERSION" = "ID=\"cloudlinux\"" ]; then
|
||||
# yum install -y nano net-tools dovecot-pigeonhole 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
|
||||
#
|
||||
#elif [ "$OS" = "NAME=\"CloudLinux\"" ]; 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;
|
||||
systemctl restart dovecot && systemctl restart postfix && systemctl restart spamassassin && systemctl restart mailscanner
|
||||
|
||||
csf -e
|
||||
|
||||
|
|
|
|||
|
|
@ -1,28 +1,28 @@
|
|||
#!/bin/bash
|
||||
## Uninstall Mailscanner CyberPanel
|
||||
|
||||
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)
|
||||
CLNVERSION=$(sed '3q;d' /etc/os-release)
|
||||
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)
|
||||
CLNVERSION=$(sed '3q;d' /etc/os-release)
|
||||
fi
|
||||
|
||||
systemctl stop mailscanner
|
||||
|
||||
if [ "$OS" = "NAME=\"Ubuntu\"" ];then
|
||||
apt purge -y mailscanner
|
||||
if [ "$OS" = "NAME=\"Ubuntu\"" ]; then
|
||||
apt purge -y mailscanner
|
||||
|
||||
elif
|
||||
[ "$OS" = "NAME=\"CentOS Linux\"" ]
|
||||
then
|
||||
yum remove -y MailScanner
|
||||
|
||||
elif [ "$OS" = "NAME=\"CentOS Linux\"" ];then
|
||||
yum remove -y MailScanner
|
||||
|
||||
elif [ "$OS" = "NAME=\"CloudLinux\"" ];then
|
||||
yum remove -y MailScanner
|
||||
elif [ "$OS" = "NAME=\"CloudLinux\"" ]; then
|
||||
yum remove -y MailScanner
|
||||
|
||||
fi
|
||||
|
||||
|
||||
sed -i '/\/^Received:\/ HOLD/d' /etc/postfix/header_checks
|
||||
rm -rf /etc/MailScanner
|
||||
rm -rf /usr/share/MailScanner
|
||||
|
|
|
|||
|
|
@ -10,6 +10,12 @@ class secMiddleware:
|
|||
HIGH = 0
|
||||
LOW = 1
|
||||
|
||||
def get_client_ip(request):
|
||||
ip = request.META.get('HTTP_CF_CONNECTING_IP')
|
||||
if ip is None:
|
||||
ip = request.META.get('REMOTE_ADDR')
|
||||
return ip
|
||||
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
|
||||
|
|
@ -17,7 +23,7 @@ class secMiddleware:
|
|||
try:
|
||||
uID = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=uID)
|
||||
ipAddr = request.META.get('REMOTE_ADDR')
|
||||
ipAddr = get_client_ip(request)
|
||||
|
||||
if ipAddr.find('.') > -1:
|
||||
if request.session['ipAddr'] == ipAddr or admin.securityLevel == secMiddleware.LOW:
|
||||
|
|
@ -25,20 +31,19 @@ class secMiddleware:
|
|||
else:
|
||||
del request.session['userID']
|
||||
del request.session['ipAddr']
|
||||
logging.writeToFile(request.META.get('REMOTE_ADDR'))
|
||||
logging.writeToFile(get_client_ip(request))
|
||||
final_dic = {'error_message': "Session reuse detected, IPAddress logged.",
|
||||
"errorMessage": "Session reuse detected, IPAddress logged."}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
ipAddr = request.META.get('REMOTE_ADDR').split(':')[:3]
|
||||
|
||||
ipAddr = get_client_ip(request).split(':')[:3]
|
||||
if request.session['ipAddr'] == ipAddr or admin.securityLevel == secMiddleware.LOW:
|
||||
pass
|
||||
else:
|
||||
del request.session['userID']
|
||||
del request.session['ipAddr']
|
||||
logging.writeToFile(request.META.get('REMOTE_ADDR'))
|
||||
logging.writeToFile(get_client_ip(request))
|
||||
final_dic = {'error_message': "Session reuse detected, IPAddress logged.",
|
||||
"errorMessage": "Session reuse detected, IPAddress logged."}
|
||||
final_json = json.dumps(final_dic)
|
||||
|
|
@ -117,4 +122,4 @@ class secMiddleware:
|
|||
response['X-Content-Type-Options'] = "nosniff"
|
||||
response['Referrer-Policy'] = "same-origin"
|
||||
|
||||
return response
|
||||
return response
|
||||
|
|
|
|||
|
|
@ -135,7 +135,9 @@ class IncJobs(multi.Thread):
|
|||
secret = open(path, 'r').read()
|
||||
return key, secret
|
||||
|
||||
def awsFunction(self, fType, backupPath=None, snapshotID=None, bType=None):
|
||||
## Last argument delete is set when the snapshot is to be deleted from this repo, when this argument is set, any preceding argument is not used
|
||||
|
||||
def awsFunction(self, fType, backupPath=None, snapshotID=None, bType=None, delete=None):
|
||||
try:
|
||||
if fType == 'backup':
|
||||
key, secret = self.getAWSData()
|
||||
|
|
@ -144,8 +146,8 @@ class IncJobs(multi.Thread):
|
|||
backupExcludesFile = '/home/%s/backup-exclude.conf' % (self.website.domain)
|
||||
resticBackupExcludeCMD = ' --exclude-file=%s' % (backupExcludesFile)
|
||||
|
||||
command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s backup %s --password-file %s' % (
|
||||
key, secret, self.website.domain, backupPath, self.passwordFile)
|
||||
command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s backup %s --password-file %s --exclude /home/%s/backup --exclude /home/%s/incbackup' % (
|
||||
key, secret, self.website.domain, backupPath, self.passwordFile, self.website.domain, self.website.domain)
|
||||
|
||||
# If /home/%s/backup-exclude.conf file exists lets pass this to restic by appending the command to end.
|
||||
if os.path.isfile(backupExcludesFile):
|
||||
|
|
@ -184,6 +186,27 @@ class IncJobs(multi.Thread):
|
|||
if result.find('restoring') == -1:
|
||||
logging.statusWriter(self.statusPath, 'Failed: %s. [5009]' % (result), 1)
|
||||
return 0
|
||||
elif delete:
|
||||
|
||||
self.backupDestinations = self.jobid.destination
|
||||
|
||||
key, secret = self.getAWSData()
|
||||
|
||||
command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s forget %s --password-file %s' % (
|
||||
key, secret, self.website, snapshotID, self.passwordFile)
|
||||
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if result.find('removed snapshot') > -1 or result.find('deleted') > -1:
|
||||
pass
|
||||
else:
|
||||
logging.statusWriter(self.statusPath, 'Failed: %s. [5009]' % (result), 1)
|
||||
return 0
|
||||
|
||||
command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s prune --password-file %s' % (
|
||||
key, secret, self.website, self.passwordFile)
|
||||
|
||||
ProcessUtilities.outputExecutioner(command)
|
||||
else:
|
||||
self.backupDestinations = self.jobid.destination
|
||||
|
||||
|
|
@ -205,14 +228,17 @@ class IncJobs(multi.Thread):
|
|||
logging.statusWriter(self.statusPath, "%s [88][5009]" % (str(msg)), 1)
|
||||
return 0
|
||||
|
||||
def localFunction(self, backupPath, type, restore=None):
|
||||
## Last argument delete is set when the snapshot is to be deleted from this repo, when this argument is set, any preceding argument is not used
|
||||
|
||||
def localFunction(self, backupPath, type, restore=None, delete=None):
|
||||
|
||||
if restore == None:
|
||||
# Define our excludes file for use with restic
|
||||
backupExcludesFile = '/home/%s/backup-exclude.conf' % (self.website.domain)
|
||||
resticBackupExcludeCMD = ' --exclude-file=%s' % (backupExcludesFile)
|
||||
|
||||
command = 'restic -r %s backup %s --password-file %s --exclude %s' % (
|
||||
self.repoPath, backupPath, self.passwordFile, self.repoPath)
|
||||
command = 'restic -r %s backup %s --password-file %s --exclude %s --exclude /home/%s/backup' % (
|
||||
self.repoPath, backupPath, self.passwordFile, self.repoPath, self.website.domain)
|
||||
# If /home/%s/backup-exclude.conf file exists lets pass this to restic by appending the command to end.
|
||||
if os.path.isfile(backupExcludesFile):
|
||||
command = command + resticBackupExcludeCMD
|
||||
|
|
@ -233,6 +259,23 @@ class IncJobs(multi.Thread):
|
|||
newSnapshot = JobSnapshots(job=self.jobid, type='%s:%s' % (type, backupPath), snapshotid=snapShotid,
|
||||
destination=self.backupDestinations)
|
||||
newSnapshot.save()
|
||||
return 1
|
||||
elif delete:
|
||||
|
||||
repoLocation = '/home/%s/incbackup' % (self.website)
|
||||
|
||||
command = 'restic -r %s forget %s --password-file %s' % (repoLocation, self.jobid.snapshotid, self.passwordFile)
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if result.find('removed snapshot') > -1 or result.find('deleted') > -1:
|
||||
pass
|
||||
else:
|
||||
logging.statusWriter(self.statusPath, 'Failed: %s. [5009]' % (result), 1)
|
||||
return 0
|
||||
|
||||
command = 'restic -r %s prune --password-file %s' % (repoLocation, self.passwordFile)
|
||||
ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
return 1
|
||||
else:
|
||||
repoLocation = '/home/%s/incbackup' % (self.website)
|
||||
|
|
@ -247,14 +290,16 @@ class IncJobs(multi.Thread):
|
|||
|
||||
return 1
|
||||
|
||||
def sftpFunction(self, backupPath, type, restore=None):
|
||||
## Last argument delete is set when the snapshot is to be deleted from this repo, when this argument is set, any preceding argument is not used
|
||||
|
||||
def sftpFunction(self, backupPath, type, restore=None, delete=None):
|
||||
if restore == None:
|
||||
# Define our excludes file for use with restic
|
||||
backupExcludesFile = '/home/%s/backup-exclude.conf' % (self.website.domain)
|
||||
resticBackupExcludeCMD = ' --exclude-file=%s' % (backupExcludesFile)
|
||||
remotePath = '/home/backup/%s' % (self.website.domain)
|
||||
command = 'export PATH=${PATH}:/usr/bin && restic -r %s:%s backup %s --password-file %s --exclude %s' % (
|
||||
self.backupDestinations, remotePath, backupPath, self.passwordFile, self.repoPath)
|
||||
command = 'export PATH=${PATH}:/usr/bin && restic -r %s:%s backup %s --password-file %s --exclude %s --exclude /home/%s/backup' % (
|
||||
self.backupDestinations, remotePath, backupPath, self.passwordFile, self.repoPath, self.website.domain)
|
||||
# If /home/%s/backup-exclude.conf file exists lets pass this to restic by appending the command to end.
|
||||
if os.path.isfile(backupExcludesFile):
|
||||
command = command + resticBackupExcludeCMD
|
||||
|
|
@ -276,6 +321,20 @@ class IncJobs(multi.Thread):
|
|||
destination=self.backupDestinations)
|
||||
newSnapshot.save()
|
||||
return 1
|
||||
elif delete:
|
||||
repoLocation = '/home/backup/%s' % (self.website)
|
||||
command = 'export PATH=${PATH}:/usr/bin && restic -r %s:%s forget %s --password-file %s' % (
|
||||
self.jobid.destination, repoLocation, self.jobid.snapshotid, self.passwordFile)
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if result.find('removed snapshot') > -1 or result.find('deleted') > -1:
|
||||
pass
|
||||
else:
|
||||
logging.statusWriter(self.statusPath, 'Failed: %s. [5009]' % (result), 1)
|
||||
return 0
|
||||
|
||||
command = 'export PATH=${PATH}:/usr/bin && restic -r %s:%s prune --password-file %s' % (self.jobid.destination, repoLocation, self.passwordFile)
|
||||
ProcessUtilities.outputExecutioner(command)
|
||||
else:
|
||||
if self.reconstruct == 'remote':
|
||||
repoLocation = '/home/backup/%s' % (self.website)
|
||||
|
|
@ -437,6 +496,7 @@ class IncJobs(multi.Thread):
|
|||
|
||||
def restorePoint(self):
|
||||
try:
|
||||
|
||||
self.statusPath = self.extraArgs['tempPath']
|
||||
self.website = self.extraArgs['website']
|
||||
jobid = self.extraArgs['jobid']
|
||||
|
|
@ -526,177 +586,29 @@ class IncJobs(multi.Thread):
|
|||
def prepareBackupMeta(self):
|
||||
try:
|
||||
|
||||
######### Generating meta
|
||||
|
||||
## XML Generation
|
||||
|
||||
metaFileXML = Element('metaFile')
|
||||
|
||||
child = SubElement(metaFileXML, 'masterDomain')
|
||||
child.text = self.website.domain
|
||||
|
||||
child = SubElement(metaFileXML, 'phpSelection')
|
||||
child.text = self.website.phpSelection
|
||||
|
||||
child = SubElement(metaFileXML, 'externalApp')
|
||||
child.text = self.website.externalApp
|
||||
|
||||
childDomains = self.website.childdomains_set.all()
|
||||
|
||||
databases = self.website.databases_set.all()
|
||||
|
||||
## Child domains XML
|
||||
|
||||
childDomainsXML = Element('ChildDomains')
|
||||
|
||||
for items in childDomains:
|
||||
childDomainXML = Element('domain')
|
||||
|
||||
child = SubElement(childDomainXML, 'domain')
|
||||
child.text = items.domain
|
||||
child = SubElement(childDomainXML, 'phpSelection')
|
||||
child.text = items.phpSelection
|
||||
child = SubElement(childDomainXML, 'path')
|
||||
child.text = items.path
|
||||
|
||||
childDomainsXML.append(childDomainXML)
|
||||
|
||||
metaFileXML.append(childDomainsXML)
|
||||
|
||||
## Databases XML
|
||||
|
||||
databasesXML = Element('Databases')
|
||||
|
||||
for items in databases:
|
||||
try:
|
||||
dbuser = DBUsers.objects.get(user=items.dbUser)
|
||||
userToTry = items.dbUser
|
||||
except:
|
||||
dbusers = DBUsers.objects.all().filter(user=items.dbUser)
|
||||
for it in dbusers:
|
||||
dbuser = it
|
||||
break
|
||||
|
||||
userToTry = mysqlUtilities.mysqlUtilities.fetchuser(items.dbName)
|
||||
|
||||
if userToTry == 0 or userToTry == 1:
|
||||
continue
|
||||
|
||||
try:
|
||||
dbuser = DBUsers.objects.get(user=userToTry)
|
||||
except:
|
||||
dbusers = DBUsers.objects.all().filter(user=userToTry)
|
||||
for it in dbusers:
|
||||
dbuser = it
|
||||
break
|
||||
## Use the meta function from backup utils for future improvements.
|
||||
|
||||
|
||||
databaseXML = Element('database')
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile('Creating meta for %s. [IncBackupsControl.py]' % (self.website.domain))
|
||||
|
||||
child = SubElement(databaseXML, 'dbName')
|
||||
child.text = items.dbName
|
||||
child = SubElement(databaseXML, 'dbUser')
|
||||
child.text = userToTry
|
||||
child = SubElement(databaseXML, 'password')
|
||||
child.text = dbuser.password
|
||||
|
||||
databasesXML.append(databaseXML)
|
||||
|
||||
metaFileXML.append(databasesXML)
|
||||
|
||||
## Get Aliases
|
||||
|
||||
aliasesXML = Element('Aliases')
|
||||
|
||||
aliases = backupUtilities.getAliases(self.website.domain)
|
||||
|
||||
for items in aliases:
|
||||
child = SubElement(aliasesXML, 'alias')
|
||||
child.text = items
|
||||
|
||||
metaFileXML.append(aliasesXML)
|
||||
|
||||
## Finish Alias
|
||||
|
||||
## DNS Records XML
|
||||
|
||||
try:
|
||||
|
||||
dnsRecordsXML = Element("dnsrecords")
|
||||
dnsRecords = DNS.getDNSRecords(self.website.domain)
|
||||
|
||||
for items in dnsRecords:
|
||||
dnsRecordXML = Element('dnsrecord')
|
||||
|
||||
child = SubElement(dnsRecordXML, 'type')
|
||||
child.text = items.type
|
||||
child = SubElement(dnsRecordXML, 'name')
|
||||
child.text = items.name
|
||||
child = SubElement(dnsRecordXML, 'content')
|
||||
child.text = items.content
|
||||
child = SubElement(dnsRecordXML, 'priority')
|
||||
child.text = str(items.prio)
|
||||
|
||||
dnsRecordsXML.append(dnsRecordXML)
|
||||
|
||||
metaFileXML.append(dnsRecordsXML)
|
||||
|
||||
except BaseException as msg:
|
||||
logging.statusWriter(self.statusPath, '%s. [158:prepMeta]' % (str(msg)), 1)
|
||||
|
||||
## Email accounts XML
|
||||
|
||||
try:
|
||||
emailRecordsXML = Element('emails')
|
||||
eDomain = eDomains.objects.get(domain=self.website.domain)
|
||||
emailAccounts = eDomain.eusers_set.all()
|
||||
|
||||
for items in emailAccounts:
|
||||
emailRecordXML = Element('emailAccount')
|
||||
|
||||
child = SubElement(emailRecordXML, 'email')
|
||||
child.text = items.email
|
||||
child = SubElement(emailRecordXML, 'password')
|
||||
child.text = items.password
|
||||
|
||||
emailRecordsXML.append(emailRecordXML)
|
||||
|
||||
metaFileXML.append(emailRecordsXML)
|
||||
except BaseException as msg:
|
||||
pass
|
||||
#logging.statusWriter(self.statusPath, '%s. [warning:179:prepMeta]' % (str(msg)), 1)
|
||||
|
||||
## Email meta generated!
|
||||
|
||||
def prettify(elem):
|
||||
"""Return a pretty-printed XML string for the Element.
|
||||
"""
|
||||
rough_string = ElementTree.tostring(elem, 'utf-8')
|
||||
reparsed = minidom.parseString(rough_string)
|
||||
return reparsed.toprettyxml(indent=" ")
|
||||
|
||||
## /home/example.com/backup/backup-example-06-50-03-Thu-Feb-2018/meta.xml -- metaPath
|
||||
|
||||
metaPath = '/home/cyberpanel/%s' % (str(randint(1000, 9999)))
|
||||
|
||||
xmlpretty = prettify(metaFileXML).encode('ascii', 'ignore')
|
||||
metaFile = open(metaPath, 'w')
|
||||
metaFile.write(xmlpretty.decode('utf-8'))
|
||||
metaFile.close()
|
||||
os.chmod(metaPath, 0o640)
|
||||
from plogical.backupUtilities import backupUtilities
|
||||
status, message, metaPath = backupUtilities.prepareBackupMeta(self.website.domain, None, None, None, 0)
|
||||
|
||||
## meta generated
|
||||
|
||||
logging.statusWriter(self.statusPath, 'Meta data is ready..', 1)
|
||||
|
||||
metaPathNew = '/home/%s/meta.xml' % (self.website.domain)
|
||||
command = 'mv %s %s' % (metaPath, metaPathNew)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
return 1
|
||||
if status == 1:
|
||||
logging.statusWriter(self.statusPath, 'Meta data is ready..', 1)
|
||||
metaPathNew = '/home/%s/meta.xml' % (self.website.domain)
|
||||
command = 'mv %s %s' % (metaPath, metaPathNew)
|
||||
ProcessUtilities.executioner(command)
|
||||
return 1
|
||||
else:
|
||||
logging.statusWriter(self.statusPath, "%s [544][5009]" % (message), 1)
|
||||
return 0
|
||||
|
||||
except BaseException as msg:
|
||||
logging.statusWriter(self.statusPath, "%s [207][5009]" % (str(msg)), 1)
|
||||
logging.statusWriter(self.statusPath, "%s [548][5009]" % (str(msg)), 1)
|
||||
return 0
|
||||
|
||||
def backupData(self):
|
||||
|
|
@ -728,6 +640,7 @@ class IncJobs(multi.Thread):
|
|||
databases = self.website.databases_set.all()
|
||||
|
||||
for items in databases:
|
||||
|
||||
if mysqlUtilities.mysqlUtilities.createDatabaseBackup(items.dbName, '/home/cyberpanel') == 0:
|
||||
return 0
|
||||
|
||||
|
|
@ -760,6 +673,7 @@ class IncJobs(multi.Thread):
|
|||
backupPath = '/home/vmail/%s' % (self.website.domain)
|
||||
|
||||
if os.path.exists(backupPath):
|
||||
|
||||
if self.backupDestinations == 'local':
|
||||
if self.localFunction(backupPath, 'email') == 0:
|
||||
return 0
|
||||
|
|
@ -807,6 +721,10 @@ class IncJobs(multi.Thread):
|
|||
if self.backupDestinations == 'local':
|
||||
command = 'restic init --repo %s --password-file %s' % (self.repoPath, self.passwordFile)
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(result)
|
||||
|
||||
if result.find('config file already exists') == -1:
|
||||
logging.statusWriter(self.statusPath, result, 1)
|
||||
|
||||
|
|
@ -815,6 +733,10 @@ class IncJobs(multi.Thread):
|
|||
command = 'export PATH=${PATH}:/usr/bin && restic init --repo %s:%s --password-file %s' % (
|
||||
self.backupDestinations, remotePath, self.passwordFile)
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(result)
|
||||
|
||||
if result.find('config file already exists') == -1:
|
||||
logging.statusWriter(self.statusPath, result, 1)
|
||||
else:
|
||||
|
|
@ -822,9 +744,12 @@ class IncJobs(multi.Thread):
|
|||
command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s init --password-file %s' % (
|
||||
key, secret, self.website.domain, self.passwordFile)
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(result)
|
||||
|
||||
if result.find('config file already exists') == -1:
|
||||
logging.statusWriter(self.statusPath, result, 1)
|
||||
return 1
|
||||
|
||||
logging.statusWriter(self.statusPath,
|
||||
'Repo %s initiated for %s.' % (self.backupDestinations, self.website.domain), 1)
|
||||
|
|
@ -851,6 +776,7 @@ Subject: %s
|
|||
mailUtilities.SendEmail(sender, TO, message)
|
||||
|
||||
def createBackup(self):
|
||||
|
||||
self.statusPath = self.extraArgs['tempPath']
|
||||
website = self.extraArgs['website']
|
||||
self.backupDestinations = self.extraArgs['backupDestinations']
|
||||
|
|
@ -861,6 +787,7 @@ Subject: %s
|
|||
### Checking if restic is installed before moving on
|
||||
|
||||
command = 'restic'
|
||||
|
||||
if ProcessUtilities.outputExecutioner(command).find('restic is a backup program which') == -1:
|
||||
try:
|
||||
|
||||
|
|
@ -916,6 +843,8 @@ Subject: %s
|
|||
if self.initiateRepo() == 0:
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
if self.prepareBackupMeta() == 0:
|
||||
return 0
|
||||
|
||||
|
|
@ -945,3 +874,38 @@ Subject: %s
|
|||
'Failed to delete meta file: %s. [IncJobs.createBackup.591]' % str(msg), 1)
|
||||
|
||||
logging.statusWriter(self.statusPath, 'Completed', 1)
|
||||
|
||||
### Delete Snapshot
|
||||
|
||||
def DeleteSnapShot(self, inc_job):
|
||||
try:
|
||||
|
||||
self.statusPath = logging.fileName
|
||||
|
||||
job_snapshots = inc_job.jobsnapshots_set.all()
|
||||
|
||||
### Fetch the website name from JobSnapshot object and set these variable as they are needed in called functions below
|
||||
|
||||
self.website = job_snapshots[0].job.website.domain
|
||||
self.passwordFile = '/home/%s/%s' % (self.website, self.website)
|
||||
|
||||
for job_snapshot in job_snapshots:
|
||||
|
||||
## Functions above use the self.jobid varilable to extract information about this snapshot, so this below variable needs to be set
|
||||
|
||||
self.jobid = job_snapshot
|
||||
|
||||
if self.jobid.destination == 'local':
|
||||
self.localFunction('none', 'none', 0, 1)
|
||||
elif self.jobid.destination[:4] == 'sftp':
|
||||
self.sftpFunction('none', 'none', 0, 1)
|
||||
else:
|
||||
self.awsFunction('restore', '', self.jobid.snapshotid, None, 1)
|
||||
|
||||
return 1
|
||||
|
||||
except BaseException as msg:
|
||||
logging.statusWriter(self.statusPath, "%s [903:DeleteSnapShot][5009]" % (str(msg)), 1)
|
||||
return 0
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -405,7 +405,12 @@ def delete_backup(request):
|
|||
|
||||
backup_id = data['backupID']
|
||||
|
||||
IncJob.objects.get(id=backup_id).delete()
|
||||
inc_job = IncJob.objects.get(id=backup_id)
|
||||
|
||||
job = IncJobs(None, None)
|
||||
job.DeleteSnapShot(inc_job)
|
||||
|
||||
inc_job.delete()
|
||||
|
||||
final_dic = {'status': 1, 'error_message': 'None'}
|
||||
final_json = json.dumps(final_dic)
|
||||
|
|
@ -450,7 +455,6 @@ def fetch_restore_points(request):
|
|||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
def restore_point(request):
|
||||
try:
|
||||
user_id, current_acl = _get_user_acl(request)
|
||||
|
|
|
|||
|
|
@ -696,7 +696,7 @@ class BackupManager:
|
|||
finalDic['port'] = "22"
|
||||
|
||||
try:
|
||||
finalDic['user'] = data['user']
|
||||
finalDic['user'] = data['userName']
|
||||
except:
|
||||
finalDic['user'] = "root"
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
|
||||
<form action="/" class="form-horizontal bordered-row">
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -528,9 +528,9 @@ body #nav-toggle.collapsed span {
|
|||
width: 100px;
|
||||
}
|
||||
.closed-sidebar #header-logo .logo-content-small {
|
||||
width: 62px;
|
||||
width: 50px;
|
||||
margin-left: 0;
|
||||
left: 0px;
|
||||
left: 15px;
|
||||
display: block;
|
||||
}
|
||||
.closed-sidebar #header-logo .logo-content-big {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@
|
|||
|
||||
<!-- HELPERS -->
|
||||
|
||||
{% with version="2.1.1.1" %}
|
||||
{% with version="2.1.2" %}
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'baseTemplate/assets/finalBase/finalBase.css' %}">
|
||||
|
||||
|
|
@ -90,7 +90,8 @@
|
|||
<link rel="stylesheet" type="text/css" href="{% static 'baseTemplate/custom-js/pnotify.custom.min.css' %}">
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'websiteFunctions/websiteFunctions.css' %}">
|
||||
<link rel="icon" type="image/png" href="{% static 'baseTemplate/assets/finalBase/favicon.png' %}">
|
||||
<link type="text/css" href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet"/>
|
||||
<link type="text/css" href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css"
|
||||
rel="stylesheet"/>
|
||||
{% block styles %}
|
||||
{% endblock %}
|
||||
|
||||
|
|
@ -115,11 +116,6 @@
|
|||
|
||||
|
||||
<body>
|
||||
<div id="sb-site">
|
||||
|
||||
|
||||
<!------- ng-controller="systemStatusInfo" ------------>
|
||||
|
||||
|
||||
<div class="sb-slidebar bg-black sb-right sb-style-overlay">
|
||||
<div class="scrollable-content scrollable-slim-sidebar">
|
||||
|
|
@ -174,7 +170,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="loading">
|
||||
<div class="spinner">
|
||||
<div class="bounce1"></div>
|
||||
|
|
@ -203,60 +198,20 @@
|
|||
<i class="glyph-icon icon-angle-left"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div id="header-nav-left">
|
||||
<div ng-controller="adminController" class="user-account-btn dropdown">
|
||||
<a href="#" title="{% trans 'My Account' %}" class="user-profile clearfix"
|
||||
data-toggle="dropdown">
|
||||
<img width="28" src="{% static 'baseTemplate/assets/image-resources/gravatar.png' %}"
|
||||
alt="Profile image">
|
||||
<span>{$ currentAdmin $}</span>
|
||||
<i class="glyph-icon icon-angle-down"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu float-left">
|
||||
<div class="box-sm">
|
||||
<div class="login-box clearfix">
|
||||
<div class="user-img">
|
||||
<a href="#" title="{% trans '' %}" class="change-img">Change photo</a>
|
||||
<img src="{% static 'baseTemplate/assets/image-resources/gravatar.png' %}"
|
||||
alt="">
|
||||
</div>
|
||||
<div class="user-info">
|
||||
<span>
|
||||
{$ currentAdmin $}
|
||||
<i>{$ admin_type $}</i>
|
||||
</span>
|
||||
<a href="{% url 'modifyUsers' %}"
|
||||
title="{% trans 'Edit profile' %}">{% trans "Edit profile" %}</a>
|
||||
<a href="{% url 'viewProfile' %}"
|
||||
title="{% trans 'View Profile' %}">{% trans "View Profile" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="divider"></div>
|
||||
<div class="pad5A button-pane button-pane-alt text-center">
|
||||
<a href="{% url 'logout' %}" class="btn display-block font-normal btn-danger">
|
||||
<i class="glyph-icon icon-power-off"></i>
|
||||
{% trans "Logout" %}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- #header-nav-left -->
|
||||
|
||||
|
||||
<div ng-controller="loadAvg" id="header-nav-right">
|
||||
|
||||
<a class="hide-on-phone" style="background-color: none;width: 33px" href="#" class="hdr-btn"
|
||||
<a class="hide-on-phone" style="background-color: unset;width: 33px" href="#" class="hdr-btn"
|
||||
title="{% trans 'CPU Load Average' %}" data-placement="bottom">
|
||||
<span class="badge bg-yellow">{$ one $}</span>
|
||||
</a>
|
||||
|
||||
<a class="hide-on-phone" style="background-color: none;width: 33px" href="#" class="hdr-btn"
|
||||
<a class="hide-on-phone" style="background-color: unset;width: 33px" href="#" class="hdr-btn"
|
||||
title="{% trans 'CPU Load Average' %}" data-placement="bottom">
|
||||
<span class="badge bg-yellow">{$ two $}</span>
|
||||
</a>
|
||||
|
||||
<a class="hide-on-phone" style="background-color: none;width: 33px" href="#" class="hdr-btn"
|
||||
<a class="hide-on-phone" style="background-color: unset;width: 33px" href="#" class="hdr-btn"
|
||||
title="{% trans 'CPU Load Average' %}" data-placement="bottom">
|
||||
<span class="badge bg-yellow">{$ three $}</span>
|
||||
</a>
|
||||
|
|
@ -324,20 +279,19 @@
|
|||
</a>
|
||||
|
||||
|
||||
</div><!-- #header-nav-right -->
|
||||
</div>
|
||||
<!-- #header-nav-right -->
|
||||
|
||||
</div>
|
||||
<div id="page-sidebar">
|
||||
<div class="scroll-sidebar">
|
||||
|
||||
|
||||
<ul id="sidebar-menu">
|
||||
<li class="header"><span>{% trans "Overview" %}</span></li>
|
||||
<li>
|
||||
<a href="#" title="{% trans 'Server IP Address' %}">
|
||||
<i class="glyph-icon tooltip-button icon-laptop" title="{% trans 'Server IP Address' %}"
|
||||
data-original-title=".icon-laptop"></i>
|
||||
<span style="color: #db6868;font-weight: bold;" id="serverIPAddress"></span>
|
||||
<span style="color: #db6868;font-weight: bold;">{{ ipAddress }}</span>
|
||||
</a>
|
||||
<a href="{% url 'index' %}" title="{% trans 'Dashboard' %}">
|
||||
<i class="glyph-icon icon-dashboard"></i>
|
||||
|
|
@ -428,8 +382,11 @@
|
|||
<li><a href="{% url 'listWebsites' %}"
|
||||
title="{% trans 'List Websites' %}"><span>{% trans "List Websites" %}</span></a>
|
||||
</li>
|
||||
<li><a href="{% url 'CreateNewDomain' %}"
|
||||
title="{% trans 'Create New Domain' %}"><span>{% trans "Create New Domain" %}</span></a>
|
||||
</li>
|
||||
<li><a href="{% url 'listChildDomains' %}"
|
||||
title="{% trans 'List Child Domains' %}"><span>{% trans "List Child Domains" %}</span></a>
|
||||
title="{% trans 'List Domains' %}"><span>{% trans "List Domains" %}</span></a>
|
||||
</li>
|
||||
{% if admin or modifyWebsite %}
|
||||
<li><a href="{% url 'modifyWebsite' %}"
|
||||
|
|
@ -708,7 +665,7 @@
|
|||
{% endif %}
|
||||
</ul>
|
||||
|
||||
</div><!-- .sidebar-submenu -->
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
|
@ -737,7 +694,7 @@
|
|||
{% endif %}
|
||||
</ul>
|
||||
|
||||
</div><!-- .sidebar-submenu -->
|
||||
</div>
|
||||
</li>
|
||||
|
||||
{% if admin %}
|
||||
|
|
@ -1044,10 +1001,8 @@
|
|||
{% endif %}
|
||||
|
||||
</ul><!-- #sidebar-menu -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="page-content-wrapper">
|
||||
<div id="page-content">
|
||||
|
||||
|
|
@ -1058,13 +1013,8 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- WIDGETS -->
|
||||
|
||||
<!-- Sparklines charts -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrious/4.0.2/qrious.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
||||
<script src="{% static 'baseTemplate/custom-js/pnotify.custom.min.js' %}"></script>
|
||||
|
|
@ -1081,7 +1031,6 @@
|
|||
<script src="{% static 'serverLogs/serverLogs.js' %}?ver={{ version }}"></script>
|
||||
<script src="{% static 'emailPremium/emailPremium.js' %}?ver={{ version }}"></script>
|
||||
<script src="{% static 'emailMarketing/emailMarketing.js' %}?ver={{ version }}"></script>
|
||||
|
||||
<script type="text/javascript" src="{% static 'baseTemplate/assets/finalJS/final.js' %}"></script>
|
||||
<script src="{% static 'backup/backup.js' %}?ver={{ version }}"></script>
|
||||
<script src="{% static 'managePHP/managePHP.js' %}?ver={{ version }}"></script>
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ def getAdminStatus(request):
|
|||
|
||||
def getSystemStatus(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(val)
|
||||
HTTPData = SystemInformation.getSystemInformation()
|
||||
json_data = json.dumps(HTTPData)
|
||||
return HttpResponse(json_data)
|
||||
|
|
@ -195,4 +197,4 @@ def upgradeVersion(request):
|
|||
return HttpResponse("Version upgrade OK.")
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse(str(msg))
|
||||
return HttpResponse(str(msg))
|
||||
|
|
|
|||
|
|
@ -1492,7 +1492,7 @@ class CloudManager:
|
|||
writeToFile.write('Starting..,0')
|
||||
writeToFile.close()
|
||||
|
||||
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/mailServer/mailserverManager.py"
|
||||
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
|
||||
execPath = execPath + ' ResetEmailConfigurations --tempStatusPath %s' % (tempStatusPath)
|
||||
|
||||
ProcessUtilities.popenExecutioner(execPath)
|
||||
|
|
@ -2843,6 +2843,9 @@ class CloudManager:
|
|||
|
||||
zones = cf.zones.get(params = {'per_page':100})
|
||||
|
||||
command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.6/site-packages/tldextract/.suffix_cache'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
for website in Websites.objects.all():
|
||||
import tldextract
|
||||
extractDomain = tldextract.extract(website.domain)
|
||||
|
|
@ -2882,6 +2885,9 @@ class CloudManager:
|
|||
|
||||
### For child domainsa
|
||||
|
||||
command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.6/site-packages/tldextract/.suffix_cache'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
from websiteFunctions.models import ChildDomains
|
||||
for website in ChildDomains.objects.all():
|
||||
|
||||
|
|
|
|||
|
|
@ -987,9 +987,12 @@ if [[ "$Server_OS" = "CentOS" ]] ; then
|
|||
else
|
||||
apt update -y
|
||||
DEBIAN_FRONTEND=noninteractive apt upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
|
||||
<<<<<<< HEAD
|
||||
if [[ "$Server_Provider" = "Alibaba Cloud" ]] ; then
|
||||
apt install -y --allow-downgrades libgnutls30=3.6.13-2ubuntu1.3
|
||||
fi
|
||||
=======
|
||||
>>>>>>> v2.1.1
|
||||
DEBIAN_FRONTEND=noninteracitve apt install -y dnsutils net-tools 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1129,6 +1129,16 @@ def installMailScanner(request):
|
|||
return ACLManager.loadErrorJson()
|
||||
try:
|
||||
|
||||
### Check selinux
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'sestatus'
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if result.find('disabled') == -1:
|
||||
final_json = json.dumps({'status': 0, 'error_message': "Disable selinux before installing MailScanner."})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
|
||||
execPath = execPath + " installMailScanner"
|
||||
ProcessUtilities.popenExecutioner(execPath)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
<nav id="navBar" class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="header-logo">
|
||||
<a href="#"><img src="{% static 'filemanager/images/fileManager.png' %}"> <span style="display: none" id="domainNameInitial">{{ domainName }}</span></a>
|
||||
<a href="/websites/{{ domainName }}"><img src="{% static 'filemanager/images/fileManager.png' %}"> <span style="display: none" id="domainNameInitial">{{ domainName }}</span></a>
|
||||
</div>
|
||||
<!--- second bar ---->
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from plogical.acl import ACLManager
|
|||
import plogical.CyberCPLogFileWriter as logging
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
import subprocess
|
||||
from django.shortcuts import HttpResponse, render
|
||||
from django.shortcuts import HttpResponse, render, redirect
|
||||
from random import randint
|
||||
import time
|
||||
from plogical.firewallUtilities import FirewallUtilities
|
||||
|
|
@ -39,9 +39,14 @@ class FirewallManager:
|
|||
return proc.render()
|
||||
|
||||
def firewallHome(self, request = None, userID = None):
|
||||
proc = httpProc(request, 'firewall/firewall.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
csfPath = '/etc/csf'
|
||||
|
||||
if os.path.exists(csfPath):
|
||||
return redirect('/configservercsf/')
|
||||
else:
|
||||
proc = httpProc(request, 'firewall/firewall.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def getCurrentRules(self, userID = None):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -17,10 +17,7 @@ import stat
|
|||
VERSION = '2.1'
|
||||
BUILD = 1
|
||||
|
||||
char_set = {'small': 'abcdefghijklmnopqrstuvwxyz',
|
||||
'nums': '0123456789',
|
||||
'big': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||
}
|
||||
char_set = {'small': 'abcdefghijklmnopqrstuvwxyz','nums': '0123456789','big': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}
|
||||
|
||||
|
||||
def generate_pass(length=14):
|
||||
|
|
@ -817,39 +814,6 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
|||
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
# if self.distro != centos:
|
||||
# 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)
|
||||
#
|
||||
# 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'
|
||||
# subprocess.call(command, shell=True)
|
||||
# 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'
|
||||
# subprocess.call(command, shell=True)
|
||||
#
|
||||
# command = 'apt --fix-broken install -y'
|
||||
# subprocess.call(command, shell=True)
|
||||
#
|
||||
# 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
|
||||
|
||||
except BaseException as msg:
|
||||
logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_postfix_dovecot]")
|
||||
return 0
|
||||
|
|
@ -1426,13 +1390,13 @@ imap_folder_list_limit = 0
|
|||
|
||||
lscpdPath = '/usr/local/lscp/bin/lscpd'
|
||||
|
||||
command = 'cp -f /usr/local/CyberCP/lscpd-0.2.7 /usr/local/lscp/bin/lscpd-0.2.7'
|
||||
command = 'cp -f /usr/local/CyberCP/lscpd-0.3.1 /usr/local/lscp/bin/lscpd-0.3.1'
|
||||
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.7 /usr/local/lscp/bin/lscpd'
|
||||
command = 'mv /usr/local/lscp/bin/lscpd-0.3.1 /usr/local/lscp/bin/lscpd'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = 'chmod 755 %s' % (lscpdPath)
|
||||
|
|
@ -1720,9 +1684,26 @@ imap_folder_list_limit = 0
|
|||
0 0 * * 0 /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Weekly
|
||||
*/3 * * * * if ! find /home/*/public_html/ -maxdepth 2 -type f -newer /usr/local/lsws/cgid -name '.htaccess' -exec false {} +; then /usr/local/lsws/bin/lswsctrl restart; fi
|
||||
"""
|
||||
|
||||
cronFile.write(content)
|
||||
cronFile.close()
|
||||
|
||||
### Check and remove OLS restart if lsws ent detected
|
||||
|
||||
if not os.path.exists('/usr/local/lsws/bin/openlitespeed'):
|
||||
|
||||
data = open(cronPath, 'r').readlines()
|
||||
|
||||
writeToFile = open(cronPath, 'w')
|
||||
|
||||
for items in data:
|
||||
if items.find('-maxdepth 2 -type f -newer') > -1:
|
||||
pass
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
writeToFile.close()
|
||||
|
||||
if not os.path.exists(CentOSPath):
|
||||
command = 'chmod 600 %s' % (cronPath)
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
|
|
|||
|
|
@ -95,6 +95,8 @@ class InstallCyberPanel:
|
|||
|
||||
if str.lower(self.serial) == 'trial':
|
||||
command = 'wget -q --output-document=lsws-6.0/trial.key http://license.litespeedtech.com/reseller/trial.key'
|
||||
if self.serial == '1111-2222-3333-4444':
|
||||
command = 'wget -q --output-document=/root/cyberpanel/install/lsws-6.0/trial.key http://license.litespeedtech.com/reseller/trial.key'
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
else:
|
||||
writeSerial = open('lsws-6.0/serial.no', 'w')
|
||||
|
|
|
|||
|
|
@ -30,6 +30,6 @@ class InstallLog:
|
|||
|
||||
try:
|
||||
finalData = json.dumps({'ipAddress': InstallLog.ServerIP, "InstallCyberPanelStatus": message})
|
||||
requests.post(InstallLog.LogURL, data=finalData)
|
||||
requests.post(InstallLog.LogURL, data=finalData, timeout=10)
|
||||
except:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -139,6 +139,8 @@ SecFilterSelective ARGS "or.+1[[:space:]]*=[[:space:]]1|or 1=1--'|'.+--&quo
|
|||
|
||||
SecFilterSelective ARGS "into[[:space:]]+outfile|load[[:space:]]+data|/\*.+\*/"</ruleSet>
|
||||
</censorshipRuleSet>
|
||||
<bubbleWrap>1</bubbleWrap>
|
||||
<bubbleWrapCmd>/bin/bwrap --ro-bind /usr /usr --ro-bind /lib /lib --ro-bind-try /lib64 /lib64 --ro-bind /bin /bin --ro-bind /sbin /sbin --dir /var --ro-bind-try /var/www /var/www --dir /tmp --proc /proc --symlink../tmp var/tmp --dev /dev --ro-bind-try /etc/localtime /etc/localtime --ro-bind-try /etc/ld.so.cache /etc/ld.so.cache --ro-bind-try /etc/resolv.conf /etc/resolv.conf --ro-bind-try /etc/ssl /etc/ssl --ro-bind-try /etc/pki /etc/pki --ro-bind-try /etc/man_db.conf /etc/man_db.conf --ro-bind-try /usr/local/bin/msmtp /etc/alternatives/mta --ro-bind-try /usr/local/bin/msmtp /usr/sbin/exim --bind-try $HOMEDIR $HOMEDIR --bind-try /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock --bind-try /home/mysql/mysql.sock /home/mysql/mysql.sock --bind-try /tmp/mysql.sock /tmp/mysql.sock --bind-try /run/mysqld/mysqld.sock /run/mysqld/mysqld.sock --bind-try /var/run/mysqld/mysqld.sock /var/run/mysqld/mysqld.sock '$COPY-TRY /etc/exim.jail/$USER.conf $HOMEDIR/.msmtprc' --unshare-all --share-net --die-with-parent --dir /run/user/$UID ‘$PASSWD 65534’ ‘$GROUP 65534’</bubbleWrapCmd>
|
||||
<accessDenyDir>
|
||||
<dir>/</dir>
|
||||
<dir>/etc/*</dir>
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -3,13 +3,10 @@
|
|||
import os.path
|
||||
import sys
|
||||
import django
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
from django.shortcuts import render,redirect
|
||||
from django.http import HttpResponse
|
||||
try:
|
||||
from .models import Domains,EUsers
|
||||
|
|
@ -62,7 +59,6 @@ class MailServerManager(multi.Thread):
|
|||
None, 'createEmail')
|
||||
return proc.render()
|
||||
|
||||
|
||||
def createEmailAccount(self):
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
|
@ -663,6 +659,9 @@ class MailServerManager(multi.Thread):
|
|||
|
||||
try:
|
||||
|
||||
command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.6/site-packages/tldextract/.suffix_cache'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
import tldextract
|
||||
|
||||
extractDomain = tldextract.extract(domainName)
|
||||
|
|
@ -721,6 +720,10 @@ class MailServerManager(multi.Thread):
|
|||
DNS.dnsTemplate(domainName, admin)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
|
||||
command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.6/site-packages/tldextract/.suffix_cache'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
import tldextract
|
||||
|
||||
extractDomain = tldextract.extract(domainName)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "List Email Accounts" %}
|
||||
<h2>{% trans "List Email Accounts" %} - <a target="_blank" href="https://go.cyberpanel.net/DebugEmail" style="height: 23px;line-height: 21px;" class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>{% trans "Debug Email Issues" %}</span></a>
|
||||
<a class="pull-right btn btn-primary" href="{% url "createEmailAccount" %}">{% trans "Create Email" %}</a>
|
||||
</h2>
|
||||
<p>{% trans "List Emails Accounts. Change their passwords or delete them." %}</p>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@ def managePowerDNS(request):
|
|||
data = {}
|
||||
data['status'] = 1
|
||||
|
||||
pdnsStatus = PDNSStatus.objects.get(pk=1)
|
||||
try:
|
||||
pdnsStatus = PDNSStatus.objects.get(pk=1)
|
||||
except:
|
||||
pdnsStatus = PDNSStatus(type='NATIVE', serverStatus=1)
|
||||
pdnsStatus.save()
|
||||
|
||||
if pdnsStatus.type == 'MASTER':
|
||||
counter = 1
|
||||
|
|
|
|||
|
|
@ -343,6 +343,7 @@ password=%s""" % (rootdbpassword, rootdbpassword)
|
|||
|
||||
def SyncNow(self):
|
||||
try:
|
||||
|
||||
self.PostStatus('Syncing data from home directory to fail over server..')
|
||||
|
||||
command = "rsync -avzp -e 'ssh -o StrictHostKeyChecking=no -p %s -i /root/.ssh/cyberpanel' /home root@%s:/" % (self.config['failoverServerSSHPort'], self.config['failoverServerIP'])
|
||||
|
|
|
|||
|
|
@ -23,8 +23,11 @@ class UpgradeCyberPanel:
|
|||
|
||||
def PostStatus(self, message):
|
||||
finalData = json.dumps({'ipAddress': self.ipAddress, "UpgradeCyberPanelStatus": message})
|
||||
resp = requests.post(UpgradeCyberPanel.LogURL, data=finalData, verify=False)
|
||||
print (resp.text)
|
||||
|
||||
try:
|
||||
resp = requests.post(UpgradeCyberPanel.LogURL, data=finalData, verify=False, timeout=10)
|
||||
except:
|
||||
pass
|
||||
|
||||
def RestoreOldCP(self):
|
||||
|
||||
|
|
|
|||
|
|
@ -348,6 +348,7 @@ class IncScheduler():
|
|||
|
||||
@staticmethod
|
||||
def startNormalBackups(type):
|
||||
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from plogical.backupSchedule import backupSchedule
|
||||
import socket
|
||||
|
|
|
|||
|
|
@ -42,9 +42,10 @@ def main():
|
|||
|
||||
numberOfAdministrator = Administrator.objects.count()
|
||||
if numberOfAdministrator == 0:
|
||||
|
||||
ACLManager.createDefaultACLs()
|
||||
acl = ACL.objects.get(name='admin')
|
||||
token = hashPassword.generateToken('admin', '1234567')
|
||||
token = hashPassword.generateToken('admin', adminPass)
|
||||
|
||||
email = 'usman@cyberpersons.com'
|
||||
admin = Administrator(userName="admin", password=hashPassword.hash_password(adminPass), type=1, email=email,
|
||||
|
|
|
|||
|
|
@ -67,14 +67,20 @@ class backupUtilities:
|
|||
self.extraArgs = extraArgs
|
||||
|
||||
@staticmethod
|
||||
def prepareBackupMeta(backupDomain, backupName, tempStoragePath, backupPath):
|
||||
def prepareBackupMeta(backupDomain, backupName, tempStoragePath, backupPath, FromInner = 1):
|
||||
try:
|
||||
|
||||
|
||||
connection, cursor = mysqlUtilities.mysqlUtilities.setupConnection()
|
||||
|
||||
status = os.path.join(backupPath, 'status')
|
||||
if FromInner:
|
||||
status = os.path.join(backupPath, 'status')
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, 'Setting up meta data..')
|
||||
else:
|
||||
status = '/home/cyberpanel/dummy'
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, 'Setting up meta data..')
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile('Creating meta for %s.' % (backupDomain))
|
||||
|
||||
website = Websites.objects.get(domain=backupDomain)
|
||||
|
||||
|
|
@ -278,6 +284,9 @@ class backupUtilities:
|
|||
|
||||
metaPath = '/tmp/%s' % (str(randint(1000, 9999)))
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile('Path to meta file %s' % (metaPath))
|
||||
|
||||
xmlpretty = prettify(metaFileXML).encode('ascii', 'ignore')
|
||||
metaFile = open(metaPath, 'w')
|
||||
metaFile.write(xmlpretty.decode())
|
||||
|
|
@ -286,19 +295,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()
|
||||
if FromInner:
|
||||
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..')
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, 'Meta data is ready..')
|
||||
|
||||
return 1, 'None', metaPath
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile("%s [207][5009]" % (str(msg)))
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "%s [207][5009]" % (str(msg)))
|
||||
return 0, str(msg)
|
||||
if FromInner:
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "%s [207][5009]" % (str(msg)))
|
||||
return 0, str(msg), 'None'
|
||||
|
||||
|
||||
@staticmethod
|
||||
def startBackup(tempStoragePath, backupName, backupPath, metaPath=None):
|
||||
|
|
@ -610,13 +621,10 @@ class backupUtilities:
|
|||
if VERSION == '2.1' and BUILD == '1':
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile('Backup version 2.1.1 detected..')
|
||||
|
||||
databaseUsers = database.findall('databaseUsers')
|
||||
|
||||
for databaseUser in databaseUsers:
|
||||
|
||||
dbUser = databaseUser.find('dbUser').text
|
||||
|
||||
if mysqlUtilities.mysqlUtilities.createDatabase(dbName, dbUser, 'cyberpanel') == 0:
|
||||
raise BaseException
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,9 @@ class DNS:
|
|||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
|
||||
command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.6/site-packages/tldextract/.suffix_cache'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
import tldextract
|
||||
|
||||
extractDomain = tldextract.extract(domain)
|
||||
|
|
@ -515,6 +518,9 @@ class DNS:
|
|||
def createDKIMRecords(domain):
|
||||
try:
|
||||
|
||||
command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.6/site-packages/tldextract/.suffix_cache'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
import tldextract
|
||||
|
||||
extractDomain = tldextract.extract(domain)
|
||||
|
|
|
|||
|
|
@ -1,190 +1,190 @@
|
|||
import os
|
||||
import shutil
|
||||
import pathlib
|
||||
import stat
|
||||
|
||||
|
||||
def mkdir_p(path, exist_ok=True):
|
||||
"""
|
||||
Creates the directory and paths leading up to it like unix mkdir -p .
|
||||
Defaults to exist_ok so if it exists were not throwing fatal errors
|
||||
https://docs.python.org/3.7/library/os.html#os.makedirs
|
||||
"""
|
||||
if not os.path.exists(path):
|
||||
print('creating directory: ' + path)
|
||||
os.makedirs(path, exist_ok)
|
||||
|
||||
|
||||
def chmod_digit(file_path, perms):
|
||||
"""
|
||||
Helper function to chmod like you would in unix without having to preface 0o or converting to octal yourself.
|
||||
Credits: https://stackoverflow.com/a/60052847/1621381
|
||||
"""
|
||||
try:
|
||||
os.chmod(file_path, int(str(perms), base=8))
|
||||
except:
|
||||
print(f'Could not chmod : {file_path} to {perms}')
|
||||
pass
|
||||
|
||||
|
||||
def touch(filepath: str, exist_ok=True):
|
||||
"""
|
||||
Touches a file like unix `touch somefile` would.
|
||||
"""
|
||||
try:
|
||||
pathlib.Path(filepath).touch(exist_ok)
|
||||
except FileExistsError:
|
||||
print('Could touch : ' + filepath)
|
||||
pass
|
||||
|
||||
|
||||
def symlink(src, dst):
|
||||
"""
|
||||
Symlink a path to another if the src exists.
|
||||
"""
|
||||
try:
|
||||
if os.access(src, os.R_OK):
|
||||
os.symlink(src, dst)
|
||||
except:
|
||||
print(f'Could not symlink Source: {src} > Destination: {dst}')
|
||||
pass
|
||||
|
||||
|
||||
def chown(path, user, group=-1):
|
||||
"""
|
||||
Chown file/path to user/group provided. Passing -1 to user or group will leave it unchanged.
|
||||
Useful if just changing user or group vs both.
|
||||
"""
|
||||
try:
|
||||
shutil.chown(path, user, group)
|
||||
except PermissionError:
|
||||
print(f'Could not change permissions for: {path} to {user}:{group}')
|
||||
pass
|
||||
|
||||
|
||||
def recursive_chown(path, owner, group=-1):
|
||||
"""
|
||||
Recursively chown a path and contents to owner.
|
||||
https://docs.python.org/3/library/shutil.html
|
||||
"""
|
||||
for dirpath, dirnames, filenames in os.walk(path):
|
||||
try:
|
||||
shutil.chown(dirpath, owner, group)
|
||||
except PermissionError:
|
||||
print('Could not change permissions for: ' + dirpath + ' to: ' + owner)
|
||||
pass
|
||||
for filename in filenames:
|
||||
try:
|
||||
shutil.chown(os.path.join(dirpath, filename), owner, group)
|
||||
except PermissionError:
|
||||
print('Could not change permissions for: ' + os.path.join(dirpath, filename) + ' to: ' + owner)
|
||||
pass
|
||||
|
||||
|
||||
def recursive_permissions(path, dir_mode=755, file_mode=644, topdir=True):
|
||||
"""
|
||||
Recursively chmod a path and contents to mode.
|
||||
Defaults to chmod top level directory but can be optionally
|
||||
toggled off when you want to chmod only contents of like a user's homedir vs homedir itself
|
||||
https://docs.python.org/3.6/library/os.html#os.walk
|
||||
"""
|
||||
|
||||
# Here we are converting the integers to string and then to octal.
|
||||
# so this function doesn't need to be called with 0o prefixed for the file and dir mode
|
||||
dir_mode = int(str(dir_mode), base=8)
|
||||
file_mode = int(str(file_mode), base=8)
|
||||
|
||||
if topdir:
|
||||
# Set chmod on top level path
|
||||
try:
|
||||
os.chmod(path, dir_mode)
|
||||
except:
|
||||
print('Could not chmod :' + path + ' to ' + str(dir_mode))
|
||||
for root, dirs, files in os.walk(path):
|
||||
for d in dirs:
|
||||
try:
|
||||
os.chmod(os.path.join(root, d), dir_mode)
|
||||
except:
|
||||
print('Could not chmod :' + os.path.join(root, d) + ' to ' + str(dir_mode))
|
||||
pass
|
||||
for f in files:
|
||||
try:
|
||||
os.chmod(os.path.join(root, f), file_mode)
|
||||
except:
|
||||
print('Could not chmod :' + path + ' to ' + str(file_mode))
|
||||
pass
|
||||
|
||||
|
||||
# Left intentionally here for reference.
|
||||
# Set recursive chown for a path
|
||||
# recursive_chown(my_path, 'root', 'root')
|
||||
# for changing group recursively without affecting user
|
||||
# recursive_chown('/usr/local/lscp/cyberpanel/rainloop/data', -1, 'lscpd')
|
||||
|
||||
# explicitly set permissions for directories/folders to 0755 and files to 0644
|
||||
# recursive_permissions(my_path, 755, 644)
|
||||
|
||||
# Fix permissions and use default values
|
||||
# recursive_permissions(my_path)
|
||||
# =========================================================
|
||||
# Below is a helper class for getting and working with permissions
|
||||
# Original credits to : https://github.com/keysemble/perfm
|
||||
|
||||
def perm_octal_digit(rwx):
|
||||
digit = 0
|
||||
if rwx[0] == 'r':
|
||||
digit += 4
|
||||
if rwx[1] == 'w':
|
||||
digit += 2
|
||||
if rwx[2] == 'x':
|
||||
digit += 1
|
||||
return digit
|
||||
|
||||
|
||||
class FilePerm:
|
||||
def __init__(self, filepath):
|
||||
filemode = stat.filemode(os.stat(filepath).st_mode)
|
||||
permissions = [filemode[-9:][i:i + 3] for i in range(0, len(filemode[-9:]), 3)]
|
||||
self.filepath = filepath
|
||||
self.access_dict = dict(zip(['user', 'group', 'other'], [list(perm) for perm in permissions]))
|
||||
|
||||
def mode(self):
|
||||
mode = 0
|
||||
for shift, digit in enumerate(self.octal()[::-1]):
|
||||
mode += digit << (shift * 3)
|
||||
return mode
|
||||
|
||||
def digits(self):
|
||||
"""Get the octal chmod equivalent value 755 in single string"""
|
||||
return "".join(map(str, self.octal()))
|
||||
|
||||
def octal(self):
|
||||
"""Get the octal value in a list [7, 5, 5]"""
|
||||
return [perm_octal_digit(p) for p in self.access_dict.values()]
|
||||
|
||||
def access_bits(self, access):
|
||||
if access in self.access_dict.keys():
|
||||
r, w, x = self.access_dict[access]
|
||||
return [r == 'r', w == 'w', x == 'x']
|
||||
|
||||
def update_bitwise(self, settings):
|
||||
def perm_list(read=False, write=False, execute=False):
|
||||
pl = ['-', '-', '-']
|
||||
if read:
|
||||
pl[0] = 'r'
|
||||
if write:
|
||||
pl[1] = 'w'
|
||||
if execute:
|
||||
pl[2] = 'x'
|
||||
return pl
|
||||
|
||||
self.access_dict = dict(
|
||||
[(access, perm_list(read=r, write=w, execute=x)) for access, [r, w, x] in settings.items()])
|
||||
os.chmod(self.filepath, self.mode())
|
||||
|
||||
# project_directory = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
# home_directory = os.path.expanduser('~')
|
||||
# print(f'Path: {home_directory} Mode: {FilePerm(home_directory).mode()} Octal: {FilePerm(home_directory).octal()} '
|
||||
# f'Digits: {FilePerm(home_directory).digits()}')
|
||||
# Example: Output
|
||||
# Path: /home/cooluser Mode: 493 Octal: [7, 5, 5] Digits: 755
|
||||
import os
|
||||
import shutil
|
||||
import pathlib
|
||||
import stat
|
||||
|
||||
|
||||
def mkdir_p(path, exist_ok=True):
|
||||
"""
|
||||
Creates the directory and paths leading up to it like unix mkdir -p .
|
||||
Defaults to exist_ok so if it exists were not throwing fatal errors
|
||||
https://docs.python.org/3.7/library/os.html#os.makedirs
|
||||
"""
|
||||
if not os.path.exists(path):
|
||||
print('creating directory: ' + path)
|
||||
os.makedirs(path, exist_ok)
|
||||
|
||||
|
||||
def chmod_digit(file_path, perms):
|
||||
"""
|
||||
Helper function to chmod like you would in unix without having to preface 0o or converting to octal yourself.
|
||||
Credits: https://stackoverflow.com/a/60052847/1621381
|
||||
"""
|
||||
try:
|
||||
os.chmod(file_path, int(str(perms), base=8))
|
||||
except:
|
||||
print(f'Could not chmod : {file_path} to {perms}')
|
||||
pass
|
||||
|
||||
|
||||
def touch(filepath: str, exist_ok=True):
|
||||
"""
|
||||
Touches a file like unix `touch somefile` would.
|
||||
"""
|
||||
try:
|
||||
pathlib.Path(filepath).touch(exist_ok)
|
||||
except FileExistsError:
|
||||
print('Could touch : ' + filepath)
|
||||
pass
|
||||
|
||||
|
||||
def symlink(src, dst):
|
||||
"""
|
||||
Symlink a path to another if the src exists.
|
||||
"""
|
||||
try:
|
||||
if os.access(src, os.R_OK):
|
||||
os.symlink(src, dst)
|
||||
except:
|
||||
print(f'Could not symlink Source: {src} > Destination: {dst}')
|
||||
pass
|
||||
|
||||
|
||||
def chown(path, user, group=-1):
|
||||
"""
|
||||
Chown file/path to user/group provided. Passing -1 to user or group will leave it unchanged.
|
||||
Useful if just changing user or group vs both.
|
||||
"""
|
||||
try:
|
||||
shutil.chown(path, user, group)
|
||||
except PermissionError:
|
||||
print(f'Could not change permissions for: {path} to {user}:{group}')
|
||||
pass
|
||||
|
||||
|
||||
def recursive_chown(path, owner, group=-1):
|
||||
"""
|
||||
Recursively chown a path and contents to owner.
|
||||
https://docs.python.org/3/library/shutil.html
|
||||
"""
|
||||
for dirpath, dirnames, filenames in os.walk(path):
|
||||
try:
|
||||
shutil.chown(dirpath, owner, group)
|
||||
except PermissionError:
|
||||
print('Could not change permissions for: ' + dirpath + ' to: ' + owner)
|
||||
pass
|
||||
for filename in filenames:
|
||||
try:
|
||||
shutil.chown(os.path.join(dirpath, filename), owner, group)
|
||||
except PermissionError:
|
||||
print('Could not change permissions for: ' + os.path.join(dirpath, filename) + ' to: ' + owner)
|
||||
pass
|
||||
|
||||
|
||||
def recursive_permissions(path, dir_mode=755, file_mode=644, topdir=True):
|
||||
"""
|
||||
Recursively chmod a path and contents to mode.
|
||||
Defaults to chmod top level directory but can be optionally
|
||||
toggled off when you want to chmod only contents of like a user's homedir vs homedir itself
|
||||
https://docs.python.org/3.6/library/os.html#os.walk
|
||||
"""
|
||||
|
||||
# Here we are converting the integers to string and then to octal.
|
||||
# so this function doesn't need to be called with 0o prefixed for the file and dir mode
|
||||
dir_mode = int(str(dir_mode), base=8)
|
||||
file_mode = int(str(file_mode), base=8)
|
||||
|
||||
if topdir:
|
||||
# Set chmod on top level path
|
||||
try:
|
||||
os.chmod(path, dir_mode)
|
||||
except:
|
||||
print('Could not chmod :' + path + ' to ' + str(dir_mode))
|
||||
for root, dirs, files in os.walk(path):
|
||||
for d in dirs:
|
||||
try:
|
||||
os.chmod(os.path.join(root, d), dir_mode)
|
||||
except:
|
||||
print('Could not chmod :' + os.path.join(root, d) + ' to ' + str(dir_mode))
|
||||
pass
|
||||
for f in files:
|
||||
try:
|
||||
os.chmod(os.path.join(root, f), file_mode)
|
||||
except:
|
||||
print('Could not chmod :' + path + ' to ' + str(file_mode))
|
||||
pass
|
||||
|
||||
|
||||
# Left intentionally here for reference.
|
||||
# Set recursive chown for a path
|
||||
# recursive_chown(my_path, 'root', 'root')
|
||||
# for changing group recursively without affecting user
|
||||
# recursive_chown('/usr/local/lscp/cyberpanel/rainloop/data', -1, 'lscpd')
|
||||
|
||||
# explicitly set permissions for directories/folders to 0755 and files to 0644
|
||||
# recursive_permissions(my_path, 755, 644)
|
||||
|
||||
# Fix permissions and use default values
|
||||
# recursive_permissions(my_path)
|
||||
# =========================================================
|
||||
# Below is a helper class for getting and working with permissions
|
||||
# Original credits to : https://github.com/keysemble/perfm
|
||||
|
||||
def perm_octal_digit(rwx):
|
||||
digit = 0
|
||||
if rwx[0] == 'r':
|
||||
digit += 4
|
||||
if rwx[1] == 'w':
|
||||
digit += 2
|
||||
if rwx[2] == 'x':
|
||||
digit += 1
|
||||
return digit
|
||||
|
||||
|
||||
class FilePerm:
|
||||
def __init__(self, filepath):
|
||||
filemode = stat.filemode(os.stat(filepath).st_mode)
|
||||
permissions = [filemode[-9:][i:i + 3] for i in range(0, len(filemode[-9:]), 3)]
|
||||
self.filepath = filepath
|
||||
self.access_dict = dict(zip(['user', 'group', 'other'], [list(perm) for perm in permissions]))
|
||||
|
||||
def mode(self):
|
||||
mode = 0
|
||||
for shift, digit in enumerate(self.octal()[::-1]):
|
||||
mode += digit << (shift * 3)
|
||||
return mode
|
||||
|
||||
def digits(self):
|
||||
"""Get the octal chmod equivalent value 755 in single string"""
|
||||
return "".join(map(str, self.octal()))
|
||||
|
||||
def octal(self):
|
||||
"""Get the octal value in a list [7, 5, 5]"""
|
||||
return [perm_octal_digit(p) for p in self.access_dict.values()]
|
||||
|
||||
def access_bits(self, access):
|
||||
if access in self.access_dict.keys():
|
||||
r, w, x = self.access_dict[access]
|
||||
return [r == 'r', w == 'w', x == 'x']
|
||||
|
||||
def update_bitwise(self, settings):
|
||||
def perm_list(read=False, write=False, execute=False):
|
||||
pl = ['-', '-', '-']
|
||||
if read:
|
||||
pl[0] = 'r'
|
||||
if write:
|
||||
pl[1] = 'w'
|
||||
if execute:
|
||||
pl[2] = 'x'
|
||||
return pl
|
||||
|
||||
self.access_dict = dict(
|
||||
[(access, perm_list(read=r, write=w, execute=x)) for access, [r, w, x] in settings.items()])
|
||||
os.chmod(self.filepath, self.mode())
|
||||
|
||||
# project_directory = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
# home_directory = os.path.expanduser('~')
|
||||
# print(f'Path: {home_directory} Mode: {FilePerm(home_directory).mode()} Octal: {FilePerm(home_directory).octal()} '
|
||||
# f'Digits: {FilePerm(home_directory).digits()}')
|
||||
# Example: Output
|
||||
# Path: /home/cooluser Mode: 493 Octal: [7, 5, 5] Digits: 755
|
||||
|
|
@ -238,6 +238,5 @@ def main():
|
|||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -121,7 +121,7 @@ class FTPUtilities:
|
|||
path = path.lstrip("/")
|
||||
|
||||
if path != 'None':
|
||||
path = "/home/" + domainName + "/public_html/" + path
|
||||
path = "/home/" + domainName + "/" + path
|
||||
|
||||
## Security Check
|
||||
|
||||
|
|
|
|||
|
|
@ -13,36 +13,44 @@ class httpProc:
|
|||
|
||||
def render(self):
|
||||
try:
|
||||
from loginSystem.models import Administrator
|
||||
from plogical.acl import ACLManager
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
try:
|
||||
from loginSystem.models import Administrator
|
||||
from plogical.acl import ACLManager
|
||||
|
||||
### Permissions Check
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
if self.function != None:
|
||||
if not currentACL['admin']:
|
||||
if not currentACL[self.function]:
|
||||
templateName = 'baseTemplate/error.html'
|
||||
return render(self.request, templateName, {'error_message': 'You are not authorized to access %s' % (self.function)})
|
||||
### Permissions Check
|
||||
|
||||
###
|
||||
if self.function != None:
|
||||
if not currentACL['admin']:
|
||||
if not currentACL[self.function]:
|
||||
templateName = 'baseTemplate/error.html'
|
||||
return render(self.request, templateName, {'error_message': 'You are not authorized to access %s' % (self.function)})
|
||||
|
||||
if self.data == None:
|
||||
self.data = {}
|
||||
###
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
self.data['ipAddress'] = ipAddress
|
||||
if self.data == None:
|
||||
self.data = {}
|
||||
|
||||
self.data.update(currentACL)
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
self.data['ipAddress'] = ipAddress
|
||||
self.data['fullName'] = '%s %s' % (admin.firstName, admin.lastName)
|
||||
|
||||
return render(self.request, self.templateName, self.data)
|
||||
except BaseException as msg:
|
||||
templateName = 'baseTemplate/error.html'
|
||||
return render(self.request, templateName, {'error_message': str(msg)})
|
||||
self.data.update(currentACL)
|
||||
|
||||
return render(self.request, self.templateName, self.data)
|
||||
except BaseException as msg:
|
||||
templateName = 'baseTemplate/error.html'
|
||||
return render(self.request, templateName, {'error_message': str(msg)})
|
||||
except:
|
||||
from loginSystem.views import loadLoginPage
|
||||
from django.shortcuts import redirect
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def renderPre(self):
|
||||
if self.data == None:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
import json
|
||||
import os,sys
|
||||
|
||||
from django.http import HttpResponse
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
import django
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
|
|
@ -17,6 +21,7 @@ import os
|
|||
import bcrypt
|
||||
import getpass
|
||||
import smtplib
|
||||
import threading as multi
|
||||
|
||||
try:
|
||||
from mailServer.models import Domains, EUsers
|
||||
|
|
@ -213,6 +218,9 @@ class mailUtilities:
|
|||
try:
|
||||
## Generate DKIM Keys
|
||||
|
||||
command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.6/site-packages/tldextract/.suffix_cache'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
import tldextract
|
||||
|
||||
actualDomain = virtualHostName
|
||||
|
|
@ -734,6 +742,872 @@ milter_default_action = accept
|
|||
str(msg) + " [checkIfMailScannerInstalled]")
|
||||
return 0
|
||||
|
||||
####### Imported below functions from mailserver/mailservermanager, need to refactor later
|
||||
|
||||
class MailServerManagerUtils(multi.Thread):
|
||||
|
||||
def __init__(self, request=None, function=None, extraArgs=None):
|
||||
multi.Thread.__init__(self)
|
||||
self.request = request
|
||||
self.function = function
|
||||
self.extraArgs = extraArgs
|
||||
self.MailSSL = 0
|
||||
|
||||
def checkIfMailServerSSLIssued(self):
|
||||
|
||||
postfixPath = '/etc/postfix/main.cf'
|
||||
|
||||
postFixData = ProcessUtilities.outputExecutioner('cat %s' % (postfixPath))
|
||||
|
||||
if postFixData.find('myhostname = server.example.com') > -1:
|
||||
self.MailSSL = 0
|
||||
return 0
|
||||
else:
|
||||
try:
|
||||
|
||||
postFixLines = ProcessUtilities.outputExecutioner('cat %s' % (postfixPath)).splitlines()
|
||||
|
||||
for items in postFixLines:
|
||||
if items.find('myhostname') > -1 and items[0] != '#':
|
||||
self.mailHostName = items.split('=')[1].strip(' ')
|
||||
self.MailSSL = 1
|
||||
except BaseException as msg:
|
||||
self.MailSSL = 0
|
||||
logging.CyberCPLogFileWriter.writeToFile('%s. [checkIfMailServerSSLIssued:864]' % (str(msg)))
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
|
||||
command = 'openssl s_client -connect %s:465' % (ipAddress)
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if result.find('18 (self signed certificate)') > -1:
|
||||
return 0
|
||||
else:
|
||||
return 1
|
||||
|
||||
def RunServerLevelEmailChecks(self):
|
||||
try:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Checking if MailServer SSL issued..,10')
|
||||
|
||||
reportFile = self.extraArgs['reportFile']
|
||||
|
||||
report = {}
|
||||
report['MailSSL'] = self.checkIfMailServerSSLIssued()
|
||||
|
||||
writeToFile = open(reportFile, 'w')
|
||||
writeToFile.write(json.dumps(report))
|
||||
writeToFile.close()
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Completed [200].')
|
||||
|
||||
except BaseException as msg:
|
||||
final_dic = {'installOpenDKIM': 0, 'error_message': str(msg)}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def install_postfix_dovecot(self):
|
||||
try:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'yum remove postfix -y'
|
||||
ProcessUtilities.executioner(command)
|
||||
elif ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
command = 'apt-get -y remove postfix'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
### On Ubuntu 18 find if old dovecot and remove
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
try:
|
||||
|
||||
command = 'apt-get purge dovecot* -y'
|
||||
os.system(command)
|
||||
|
||||
command = 'apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 18A348AEED409DA1'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
writeToFile = open('/etc/apt/sources.list.d/dovecot.list', 'a')
|
||||
writeToFile.writelines('deb [arch=amd64] https://repo.dovecot.org/ce-2.3-latest/ubuntu/bionic bionic main\n')
|
||||
writeToFile.close()
|
||||
|
||||
command = 'apt update'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
##
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Re-installing postfix..,10')
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
|
||||
command = 'yum --nogpg install https://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm -y'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'yum install --enablerepo=gf-plus -y postfix3 postfix3-ldap postfix3-mysql postfix3-pcre'
|
||||
elif ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
|
||||
command = 'dnf --nogpg install -y https://mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-11.gf.el8.noarch.rpm'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'dnf install --enablerepo=gf-plus postfix3 postfix3-mysql -y'
|
||||
ProcessUtilities.executioner(command)
|
||||
else:
|
||||
|
||||
|
||||
import socket
|
||||
command = 'apt-get install -y debconf-utils'
|
||||
ProcessUtilities.executioner(command)
|
||||
file_name = 'pf.unattend.text'
|
||||
pf = open(file_name, 'w')
|
||||
pf.write('postfix postfix/mailname string ' + str(socket.getfqdn() + '\n'))
|
||||
pf.write('postfix postfix/main_mailer_type string "Internet Site"\n')
|
||||
pf.close()
|
||||
command = 'debconf-set-selections ' + file_name
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'apt-get -y install postfix postfix-mysql'
|
||||
# os.remove(file_name)
|
||||
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Re-installing Dovecot..,15')
|
||||
|
||||
##
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
command = 'yum --enablerepo=gf-plus -y install dovecot23 dovecot23-mysql'
|
||||
ProcessUtilities.executioner(command)
|
||||
elif ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'dnf install --enablerepo=gf-plus dovecot23 dovecot23-mysql -y'
|
||||
ProcessUtilities.executioner(command)
|
||||
else:
|
||||
command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install dovecot-mysql dovecot-imapd dovecot-pop3d'
|
||||
os.system(command)
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Postfix/dovecot reinstalled.,40')
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'%s [install_postfix_dovecot][404]' % (str(msg)), 10)
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
def setup_email_Passwords(self, mysqlPassword):
|
||||
try:
|
||||
|
||||
mysql_virtual_domains = "/usr/local/CyberCP/install/email-configs-one/mysql-virtual_domains.cf"
|
||||
mysql_virtual_forwardings = "/usr/local/CyberCP/install/email-configs-one/mysql-virtual_forwardings.cf"
|
||||
mysql_virtual_mailboxes = "/usr/local/CyberCP/install/email-configs-one/mysql-virtual_mailboxes.cf"
|
||||
mysql_virtual_email2email = "/usr/local/CyberCP/install/email-configs-one/mysql-virtual_email2email.cf"
|
||||
dovecotmysql = "/usr/local/CyberCP/install/email-configs-one/dovecot-sql.conf.ext"
|
||||
|
||||
### update password:
|
||||
|
||||
data = open(dovecotmysql, "r").readlines()
|
||||
|
||||
writeDataToFile = open(dovecotmysql, "w")
|
||||
|
||||
dataWritten = "connect = host=localhost dbname=cyberpanel user=cyberpanel password=" + mysqlPassword + " port=3306\n"
|
||||
|
||||
for items in data:
|
||||
if items.find("connect") > -1:
|
||||
writeDataToFile.writelines(dataWritten)
|
||||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
# if self.distro == ubuntu:
|
||||
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
### update password:
|
||||
|
||||
data = open(mysql_virtual_domains, "r").readlines()
|
||||
|
||||
writeDataToFile = open(mysql_virtual_domains, "w")
|
||||
|
||||
dataWritten = "password = " + mysqlPassword + "\n"
|
||||
|
||||
for items in data:
|
||||
if items.find("password") > -1:
|
||||
writeDataToFile.writelines(dataWritten)
|
||||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
# if self.distro == ubuntu:
|
||||
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
### update password:
|
||||
|
||||
data = open(mysql_virtual_forwardings, "r").readlines()
|
||||
|
||||
writeDataToFile = open(mysql_virtual_forwardings, "w")
|
||||
|
||||
dataWritten = "password = " + mysqlPassword + "\n"
|
||||
|
||||
for items in data:
|
||||
if items.find("password") > -1:
|
||||
writeDataToFile.writelines(dataWritten)
|
||||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
# if self.distro == ubuntu:
|
||||
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
### update password:
|
||||
|
||||
data = open(mysql_virtual_mailboxes, "r").readlines()
|
||||
|
||||
writeDataToFile = open(mysql_virtual_mailboxes, "w")
|
||||
|
||||
dataWritten = "password = " + mysqlPassword + "\n"
|
||||
|
||||
for items in data:
|
||||
if items.find("password") > -1:
|
||||
writeDataToFile.writelines(dataWritten)
|
||||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
# if self.distro == ubuntu:
|
||||
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
### update password:
|
||||
|
||||
data = open(mysql_virtual_email2email, "r").readlines()
|
||||
|
||||
writeDataToFile = open(mysql_virtual_email2email, "w")
|
||||
|
||||
dataWritten = "password = " + mysqlPassword + "\n"
|
||||
|
||||
for items in data:
|
||||
if items.find("password") > -1:
|
||||
writeDataToFile.writelines(dataWritten)
|
||||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
# if self.distro == ubuntu:
|
||||
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
if self.remotemysql == 'ON':
|
||||
command = "sed -i 's|host=localhost|host=%s|g' %s" % (self.mysqlhost, dovecotmysql)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "sed -i 's|port=3306|port=%s|g' %s" % (self.mysqlport, dovecotmysql)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = "sed -i 's|localhost|%s:%s|g' %s" % (self.mysqlhost, self.mysqlport, mysql_virtual_domains)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "sed -i 's|localhost|%s:%s|g' %s" % (
|
||||
self.mysqlhost, self.mysqlport, mysql_virtual_forwardings)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "sed -i 's|localhost|%s:%s|g' %s" % (
|
||||
self.mysqlhost, self.mysqlport, mysql_virtual_mailboxes)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "sed -i 's|localhost|%s:%s|g' %s" % (
|
||||
self.mysqlhost, self.mysqlport, mysql_virtual_email2email)
|
||||
ProcessUtilities.executioner(command)
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'%s [setup_email_Passwords][404]' % (str(msg)), 10)
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
def centos_lib_dir_to_ubuntu(self, filename, old, new):
|
||||
try:
|
||||
fd = open(filename, 'r')
|
||||
lines = fd.readlines()
|
||||
fd.close()
|
||||
fd = open(filename, 'w')
|
||||
centos_prefix = old
|
||||
ubuntu_prefix = new
|
||||
for line in lines:
|
||||
index = line.find(centos_prefix)
|
||||
if index != -1:
|
||||
line = line[:index] + ubuntu_prefix + line[index + len(centos_prefix):]
|
||||
fd.write(line)
|
||||
fd.close()
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'%s [centos_lib_dir_to_ubuntu][404]' % (str(msg)), 10)
|
||||
|
||||
def setup_postfix_dovecot_config(self):
|
||||
try:
|
||||
|
||||
mysql_virtual_domains = "/etc/postfix/mysql-virtual_domains.cf"
|
||||
mysql_virtual_forwardings = "/etc/postfix/mysql-virtual_forwardings.cf"
|
||||
mysql_virtual_mailboxes = "/etc/postfix/mysql-virtual_mailboxes.cf"
|
||||
mysql_virtual_email2email = "/etc/postfix/mysql-virtual_email2email.cf"
|
||||
main = "/etc/postfix/main.cf"
|
||||
master = "/etc/postfix/master.cf"
|
||||
dovecot = "/etc/dovecot/dovecot.conf"
|
||||
dovecotmysql = "/etc/dovecot/dovecot-sql.conf.ext"
|
||||
|
||||
if os.path.exists(mysql_virtual_domains):
|
||||
os.remove(mysql_virtual_domains)
|
||||
|
||||
if os.path.exists(mysql_virtual_forwardings):
|
||||
os.remove(mysql_virtual_forwardings)
|
||||
|
||||
if os.path.exists(mysql_virtual_mailboxes):
|
||||
os.remove(mysql_virtual_mailboxes)
|
||||
|
||||
if os.path.exists(mysql_virtual_email2email):
|
||||
os.remove(mysql_virtual_email2email)
|
||||
|
||||
if os.path.exists(main):
|
||||
os.remove(main)
|
||||
|
||||
if os.path.exists(master):
|
||||
os.remove(master)
|
||||
|
||||
if os.path.exists(dovecot):
|
||||
os.remove(dovecot)
|
||||
|
||||
if os.path.exists(dovecotmysql):
|
||||
os.remove(dovecotmysql)
|
||||
|
||||
###############Getting SSL
|
||||
|
||||
command = 'openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /etc/postfix/key.pem -out /etc/postfix/cert.pem'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /etc/dovecot/key.pem -out /etc/dovecot/cert.pem'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
# Cleanup config files for ubuntu
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
self.centos_lib_dir_to_ubuntu("/usr/local/CyberCP/install/email-configs-one/master.cf", "/usr/libexec/",
|
||||
"/usr/lib/")
|
||||
self.centos_lib_dir_to_ubuntu("/usr/local/CyberCP/install/email-configs-one/main.cf",
|
||||
"/usr/libexec/postfix",
|
||||
"/usr/lib/postfix/sbin")
|
||||
|
||||
########### Copy config files
|
||||
import shutil
|
||||
|
||||
shutil.copy("/usr/local/CyberCP/install/email-configs-one/mysql-virtual_domains.cf",
|
||||
"/etc/postfix/mysql-virtual_domains.cf")
|
||||
shutil.copy("/usr/local/CyberCP/install/email-configs-one/mysql-virtual_forwardings.cf",
|
||||
"/etc/postfix/mysql-virtual_forwardings.cf")
|
||||
shutil.copy("/usr/local/CyberCP/install/email-configs-one/mysql-virtual_mailboxes.cf",
|
||||
"/etc/postfix/mysql-virtual_mailboxes.cf")
|
||||
shutil.copy("/usr/local/CyberCP/install/email-configs-one/mysql-virtual_email2email.cf",
|
||||
"/etc/postfix/mysql-virtual_email2email.cf")
|
||||
shutil.copy("/usr/local/CyberCP/install/email-configs-one/main.cf", main)
|
||||
shutil.copy("/usr/local/CyberCP/install/email-configs-one/master.cf", master)
|
||||
shutil.copy("/usr/local/CyberCP/install/email-configs-one/dovecot.conf", dovecot)
|
||||
shutil.copy("/usr/local/CyberCP/install/email-configs-one/dovecot-sql.conf.ext", dovecotmysql)
|
||||
|
||||
######################################## Permissions
|
||||
|
||||
command = 'chmod o= /etc/postfix/mysql-virtual_domains.cf'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'chmod o= /etc/postfix/mysql-virtual_forwardings.cf'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'chmod o= /etc/postfix/mysql-virtual_mailboxes.cf'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'chmod o= /etc/postfix/mysql-virtual_email2email.cf'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'chmod o= ' + main
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'chmod o= ' + master
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
#######################################
|
||||
|
||||
command = 'chgrp postfix /etc/postfix/mysql-virtual_domains.cf'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'chgrp postfix /etc/postfix/mysql-virtual_forwardings.cf'
|
||||
ProcessUtilities.executioner(command)
|
||||
##
|
||||
|
||||
command = 'chgrp postfix /etc/postfix/mysql-virtual_mailboxes.cf'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'chgrp postfix /etc/postfix/mysql-virtual_email2email.cf'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'chgrp postfix ' + main
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'chgrp postfix ' + master
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
######################################## users and groups
|
||||
|
||||
command = 'groupadd -g 5000 vmail'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'useradd -g vmail -u 5000 vmail -d /home/vmail -m'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
######################################## Further configurations
|
||||
|
||||
# hostname = socket.gethostname()
|
||||
|
||||
################################### Restart postix
|
||||
|
||||
command = 'systemctl enable postfix.service'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'systemctl start postfix.service'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
######################################## Permissions
|
||||
|
||||
command = 'chgrp dovecot /etc/dovecot/dovecot-sql.conf.ext'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'chmod o= /etc/dovecot/dovecot-sql.conf.ext'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
################################### Restart dovecot
|
||||
|
||||
command = 'systemctl enable dovecot.service'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'systemctl start dovecot.service'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = 'systemctl restart postfix.service'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## changing permissions for main.cf
|
||||
|
||||
command = "chmod 755 " + main
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
command = "mkdir -p /etc/pki/dovecot/private/"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "mkdir -p /etc/pki/dovecot/certs/"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "mkdir -p /etc/opendkim/keys/"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "sed -i 's/auth_mechanisms = plain/#auth_mechanisms = plain/g' /etc/dovecot/conf.d/10-auth.conf"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## Ubuntu 18.10 ssl_dh for dovecot 2.3.2.1
|
||||
|
||||
if ProcessUtilities.ubuntu:
|
||||
dovecotConf = '/etc/dovecot/dovecot.conf'
|
||||
|
||||
data = open(dovecotConf, 'r').readlines()
|
||||
writeToFile = open(dovecotConf, 'w')
|
||||
for items in data:
|
||||
if items.find('ssl_key = <key.pem') > -1:
|
||||
writeToFile.writelines(items)
|
||||
writeToFile.writelines('ssl_dh = </usr/share/dovecot/dh.pem\n')
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
writeToFile.close()
|
||||
|
||||
command = "systemctl restart dovecot"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## For ubuntu 20
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
|
||||
command = "sed -i 's|daemon_directory = /usr/libexec/postfix|daemon_directory = /usr/lib/postfix/sbin|g' /etc/postfix/main.cf"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'%s [setup_postfix_dovecot_config][404]' % (
|
||||
str(msg)), 10)
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
def fixCyberPanelPermissions(self):
|
||||
|
||||
###### fix Core CyberPanel permissions
|
||||
command = "find /usr/local/CyberCP -type d -exec chmod 0755 {} \;"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "find /usr/local/CyberCP -type f -exec chmod 0644 {} \;"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "chmod -R 755 /usr/local/CyberCP/bin"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## change owner
|
||||
|
||||
command = "chown -R root:root /usr/local/CyberCP"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
########### Fix LSCPD
|
||||
|
||||
command = "find /usr/local/lscp -type d -exec chmod 0755 {} \;"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "find /usr/local/lscp -type f -exec chmod 0644 {} \;"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "chmod -R 755 /usr/local/lscp/bin"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "chmod -R 755 /usr/local/lscp/fcgi-bin"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin/tmp"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## change owner
|
||||
|
||||
command = "chown -R root:root /usr/local/lscp"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/rainloop/data"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "chmod 700 /usr/local/CyberCP/cli/cyberPanel.py"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "chmod 700 /usr/local/CyberCP/plogical/upgradeCritical.py"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "chmod 755 /usr/local/CyberCP/postfixSenderPolicy/client.py"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "chmod 640 /usr/local/CyberCP/CyberCP/settings.py"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "chown root:cyberpanel /usr/local/CyberCP/CyberCP/settings.py"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
files = ['/etc/yum.repos.d/MariaDB.repo', '/etc/pdns/pdns.conf', '/etc/systemd/system/lscpd.service',
|
||||
'/etc/pure-ftpd/pure-ftpd.conf', '/etc/pure-ftpd/pureftpd-pgsql.conf',
|
||||
'/etc/pure-ftpd/pureftpd-mysql.conf', '/etc/pure-ftpd/pureftpd-ldap.conf',
|
||||
'/etc/dovecot/dovecot.conf', '/usr/local/lsws/conf/httpd_config.xml',
|
||||
'/usr/local/lsws/conf/modsec.conf', '/usr/local/lsws/conf/httpd.conf']
|
||||
|
||||
for items in files:
|
||||
command = 'chmod 644 %s' % (items)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
impFile = ['/etc/pure-ftpd/pure-ftpd.conf', '/etc/pure-ftpd/pureftpd-pgsql.conf',
|
||||
'/etc/pure-ftpd/pureftpd-mysql.conf', '/etc/pure-ftpd/pureftpd-ldap.conf',
|
||||
'/etc/dovecot/dovecot.conf', '/etc/pdns/pdns.conf', '/etc/pure-ftpd/db/mysql.conf',
|
||||
'/etc/powerdns/pdns.conf']
|
||||
|
||||
for items in impFile:
|
||||
command = 'chmod 600 %s' % (items)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'chmod 640 /etc/postfix/*.cf'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'chmod 644 /etc/postfix/main.cf'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'chmod 640 /etc/dovecot/*.conf'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'chmod 644 /etc/dovecot/dovecot.conf'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'chmod 640 /etc/dovecot/dovecot-sql.conf.ext'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'chmod 644 /etc/postfix/dynamicmaps.cf'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
fileM = ['/usr/local/lsws/FileManager/', '/usr/local/CyberCP/install/FileManager',
|
||||
'/usr/local/CyberCP/serverStatus/litespeed/FileManager', '/usr/local/lsws/Example/html/FileManager']
|
||||
|
||||
for items in fileM:
|
||||
try:
|
||||
import shutil
|
||||
shutil.rmtree(items)
|
||||
except:
|
||||
pass
|
||||
|
||||
command = 'chmod 755 /etc/pure-ftpd/'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'chmod +x /usr/local/CyberCP/plogical/renew.py'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'chmod +x /usr/local/CyberCP/CLManager/CLPackages.py'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
clScripts = ['/usr/local/CyberCP/CLScript/panel_info.py', '/usr/local/CyberCP/CLScript/CloudLinuxPackages.py',
|
||||
'/usr/local/CyberCP/CLScript/CloudLinuxUsers.py',
|
||||
'/usr/local/CyberCP/CLScript/CloudLinuxDomains.py'
|
||||
, '/usr/local/CyberCP/CLScript/CloudLinuxResellers.py', '/usr/local/CyberCP/CLScript/CloudLinuxAdmins.py',
|
||||
'/usr/local/CyberCP/CLScript/CloudLinuxDB.py', '/usr/local/CyberCP/CLScript/UserInfo.py']
|
||||
|
||||
for items in clScripts:
|
||||
command = 'chmod +x %s' % (items)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'chmod 600 /usr/local/CyberCP/plogical/adminPass.py'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'chmod 600 /etc/cagefs/exclude/cyberpanelexclude'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "find /usr/local/CyberCP/ -name '*.pyc' -delete"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.cent8:
|
||||
command = 'chown root:pdns /etc/pdns/pdns.conf'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'chmod 640 /etc/pdns/pdns.conf'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'chmod 640 /usr/local/lscp/cyberpanel/logs/access.log'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
###
|
||||
|
||||
def ResetEmailConfigurations(self):
|
||||
try:
|
||||
### Check if remote or local mysql
|
||||
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
|
||||
try:
|
||||
jsonData = json.loads(ProcessUtilities.outputExecutioner('cat %s' % (passFile)))
|
||||
|
||||
self.mysqluser = jsonData['mysqluser']
|
||||
self.mysqlpassword = jsonData['mysqlpassword']
|
||||
self.mysqlport = jsonData['mysqlport']
|
||||
self.mysqlhost = jsonData['mysqlhost']
|
||||
self.remotemysql = 'ON'
|
||||
|
||||
if self.mysqlhost.find('rds.amazon') > -1:
|
||||
self.RDS = 1
|
||||
|
||||
## Also set localhost to this server
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddressLocal = ipData.split('\n', 1)[0]
|
||||
|
||||
self.LOCALHOST = ipAddressLocal
|
||||
except BaseException as msg:
|
||||
self.remotemysql = 'OFF'
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile('%s. [setupConnection:75]' % (str(msg)))
|
||||
|
||||
###
|
||||
|
||||
self.checkIfMailServerSSLIssued()
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Removing and re-installing postfix/dovecot..,5')
|
||||
|
||||
if self.install_postfix_dovecot() == 0:
|
||||
return 0
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Resetting configurations..,40')
|
||||
|
||||
import sys
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
from CyberCP import settings
|
||||
|
||||
if self.setup_email_Passwords(settings.DATABASES['default']['PASSWORD']) == 0:
|
||||
return 0
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Configurations reset..,70')
|
||||
|
||||
if self.setup_postfix_dovecot_config() == 0:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'setup_postfix_dovecot_config failed. [404].')
|
||||
return 0
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Restoring OpenDKIM configurations..,70')
|
||||
|
||||
if self.configureOpenDKIM() == 0:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'configureOpenDKIM failed. [404].')
|
||||
return 0
|
||||
|
||||
if self.MailSSL:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Setting up Mail Server SSL if any..,75')
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
virtualHostUtilities.issueSSLForMailServer(self.mailHostName,
|
||||
'/home/%s/public_html' % (self.mailHostName))
|
||||
|
||||
from websiteFunctions.models import ChildDomains
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
for websites in Websites.objects.all():
|
||||
try:
|
||||
child = ChildDomains.objects.get(domain='mail.%s' % (websites.domain))
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Creating mail domain for %s..,80' % (websites.domain))
|
||||
virtualHostUtilities.setupAutoDiscover(1, '/dev/null', websites.domain, websites.admin)
|
||||
except:
|
||||
pass
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Fixing permissions..,90')
|
||||
|
||||
self.fixCyberPanelPermissions()
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Completed [200].')
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Failed. Error %s [404].' % str(msg))
|
||||
|
||||
def configureOpenDKIM(self):
|
||||
try:
|
||||
|
||||
## Configure OpenDKIM specific settings
|
||||
|
||||
openDKIMConfigurePath = "/etc/opendkim.conf"
|
||||
|
||||
configData = """
|
||||
Mode sv
|
||||
Canonicalization relaxed/simple
|
||||
KeyTable refile:/etc/opendkim/KeyTable
|
||||
SigningTable refile:/etc/opendkim/SigningTable
|
||||
ExternalIgnoreList refile:/etc/opendkim/TrustedHosts
|
||||
InternalHosts refile:/etc/opendkim/TrustedHosts
|
||||
"""
|
||||
|
||||
writeToFile = open(openDKIMConfigurePath, 'a')
|
||||
writeToFile.write(configData)
|
||||
writeToFile.close()
|
||||
|
||||
## Configure postfix specific settings
|
||||
|
||||
postfixFilePath = "/etc/postfix/main.cf"
|
||||
|
||||
configData = """
|
||||
smtpd_milters = inet:127.0.0.1:8891
|
||||
non_smtpd_milters = $smtpd_milters
|
||||
milter_default_action = accept
|
||||
"""
|
||||
|
||||
writeToFile = open(postfixFilePath, 'a')
|
||||
writeToFile.write(configData)
|
||||
writeToFile.close()
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
data = open(openDKIMConfigurePath, 'r').readlines()
|
||||
writeToFile = open(openDKIMConfigurePath, 'w')
|
||||
for items in data:
|
||||
if items.find('Socket') > -1 and items.find('local:') and items[0] != '#':
|
||||
writeToFile.writelines('Socket inet:8891@localhost\n')
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
writeToFile.close()
|
||||
|
||||
#### Restarting Postfix and OpenDKIM
|
||||
|
||||
command = "systemctl start opendkim"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "systemctl enable opendkim"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = "systemctl restart postfix"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
return 1
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'configureOpenDKIM failed. Error %s [404].' % str(msg))
|
||||
return 0
|
||||
|
||||
def debugEmailForSite(self, websiteName):
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
|
||||
try:
|
||||
import socket
|
||||
siteIPAddr = socket.gethostbyname('mail.%s' % (websiteName))
|
||||
|
||||
if siteIPAddr != ipAddress:
|
||||
return 0, 'mail.%s does not point to %s.' % (websiteName, ipAddress)
|
||||
except:
|
||||
return 0, 'mail.%s does not point to %s.' % (websiteName, ipAddress)
|
||||
|
||||
command = 'openssl s_client -connect mail.%s:993' % (websiteName)
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if result.find('18 (self signed certificate)') > -1:
|
||||
return 0, 'No valid SSL on port 993.'
|
||||
else:
|
||||
return 1, 'All checks are OK.'
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
|
|
@ -744,6 +1618,7 @@ def main():
|
|||
parser.add_argument('--password', help='Email password!')
|
||||
parser.add_argument('--tempConfigPath', help='Temporary Configuration Path!')
|
||||
parser.add_argument('--install', help='Enable/Disable Policy Server!')
|
||||
parser.add_argument('--tempStatusPath', help='Path of temporary status file.')
|
||||
|
||||
|
||||
|
||||
|
|
@ -767,6 +1642,10 @@ def main():
|
|||
mailUtilities.installMailScanner("install", "installMailScanner")
|
||||
elif args.function == 'AfterEffects':
|
||||
mailUtilities.AfterEffects(args.domain)
|
||||
elif args.function == "ResetEmailConfigurations":
|
||||
extraArgs = {'tempStatusPath': args.tempStatusPath}
|
||||
background = MailServerManagerUtils(None, 'ResetEmailConfigurations', extraArgs)
|
||||
background.ResetEmailConfigurations()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -931,7 +931,7 @@ password=%s
|
|||
|
||||
data = open(cnfPath, 'r').read()
|
||||
|
||||
if data.find('bind-address') > -1 and data.find('skip-name-resolve') > -1:
|
||||
if data.find('bind-address'):
|
||||
print('1,None')
|
||||
return 1
|
||||
else:
|
||||
|
|
@ -943,7 +943,6 @@ password=%s
|
|||
mysqldContent = '''
|
||||
[mysqld]
|
||||
bind-address=%s
|
||||
skip-name-resolve
|
||||
''' % (ipAddressLocal)
|
||||
|
||||
writeToFile = open(cnfPath, 'a')
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/local/CyberCP/bin/python
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
import django
|
||||
|
|
@ -15,9 +16,11 @@ import argparse
|
|||
try:
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
class restoreMeta():
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -104,37 +107,65 @@ class restoreMeta():
|
|||
website = Websites.objects.get(domain=masterDomain)
|
||||
|
||||
for database in databases:
|
||||
|
||||
dbName = database.find('dbName').text
|
||||
dbUser = database.find('dbUser').text
|
||||
dbPassword = database.find('password').text
|
||||
|
||||
try:
|
||||
dbExist = Databases.objects.get(dbName=dbName)
|
||||
logging.statusWriter(statusPath, 'Database exists, changing Database password.. %s' % (dbName))
|
||||
mysqlUtilities.mysqlUtilities.changePassword(dbUser, dbPassword, 1)
|
||||
if mysqlUtilities.mysqlUtilities.changePassword(dbUser, dbPassword, 1) == 0:
|
||||
logging.statusWriter(statusPath, 'Failed changing password for database: %s' % (dbName))
|
||||
else:
|
||||
logging.statusWriter(statusPath, 'Password successfully changed for database: %s.' % (dbName))
|
||||
except:
|
||||
logging.statusWriter(statusPath, 'Database did not exist, creating new.. %s' % (dbName))
|
||||
if mysqlUtilities.mysqlUtilities.createDatabase(dbName, dbUser, "cyberpanel") == 0:
|
||||
logging.statusWriter(statusPath, 'Failed the creation of database: %s' % (dbName))
|
||||
else:
|
||||
logging.statusWriter(statusPath, 'Database: %s successfully created.' % (dbName))
|
||||
logging.writeToFile('Backup version 2.1.1 detected..')
|
||||
|
||||
mysqlUtilities.mysqlUtilities.changePassword(dbUser, dbPassword, 1)
|
||||
if mysqlUtilities.mysqlUtilities.changePassword(dbUser, dbPassword, 1) == 0:
|
||||
logging.statusWriter(statusPath, 'Failed changing password for database: %s' % (dbName))
|
||||
else:
|
||||
logging.statusWriter(statusPath, 'Password successfully changed for database: %s.' % (dbName))
|
||||
first = 1
|
||||
|
||||
databaseUsers = database.findall('databaseUsers')
|
||||
|
||||
try:
|
||||
newDB = Databases(website=website, dbName=dbName, dbUser=dbUser)
|
||||
newDB.save()
|
||||
except:
|
||||
pass
|
||||
for databaseUser in databaseUsers:
|
||||
|
||||
dbUser = databaseUser.find('dbUser').text
|
||||
dbHost = databaseUser.find('dbHost').text
|
||||
password = databaseUser.find('password').text
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile('Database user: %s' % (dbUser))
|
||||
logging.writeToFile('Database host: %s' % (dbHost))
|
||||
logging.writeToFile('Database password: %s' % (password))
|
||||
|
||||
if first:
|
||||
|
||||
first = 0
|
||||
|
||||
try:
|
||||
dbExist = Databases.objects.get(dbName=dbName)
|
||||
logging.statusWriter(statusPath, 'Database exists, changing Database password.. %s' % (dbName))
|
||||
|
||||
if mysqlUtilities.mysqlUtilities.changePassword(dbUser, password, 1, dbHost) == 0:
|
||||
logging.statusWriter(statusPath, 'Failed changing password for database: %s' % (dbName))
|
||||
else:
|
||||
logging.statusWriter(statusPath, 'Password successfully changed for database: %s.' % (dbName))
|
||||
|
||||
except:
|
||||
|
||||
logging.statusWriter(statusPath, 'Database did not exist, creating new.. %s' % (dbName))
|
||||
|
||||
if mysqlUtilities.mysqlUtilities.createDatabase(dbName, dbUser, "cyberpanel") == 0:
|
||||
logging.statusWriter(statusPath, 'Failed the creation of database: %s' % (dbName))
|
||||
else:
|
||||
logging.statusWriter(statusPath, 'Database: %s successfully created.' % (dbName))
|
||||
|
||||
mysqlUtilities.mysqlUtilities.changePassword(dbUser, password, 1)
|
||||
|
||||
if mysqlUtilities.mysqlUtilities.changePassword(dbUser, password, 1) == 0:
|
||||
logging.statusWriter(statusPath, 'Failed changing password for database: %s' % (dbName))
|
||||
else:
|
||||
logging.statusWriter(statusPath, 'Password successfully changed for database: %s.' % (dbName))
|
||||
|
||||
try:
|
||||
newDB = Databases(website=website, dbName=dbName, dbUser=dbUser)
|
||||
newDB.save()
|
||||
except:
|
||||
pass
|
||||
|
||||
## This function will not create database, only database user is created as third value is 0 for createDB
|
||||
|
||||
mysqlUtilities.mysqlUtilities.createDatabase(dbName, dbUser, password, 0, dbHost)
|
||||
mysqlUtilities.mysqlUtilities.changePassword(dbUser, password, 1, dbHost)
|
||||
|
||||
|
||||
## Databases restored
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ class sslUtilities:
|
|||
|
||||
command = acmePath + " --issue -d " + virtualHostName + " -d www." + virtualHostName \
|
||||
+ ' --cert-file ' + existingCertPath + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \
|
||||
+ ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force'
|
||||
+ ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --server letsencrypt --force'
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile(command, 0)
|
||||
|
||||
|
|
@ -319,7 +319,7 @@ class sslUtilities:
|
|||
logging.CyberCPLogFileWriter.writeToFile("Trying to obtain SSL for: " + virtualHostName, 0)
|
||||
command = acmePath + " --issue -d " + virtualHostName + ' --cert-file ' + existingCertPath \
|
||||
+ '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \
|
||||
+ ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force'
|
||||
+ ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --server letsencrypt --force'
|
||||
output = subprocess.check_output(shlex.split(command)).decode("utf-8")
|
||||
logging.CyberCPLogFileWriter.writeToFile("Successfully obtained SSL for: " + virtualHostName, 0)
|
||||
finalText = '%s\nSuccessfully obtained SSL for: %s.' % (finalText, virtualHostName)
|
||||
|
|
|
|||
|
|
@ -448,7 +448,6 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
|||
count = 0
|
||||
|
||||
while (1):
|
||||
|
||||
command = 'find . -type f -exec chmod 644 {} \;'
|
||||
cmd = shlex.split(command)
|
||||
res = subprocess.call(cmd)
|
||||
|
|
@ -1839,13 +1838,13 @@ imap_folder_list_limit = 0
|
|||
if os.path.exists(lscpdPath):
|
||||
os.remove(lscpdPath)
|
||||
|
||||
command = 'cp -f /usr/local/CyberCP/lscpd-0.2.7 /usr/local/lscp/bin/lscpd-0.2.7'
|
||||
command = 'cp -f /usr/local/CyberCP/lscpd-0.3.1 /usr/local/lscp/bin/lscpd-0.3.1'
|
||||
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.7 /usr/local/lscp/bin/lscpd'
|
||||
command = 'mv /usr/local/lscp/bin/lscpd-0.3.1 /usr/local/lscp/bin/lscpd'
|
||||
Upgrade.executioner(command, command, 0)
|
||||
|
||||
command = 'chmod 755 %s' % (lscpdPath)
|
||||
|
|
@ -2075,6 +2074,8 @@ echo $oConfig->Save() ? 'Done' : 'Error';
|
|||
def AutoUpgradeAcme():
|
||||
command = '/root/.acme.sh/acme.sh --upgrade --auto-upgrade'
|
||||
Upgrade.executioner(command, command, 0)
|
||||
command = '/root/.acme.sh/acme.sh --set-default-ca --server letsencrypt'
|
||||
Upgrade.executioner(command, command, 0)
|
||||
|
||||
@staticmethod
|
||||
def installPHP73():
|
||||
|
|
@ -2406,6 +2407,23 @@ vmail
|
|||
writeToFile.write(content)
|
||||
writeToFile.close()
|
||||
|
||||
### Check and remove OLS restart if lsws ent detected
|
||||
|
||||
if not os.path.exists('/usr/local/lsws/bin/openlitespeed'):
|
||||
|
||||
data = open(cronPath, 'r').readlines()
|
||||
|
||||
writeToFile = open(cronPath, 'w')
|
||||
|
||||
for items in data:
|
||||
if items.find('-maxdepth 2 -type f -newer') > -1:
|
||||
pass
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
writeToFile.close()
|
||||
|
||||
|
||||
if not os.path.exists(CentOSPath):
|
||||
command = 'chmod 600 %s' % (cronPath)
|
||||
Upgrade.executioner(command, 0)
|
||||
|
|
@ -2528,12 +2546,18 @@ vmail
|
|||
Upgrade.setupCLI()
|
||||
Upgrade.someDirectories()
|
||||
Upgrade.installLSCPD(branch)
|
||||
Upgrade.GeneralMigrations()
|
||||
|
||||
### General migrations are not needed any more
|
||||
|
||||
# Upgrade.GeneralMigrations()
|
||||
|
||||
# Upgrade.p3()
|
||||
|
||||
if os.path.exists(postfixPath):
|
||||
Upgrade.upgradeDovecot()
|
||||
time.sleep(3)
|
||||
## Also disable email service upgrade
|
||||
|
||||
# if os.path.exists(postfixPath):
|
||||
# Upgrade.upgradeDovecot()
|
||||
|
||||
|
||||
## Upgrade version
|
||||
|
||||
|
|
@ -2541,7 +2565,10 @@ vmail
|
|||
|
||||
##
|
||||
|
||||
Upgrade.upgradeVersion()
|
||||
### Disable version upgrade too
|
||||
|
||||
# Upgrade.upgradeVersion()
|
||||
|
||||
Upgrade.UpdateMaxSSLCons()
|
||||
|
||||
## Update LSCPD PHP
|
||||
|
|
@ -2587,6 +2614,7 @@ vmail
|
|||
Upgrade.stdOut("Upgrade Completed.")
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
||||
parser.add_argument('branch', help='Install from branch name.')
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class vhost:
|
|||
if os.path.exists("/etc/lsb-release"):
|
||||
command = '/usr/sbin/adduser --no-create-home --home ' + path + ' --disabled-login --gecos "" ' + virtualHostUser
|
||||
else:
|
||||
command = "adduser " + virtualHostUser + " -M -d " + path
|
||||
command = "/usr/sbin/adduser " + virtualHostUser + " -M -d " + path
|
||||
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
|
|
|
|||
|
|
@ -227,7 +227,6 @@ rewrite {
|
|||
|
||||
</VirtualHost>
|
||||
"""
|
||||
|
||||
apacheConfChild = """<VirtualHost *:8081>
|
||||
|
||||
ServerName {virtualHostName}
|
||||
|
|
@ -282,7 +281,6 @@ rewrite {
|
|||
|
||||
</VirtualHost>
|
||||
"""
|
||||
|
||||
proxyApacheBackend = """extprocessor apachebackend {
|
||||
type proxy
|
||||
address http://127.0.0.1:8081
|
||||
|
|
@ -303,7 +301,6 @@ retryTimeout 0
|
|||
respBuffer 0
|
||||
}
|
||||
"""
|
||||
|
||||
OLSLBConf = """docRoot $VH_ROOT/public_html
|
||||
vhDomain $VH_NAME
|
||||
vhAliases www.$VH_NAME
|
||||
|
|
@ -343,7 +340,6 @@ REWRITERULE ^(.*)$ HTTP://proxyApacheBackendSSL/$1 [P,L]
|
|||
}
|
||||
|
||||
"""
|
||||
|
||||
phpFpmPool = """[{www}]
|
||||
listen = /var/run/php-fpm/{Sock}.sock
|
||||
listen.owner = nobody
|
||||
|
|
@ -370,7 +366,6 @@ pm.start_servers = {pmStartServers}
|
|||
pm.min_spare_servers = {pmMinSpareServers}
|
||||
pm.max_spare_servers = {pmMaxSpareServers}
|
||||
"""
|
||||
|
||||
lswsRediConfMaster = """"vhost:{virtualHostName}" '{
|
||||
"username": "{externalApp}",
|
||||
"documentRoot": "/home/{virtualHostName}/public_html",
|
||||
|
|
@ -401,7 +396,6 @@ pm.max_spare_servers = {pmMaxSpareServers}
|
|||
</IfModule>
|
||||
}
|
||||
}'"""
|
||||
|
||||
lswsRediConfChild = """"vhost:{virtualHostName}" '{
|
||||
"username": "{externalApp}",
|
||||
"documentRoot": "{path}",
|
||||
|
|
@ -417,7 +411,6 @@ pm.max_spare_servers = {pmMaxSpareServers}
|
|||
</IfModule>
|
||||
}
|
||||
}'"""
|
||||
|
||||
lswsRediConfChildWWW = """"vhost:{virtualHostName}" '{
|
||||
"username": "{externalApp}",
|
||||
"documentRoot": "{path}",
|
||||
|
|
|
|||
|
|
@ -81,11 +81,4 @@ uritemplate==3.0.1
|
|||
urllib3==1.25.11
|
||||
validators==0.18.1
|
||||
wcwidth==0.2.5
|
||||
websocket-client==0.57.0
|
||||
zope.component==4.6.2
|
||||
zope.deferredimport==4.3.1
|
||||
zope.deprecation==4.4.0
|
||||
zope.event==4.5.0
|
||||
zope.hookable==5.0.1
|
||||
zope.interface==5.2.0
|
||||
zope.proxy==4.3.5
|
||||
websocket-client==0.57.0
|
||||
|
|
@ -14,7 +14,7 @@ from websiteFunctions.models import Websites
|
|||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
from plogical.sslUtilities import sslUtilities
|
||||
from plogical.vhost import vhost
|
||||
from shutil import copytree, ignore_patterns
|
||||
from shutil import ignore_patterns
|
||||
|
||||
|
||||
class ServerStatusUtil:
|
||||
|
|
@ -348,6 +348,28 @@ class ServerStatusUtil:
|
|||
ProcessUtilities.stopLitespeed()
|
||||
ProcessUtilities.restartLitespeed()
|
||||
|
||||
### Check and remove OLS restart if lsws ent detected
|
||||
|
||||
CentOSPath = '/etc/redhat-release'
|
||||
|
||||
if os.path.exists(CentOSPath):
|
||||
cronPath = '/var/spool/cron/root'
|
||||
else:
|
||||
cronPath = '/var/spool/cron/crontabs/root'
|
||||
|
||||
data = open(cronPath, 'r').readlines()
|
||||
|
||||
writeToFile = open(cronPath, 'w')
|
||||
|
||||
for items in data:
|
||||
if items.find('-maxdepth 2 -type f -newer') > -1:
|
||||
pass
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
writeToFile.close()
|
||||
|
||||
###
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,"Successfully switched to LITESPEED ENTERPRISE WEB SERVER. [200]\n", 1)
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ def serverStatusHome(request):
|
|||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
|
||||
def litespeedStatus(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
@ -152,7 +151,6 @@ def getFurtherDataFromLogFile(request):
|
|||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getFurtherDataFromLogFile]")
|
||||
return HttpResponse("Not Logged in as admin")
|
||||
|
||||
|
||||
def services(request):
|
||||
data = {}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@
|
|||
color: #333;
|
||||
}
|
||||
|
||||
#searchbar {
|
||||
#toolbar #searchbar {
|
||||
height: 19px;
|
||||
border: 1px solid #ccc;
|
||||
padding: 2px 5px;
|
||||
|
|
@ -99,7 +99,7 @@
|
|||
max-width: 100%;
|
||||
}
|
||||
|
||||
#searchbar:focus {
|
||||
#toolbar #searchbar:focus {
|
||||
border-color: #999;
|
||||
}
|
||||
|
||||
|
|
@ -128,6 +128,7 @@
|
|||
/* FILTER COLUMN */
|
||||
|
||||
#changelist-filter {
|
||||
flex: 0 0 240px;
|
||||
order: 1;
|
||||
width: 240px;
|
||||
background: #f8f8f8;
|
||||
|
|
|
|||
|
|
@ -120,7 +120,8 @@ input[type="submit"], button {
|
|||
}
|
||||
|
||||
#changelist-search .quiet {
|
||||
width: 100%;
|
||||
width: 0;
|
||||
flex: 1 0 auto;
|
||||
margin: 5px 0 0 25px;
|
||||
}
|
||||
|
||||
|
|
@ -156,7 +157,7 @@ input[type="submit"], button {
|
|||
}
|
||||
|
||||
#changelist-filter {
|
||||
width: 200px;
|
||||
flex-basis: 200px;
|
||||
}
|
||||
|
||||
.change-list .filtered .results,
|
||||
|
|
@ -216,7 +217,7 @@ input[type="submit"], button {
|
|||
}
|
||||
|
||||
textarea {
|
||||
max-width: 518px;
|
||||
max-width: 100%;
|
||||
max-height: 120px;
|
||||
}
|
||||
|
||||
|
|
@ -557,6 +558,7 @@ input[type="submit"], button {
|
|||
.aligned .form-row,
|
||||
.aligned .form-row > div {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
max-width: 100vw;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -528,9 +528,9 @@ body #nav-toggle.collapsed span {
|
|||
width: 100px;
|
||||
}
|
||||
.closed-sidebar #header-logo .logo-content-small {
|
||||
width: 62px;
|
||||
width: 50px;
|
||||
margin-left: 0;
|
||||
left: 0px;
|
||||
left: 15px;
|
||||
display: block;
|
||||
}
|
||||
.closed-sidebar #header-logo .logo-content-big {
|
||||
|
|
|
|||
|
|
@ -1494,6 +1494,8 @@ app.controller('listTableUsers', function ($scope, $http) {
|
|||
|
||||
$scope.cyberpanelLoading = true;
|
||||
|
||||
var UserToDelete;
|
||||
|
||||
$scope.populateCurrentRecords = function () {
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
|
|
@ -1547,13 +1549,18 @@ app.controller('listTableUsers', function ($scope, $http) {
|
|||
$scope.populateCurrentRecords();
|
||||
|
||||
|
||||
$scope.deleteUserFinal = function (name) {
|
||||
$scope.deleteUserInitial = function (name){
|
||||
UserToDelete = name;
|
||||
$scope.UserToDelete = name;
|
||||
};
|
||||
|
||||
$scope.deleteUserFinal = function () {
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
var url = "/users/submitUserDeletion";
|
||||
|
||||
var data = {
|
||||
accountUsername: name,
|
||||
accountUsername: UserToDelete,
|
||||
};
|
||||
|
||||
var config = {
|
||||
|
|
|
|||
|
|
@ -1896,7 +1896,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.sslStatus == 1) {
|
||||
if (response.data.sslStatus === 1) {
|
||||
|
||||
$scope.sslSaved = false;
|
||||
$scope.couldNotSaveSSL = true;
|
||||
|
|
@ -2040,9 +2040,14 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
$scope.success = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = true;
|
||||
$scope.DomainCreateForm = true;
|
||||
|
||||
var statusFile;
|
||||
|
||||
$scope.WebsiteSelection = function (){
|
||||
$scope.DomainCreateForm = false;
|
||||
};
|
||||
|
||||
$scope.createDomain = function () {
|
||||
|
||||
$scope.domainLoading = false;
|
||||
|
|
@ -2053,6 +2058,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = true;
|
||||
$scope.currentStatus = "Starting creation..";
|
||||
$scope.DomainCreateForm = true;
|
||||
|
||||
var ssl, dkimCheck, openBasedir;
|
||||
|
||||
|
|
@ -2091,7 +2097,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
phpSelection: phpSelection,
|
||||
ssl: ssl,
|
||||
path: path,
|
||||
masterDomain: $("#domainNamePage").text(),
|
||||
masterDomain: $scope.masterDomain,
|
||||
dkimCheck: dkimCheck,
|
||||
openBasedir: openBasedir
|
||||
};
|
||||
|
|
@ -2114,6 +2120,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
|
||||
$scope.domainLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.DomainCreateForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = false;
|
||||
$scope.success = true;
|
||||
|
|
@ -2130,6 +2137,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
|
||||
$scope.domainLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.DomainCreateForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = true;
|
||||
|
|
@ -2144,11 +2152,13 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
$scope.goBack = function () {
|
||||
$scope.domainLoading = true;
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.DomainCreateForm = true;
|
||||
$scope.installationProgress = true;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = true;
|
||||
$scope.DomainCreateForm = true;
|
||||
$("#installProgress").css("width", "0%");
|
||||
};
|
||||
|
||||
|
|
@ -2194,6 +2204,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
|
||||
$scope.domainLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.DomainCreateForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = false;
|
||||
$scope.success = true;
|
||||
|
|
@ -2221,6 +2232,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
|
||||
$scope.domainLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.DomainCreateForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = true;
|
||||
|
|
|
|||
|
|
@ -1494,6 +1494,8 @@ app.controller('listTableUsers', function ($scope, $http) {
|
|||
|
||||
$scope.cyberpanelLoading = true;
|
||||
|
||||
var UserToDelete;
|
||||
|
||||
$scope.populateCurrentRecords = function () {
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
|
|
@ -1547,13 +1549,18 @@ app.controller('listTableUsers', function ($scope, $http) {
|
|||
$scope.populateCurrentRecords();
|
||||
|
||||
|
||||
$scope.deleteUserFinal = function (name) {
|
||||
$scope.deleteUserInitial = function (name){
|
||||
UserToDelete = name;
|
||||
$scope.UserToDelete = name;
|
||||
};
|
||||
|
||||
$scope.deleteUserFinal = function () {
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
var url = "/users/submitUserDeletion";
|
||||
|
||||
var data = {
|
||||
accountUsername: name,
|
||||
accountUsername: UserToDelete,
|
||||
};
|
||||
|
||||
var config = {
|
||||
|
|
@ -1716,6 +1723,7 @@ app.controller('listTableUsers', function ($scope, $http) {
|
|||
};
|
||||
|
||||
$scope.controlUserState = function (userName, state) {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
var url = "/users/controlUserState";
|
||||
|
|
|
|||
|
|
@ -51,18 +51,53 @@
|
|||
<td>
|
||||
<a ng-show="record.state=='ACTIVE'"
|
||||
class="btn btn-border btn-alt border-red btn-link font-red" href="#"
|
||||
ng-click="controlUserState(record.name, 'SUSPEND')" title=""><span>{% trans 'Suspend' %}</span></a>
|
||||
ng-click="controlUserState(record.name, 'SUSPEND')"
|
||||
title=""><span>{% trans 'Suspend' %}</span></a>
|
||||
<a ng-show="record.state=='SUSPENDED'"
|
||||
class="btn btn-border btn-alt border-green btn-link font-green" href="#"
|
||||
ng-click="controlUserState(record.name, 'ACTIVATE')" title=""><span>{% trans 'Activate' %}</span></a>
|
||||
ng-click="controlUserState(record.name, 'ACTIVATE')"
|
||||
title=""><span>{% trans 'Activate' %}</span></a>
|
||||
<a data-toggle="modal" data-target="#settings"
|
||||
ng-click="editInitial(record.name)"
|
||||
class="btn btn-border btn-alt border-purple btn-link font-purple" href="#"
|
||||
title=""><span>{% trans 'Edit' %}</span></a>
|
||||
<a ng-click="deleteUserFinal(record.name)"
|
||||
<a data-toggle="modal" data-target="#DeleteUserModal"
|
||||
ng-click="deleteUserInitial(record.name)"
|
||||
class="btn btn-border btn-alt border-red btn-link font-red" href="#"
|
||||
title=""><span>{% trans 'Delete' %}</span></a>
|
||||
|
||||
<!--- Delete User Modal --->
|
||||
<div id="DeleteUserModal" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×
|
||||
</button>
|
||||
<h4 class="modal-title">Deleting user {$ UserToDelete $}
|
||||
<img ng-hide="cyberpanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<p style="color: red; font-size: larger">This will delete all sites
|
||||
owned by this user and this
|
||||
process can not be reversed.</p>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default"
|
||||
data-dismiss="modal">Close
|
||||
</button>
|
||||
<button ng-click="deleteUserFinal()" type="button" class="btn btn-primary">Delete Now</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--- Delete User Modal End--->
|
||||
|
||||
<!--- Modal --->
|
||||
<div id="settings" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
|
|
|
|||
|
|
@ -191,12 +191,18 @@ class StagingSetup(multi.Thread):
|
|||
logging.statusWriter(tempStatusPath, 'Syncing databases..,10')
|
||||
|
||||
command = 'wp --allow-root --skip-plugins --skip-themes --path=%s db export %s/dbexport-stage.sql' % (child.path, masterPath)
|
||||
ProcessUtilities.executioner(command)
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(result)
|
||||
|
||||
## Restore to master domain
|
||||
|
||||
command = 'wp --allow-root --skip-plugins --skip-themes --path=%s --quiet db import %s/dbexport-stage.sql' % (masterPath, masterPath)
|
||||
ProcessUtilities.executioner(command)
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(result)
|
||||
|
||||
try:
|
||||
command = 'rm -f %s/dbexport-stage.sql' % (masterPath)
|
||||
|
|
@ -211,6 +217,9 @@ class StagingSetup(multi.Thread):
|
|||
command = 'wp theme path --allow-root --skip-plugins --skip-themes --path=%s' % (masterPath)
|
||||
WpContentPath = ProcessUtilities.outputExecutioner(command).splitlines()[-1].replace('wp-content/themes', '')
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(WpContentPath)
|
||||
|
||||
command = 'cp -R %s/wp-content/ %s' % (child.path, WpContentPath)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
|
|
@ -222,10 +231,16 @@ class StagingSetup(multi.Thread):
|
|||
## Search and replace url
|
||||
|
||||
command = 'wp search-replace --allow-root --skip-plugins --skip-themes --path=%s "%s" "%s"' % (masterPath, child.domain, replaceDomain)
|
||||
ProcessUtilities.executioner(command)
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(result)
|
||||
|
||||
command = 'wp search-replace --allow-root --skip-plugins --skip-themes --path=%s "www.%s" "%s"' % (masterPath, child.domain, replaceDomain)
|
||||
ProcessUtilities.executioner(command)
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(result)
|
||||
|
||||
from filemanager.filemanager import FileManager
|
||||
|
||||
|
|
@ -237,15 +252,6 @@ class StagingSetup(multi.Thread):
|
|||
|
||||
logging.statusWriter(tempStatusPath, 'Completed,[200]')
|
||||
|
||||
http = []
|
||||
finalHTTP = []
|
||||
|
||||
for items in http:
|
||||
if items.find('x-litespeed-cache') > -1 or items.find('x-lsadc-cache') > -1 or items.find('x-qc-cache') > -1:
|
||||
finalHTTP.append('<strong>%s</strong>' % (items))
|
||||
else:
|
||||
finalHTTP.append(items)
|
||||
|
||||
return 0
|
||||
except BaseException as msg:
|
||||
mesg = '%s. [404]' % (str(msg))
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ from datetime import datetime
|
|||
class Websites(models.Model):
|
||||
admin = models.ForeignKey(Administrator, on_delete=models.PROTECT)
|
||||
package = models.ForeignKey(Package, on_delete=models.PROTECT)
|
||||
domain = models.CharField(max_length=50,unique=True)
|
||||
adminEmail = models.CharField(max_length=50)
|
||||
domain = models.CharField(max_length=255,unique=True)
|
||||
adminEmail = models.CharField(max_length=255)
|
||||
phpSelection = models.CharField(max_length=10)
|
||||
ssl = models.IntegerField()
|
||||
state = models.IntegerField(default=1)
|
||||
|
|
|
|||
|
|
@ -1896,7 +1896,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.sslStatus == 1) {
|
||||
if (response.data.sslStatus === 1) {
|
||||
|
||||
$scope.sslSaved = false;
|
||||
$scope.couldNotSaveSSL = true;
|
||||
|
|
@ -2040,9 +2040,14 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
$scope.success = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = true;
|
||||
$scope.DomainCreateForm = true;
|
||||
|
||||
var statusFile;
|
||||
|
||||
$scope.WebsiteSelection = function (){
|
||||
$scope.DomainCreateForm = false;
|
||||
};
|
||||
|
||||
$scope.createDomain = function () {
|
||||
|
||||
$scope.domainLoading = false;
|
||||
|
|
@ -2053,6 +2058,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = true;
|
||||
$scope.currentStatus = "Starting creation..";
|
||||
$scope.DomainCreateForm = true;
|
||||
|
||||
var ssl, dkimCheck, openBasedir;
|
||||
|
||||
|
|
@ -2091,7 +2097,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
phpSelection: phpSelection,
|
||||
ssl: ssl,
|
||||
path: path,
|
||||
masterDomain: $("#domainNamePage").text(),
|
||||
masterDomain: $scope.masterDomain,
|
||||
dkimCheck: dkimCheck,
|
||||
openBasedir: openBasedir
|
||||
};
|
||||
|
|
@ -2114,6 +2120,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
|
||||
$scope.domainLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.DomainCreateForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = false;
|
||||
$scope.success = true;
|
||||
|
|
@ -2130,6 +2137,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
|
||||
$scope.domainLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.DomainCreateForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = true;
|
||||
|
|
@ -2144,11 +2152,13 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
$scope.goBack = function () {
|
||||
$scope.domainLoading = true;
|
||||
$scope.installationDetailsForm = false;
|
||||
$scope.DomainCreateForm = true;
|
||||
$scope.installationProgress = true;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = true;
|
||||
$scope.DomainCreateForm = true;
|
||||
$("#installProgress").css("width", "0%");
|
||||
};
|
||||
|
||||
|
|
@ -2194,6 +2204,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
|
||||
$scope.domainLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.DomainCreateForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = false;
|
||||
$scope.success = true;
|
||||
|
|
@ -2221,6 +2232,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
|||
|
||||
$scope.domainLoading = true;
|
||||
$scope.installationDetailsForm = true;
|
||||
$scope.DomainCreateForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = true;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,158 @@
|
|||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Create New Domain - 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 "Create Child Domain" %}</h2>
|
||||
<p>{% trans "Create child-domains, child domains are owned by a master website. " %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-controller="websitePages" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Details" %} <img ng-hide="domainLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<form name="websiteCreationForm" action="/" id="createPackages"
|
||||
class="form-horizontal bordered-row panel-body">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select Website" %} </label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-change="WebsiteSelection()" ng-model="masterDomain" class="form-control">
|
||||
{% for items in websiteList %}
|
||||
<option>{{ items }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="DomainCreateForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Domain Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="dom" type="text" class="form-control"
|
||||
ng-model="domainNameCreate" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="DomainCreateForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Path" %}: /home/{$ masterDomain $}/ </label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="docRootPath" required>
|
||||
</div>
|
||||
<div ng-show="websiteCreationForm.dom.$error.pattern"
|
||||
class="current-pack">{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="DomainCreateForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select PHP" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-model="phpSelection" class="form-control">
|
||||
{% for php in phps %}
|
||||
<option>{{ php }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="DomainCreateForm" ng-hide="installationDetailsForm"
|
||||
class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Additional Features" %}</label>
|
||||
<div class="col-sm-9">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input ng-model="sslCheck" type="checkbox" value="">
|
||||
SSL
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-9">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input ng-model="dkimCheck" type="checkbox" value="">
|
||||
DKIM Support
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-9">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input ng-model="openBasedir" type="checkbox" value="">
|
||||
open_basedir Protection
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="DomainCreateForm" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="createDomain()"
|
||||
class="btn btn-primary btn-lg">{% trans "Create Domain" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationProgress" class="form-group">
|
||||
<label class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-7">
|
||||
|
||||
<div class="alert alert-success text-center">
|
||||
<h2>{$ currentStatus $}</h2>
|
||||
</div>
|
||||
|
||||
<div class="progress">
|
||||
<div id="installProgress" class="progress-bar" role="progressbar"
|
||||
aria-valuenow="70" aria-valuemin="0" aria-valuemax="100"
|
||||
style="width:0%">
|
||||
<span class="sr-only">70% Complete</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="errorMessageBox" class="alert alert-danger">
|
||||
<p>{% trans "Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="success" class="alert alert-success">
|
||||
<p>{% trans "Website succesfully created." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationProgress" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-disabled="goBackDisable" ng-click="goBack()"
|
||||
class="btn btn-primary btn-lg">{% trans "Go Back" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
<div ng-controller="installWordPressCTRL" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
<span id="domainNamePage">{{ domainName }}</span> - {% trans "Installation Details" %} <img ng-hide="wpInstallLoading" src="{% static 'images/loading.gif' %}">
|
||||
<span id="domainNamePage">{{ domainName }}</span> - {% trans "Installation Details" %} - <a href="https://go.cyberpanel.net/StessTest">Stress Test</a></strong> <img ng-hide="wpInstallLoading" src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
|
|
@ -84,19 +84,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div ng-hide="installationFailed" class="alert alert-danger">
|
||||
<p>{% trans "Installation failed. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationSuccessfull" class="alert alert-success">
|
||||
<p>{% trans "Installation successful. Visit:" %} {$ installationURL $}</p>
|
||||
<p>{% trans "Installation successful. Visit:" %} {$ installationURL $} or perform <strong><a href="https://go.cyberpanel.net/StessTest">stress test</a></strong>.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
class="btn btn-border btn-alt border-azure btn-link font-azure"
|
||||
href="/websites/{{ domain }}/{{ childDomain }}/syncToMaster"
|
||||
title=""><span>{% trans "Copy/Sync to Master" %}</span></a>
|
||||
<a style="float: right" class="btn btn-border btn-alt border-black btn-link font-black"
|
||||
href="https://go.cyberpanel.net/StessTest" title=""><span>{% trans "Stress Test" %}</span></a>
|
||||
</h3>
|
||||
|
||||
<div class="">
|
||||
|
|
|
|||
|
|
@ -32,8 +32,10 @@
|
|||
<a style="float: right; margin-left: 2%"
|
||||
class="btn btn-border btn-alt border-azure btn-link font-azure"
|
||||
href="/websites/{{ domain }}/setupStaging" title=""><span>{% trans "Clone/Staging" %}</span></a>
|
||||
<a style="float: right" class="btn btn-border btn-alt border-blue-alt btn-link font-blue-alt"
|
||||
<a style="float: right; margin-left: 2%" class="btn btn-border btn-alt border-blue-alt btn-link font-blue-alt"
|
||||
href="/websites/{{ domain }}/sshAccess" title=""><span>{% trans "Set up SSH Access" %}</span></a>
|
||||
<a style="float: right" class="btn btn-border btn-alt border-black btn-link font-black"
|
||||
href="https://go.cyberpanel.net/StessTest" title=""><span>{% trans "Stress Test" %}</span></a>
|
||||
</h3>
|
||||
|
||||
<div class="content-box-wrapper">
|
||||
|
|
@ -240,10 +242,10 @@
|
|||
<div class="content-box-wrapper">
|
||||
<div class="row mx-10">
|
||||
<div class="col-md-3 panel-body">
|
||||
<a href="" ng-click="showCreateDomainForm()" title="{% trans 'Add Domains' %}" href="">
|
||||
<a href="{% url 'CreateNewDomain' %}" title="{% trans 'Add Domains' %}" href="">
|
||||
<img src="{% static 'images/icons/domains.png' %}" width="65" class="mr-10">
|
||||
</a>
|
||||
<a ng-click="showCreateDomainForm()" title="{% trans 'Add Domains' %}" href=""
|
||||
<a href="{% url 'CreateNewDomain' %}" title="{% trans 'Add Domains' %}" href=""
|
||||
title="{% trans 'Add Domains' %}">
|
||||
<span class="h4">{% trans "Add Domains" %}</span>
|
||||
</a>
|
||||
|
|
@ -273,7 +275,7 @@
|
|||
|
||||
<div class="col-md-3 panel-body">
|
||||
<a href="{% url 'listCron' %}?domain={{ domain }}" target="_self" title="{% trans 'Add new Cron Job' %}"
|
||||
href="" title="{% trans 'List Domains' %}">
|
||||
href="" title="{% trans 'Add new Cron Job' %}">
|
||||
<img src="{% static 'images/icons/repeat.png' %}" width="65" class="mr-10">
|
||||
</a>
|
||||
<a href="{% url 'listCron' %}?domain={{ domain }}" target="_self" title="{% trans 'Add new Cron Job' %}"
|
||||
|
|
@ -312,7 +314,6 @@
|
|||
class="current-pack">{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select PHP" %}</label>
|
||||
<div class="col-sm-6">
|
||||
|
|
@ -324,7 +325,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="installationDetailsForm" ng-hide="installationDetailsForm"
|
||||
class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Additional Features" %}</label>
|
||||
|
|
@ -356,7 +356,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
|
|
@ -366,7 +365,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="installationProgress" class="form-group">
|
||||
<label class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-7">
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@ urlpatterns = [
|
|||
url(r'^deleteWebsite$', views.deleteWebsite, name='deleteWebsite'),
|
||||
url(r'^siteState$', views.siteState, name='siteState'),
|
||||
|
||||
##
|
||||
|
||||
url(r'^CreateNewDomain$', views.CreateNewDomain, name='CreateNewDomain'),
|
||||
|
||||
|
||||
# Website modification url
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,14 @@ def deleteWebsite(request):
|
|||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def CreateNewDomain(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager()
|
||||
return wm.CreateNewDomain(request, userID)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def siteState(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
|
|
|||
|
|
@ -75,6 +75,12 @@ class WebsiteManager:
|
|||
{'websiteList': websitesName}, 'deleteWebsite')
|
||||
return proc.render()
|
||||
|
||||
def CreateNewDomain(self, request=None, userID=None, data=None):
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
proc = httpProc(request, 'websiteFunctions/createDomain.html', {'websiteList': websitesName, 'phps': PHPManager.findPHPVersions()})
|
||||
return proc.render()
|
||||
|
||||
def siteState(self, request=None, userID=None, data=None):
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue