-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcloudflared-install.sh
68 lines (59 loc) · 2.52 KB
/
cloudflared-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
#!/bin/sh
set -e
echo "Version 0.2f"
echo "Do you wish to configure the default DNS server and install cloudflared proxy?"
read -r -p "Are you sure? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
echo "Starting configuration"
else
echo "exit cloudflared-installer"
exit 1
fi
WORKING_FILE=/etc/init.d/cloudflared
if [ -f $WORKING_FILE ]; then
echo "Found $WORKING_FILE stopping service"
sudo $WORKING_FILE stop
echo "Found /etc/init.d/cloudflared-dns removing file"
sudo rm $WORKING_FILE
fi
WORKING_FILE=/usr/local/bin/cloudflared
if [ -f $WORKING_FILE ]; then
echo "Found $WORKING_FILE removing file"
sudo rm $WORKING_FILE
fi
WORKING_FILE=/etc/cloudflared/config.yml
if [ -f $WORKING_FILE ]; then
read -r -p "found $WORKING_FILE would you like to install the repository maintainers configuration?? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
echo "Replacing your configuration. Moving your configuration to /tmp/cloudflared-config.yml-backup"
sudo mv $WORKING_FILE /tmp/cloudflared-config.yml-backup
else
echo "Keeping your configuration."
fi
fi
WORKING_FILE=/etc/cloudflared
if [ ! -d $WORKING_FILE ]; then
echo "make folder $WORKING_FILE"
sudo mkdir $WORKING_FILE
fi
WORKING_FILE=/etc/cloudflared/config.yml
if [ ! -f /etc/cloudflared/config.yml ]; then
echo "Downloading config.yml"
sudo /usr/bin/curl --fail https://raw.githubusercontent.com/yon2004/ubnt_cloudflared/master/config.yml --output $WORKING_FILE
fi
echo "downloading cloudflared binary"
sudo /usr/bin/curl --fail https://raw.githubusercontent.com/yon2004/ubnt_cloudflared/master/cloudflared --output /usr/local/bin/cloudflared
echo "setting execute permission on /usr/local/bin/cloudflared"
sudo /bin/chmod +x /usr/local/bin/cloudflared
sudo /usr/local/bin/cloudflared service install
sudo /etc/init.d/cloudflared start
echo "configure dns server"
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper begin
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper delete service dns forwarding options
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper set service dns forwarding cache-size 2500
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper set service dns forwarding options "no-resolv"
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper set service dns forwarding options "server=127.0.0.1#5053"
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper commit
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper end
echo "cloudflared has been installed"
echo "now you should update your DHCP DNS setting to direct clients to me"