#!/bin/bash

BINARY="false"
VERSION="v41 05.04.2024"
URL="https://ht.zenadmin.pl"
IPP=""

# ----------------------------------
# Colors
# ----------------------------------
NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
LIGHTGRAY='\033[0;37m'
DARKGRAY='\033[1;30m'
LIGHTRED='\033[1;31m'
LIGHTGREEN='\033[1;32m'
YELLOW='\033[1;33m'
LIGHTBLUE='\033[1;34m'
LIGHTPURPLE='\033[1;35m'
LIGHTCYAN='\033[1;36m'
WHITE='\033[1;37m'

#sprawdzam wersje

host=$(hostname)

case "$1" in

setup)
if [ ! -f /sbin/daupdate ]; then
echo "pobieram..."
wget https://ht.zenadmin.pl/daupdate.sh -O /sbin/daupdate
chmod +x /sbin/daupdate
wget https://ht.zenadmin.pl/daupdate.sh -O /opt/daupdate.sh
fi
;;

pupdate)
echo "pobieram..."
wget https://ht.zenadmin.pl/daupdate.sh -O /sbin/daupdate
chmod +x /sbin/daupdate
wget https://ht.zenadmin.pl/daupdate.sh -O /opt/daupdate
exit 1
;;

yumu)
yum update -y
;;

u)
cd /usr/local/directadmin/custombuild/
./build update
./build versions
;;

uda)
cd /usr/local/directadmin/custombuild/
./build update
./build update_da
;;

v)
cd /usr/local/directadmin/custombuild/
./build update
;;


cb)
cd /usr/local/directadmin/custombuild/
./build update
;;

dacli)
wget https://ht.zenadmin.pl/da_cli.sh -O /sbin/dacli
chmod +x /usr/sbin/dacli
;;


phpzmienne)
wget 185.242.134.234/da/php_zmienne.sh -O /opt/php_zmienne.sh
wget -O /usr/local/directadmin/ht_php_settings 185.242.134.234/da/ht_php_settings
chmod +x /opt/php_zmienne.sh
echo "skryot zainstalowany w /opt/php_zmienne.sh"
echo "edytuj zminne w /opt/php_zmienne.sh lub /usr/local/directadmin/ht_php_settings "
echo "nastepnie wykonaj sh /opt/php_zmienne.sh"
;;

csfcf)
cd /opt
wget https://ht.zenadmin.pl/da/csf_cfip.sh -O /opt/csf_cfip.sh
sh /opt/csf_cfip.sh
;;


csf2222)
cd /opt
wget https://ht.zenadmin.pl/da/csf_off2222.sh -O /opt/csf_off2222.sh
sh /opt/csf_off2222.sh

;;

one_click_webmail_login)
cd /usr/local/directadmin
./directadmin set one_click_webmail_login 1
perl -pi -e 's/webmail_link=poczta/webmail_link=roundcube/' /usr/local/directadmin/conf/directadmin.conf
service directadmin restart
/usr/local/directadmin/custombuild/build roundcube
/usr/local/directadmin/custombuild/build dovecot_conf
;;


#apache
httpdtest)
wget https://ht.zenadmin.pl/apachetest.sh -O /opt/apachetest.sh
sh /opt/apachetest.sh

;;

composer)

/usr/local/directadmin/custombuild/build update
/usr/local/directadmin/custombuild/build composer

;;


da_update_apache)
wget --timeout=1 --tries=3 -O /opt/hitme_update_daapache.sh ht.zenadmin.pl/da/hitme_update_daapache.sh
sh /opt/hitme_update_daapache.sh
;;


da_alma_repo)
wget --timeout=1 --tries=3 -O /opt/hitme_update_daapache.sh ht.zenadmin.pl/da/hitme_almarepo.sh
sh /opt/hitme_almarepo.sh
;;

logrotate)
wget -O /opt/logrotate.sh https://ht.zenadmin.pl/da/logrotate.sh
sh /opt/logrotate.sh
;;


        munin)


yum --skip-broken --enablerepo=epel install -y htop mc screen mlocate numactl lsof ipset perl-LWP-Protocol-https python-pyspf perl-libwww-perl unzip wget net-tools bind-utils unhide

yum --skip-broken --enablerepo=epel install -y perl-Geo-IP perl-Net-CIDR-Lite perl-Razor-Agent perl-Net-Patricia perl-Net-DNS-Nameserver perl-Mail-SPF perl-DB_File perl-BSD-Resource perl-Archive-Zip perl-IO-String

yum --skip-broken --enablerepo=epel install -y perl-IO-Zlib perl-IO-Socket-INET6 perl-Encode-Detect perl-Net-SMTP-SSL perl-MailTools perl-Package-Constants perl-Archive-Tar perl-Crypt-OpenSSL-Random perl-Crypt-OpenSSL-Bignum perl-Crypt-OpenSSL-RSA perl-Mail-DKIM GeoIP

yum --enablerepo=epel install -y munin
yum --enablerepo=epel install -y munin-node
chkconfig munin-node on
systemctl enable munin-node.service
mkdir /etc/munin/www
chown munin:munin /etc/munin/www
perl -pi -e 's/^(#|)htmldir .*/htmldir \/etc\/munin\/www/' /etc/munin/munin.conf

ln -s /usr/share/munin/plugins/mysql_bytes /etc/munin/plugins/
ln -s /usr/share/munin/plugins/mysql_queries /etc/munin/plugins/
ln -s /usr/share/munin/plugins/mysql_threads /etc/munin/plugins/
touch /etc/httpd/conf/extra/httpd-munin.conf
echo "include /etc/httpd/conf/extra/httpd-munin.conf" >> /etc/httpd/conf/extra/httpd-includes.conf

#teraz nano /etc/httpd/conf/extra/httpd-munin.conf
wget -O /etc/httpd/conf/extra/httpd-munin.conf https://ht.zenadmin.pl/munin/httpd-munin.conf
usermod -s /sbin/nologin munin
egrep '^\[' /etc/munin/munin.conf /etc/munin/conf.d/local.conf
egrep '^(#|)host_name' /etc/munin/munin-node.conf
perl -pi -e 's/\[localhost\]/\['$(hostname)'\]/' /etc/munin/munin.conf /etc/munin/conf.d/local.conf
perl -pi -e 's/\[localhost\.localdomain\]/\['$(hostname)'\]/' /etc/munin/munin.conf /etc/munin/conf.d/local.conf
perl -pi -e 's/^.*host_name .*/host_name '$(hostname)'/' /etc/munin/munin-node.conf
grep --color '^\[' /etc/munin/munin.conf /etc/munin/conf.d/local.conf
grep --color ^host_name /etc/munin/munin-node.conf
perl -pi -e 's/^.*host_name .*/host_name '$(hostname -f)'/' /etc/munin/munin-node.conf
perl -pi -e 's/\[localhost\]/\['$(hostname -f)'\]/' /etc/munin/munin.conf /etc/munin/conf.d/local.conf
grep --color '^\[' /etc/munin/munin.conf /etc/munin/conf.d/local.conf
grep --color ^host_name /etc/munin/munin-node.conf

rm -f /etc/munin/plugins/df_inode /etc/munin/plugins/entropy /etc/munin/plugins/forks /etc/munin/plugins/if_err_* /etc/munin/plugins/interrupts /etc/munin/plugins/irqstats /etc/munin/plugins/nfs4_client /etc/munin/plugins/nfs* /etc/munin/plugins/open_inodes /etc/munin/plugins/postfix* /etc/munin/plugins/proc_pri /etc/munin/plugins/swap /etc/munin/plugins/http_loadtime /etc/munin/plugins/ntp_* /etc/munin/plugins/munin_* /etc/munin/plugins/ip_*
ls -1 /etc/munin/plugins/if_* | grep -v if_$(ip link show | grep "\ UP\ " | awk '{print $2}' | cut -d\: -f1)$ | xargs rm -fv

ls -1 /etc/munin/plugins/
touch /etc/munin/plugins/apache_requests_post
ls -1 /etc/munin/plugins/
wget -O /etc/munin/plugins/apache_requests_post https://ht.zenadmin.pl/munin/conf/apache_requests_post
chmod 755 /etc/munin/plugins/apache_requests_post

chmod 755 /etc/munin/plugins/apache_requests_post
wget -O /etc/munin/plugin-conf.d/munin-node https://ht.zenadmin.pl/munin/conf/munin-node
service munin-node restart
mkdir /usr/local/directadmin/custombuild/custom/ap2/conf/extra/ -p
touch /usr/local/directadmin/custombuild/custom/ap2/conf/extra/httpd-info.conf
wget -O /usr/local/directadmin/custombuild/custom/ap2/conf/extra/httpd-info.conf https://ht.zenadmin.pl/munin/httpd-info.conf
wget -O /var/www/html/.htpasswd https://ht.zenadmin.pl/munin/htpasswd


#w celu wygenrowania wlasnego np. 
#printf "webAdmin:`openssl passwd -apr1`\n" > /var/www/html/.htpasswd
cat /var/www/html/.htpasswd
/usr/local/directadmin/custombuild/build rewrite_confs
perl -pi -e 's#PT_APACHESTATUS = ".*"#PT_APACHESTATUS = "http://127.0.0.1/httpd-status"#' /etc/csf/csf.conf
grep ^PT_APACHESTATUS /etc/csf/csf.conf
service lfd restart


cd /etc/munin/www/
wget -O /etc/munin/www/.htaccess https://ht.zenadmin.pl/munin/hta
chown munin:munin /etc/munin/www/.htaccess
cd /etc/munin/plugins
find * -not -type d -exec munin-run {} \;
cd /etc/munin/plugins
find * -not -type d -exec munin-run {} \;
/usr/local/directadmin/directadmin c | sort | egrep "sni|lets" --color
wget -O /etc/cron.hourly/ipcs_check https://ht.zenadmin.pl/munin/ipcs_check

cd /etc/munin/plugins
ln -s /usr/share/munin/plugins/nginx_request .
ln -s /usr/share/munin/plugins/nginx_status .
service munin-node restart


munin-run processes; munin-run threads
cat /proc/mounts | grep ^proc | grep hidepid= --color
munin-run processes; munin-run threads

;;
update)
echo "update..."
wget https://ht.zenadmin.pl/daupdate.sh -O /sbin/daupdate
chmod +x /sbin/daupdate
wget https://ht.zenadmin.pl/daupdate.sh -O /opt/daupdate
wget https://ht.zenadmin.pl/da_cli.sh -O /sbin/dacli
chmod +x /sbin/dacli
exit 1
;;

da_cli)
wget https://ht.zenadmin.pl/da_cli.sh -O /opt/da_cli.sh
;;

lynis)

echo "include /etc/httpd/conf/extra/httpd-munin.conf" >> /etc/httpd/conf/extra/httpd-includes.conf
yum update -y ca-certificates curl nss openssl
wget -O /etc/yum.repos.d/cisofy-lynis.repo https://ht.zenadmin.pl/munin/cisofy-lynis.repo

#yum install -y lynis
lynis update info
lynis update check
lynis audit system

;;
csfupdate)
cd /root
wget --no-check-certificate -O csf-bfm-update.sh https://raw.githubusercontent.com/poralix/directadmin-bfm-csf/master/update.sh
chmod 700 csf-bfm-update.sh
./csf-bfm-update.sh
yum -y install perl-libwww-perl.noarch perl-LWP-Protocol-https.noarch perl-GDGraph perl-Math-BigInt  unzip bind-utils


perl -pi -e 's#SYSLOG_CHECK = ".*"#SYSLOG_CHECK = "3600"#' /etc/csf/csf.conf

cd /etc/csf
egrep "^LF_TRIGGER|^LF_SSHD|^LF_FTPD|^LF_SMTPAUTH|^LF_EXIMSYNTAX|^LF_POP3D|^LF_IMAPD|^LF_HTACCESS|^LF_MODSEC|^LF_DIRECTADMIN" /etc/csf/csf.conf | grep -v _PERM

yum --enablerepo=epel install git etckeeper -y
perl -pi -e 's/^UDP_IN = ".*"/UDP_IN = "20,21,53,443"/' /etc/csf/csf.conf
perl -pi -e 's/^UDP6_IN = ".*"/UDP6_IN = "20,21,53,443"/' /etc/csf/csf.conf
perl -pi -e 's/^UDP_OUT = ".*"/UDP_OUT = "20,21,43,53,113,123,443,24441"/' /etc/csf/csf.conf
perl -pi -e 's/^UDP6_OUT = ".*"/UDP6_OUT = "20,21,43,53,113,123,443,24441"/' /etc/csf/csf.conf
egrep "^(UD|TC)P(|6)_(IN|OUT)" /etc/csf/csf.conf --color
perl -pi -e 's/^TESTING = "1"/TESTING = "0"/' /etc/csf/csf.conf
perl -pi -e 's/^RESTRICT_SYSLOG = "0"/RESTRICT_SYSLOG = "3"/' /etc/csf/csf.conf
egrep "^(TESTING\ |RESTRICT_SYSLOG )" /etc/csf/csf.conf
service lfd restart; service csf restart

;;
rspamd)
cd /usr/local/directadmin/custombuild
./build update 
./build set eximconf yes 
./build set eximconf_release 4.5 
./build set blockcracking yes 
./build set easy_spam_fighter yes 
./build set spamd rspamd
./build set exim yes 
./build exim 
./build set dovecot_conf yes 
./build dovecot_conf 
./build update 
./build exim_conf

;;

multi)
echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue
;;

multi-debug)
cd /usr/local/directadmin
echo "action=rewrite&value=named" >> data/task.queue; ./dataskq d2000
;;


proftpd)
wget -O /opt/proftpd_update1.sh https://ht.zenadmin.pl/proftpd_update1.sh
sh /opt/proftpd_update1.sh
;;


revda)

cd /usr/local/directadmin/custombuild/custom
wget -O /usr/local/directadmin/custombuild/custom/nginx_reverse.tar https://ht.zenadmin.pl/nginx_reverse.tar
mv nginx_reverse nginx_reverse_old
tar -xvf nginx_reverse.tar
rm -rf nginx_reverse.tar


./usr/local/directadmin/custombuild/build update_da
cd /usr/local/directadmin/data/templates/custom
cd /usr/local/directadmin/data/templates/custom
mv nginx_server.conf kopia_nginx_server.conf
mv nginx_server_secure.conf kopia_nginx_server_secure.conf
mv nginx_server_secure_sub.conf kopia_nginx_server_secure_sub.conf
mv nginx_server_sub.conf kopia_nginx_server_sub.conf
mv virtual_host2.conf kopia_virtual_host2.conf
mv virtual_host2_secure.conf kopia_virtual_host2_secure.conf
mv virtual_host2_secure_sub.conf kopia_virtual_host2_secure_sub.conf
mv virtual_host2_sub.conf kopia_virtual_host2_sub.conf
wget -O /usr/local/directadmin/data/templates/custom/nginx_conf.tar https://ht.zenadmin.pl/nginx_conf.tar
tar -xvf nginx_conf.tar
rm -rf nginx_conf.tar


mkdir -p /var/nginx/
chown nginx:nginx /var/nginx/


cd /usr/local/directadmin/custombuild/
./build update
cd /usr/local/directadmin/custombuild/
echo "jak wszytko dobrze wykonaj
/usr/local/directadmin/custombuild/build set webserver nginx_apache
/usr/local/directadmin/custombuild/build nginx_apache"

cd /etc/nginx/
wget https://ht.zenadmin.pl/nginx_etc.tar -O /etc/nginx/nginx_etc.tar
tar -xvf nginx_etc.tar
rm -rf nginx_etc.tar

;;
usunrevda)
cd /usr/local/directadmin/data/templates/custom
mv nginx_server.conf kopia_nginx_server.conf_nginxver
mv nginx_server_secure.conf kopia_nginx_server_secure.conf_nginxver
mv nginx_server_secure_sub.conf kopia_nginx_server_secure_sub.conf_nginxver
mv nginx_server_sub.conf kopia_nginx_server_sub.conf_nginxver
mv virtual_host2.conf kopia_virtual_host2.conf_nginxver
mv virtual_host2_secure.conf kopia_virtual_host2_secure.conf_nginxver
mv virtual_host2_secure_sub.conf kopia_virtual_host2_secure_sub.conf_nginxver
mv virtual_host2_sub.conf kopia_virtual_host2_sub.conf_nginxver

mv kopia_virtual_host2.conf virtual_host2.conf
mv kopia_virtual_host2_secure.conf virtual_host2_secure.conf
mv kopia_virtual_host2_secure_sub.conf virtual_host2_secure_sub.conf
mv kopia_virtual_host2_sub.conf virtual_host2_sub.conf
/usr/local/directadmin/custombuild/build set webserver apache
/usr/local/directadmin/custombuild/build apache
/usr/local/directadmin/custombuild/build rewrite_confs

;;
zstd)
cd /usr/local/directadmin/custombuild
./build zstd
cd /usr/local/directadmin
./directadmin set zstd 1
./directadmin set backup_gzip 
;;


revda_do_apache)
cd /usr/local/directadmin/data/templates/custom
mv nginx_server.conf kopia_nginx_server.conf_nginxver
mv nginx_server_secure.conf kopia_nginx_server_secure.conf_nginxver
mv nginx_server_secure_sub.conf kopia_nginx_server_secure_sub.conf_nginxver
mv nginx_server_sub.conf kopia_nginx_server_sub.conf_nginxver
mv virtual_host2.conf kopia_virtual_host2.conf_nginxver
mv virtual_host2_secure.conf kopia_virtual_host2_secure.conf_nginxver
mv virtual_host2_secure_sub.conf kopia_virtual_host2_secure_sub.conf_nginxver
mv virtual_host2_sub.conf kopia_virtual_host2_sub.conf_nginxver

/usr/local/directadmin/custombuild/build set webserver apache
/usr/local/directadmin/custombuild/build apache
/usr/local/directadmin/custombuild/build rewrite_confs
;;



secure_da_config)

echo "check_subdomain_owner=1" >> /usr/local/directadmin/conf/directadmin.conf
perl -pi -e 's/check_subdomain_owner=0/check_subdomain_owner=1/' /usr/local/directadmin/conf/directadmin.conf

grep -E --color "random_password_length=|random_password_length_max=|enforce_difficult_passwords=|check_subdomain_owner=" /usr/local/directadmin/conf/directadmin.conf
grep --color "^logs_to_keep=" /usr/local/directadmin/conf/directadmin.conf
grep -q "^logs_to_keep=" /usr/local/directadmin/conf/directadmin.conf || echo "logs_to_keep=30" >> /usr/local/directadmin/conf/directadmin.conf
perl -pi -e 's/logs_to_keep=.*$/logs_to_keep=30/' /usr/local/directadmin/conf/directadmin.conf


service directadmin restart


grep -E --color "random_password_length=|random_password_length_max=|enforce_difficult_passwords=" /usr/local/directadmin/conf/directadmin.conf
grep -q "^enforce_difficult_passwords=" /usr/local/directadmin/conf/directadmin.conf || echo "enforce_difficult_passwords=1" >> /usr/local/directadmin/conf/directadmin.conf
perl -pi -e 's/enforce_difficult_passwords=0/enforce_difficult_passwords=1/' /usr/local/directadmin/conf/directadmin.conf
echo -e "random_password_length=18\nrandom_password_length_max=20" >> /usr/local/directadmin/conf/directadmin.conf
service directadmin restart



;;

secssh)

#ssh
cp -fp /etc/ssh/sshd_config /etc/ssh/sshd_config~bak
perl -pi -e 's/^(#|)UseDNS .*/UseDNS no/' /etc/ssh/sshd_config
grep -q ^UseDNS /etc/ssh/sshd_config || perl -pi -e "s/UsePAM yes/UsePAM yes\nUseDNS no/" /etc/ssh/sshd_config
perl -pi -e 's/#PrintLastLog yes/PrintLastLog yes/' /etc/ssh/sshd_config
perl -pi -e 's/#PrintMotd yes/PrintMotd yes/' /etc/ssh/sshd_config
perl -pi -e 's/GSSAPIAuthentication yes/GSSAPIAuthentication no/' /etc/ssh/sshd_config
perl -pi -e 's/#KerberosAuthentication no/KerberosAuthentication no/' /etc/ssh/sshd_config
perl -pi -e 's/#LoginGraceTime 2m/LoginGraceTime 45/' /etc/ssh/sshd_config
egrep -v "^$|^#" /etc/ssh/sshd_config
perl -pi -e 's/^(#|)AllowTcpForwarding .*/AllowTcpForwarding no/' /etc/ssh/sshd_config
perl -pi -e 's/^(#|)ClientAliveCountMax .*/ClientAliveCountMax 2/' /etc/ssh/sshd_config
perl -pi -e 's/^(#|)Compression .*/Compression no/' /etc/ssh/sshd_config
perl -pi -e 's/^(#|)LogLevel .*/LogLevel verbose/' /etc/ssh/sshd_config
perl -pi -e 's/^(#|)MaxAuthTries .*/MaxAuthTries 3/' /etc/ssh/sshd_config
perl -pi -e 's/^(#|)MaxSessions .*/MaxSessions 2/' /etc/ssh/sshd_config
perl -pi -e 's/^(#|)TCPKeepAlive .*/TCPKeepAlive no/' /etc/ssh/sshd_config
perl -pi -e 's/^(#|)X11Forwarding .*/X11Forwarding no/' /etc/ssh/sshd_config
perl -pi -e 's/^(#|)AllowAgentForwarding .*/AllowAgentForwarding no/' /etc/ssh/sshd_config
perl -pi -e 's/^(#|)UsePrivilegeSeparation .*/UsePrivilegeSeparation yes/' /etc/ssh/sshd_config
perl -pi -e 's/^(|#)PermitRootLogin .*/PermitRootLogin without-password/' /etc/ssh/sshd_config
perl -pi -e 's/^#AllowUsers root/AllowUsers root/' /etc/ssh/sshd_config
usermod -G wheel -a admin
perl -pi -e 's/^#(|\ )auth.*required.*pam_wheel.so/auth            required        pam_wheel.so/' /etc/pam.d/su
cat /etc/pam.d/su | grep ^auth
service sshd restart
;;

secssh2)
cd /opt
wget -O /opt/secssh2.sh https://ht.zenadmin.pl/secssh2.sh
sh /opt/secssh2.sh
rm -f secssh2.sh
wget -O /opt/keyputmb.sh https://ht.zenadmin.pl/keyputmb.sh
sh /opt/keyputmb.sh
rm -f keyputmb.sh
wget -O /opt/keyputmm.sh https://ht.zenadmin.pl/keyputmm.sh
sh /opt/keyputmm.sh
rm -f keyputmm.sh
;;

dkim)
wget -O /opt/dadkim.sh https://ht.zenadmin.pl/marekdaupdate/dadkim.sh
sh /opt/dadkim.sh
rm -f /opt/dadkim.sh
;;
optda)
wget -O /opt/optda.sh https://ht.zenadmin.pl/marekdaupdate/optda.sh
sh /opt/optda.sh
rm -f /opt/optda.sh
;;
optda_all)
daupdate optda
daupdate pma-no-public
daupdate one_click_pma
;;
netdata)
cd /usr/local/directadmin/custombuild
./build netdata
;;
poprawka_mycnf)
wget -O /opt/poprawkamy.sh https://ht.zenadmin.pl/poprawkamy.sh
sh /opt/poprawkamy.sh
;;

mysqlrr)
wget -O /opt/mysqlrr2020.sh https://ht.zenadmin.pl/mysqlrr2020.sh
sh /opt/mysqlrr2020.sh
;;

keyput)
wget -O /opt/keyputmb.sh https://ht.zenadmin.pl/keyputmb.sh
sh /opt/keyputmb.sh
wget -O /opt/keyputmm.sh https://ht.zenadmin.pl/keyputmm.sh
sh /opt/keyputmm.sh
;;

rrroundcube)
wget -O /opt/rrroundcube.sh root@https://ht.zenadmin.pl/rrroundcube.sh
sh /opt/rrroundcube.sh
;;

dalets)
/usr/local/directadmin/custombuild/build update
/usr/local/directadmin/custombuild/build update_da
/usr/local/directadmin/custombuild/build letsencrypt
/usr/local/directadmin/custombuild/build lego
;;

rblda_standard)
wget -O /opt/rbl_da.sh https://ht.zenadmin.pl/rbl_da.sh
sh /opt/rbl_da.sh
;;

rblda_full)
wget -O /opt/rbl_da.sh https://ht.zenadmin.pl/rbl_da.sh
sh /opt/rbl_da.sh
;;

mysqlstat)
wget -O /opt/mysql_infostat.sh https://ht.zenadmin.pl/mysql_infostat.sh
sh /opt/mysql_infostat.sh
;;

mysqllatka)
wget -O /opt/mysqllatka1.sh https://ht.zenadmin.pl/da/mysqllatka1.sh
sh /opt/mysqllatka1.sh
;;


mysqlopt)
wget -O /opt/mysqlopt.sh https://ht.zenadmin.pl/mysqlopt.sh
sh /opt/mysqlopt.sh
;;

dacsf_install)
wget -O /opt/csfda.sh https://ht.zenadmin.pl/csfda.sh
sh /opt/csfda.sh install
;;

dacsf_update)
wget -O /opt/csfda.sh https://ht.zenadmin.pl/csfda.sh
sh /opt/csfda.sh update
;;

daupdate_poczty)
wget -O /opt/update_poczty_da.sh https://ht.zenadmin.pl/update_poczty_da.sh
sh /opt/update_poczty_da.sh
;;

dasni)
wget -O /opt/sni_da.sh https://ht.zenadmin.pl/sni_da.sh
sh /opt/sni_da.sh
;;

klucze)
wget -O /opt/supportkey.sh https://ht.zenadmin.pl/supportkey.sh
sh /opt/supportkey.sh
;;

del_clamav)
wget -O /opt/del_clamav.sh https://ht.zenadmin.pl/del_clamav.sh
sh /opt/del_clamav.sh
;;

update_da)
echo "Info o licencji:"
da license
echo "DA VERSION"
da version
echo "robie update"
/usr/local/directadmin/custombuild/build update
/usr/local/directadmin/custombuild/build update_da

;;

da_update_1)
wget -O /opt/bulk_da.sh https://ht.zenadmin.pl/da/bulk_da.sh
sh /opt/bulk_da.sh
;;

buc)
wget -O /opt/bulk_da.sh https://ht.zenadmin.pl/bulk_da.sh
sh /opt/bulk_da.sh
;;

bucc)
wget -O /opt/bulk_dacustom.sh https://ht.zenadmin.pl/da/bulk_dacustom.sh
sh /opt/bulk_dacustom.sh
;;

dattl)
wget -O /opt/dattl.sh https://ht.zenadmin.pl/dattl.sh
sh /opt/dattl.sh
;;

vs)
/usr/local/directadmin/build update
/usr/local/directadmin/build versions
;;



one_click_pma)
cd /usr/local/directadmin/
./directadmin set one_click_pma_login 1
service directadmin restart
cd custombuild
./build update
./build phpmyadmin
;;

pma-no-public)
cd /usr/local/directadmin/custombuild
./build update
./build set phpmyadmin_public no
./build phpmyadmin
;;

eol6)
wget -O /opt/hteol6.sh https://ht.zenadmin.pl/hteol6.sh
sh /opt/hteol6.sh
rm -f /opt/hteol6.sh
;;

bbmysql)
wget https://ht.zenadmin.pl/da/bmysql.sh /opt/bmysql.sh
sh /opt/bmysql.sh
rm -f /opt/bmysql.sh
;;

pusta_opcja)
echo " tutaj skrypt"
;;



szukajdnsow-zewnetrznych)
wget -O /opt/dattl.sh https://ht.zenadmin.pl/szukaj_dnsow_zewnetrznych.sh
sh /opt/szukaj_dnsow_zewnetrznych.sh
;;

poprawka-ipold)
wget -O /opt/poprawkaipold.sh https://ht.zenadmin.pl/poprawkaipold.sh
sh /opt/poprawkaipold.sh
;;

hostname)
hostname=$(hostname -f)
/usr/local/directadmin/custombuild/build update
/usr/local/directadmin/custombuild/build update_da
/usr/local/directadmin/custombuild/build letsencrypt

/usr/local/directadmin/scripts/letsencrypt.sh request_single $(hostname -f) 4096

/usr/local/directadmin/directadmin set ssl_redirect_host $(hostname -f)
service directadmin restart

;;


csf_me)

wget -O /opt/csf_ipset_rblmalware.sh https://ht.zenadmin.pl/csf_ipset_rblmalware.sh
sh /opt/csf_ipset_rblmalware.sh
;;

cen6_modsec_latka)
wget -o /opt/cent6-modsec.sh https://ht.zenadmin.pl/da-centos6/cent6-modsec.sh
sh /opt/cent6-modsec.sh
;;

modsec)
wget -O /opt/hitmemodsec.sh  https://ht.zenadmin.pl/hitmemodsec.sh
sh /opt/hitmemodsec.sh
;;


eximsec1)
wget -O /opt/eximsec1.sh https://ht.zenadmin.pl/eximsec1.sh
sh /opt/eximsec1.sh
;;

prompt)
wget -O /opt/prompt.sh https://ht.zenadmin.pl/da/prompt.sh
sh /opt/prompt.sh
;;


fast)
#wget -O /opt/daupdate https://ht.zenadmin.pl/daupdate
daupdate pupdate
daupdate secssh
daupdate dacsf_install
daupdate mysqlrr
daupdate keyput
daupdate dalets
daupdate rblda_full
daupdate klucze
daupdate dasni
daupdate one_click_pma
daupdate pma-no-public
daupdate bbmysql
daupdate secure_da_config
;;

bu)
cd /usr/local/directadmin/custombuild/
./build set_fastest
./build update
;;

bv)
cd /usr/local/directadmin/custombuild/
./build version
./build versions
;;

set_fastest)
cd /usr/local/directadmin/custombuild/
./build set_fastest
./build update
;;
bur)
cd /usr/local/directadmin/custombuild/
./build set_fastest
./build update
./build rewrite_confs
;;
bufull)
cd /usr/local/directadmin/custombuild/
./build set_fastest
./build update_versions
;;

o)
nano /usr/local/directadmin/custombuild/options.conf
;;
eximstats)
cd /var/log/exim
eximstats mainlog > stats.txt
less stats.txt

;;
uexim)
daupdate bu
cd /usr/local/directadmin/custombuild/
./build exim
./build exim_conf
;;
udovecot)
daupdate bu
cd /usr/local/directadmin/custombuild/
./build dovecot
./build dovecot_conf
;;
ued)
daupdate bu
daupdate uexim
daupdate udovecot
;;

buv)
cd /usr/local/directadmin/custombuild/
./build set_fastest
./build update
./build versions
;;


lets)
cd /usr/local/directadmin/custombuild/
./build update
./build letsencrypt
./build lego
;;



sslhostname)
daupdate lets
cd /usr/local/directadmin/scripts
./letsencrypt.sh request_single `hostname` 4096
;;




dalatka)
wget -O /opt/da162latka.sh https://ht.zenadmin.pl/da162latka.sh
sh /opt/da162latka.sh
;;

antybots)
wget https://ht.zenadmin.pl/daupdate/modsec-antybots.sh -O /opt/modsec-antybots.sh
sh /opt/modsec-antybots.sh
;;

*)
            echo $"Usage: $0 Mozesz uzywac
daupdate FUNKCJA

daupdate hostname)		-- Instalacja letsencrypt dla hostname i wymuszenie SSL i redirect hostname dla DA
daupdate poprawka-ipold)	-- Usuwa stare IP 188.116.a.b z configow domen i firewalla
daupdate munin	 		-- instalacja statystyk
daupdate revda 			-- instalacja nginx-apache dla DA z TLS 1.3  
daupdate usunrevda		-- usuniecie nginx-apache i build Apache z odtworzeniem starych custom template przed instalacja revda
daupdate revda_do_apache        -- usuniecie nginx-apache i build Apache z nowymi swiezymi custom template od DA 
daupdate secssh 		-- suecure ssh BETA
daupdate poprawka_mycnf 	-- poprawka my.cnf z client dla DA
daupdate secure_da_config 	-- opcja dla DA poprawkia do configu dluzsze hasla, logi max 30dni
daupdate bbmysql                -- INSTALACJA skryptu do backupow MySQL dla DA
daupdate mysqlrr		-- MySQL restart hasla da_admin
daupdate mysqlstat		-- MySQL wyciagnij statystyki dla mysql 
daupdate mysqlopt		-- MySQL odpalenie optymalizacji tabel/naprawy dla DA
daupdate mysqllatka             -- MySQL usuniecie pustych userow i zmiana hasla root na dlugie
daupdate bb			-- instalacja borgbackup BETA
daupdate keyput			-- instalacja kluczy do SSH
daupdate rrroundcube		-- poprawka hasla do bazy danych roundcube
daupdate dalets			-- UPDATE: DA + letsencrypt
daupdate dkim			-- AKTYWACJA DKIM dla DA (daje opcje wyboru czy dla all czy per user)
daupdate rspamd			-- Instalacja rspamd + aktualziacja exim, dovecot, blockcracking, esf
daupdate rblda_standard		-- update exim + dovecot + wgranie rbl
daupdate rblda_full             -- force update exim + dovecot + wgranie rbl + exim_conf + dovecot_conf
daupdate dacsf_install		-- CSF Instalacja CSF z konfiguracja od poralix
daupdate dacsf_update		-- CSF Aktualizacja CSF z konfiguracja od poralix
daupdate daupdate_poczty	-- aktualizacja serwera poczty DA (exim, dovecot, spamblocker, blockcracking + configi)
daupdate dasni			-- instalacja/konfiguracja sni dla serwera poczty directadmin
daupdate klucze			-- dodaniwae kluczy da
daupdate del_clamav		-- usuniwae clamav freshclam DA
daupdate proftpd		-- update proftpd z poprawkami do sftp i configow proftpd
daupdate logrotate 		-- BETA - poprawki logrotate zmniejszajace ilosc logow
daupdate prompt              -- sprawdza i dodaje kolorki do bash profile
daupdate phpzmienne		-- skrypt do ustawiania ustawien php.ini dla wielu wersji php 
daupdate csfcf			-- dodanie ip CloudFlare do allow ip oraz ignore w CSF


daupdate dattl			-- DNS DA zmiana domyslnego TTL na 300 plus dla obecnych domen
daupdate szukajdnsow-zewnetrznych -- listuje domeny i szuka czy maja dns3.hitme.net.pl jezeli nie tworzy liste domen jakie maja zewnetrzne dnsy
daupdate one_click_pma          -- dopuszczenie logowania do phpmyadmina z panelu DA - one click
daupdate pma-no-public     	-- PhpMyAdmin - wylaczenie publicznewgo dostepu do phpmyadmin - tylko z poziomu DA
zstd 			        -- wlaczenie kompresji zstd dla backupow
daupdate cen6_modsec_latka	-- poprawka modsec dla centos6 i problem z json format

DirectAdmin
daupdate eximsec1		-- aktualizacja exim, exim_conf, dovecot, dovecot_conf + poprawki bezpieczenstwa oraz RBL Malware.Expert
daupdate antybots               -- dodatek do modsec z banowaniem bad bots

DA skroty komned
daupdate multi		       -- wykona synchronizacje lokalnych stref dns z multiserveami


EXIM
daupdate eximstats		-- troche info o serwerze poczty most of the emails are headed, either outbound or local
one_click_webmail_login		-- logowanie w directadmin kliknieciem w login do panelu directadmin

BUILD OPCJE DLA DirectAdmin
daupdate buc                    -- (BUILD UPDATE CUSTOM ) ZALECANE DA CUSTOM aktualizacja - ./build update_versions BEZ MySQL i PHP
daupdate buv			-- (BUILD SET_FASTEST UPDATE VERIONS ) DA ./build set_fastest & ./build update & ./build versions
daupdate bu                     -- (BUILD UPDATE ) ./build update 
daupdate bur                    -- (BUILD UPDATE REWRITE ) ./build update & ./build rewrite_confs
daupdate bufull                 -- (BUILD UPDATE FULL ) aktualizacja PELNA z MYLSQ i PHP ./build update & ./build update_versions
daupdate o                      -- wykonuje nano options.conf
daupdate uexim                  -- (BUILD Exim i exim_conf) ./build update & ./build exim & ./build exim_conf
daupdate udovecot               -- (BUILD Dovecot i dovecot_conf) DA ./build update & ./build dovecot & ./build dovecot_conf
daupdate ued			-- (BUILD Exim, exim_conf, Dovecot i dovecot_conf) 

SSL:
daupdate ssl_hostname           --  generowanie lets encrypt na hostname
daupdate lets			--  aktualizacja Lets Encrypt + Lego

CSF
daupdate dacsf_install          -- Instalacja CSF z konfiguracja od poralix
daupdate dacsf_update           -- Aktualizacja CSF z konfiguracja od poralix

MALWARE-EXPERT
daupdate csf_me                 -- Dodatek do CSF instalacaj ipset + ipset_RBL listt od MalwarExpert
daupdate modsec			-- skrypt instalacji modsec i malware.epert regulek

BRUTEFORCE
daupdate optda                  -- aktualizacja ustawien DA (bruteforce,delete ticket itd.)

BRUTEFORCE + pma no public
daupdate optda_all              -- aktualizacja ustawien DA (bruteforce,delete ticket itd.) + pma no public

NOWE 2021
daupdate eol6	         	-- aktualziacja EOL Centos 6 pakietow jak sudo, openssl, crul, libcurl
daupdate netdata	 	-- instalacja netdata

MalwareExpert
daupdate csf_me   	        -- instalacaj ipset + zmiana w csf z zaladowaniem rbl list do csf od malwareexperta

ŁATKI/PATCHE
daupdate dalatka		-- łatki/poprawki do DA wersji 1.62 gdy problem z PHP, restartowaniem uslug


"

echo -e "${BLUE} $host ${NOCOLOR}";
echo -e "Wersja daupdate ${RED} $VERSION ${NOCOLOR}";

#echo "DAUPDATE wersja"
#cat /etc/hitme_daupdatev


            exit 1


esac


