Created Updates (markdown)

zero77 2019-02-20 15:58:01 +00:00
parent f90cc3f442
commit b0073407c4

65
Updates.md Normal file

@ -0,0 +1,65 @@
# 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.
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/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
Inishely 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 * * * /file path/dnscrypt-proxy-update.sh`
Also, this script needs to be run as root.
```#!/bin/bash
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 | 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 1775 -R /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
}
lversion() {
cd /opt/dnscrypt-proxy
./dnscrypt-proxy -version
}
rmersion() {
curl -s https://api.github.com/repos/jedisct1/dnscrypt-proxy/releases | grep "tag_name" | head -1 | cut -d \" -f 4
}
echo locally installed
lversion
echo remote git version
rmersion
if (( rmersion > lversion )); then
echo Updating && Update
else
echo No Update Needed
fi
```