1
0

added new installation instructions

This commit is contained in:
Sai Kiran Anagani 2019-10-29 17:15:53 +05:30
parent 47b51d0cf0
commit 8623ef5c80
5 changed files with 38 additions and 32 deletions

View File

@ -2,18 +2,29 @@ version: 2
jobs:
build:
docker:
- image: circleci/golang:1.8
working_directory: /go/src/github.com/anaganisk/digitalocean-dynamic-dns-ip
- image: circleci/golang:1.11
working_directory: ~/app
steps:
- checkout
- attach_workspace:
at: ./releases
- run:
name: Build
command: |
echo 'export GO111MODULE=on' >> $BASH_ENV
source $BASH_ENV
./ci-build-script.sh
./ci-build-script.sh .
- persist_to_workspace:
root: .
paths:
- ./releases
publish-github-release:
docker:
- image: cibuilds/github:0.10
working_directory: ~/app
steps:
- attach_workspace:
at: ~/app
- run:
name: "Publish Release on GitHub"
command: |
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} ./releases/
workflows:

View File

@ -1,4 +1,4 @@
# DIGITAL OCEAN DYNAMIC IP API CLIENT
# DIGITAL OCEAN DYNAMIC IP API CLIENT [![CircleCI](https://circleci.com/gh/anaganisk/digitalocean-dynamic-dns-ip/tree/master.svg?style=svg)](https://circleci.com/gh/anaganisk/digitalocean-dynamic-dns-ip/tree/master)
A simple script in Go language to automatically update Digital ocean DNS records if you have a dynamic IP. Since it can be compiled on any platform, you can use it along with raspberrypi etc.
@ -6,18 +6,20 @@ To find your Dynamic IP, this program will call out to https://ipv4bot.whatismyi
## Requirements
Requires Git, Go 1.8+.
- The record must already exist in DigitalOcean's DNS so that it can be updated.
(manually find your IP and add it to DO's DNS it will later be updated)
- A Digital Ocean API key that can be created at https://cloud.digitalocean.com/account/api/tokens.
Requires that the record already exists in DigitalOcean's DNS so that it can be updated.
(manually find your IP and add it to DO's DNS it will later be updated)
## Installation
Requires a Digital Ocean API key that can be created at https://cloud.digitalocean.com/account/api/tokens.
Download the prebuilt binaries from [releases](https://github.com/anaganisk/digitalocean-dynamic-dns-ip/releases),
## Building
You first need to install the "homedir" module if you aren't using it in another project. To install the module.
or Build from source
```bash
# Requires Git, Go 1.8+(GO 1.11 if you want to use GO111MODULE=on).
# clone the repo in ~/go/src/github.com/anaganisk:
git clone https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git
# Skip to next step, if you have GO111MODULE=on in your environment it is fetched automatically
go get github.com/mitchellh/go-homedir
# build the project
@ -26,11 +28,6 @@ go build
## Usage
```bash
# clone the repo in ~/go/src/github.com/anaganisk:
git clone https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git
```
Create a file `.digitalocean-dynamic-ip.json` (dot prefix to hide the file) and place it in your home directory. Add the following JSON (or refer to the sample configuration file, `digitalocean-dynamic-ip.sample.json`):
```json

View File

@ -6,7 +6,6 @@ if [[ -z "$package" ]]; then
fi
package_split=(${package//\// })
package_name=${package_split[-1]}
platforms=("windows/amd64" "windows/386" "darwin/amd64" "linux/386" "linux/amd64" "linux/arm" "linux/arm64")
mkdir releases
for platform in "${platforms[@]}"
@ -14,12 +13,11 @@ do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
output_name=$package_name'-'$GOOS'-'$GOARCH
output_name='digitalocean-dynamic-dns-ip-'$GOOS'-'$GOARCH
if [ $GOOS = "windows" ]; then
output_name+='.exe'
fi
env GOOS=$GOOS GOARCH=$GOARCH go build -o releases/$output_name $package
fi
env GOOS=$GOOS GOARCH=$GOARCH go build -o releases/$output_name $package_name
if [ $? -ne 0 ]; then
echo 'An error has occurred! Aborting the script execution...'
exit 1

View File

@ -120,17 +120,17 @@ func usage() {
//CheckLocalIPs : get current IP of server. checks both IPv4 and Ipv6 to support dual stack environments
func CheckLocalIPs() (ipv4, ipv6 net.IP) {
var ipv4String, ipv6String string
ipv4CheckUrl := "https://ipv4bot.whatismyipaddress.com"
ipv6CheckUrl := "https://ipv6bot.whatismyipaddress.com"
ipv4CheckURL := "https://ipv4bot.whatismyipaddress.com"
ipv6CheckURL := "https://ipv6bot.whatismyipaddress.com"
if len(config.IPv4CheckURL) > 0 {
ipv4CheckUrl = config.IPv4CheckURL
ipv4CheckURL = config.IPv4CheckURL
}
if len(config.IPv6CheckURL) > 0 {
ipv6CheckUrl = config.IPv6CheckURL
ipv6CheckURL = config.IPv6CheckURL
}
if config.UseIPv4 == nil || *(config.UseIPv4) {
ipv4String, _ = getURLBody(ipv4CheckUrl)
ipv4String, _ = getURLBody(ipv4CheckURL)
if ipv4String == "" {
log.Println("No IPv4 address found. Consider disabling IPv4 checks in the config `\"useIPv4\": false`")
} else {
@ -147,7 +147,7 @@ func CheckLocalIPs() (ipv4, ipv6 net.IP) {
}
if config.UseIPv6 == nil || *(config.UseIPv6) {
ipv6String, _ = getURLBody(ipv6CheckUrl)
ipv6String, _ = getURLBody(ipv6CheckURL)
if ipv6String == "" {
log.Println("No IPv6 address found. Consider disabling IPv6 checks in the config `\"useIPv6\": false`")
} else {

2
go.mod
View File

@ -2,4 +2,4 @@ module github.com/anaganisk/digitalocean-dynamic-dns-ip
require github.com/mitchellh/go-homedir v1.1.0
go 1.13
go 1.8