-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·66 lines (66 loc) · 2.55 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
#!/bin/bash
#
# sweet-dns install utility
#
# Definitions
optdir=/usr/local/opt/sweet-dns
dstdir=/usr/local/bin/sweet-dns
tmpzip=/private/tmp/sweet-dns-master.zip
tmpdst=/private/tmp/sweet-dns
# Directories
if [[ ! -d $$optdir ]]; then bash -c "mkdir -p $optdir/"; fi
# Main
echo -e "\033[1mInfo >>>\033[0m Running sweet-dns installation..."
which brew > /dev/null
if [[ $? -eq 1 ]]; then
echo -e "\033[1m\e[31mWarn >>>\e[0m\033[0m Homebrew must be installed, refer to https://brew.sh/ \n"
exit 1
else
brew ls --versions dnsmasq > /dev/null
if [[ $? -eq 1 ]]; then
echo -e "\033[1mInfo >>>\033[0m Running dnsmasq installation..."
HOMEBREW_NO_AUTO_UPDATE=1 brew install dnsmasq
fi
which sweet-dns > /dev/null
if [[ $? -eq 1 ]]; then
wget -qO $tmpzip https://github.com/asiellb/sweet-dns/archive/master.zip > /dev/null
tar -xf $tmpzip -C $optdir/ --strip 1
ln -sf $optdir/bin/sweet-dns $dstdir
chmod +x $dstdir
message="\033[1mInfo >>>\033[0m Installation successfull! \n
For help use \033[1msweet-dns -h\033[0m \n "
else
curl -L https://raw.githubusercontent.com/asiellb/sweet-dns/master/bin/sweet-dns -o $tmpdst -s > /dev/null
if cmp $tmpdst $dstdir > /dev/null; then
message="\033[1mInfo >>>\033[0m sweet-dns already installed on your system and up to date! \n
For help use \033[1msweet-dns -h\033[0m \n "
else
echo -e "\033[1mInfo >>>\033[0m Updating sweet-dns installation..."
if [[ $(grep "Version:" $tmpdst | awk '{print $3}') == $(grep "Version:" $dstdir | awk '{print $3}') ]]; then
cp -rf $tmpdst $optdir/bin/sweet-dns
chmod +x $dstdir
message="\033[1mInfo >>>\033[0m Partial update successfull! \n
For help use \033[1msweet-dns -h\033[0m \n "
else
wget -qO $tmpzip https://github.com/asiellb/sweet-dns/archive/master.zip
tar -xf $tmpzip -C $optdir/ --strip 1
ln -sf $optdir/bin/sweet-dns $dstdir
chmod +x $dstdir
message="\033[1mInfo >>>\033[0m Full update successfull! \n
For help use \033[1msweet-dns -h\033[0m \n "
fi
fi
rm -f $tmpdst
rm -f $tmpzip
fi
sweet-dns -c
if [[ $? -eq 0 ]]; then
echo -e $message
exit 0
else
message="\033[1mInfo >>>\033[0m Update not complete :(! \n
For help use \033[1msweet-dns -h\033[0m \n "
echo -e $message
exit 1
fi
fi