-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from arnested/install
Add install script
- Loading branch information
Showing
3 changed files
with
63 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |