forked from DennoN-RUS/Bird4Static
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
81 lines (65 loc) · 2.25 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
#!/bin/sh
LISTS=$HOME/Bird4Static/lists
SCRIPTS=$HOME/Bird4Static/scripts
while true; do
echo "Begin install? y/n"
read yn
case $yn in
[Yy]* )
echo "Do you want to use double vpn configuration? 0 - no (default) 1 - yes"
read conf
if [ "$conf" != "1" ]; then
conf=0
CONFFOLDER="one_vpn"
echo "Starting install for one vpn"
else
CONFFOLDER="double_vpn"
echo "Starting install for double vpn"
fi
# Installing packages
opkg install bird1-ipv4 curl cron bind-dig iprange
# Create start folders
mkdir -p $SCRIPTS
mkdir -p $LISTS
# Getting the path to run the script
ABSOLUTE_FILENAME=`readlink -f "$0"`
DIRECTORY=`dirname "$ABSOLUTE_FILENAME"`
# Filling script folders and custom sheets
cp $DIRECTORY/Install/$CONFFOLDER/*.sh $SCRIPTS
chmod +x $SCRIPTS/*.sh
cp -i $DIRECTORY/Install/$CONFFOLDER/*.list $LISTS
# Copying the bird configuration file
if [ ! -f "/opt/etc/bird4.conf-opkg" ]; then
mv /opt/etc/bird4.conf /opt/etc/bird4.conf-opkg;
fi
cp -i $DIRECTORY/Install/$CONFFOLDER/bird4.conf /opt/etc/bird4.conf
# Reading vpn and provider interfaces, replacing in scripts and bird configuration
echo -e "\n----------------------"
ifconfig | grep -B 1 "inet addr" | awk '{print $1$2}' | sed ':a;N;$!ba;s/Link\n/ <--/g;s/inetaddr:/ /g;s/--\n//g'
echo "Enter the name of the provider interface from the list above (for exaple ppp0 or eth3)"
read ISP
sed -i 's/ISPINPUT/'$ISP'/' $SCRIPTS/add-bird4_routes.sh
echo "Enter the VPN interface name from the list above (for exaple ovpn_br0 or nwg0)"
read VPN1
sed -i 's/VPN1INPUT/'$VPN1'/' $SCRIPTS/add-bird4_routes.sh
sed -i 's/VPN1INPUT/'$VPN1'/' /opt/etc/bird4.conf
if [ "$conf" -eq "1" ]; then
echo "Enter the Second VPN interface name from the list above (for exaple ovpn_br0 or nwg0)"
read VPN2
sed -i 's/VPN2INPUT/'$VPN2'/' $SCRIPTS/add-bird4_routes.sh
sed -i 's/VPN2INPUT/'$VPN2'/' /opt/etc/bird4.conf
fi
# Organizing scripts into folders
ln -sf $SCRIPTS/bird-table.sh /opt/etc/init.d/S02bird-table
ln -sf $SCRIPTS/add-bird4_routes.sh /opt/etc/cron.hourly/
# Starting Services
/opt/etc/init.d/S02bird-table start
$SCRIPTS/add-bird4_routes.sh
/opt/etc/init.d/S10cron start
/opt/etc/init.d/S04bird1-ipv4 start
exit 0
;;
[Nn]* ) exit 0;;
* ) echo "Please answer yes or no.";;
esac
done