Skip to content

Commit

Permalink
Merge pull request #4 from arnested/install
Browse files Browse the repository at this point in the history
Add install script
  • Loading branch information
arnested authored Jan 4, 2021
2 parents f50f7d8 + c892bbd commit d6de2ee
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 13 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Shellcheck
on:
- pull_request
- push

jobs:
shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run shellcheck
uses: ludeeus/[email protected]
14 changes: 1 addition & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@ https://my-fancy.local).

## Install

Download the binary and installed it as e.g. `/usr/local/bin/ldddns`.

```console
sudo sh -c "curl --fail -sSL -o /usr/local/bin/ldddns https://github.com/arnested/ldddns/releases/latest/download/ldddns_$(uname -s)_$(uname -m) && chmod +x /usr/local/bin/ldddns"
```

Create a systemd service unit file:
```console
sudo sh -c "/usr/local/bin/ldddns > /etc/systemd/system/ldddns.service"
```

Enable and start the service unit:
```console
sudo systemctl enable --now ldddns.service
curl -fsSL https://raw.githubusercontent.com/arnested/ldddns/main/install.sh | bash
```
49 changes: 49 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

if [ -z "$BASH" ] ;then echo Please run this with bash; exit 1; fi

set -euo pipefail

ldddns_install() {
set -euo pipefail

tmpdir="$(mktemp -d)"

# Make a cleanup function
cleanup() {
rm --recursive --force -- "${tmpdir}"
}
trap cleanup EXIT

echo Downloading ldddns binary
curl --proto =https --fail -sSL -o "${tmpdir}/ldddns" "https://github.com/arnested/ldddns/releases/latest/download/ldddns_$(uname -s)_$(uname -m)"

chmod +x "${tmpdir}/ldddns"

install_dir=/usr/local/libexec/ldddns

echo Making directory \(${install_dir}\) for installing service binary
mkdir -p "${install_dir}"

echo Installing service binary in ${install_dir}
mv "${tmpdir}/ldddns" "${install_dir}"

echo Generating systemd service unit
"${install_dir}/ldddns" > "${tmpdir}/ldddns.service"

echo Installing systemd service unit in /etc/systemd/system/ldddns.service
mv "${tmpdir}/ldddns.service" /etc/systemd/system/ldddns.service

echo Reloading systemd daemon
systemctl daemon-reload

if systemctl is-active --quiet ldddns.service; then
echo Found existing, running ldddns.service - restarting it
systemctl restart ldddns.service
fi

echo Enabling systemd service
systemctl enable --now ldddns.service;
}

pkexec bash -c "$(declare -f ldddns_install) ; ldddns_install"

0 comments on commit d6de2ee

Please sign in to comment.