diff --git a/README.md b/README.md index 43fb52d..73b6fb8 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,17 @@ This is a simple python app to manage DyDNS updates for the user manually creating and entering ClouDNS update URLs, but I plan to integrate with the ClouDNS in the very near future. +## Installation + +This client can currently be installed as systemd service +on most unix distributions. + +To install this client as a system service: + +```shell +curl -fsSL https://raw.githubusercontent.com/rjojjr/cloudns-ddns-client/master/scripts/linux-installer.sh | sudo bash +``` + ## USAGE ### Adding Hostnames @@ -13,6 +24,9 @@ To add a ClouDNS hostname for updates, run this app with the `-a`(or `--add-hostname`) flag followed by the hostname and then the DyDNS update URL provided by the ClouDNS webapp. +**IMPORTANT** - Run the `--add-hostname` cmd with the `sudo` when +running this client as systemd service. + EX: ```shell diff --git a/scripts/cloudns-client b/scripts/cloudns-client new file mode 100644 index 0000000..d8368e4 --- /dev/null +++ b/scripts/cloudns-client @@ -0,0 +1,3 @@ +#!/bin/bash + +python3 /usr/local/cloudns-ddns-client/src/main.py "$@" \ No newline at end of file diff --git a/scripts/linux-installer.sh b/scripts/linux-installer.sh new file mode 100644 index 0000000..04e72e6 --- /dev/null +++ b/scripts/linux-installer.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +echo 'Installing ClouDNS DyDNS Update Client' + +# TODO - version argument +# TODO - argument to install from local repo(no git clone) + +# TODO - install deps. for other OSes +if [[ "$1" == "--install-apt-deps" ]]; then + echo 'Installing apt dependencies' + { + apt install python3-pip -y && \ + apt install python3-venv -y + } || { + echo 'Failed to install Torch Tuner CLI apt dependencies' && \ + exit 1 + } + +fi + +cd /usr/local || (mkdir -p /usr/local && (cd /usr/local || (echo 'failed to create install directory at /usr/local' && exit 1))) + +if [ -d ./cloudns-ddns-client ]; then + echo "Removing old update client install" + { + rm -rf ./torch-tuner + } || { + echo 'Failed to remove old update client install' && \ + exit 1 + } +fi + +{ + git clone https://github.com/rjojjr/cloudns-ddns-client.git +} || { + echo 'Failed to clone update client' && \ + exit 1 +} + +{ + cd cloudns-ddns-client +} || { + echo 'Failed to navigate to cloudns-ddns-client directory' && \ + exit 1 +} + +{ + echo 'Installing update client as system wide application' && \ + cp scripts/cloudns-client /bin/cloudns-client && \ + sudo chmod +x /bin/cloudns-client +} || { + echo 'Failed to install update client as system wide application' && \ + exit 1 +} + +{ + echo 'Installing update client systemd service' && \ + cp svc/cloudns-ddns-update-client.service /etc/systemd/system/ && \ + sudo systemctl enable cloudns-ddns-update-client.service && \ + sudo systemctl start cloudns-ddns-update-client.service +} || { + echo 'Failed to install update client service' && \ + exit 1 +} + +echo 'ClouDNS DyDNS Update Client installed successfully!' \ No newline at end of file