-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhestia_csf_install.sh
53 lines (41 loc) · 2.32 KB
/
hestia_csf_install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
#Author : vvcares.com
#Tested with Hestia v1.7.3 + Ubuntu 22.04
DIR="/etc/csf/"
T=$(date +"%m%d%Y%H%M%S")
PANEL=/usr/local/hestia/web/templates/includes/panel.php
PANEL2=/usr/local/hestia/web/list/csf
CSFCONF='/etc/csf/csf.conf'
#HESTIAPORT='source /usr/local/hestia/conf/hestia.conf | echo $BACKEND_PORT'
source /usr/local/hestia/conf/hestia.conf
HESTIAPORT="$BACKEND_PORT"
if [ -d "$DIR" ]; then
echo "*** [Existing CSF folder detected & skip new CSF install & proceeding to Setting up for hestia]"
else echo '*** [No CSF directory in default path. So installing FRESH copy of CSF..]'
sudo apt update -y && apt-get install libwww-perl -y && cd /usr/src && rm -fv csf.tgz && wget https://download.configserver.com/csf.tgz && tar -xzf csf.tgz && cd csf && sudo sh install.sh && sudo csf -v && perl /usr/local/csf/bin/csftest.pl
fi
#Setting up for hestia
rm -R /usr/local/hestia/bin/csf.pl*
rm -R $PANEL2
mkdir -v -m 0600 $PANEL2
cp -R /etc/csf/ui/images $PANEL2
find $PANEL2 -type f -exec chmod -v 644 {} \;
wget https://raw.githubusercontent.com/vvcares/hestia/master/hestia-csf/csf.pl -P /usr/local/hestia/bin
wget https://raw.githubusercontent.com/vvcares/hestia/master/hestia-csf/frame.php -P $PANEL2
wget https://raw.githubusercontent.com/vvcares/hestia/master/hestia-csf/index.php -P $PANEL2
chmod 700 /usr/local/hestia/bin/csf.pl
chmod -R 755 $PANEL2
#############
cp $CSFCONF $CSFCONF-BKP-$T #bkp existing CSF.CONF
sed -i 's/TESTING = "1"/TESTING = "0"/g' $CSFCONF #CSF Testing mode 0
sed -i '/TCP_IN = "'$HESTIAPORT'/!s/TCP_IN = "/TCP_IN = "'$HESTIAPORT,'/' $CSFCONF #Add Hestia port into CSF TCP_IN
sed -i 's/RESTRICT_SYSLOG = "0"/RESTRICT_SYSLOG = "3"/g' $CSFCONF #CSF Attribute
sudo csf -ra
#nano $CSFCONF
# Add the CSF navigation link into panel top right
if grep -q 'CSF' $PANEL; then
echo '*** [This CSF Link Is Already There.]'
else
sed -i '/<div class="top-bar-right">/a <!-- CSF Link START --> <?php if ($_SESSION["user"] == "admin") { ?><li class="top-bar-menu-item"><a title="<?= _("CSF Firewall") ?>" class="top-bar-menu-link <?php if($TAB == "CSF") echo active ?>" href="/list/csf/"><i class="fas fa-shield-halved"></i><span class="top-bar-menu-link-label u-hide-desktop"><?= _("CSF Firewall") ?></span></a></li><?php } ?> <!-- CSF Link END --> ' $PANEL
fi
#nano $PANEL