-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·132 lines (128 loc) · 4.07 KB
/
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
#
# APF 9.7 [[email protected]]
###
# Copyright (C) 2002-2011, R-fx Networks <[email protected]>
# Copyright (C) 2011, Ryan MacDonald <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
###
#
INSTALL_PATH="/etc/apf"
BINPATH="/usr/bin/apf"
COMPAT_BINPATH="/usr/bin/fwmgr"
install() {
echo " "
mkdir $INSTALL_PATH
mkdir $INSTALL_PATH/doc
cp -fR files/* $INSTALL_PATH
chmod -R 640 $INSTALL_PATH/*
chmod 750 $INSTALL_PATH/apf
chmod 750 $INSTALL_PATH/firewall
chmod 750 $INSTALL_PATH/vnet/vnetgen
chmod 750 $INSTALL_PATH/extras/get_ports
chmod 750 $INSTALL_PATH/extras/dshield/install
chmod 750 $INSTALL_PATH
cp -pf .ca.def importconf $INSTALL_PATH/extras/
cp README CHANGELOG COPYING.GPL $INSTALL_PATH/doc
ln -fs $INSTALL_PATH/apf $BINPATH
ln -fs $INSTALL_PATH/apf $COMPAT_BINPATH
rm -f /etc/cron.d/fwdev
rm -f /etc/apf/cron.fwdev
if [ -f "/etc/cron.hourly/fw" ]; then
rm -f /etc/cron.hourly/fw
fi
if [ -f "/etc/cron.daily/fw" ]; then
rm -f /etc/cron.daily/fw
fi
if [ -f "/etc/cron.daily/apf" ]; then
rm -f /etc/cron.daily/apf
cp cron.daily /etc/cron.daily/apf
chmod 755 /etc/cron.daily/apf
else
cp cron.daily /etc/cron.daily/apf
chmod 755 /etc/cron.daily/apf
fi
echo -n "Detecting init system type.. "
if [ -d "/etc/rc.d/init.d" ]; then
echo "Found rc.d."
cp -f apf.init /etc/rc.d/init.d/apf
elif [ -d "/etc/init.d" ]; then
if [ -f "/sbin/rc-update" ]; then
echo -n "Found OpenRC."
cp -f apf.rc /etc/init.d/apf
chmod +x /etc/init.d/apf
else
echo -n "Found /etc/init.d."
cp -f apf.init /etc/init.d/apf
fi
else
echo -n "Found /etc/rc.local"
if [ -f "/etc/rc.local" ]; then
val=`grep -i apf /etc/rc.local`
if [ "$val" == "" ]; then
echo "/etc/apf/apf -s >> /dev/null 2>&1" >> /etc/rc.local
fi
fi
fi
if [ -f "/var/log/apf_log" ] || [ -f "/var/log/apfados_log" ]; then
rm -f /var/log/apf_log /var/log/apfados_log
fi
if [ -d "/etc/logrotate.d" ] && [ -f "logrotate.d.apf" ]; then
cp logrotate.d.apf /etc/logrotate.d/apf
fi
if [ -f "/sbin/chkconfig" ]; then
/sbin/chkconfig --add apf
/sbin/chkconfig --level 345 apf on
fi
/etc/apf/vnet/vnetgen
if [ -f "/usr/bin/dialog" ] && [ -d "/etc/apf/extras/apf-m" ]; then
last=`pwd`
cd /etc/apf/extras/apf-m/
sh install -i
cd $last
fi
chmod 750 $INSTALL_PATH
}
VER=`cat files/VERSION | grep version | awk '{print$2}'`
if [ -d "$INSTALL_PATH" ]; then
DVAL=`date +"%d%m%Y-%s"`
cp -R $INSTALL_PATH $INSTALL_PATH.bk$DVAL
rm -f /etc/apf.bk.last
ln -fs $INSTALL_PATH.bk$DVAL /etc/apf.bk.last
rm -rf $INSTALL_PATH
echo "Installing APF $VER: "
install
else
echo "Installing APF $VER: "
install
fi
sleep 1
echo "Completed."
echo ""
echo "Installation Details:"
echo " Install path: $INSTALL_PATH/"
echo " Config path: $INSTALL_PATH/conf.apf"
echo " Executable path: $BINPATH"
echo ""
echo "Other Details:"
if [ -d "/etc/apf.bk.last" ]; then
./importconf
echo " Note: Please review /etc/apf/conf.apf for consistency, install default backed up to /etc/apf/conf.apf.orig"
else
. $INSTALL_PATH/extras/get_ports
echo " Note: These ports are not auto-configured; they are simply presented for information purposes. You must manually configure all port options."
fi
rm -f .conf.apf