2019-10-30 10:07:21 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
|
|
|
yum -y update
|
|
|
|
|
|
|
|
SERVER="$(hostname)"
|
|
|
|
export SERVER
|
|
|
|
SERVER_IP="$(ip route get 1 | awk '{print $NF;exit}')"
|
|
|
|
export SERVER_IP
|
|
|
|
echo "$SERVER"
|
|
|
|
echo "$SERVER_IP"
|
|
|
|
|
|
|
|
(
|
|
|
|
exec 2>/dev/null
|
|
|
|
|
2019-10-30 17:59:35 +00:00
|
|
|
if ! [ -x "$(command -v docker)" ]; then
|
|
|
|
yum install -y docker
|
|
|
|
fi
|
|
|
|
|
2019-10-30 10:07:21 +00:00
|
|
|
docker stop dnscrypt-server
|
|
|
|
docker stop watchtower
|
|
|
|
docker rm dnscrypt-server
|
|
|
|
docker rm watchtower
|
|
|
|
docker container prune -f
|
|
|
|
docker volume prune -f
|
|
|
|
docker image prune -f
|
|
|
|
|
|
|
|
yum remove -y firewalld
|
|
|
|
yum remove -y iptables-services
|
|
|
|
)
|
|
|
|
|
2020-04-24 10:30:13 +00:00
|
|
|
mkdir -p /etc/dnscrypt-server/lists
|
2019-10-30 10:07:21 +00:00
|
|
|
if [ -d /root/keys ]; then
|
2020-04-24 10:30:13 +00:00
|
|
|
mv /root/keys /etc/dnscrypt-server
|
2019-10-30 10:07:21 +00:00
|
|
|
fi
|
2020-04-24 10:30:13 +00:00
|
|
|
mkdir -p /etc/dnscrypt-server/keys
|
2019-10-30 10:07:21 +00:00
|
|
|
|
2020-04-24 10:30:13 +00:00
|
|
|
if [ -f /etc/dnscrypt-server/keys/state/encrypted-dns.state ]; then
|
2019-10-30 10:07:21 +00:00
|
|
|
docker run \
|
|
|
|
--ulimit nofile=90000:90000 \
|
2020-04-24 10:30:13 +00:00
|
|
|
-v /etc/dnscrypt-server/keys:/opt/encrypted-dns/etc/keys \
|
|
|
|
-v /etc/dnscrypt-server/lists:/opt/encrypted-dns/etc/lists \
|
2020-04-27 21:08:31 +00:00
|
|
|
--name=dnscrypt-server -p 443:443/udp -p 443:443/tcp \
|
2019-10-30 10:07:21 +00:00
|
|
|
-d jedisct1/dnscrypt-server start
|
|
|
|
else
|
|
|
|
docker run \
|
|
|
|
--ulimit nofile=90000:90000 \
|
2020-04-24 10:30:13 +00:00
|
|
|
-v /etc/dnscrypt-server/keys:/opt/encrypted-dns/etc/keys \
|
|
|
|
-v /etc/dnscrypt-server/lists:/opt/encrypted-dns/etc/lists \
|
2020-04-27 21:08:31 +00:00
|
|
|
--name=dnscrypt-server -p 443:443/udp -p 443:443/tcp \
|
2019-10-30 10:07:21 +00:00
|
|
|
jedisct1/dnscrypt-server init -N "$SERVER" -E "${SERVER_IP}:443"
|
|
|
|
docker start dnscrypt-server
|
|
|
|
fi
|
|
|
|
|
2020-04-24 10:30:13 +00:00
|
|
|
cat /etc/dnscrypt-server/keys/provider-info.txt
|
2019-10-30 10:07:21 +00:00
|
|
|
|
|
|
|
docker update --restart=unless-stopped dnscrypt-server
|
|
|
|
|
2020-04-26 21:34:31 +00:00
|
|
|
docker run -d --name watchtower -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower dnscrypt-server
|
2019-10-30 10:07:21 +00:00
|
|
|
docker update --restart=unless-stopped watchtower
|
|
|
|
|
2020-04-24 10:30:13 +00:00
|
|
|
ln -sf /etc/dnscrypt-server/keys /root
|
2019-10-30 10:07:21 +00:00
|
|
|
|
|
|
|
echo 3 >/proc/sys/vm/drop_caches
|
|
|
|
|
|
|
|
if [ ! -L /etc/motd ]; then
|
|
|
|
rm -f /etc/motd
|
2020-04-24 10:30:13 +00:00
|
|
|
ln -s /etc/dnscrypt-server/keys/provider-info.txt /etc/motd
|
2019-10-30 10:07:21 +00:00
|
|
|
reboot
|
|
|
|
fi
|