2023-01-28 20:47:57 -08:00
|
|
|
{{- if and (ne .host.distro.family "windows") (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "key-netdata-token")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "key-netdata-room")) -}}
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
{{ includeTemplate "universal/profile" }}
|
|
|
|
{{ includeTemplate "universal/logg" }}
|
|
|
|
|
|
|
|
### Claim the instance with Netdata Cloud
|
|
|
|
if command -v netdata-claim.sh > /dev/null; then
|
|
|
|
NETDATA_TOKEN="$(cat "{{ .chezmoi.sourceDir }}/.chezmoitemplates/secrets/key-netdata-token" | chezmoi decrypt)"
|
|
|
|
NETDATA_ROOM="$(cat "{{ .chezmoi.sourceDir }}/.chezmoitemplates/secrets/key-netdata-room" | chezmoi decrypt)"
|
2023-01-28 22:07:01 -08:00
|
|
|
netdata-claim.sh -token="$NETDATA_TOKEN" -rooms="$NETDATA_ROOM" -url="{{ .netdataClaimURL }}"
|
2023-01-28 20:47:57 -08:00
|
|
|
|
|
|
|
# Kernel optimizations
|
2023-01-28 22:07:01 -08:00
|
|
|
# These are mentioned while installing via the kickstart.sh script method. We are using Homebrew for the installation though.
|
|
|
|
# Assuming these optimizations do not cause any harm.
|
2023-01-28 20:47:57 -08:00
|
|
|
if [ -d /Applications ] && [ -d /System ]; then
|
|
|
|
# macOS
|
|
|
|
logg info 'System is macOS so Netdata kernel optimizations are not required'
|
|
|
|
else
|
|
|
|
# Linux
|
|
|
|
if [ -d /sys/kernel/mm/ksm ]; then
|
|
|
|
logg info 'Adding Netdata kernel optimization for `/sys/kernel/mm/ksm/run`'
|
|
|
|
echo 1 | sudo tee /sys/kernel/mm/ksm/run
|
|
|
|
logg info 'Adding Netdata kernel optimization for `/sys/kernel/mm/ksm/sleep_millisecs`'
|
|
|
|
echo 1000 | sudo tee /sys/kernel/mm/ksm/sleep_millisecs
|
|
|
|
else
|
|
|
|
logg info 'The `/sys/kernel/mm/ksm` directory does not exist so Netdata kernel optimizations are not being applied'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
logg warn '`netdata-claim.sh` is not available in the PATH'
|
|
|
|
fi
|
|
|
|
|
2023-01-30 00:31:07 -08:00
|
|
|
{{ end -}}
|