-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathubuntu-server-install.sh
executable file
·123 lines (104 loc) · 2.32 KB
/
ubuntu-server-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
#!/bin/bash
echo "Installing mdns server..."
if [ "$EUID" -ne 0 ]; then
echo "Sorry, you need to run this as root"
exit 1
fi
if [[ -e /etc/debian_version ]]; then
OS="debian"
source /etc/os-release
if [[ $ID == "ubuntu" ]]; then
OS="ubuntu"
MAJOR_UBUNTU_VERSION=$(echo "$VERSION_ID" | cut -d '.' -f1)
if [[ $MAJOR_UBUNTU_VERSION -lt 22 ]]; then
echo "If you're using Ubuntu < 22.04, then you can continue, at your own risk."
until [[ $CONTINUE =~ (y|n) ]]; do
read -rp "Continue? [y/n]: " -e CONTINUE
done
if [[ $CONTINUE == "n" ]]; then
exit 1
fi
fi
fi
else
echo "Looks like you aren't running this installer on Ubuntu system"
exit 1
fi
cd /tmp
git clone https://github.com/MarlikAlmighty/mdns
ERR=$?
if [[ $ERR != 0 ]]; then
echo "error while cloning mDNS from github, exit."
exit 1
fi
cd mdns
cp bin/mdns /usr/local/bin
ERR=$?
if [[ $ERR != 0 ]]; then
echo "error while installing mdns, exit."
exit 1
fi
chmod 755 /usr/local/bin/mdns
ERR=$?
if [[ $ERR != 0 ]]; then
echo "error while chmod /usr/local/bin/mdns, exit."
exit 1
fi
cp mdns.service /etc/systemd/system/mdns.service
ERR=$?
if [[ $ERR != 0 ]]; then
echo "error while installing mdns.service, exit."
exit 1
fi
systemctl daemon-reload
ERR=$?
if [[ $ERR != 0 ]]; then
echo "error while daemon-reload, exit."
exit 1
fi
systemctl enable mdns
ERR=$?
if [[ $ERR != 0 ]]; then
echo "error while enable mdns, exit."
exit 1
fi
mv /etc/systemd/resolved.conf /etc/systemd/resolved.bak
ERR=$?
if [[ $ERR != 0 ]]; then
echo "error while mv resolved.conf, exit."
exit 1
fi
cp resolved.conf /etc/systemd/resolved.conf
ERR=$?
if [[ $ERR != 0 ]]; then
echo "error while cp resolved.conf, exit."
exit 1
fi
ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
ERR=$?
if [[ $ERR != 0 ]]; then
echo "error while ln resolv.conf, exit."
exit 1
fi
systemctl restart systemd-resolved
ERR=$?
if [[ $ERR != 0 ]]; then
echo "error while restart systemd-resolved, exit."
exit 1
fi
systemctl start mdns
ERR=$?
if [[ $ERR != 0 ]]; then
echo "error while start mdns, exit."
exit 1
fi
rm -rf /tmp/mdns
ERR=$?
if [[ $ERR != 0 ]]; then
echo "error while rm -rf /tmp/mdns, exit."
exit 1
fi
# add hostname to /etc/hosts
# echo $(hostname -I | cut -d\ -f1) $(hostname) | sudo tee -a /etc/hosts > /dev/null
echo "Done, mdns is installed."
exit 0