mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-14 18:53:16 +00:00
feat!: refactor base, config, dfm and scripts
This commit is contained in:
@@ -3,11 +3,18 @@
|
||||
# Install ntfy
|
||||
#
|
||||
# shellcheck source=shared.sh
|
||||
eval "$HOME/.dotfiles/scripts/shared.sh"
|
||||
set -e
|
||||
eval "$DOTFILES/config/shared.sh"
|
||||
|
||||
x-have "ntfy" && msg "ntfy already installed" && exit 0
|
||||
# Enable verbosity with VERBOSE=1
|
||||
VERBOSE="${VERBOSE:-0}"
|
||||
|
||||
# Check if ntfy is already installed
|
||||
if x-have "ntfy"; then
|
||||
msg "ntfy already installed"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Determine the architecture
|
||||
case $(dfm check arch) in
|
||||
Linux)
|
||||
NTFY_ARCH="linux_$(arch)"
|
||||
@@ -15,21 +22,36 @@ case $(dfm check arch) in
|
||||
Darwin)
|
||||
NTFY_ARCH="macOS_all"
|
||||
;;
|
||||
*)
|
||||
msg_err "Unsupported OS"
|
||||
;;
|
||||
esac
|
||||
|
||||
NTFY_VERSION=2.2.0
|
||||
NTFY_VERSION="$(x-gh-get-latest-version binwiederhier/ntfy)"
|
||||
NTFY_URL="https://github.com/binwiederhier/ntfy"
|
||||
NTFY_DEST="/tmp/ntfy_${NTFY_VERSION}_${NTFY_ARCH}"
|
||||
|
||||
curl -L "$NTFY_URL/releases/download/v${NTFY_VERSION}/${NTFY_DEST}.tar.gz" \
|
||||
> "${NTFY_DEST}.tar.gz"
|
||||
tar zxvf "${NTFY_DEST}.tar.gz"
|
||||
cp -a "${NTFY_DEST}/ntfy" ~/.local/bin/ntfy
|
||||
mkdir -p ~/.config/ntfy
|
||||
# Download and extract ntfy
|
||||
install_ntfy()
|
||||
{
|
||||
curl -L "$NTFY_URL/releases/download/v${NTFY_VERSION}/${NTFY_DEST}.tar.gz" -o "${NTFY_DEST}.tar.gz"
|
||||
tar zxvf "${NTFY_DEST}.tar.gz"
|
||||
cp -a "${NTFY_DEST}/ntfy" ~/.local/bin/ntfy
|
||||
mkdir -p ~/.config/ntfy
|
||||
|
||||
# copy config only if it does not exist
|
||||
if [ ! -f "$HOME/.config/ntfy/client.yml" ]; then
|
||||
cp "${NTFY_DEST}/client/client.yml" ~/.config/ntfy/client.yml
|
||||
fi
|
||||
# Copy config only if it does not exist
|
||||
if [ ! -f "$HOME/.config/ntfy/client.yml" ]; then
|
||||
cp "${NTFY_DEST}/client/client.yml" ~/.config/ntfy/client.yml
|
||||
fi
|
||||
|
||||
rm -rf "${NTFY_DEST}" "${NTFY_DEST}.tar.gz"
|
||||
# Clean up
|
||||
rm -rf "${NTFY_DEST}" "${NTFY_DEST}.tar.gz"
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
install_ntfy
|
||||
msg "ntfy installation complete"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user