mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-03-04 02:14:40 +01:00
Make the script a bit more reliable
parent
23e5e2b9ff
commit
cc07466f25
1 changed files with 20 additions and 56 deletions
76
Updates.md
76
Updates.md
|
@ -1,69 +1,33 @@
|
|||
# Automatic Update For Linux
|
||||
The script below will check to see if dnscrypt-proxy needs updating by comparing the installed version with the latest git version.
|
||||
#! /bin/sh
|
||||
|
||||
If the installed version is older, then the script will update to the newest version.
|
||||
|
||||
Tested on: Ubuntu 18.04
|
||||
|
||||
## Requirements
|
||||
This script requires dnscrypt-proxy to be installed as a service using,`./dnscrypt-proxy -service install` and for dnscrypt-proxy to be installed in `/opt/dnscrypt-proxy` and for the configuration file to be named `dnscrypt-proxy.toml`.
|
||||
|
||||
If dnscrypt-proxy is not run as root then, change `sudo chown root:root -R /opt/dnscrypt-proxy` to the user dnscrypt-proxy is run as.
|
||||
|
||||
## Configuration
|
||||
|
||||
Initially make sure all the above requirements are met.
|
||||
|
||||
Then to get this script to automatically run add this as a cron job under root using `sudo crontab -e` but, change the file path to the file path the script is saved.
|
||||
|
||||
`0 */12 * * * /path/dnscrypt-proxy-update.sh`
|
||||
|
||||
Also, this script needs to be run as root.
|
||||
|
||||
```sh
|
||||
#!/bin/sh
|
||||
INSTALL_DIR="/opt/dnscrypt-proxy"
|
||||
LATEST_URL="https://api.github.com/repos/jedisct1/dnscrypt-proxy/releases/latest"
|
||||
|
||||
Update() {
|
||||
cd /opt/dnscrypt-proxy
|
||||
sudo mv dnscrypt-proxy.toml /opt/
|
||||
cd /opt
|
||||
sudo curl -L -O $( curl -s https://api.github.com/repos/jedisct1/dnscrypt-proxy/releases/latest | grep dnscrypt-proxy-linux_x86_64- | grep browser_download_url | head -1 | cut -d \" -f 4 )
|
||||
sudo service dnscrypt-proxy stop
|
||||
sudo rm -rf /opt/dnscrypt-proxy
|
||||
sudo tar xvzf dnscrypt-proxy-linux_x86_64-*.tar.gz
|
||||
cd linux-x86_64
|
||||
sudo mkdir /opt/dnscrypt-proxy
|
||||
sudo mv * /opt/dnscrypt-proxy
|
||||
sudo mv -f /opt/dnscrypt-proxy.toml /opt/dnscrypt-proxy
|
||||
sudo chown root:root -R /opt/dnscrypt-proxy
|
||||
sudo chmod 775 /opt/dnscrypt-proxy
|
||||
sudo cp -f /etc/resolv.conf /etc/resolv.conf.backup
|
||||
cd /opt
|
||||
sudo rm -rf dnscrypt-proxy-linux_x86_*
|
||||
sudo rm -rf linux-x86_64
|
||||
sudo service dnscrypt-proxy start
|
||||
sudo service dnscrypt-proxy status
|
||||
workdir="$(mktemp -d)"
|
||||
curl -sL $(curl -sL ${LATEST_URL} |
|
||||
grep dnscrypt-proxy-linux_x86_64- | grep browser_download_url | head -1 | cut -d \" -f 4) |
|
||||
tar xz -C "$workdir" -f - linux-x86_64/dnscrypt-proxy &&
|
||||
[ -x linux-x86_64/dnscrypt-proxy ] &&
|
||||
mv -f "${INSTALL_DIR}/dnscrypt-proxy" "${INSTALL_DIR}/dnscrypt-proxy.old" || : &&
|
||||
mv -f "${workdir}/linux-x86_64/dnscrypt-proxy" "${INSTALL_DIR}/" &&
|
||||
cd "$INSTALL_DIR" && rm -fr "$workdir" &&
|
||||
./dnscrypt-proxy -check && ./dnscrypt-proxy -service install 2>/dev/null || : &&
|
||||
./dnscrypt-proxy -service restart || ./dnscrypt-proxy -service start
|
||||
}
|
||||
|
||||
lversion=$(
|
||||
cd /opt/dnscrypt-proxy
|
||||
./dnscrypt-proxy -version
|
||||
)
|
||||
|
||||
rmersion=$(
|
||||
curl -s https://api.github.com/repos/jedisct1/dnscrypt-proxy/releases/latest | grep "tag_name" | head -1 | cut -d \" -f 4
|
||||
)
|
||||
lversion=$("${INSTALL_DIR}/dnscrypt-proxy" -version)
|
||||
rmersion=$(curl -sL ${LATEST_URL} | grep "tag_name" | head -1 | cut -d \" -f 4)
|
||||
[ -z "$lversion" || -z "$rmersion" ] && exit 1
|
||||
|
||||
echo locally installed
|
||||
echo $lversion
|
||||
echo "$lversion"
|
||||
|
||||
echo remote git version
|
||||
echo $rmersion
|
||||
echo "$rmersion"
|
||||
|
||||
if [[ "$rmersion" > "$lversion" ]]
|
||||
then
|
||||
if [ "$rmersion" != "$lversion" ]; then
|
||||
echo Updating && Update
|
||||
else
|
||||
echo No Update Needed
|
||||
fi
|
||||
```
|
||||
fi
|
Loading…
Add table
Reference in a new issue