Skip to content

Instantly share code, notes, and snippets.

@supersonictw
Last active December 1, 2024 13:40
Show Gist options
  • Save supersonictw/f1a45c23a7e8ca135757b1303509e37f to your computer and use it in GitHub Desktop.
Save supersonictw/f1a45c23a7e8ca135757b1303509e37f to your computer and use it in GitHub Desktop.
Nomad OpenRC from Alpine Linux 3.17 wget -O - https://ncurl.xyz/s/HbaXC_7NR | sh -
#!/bin/sh
# install-nomad-openrc.sh
# SPDX-License-Identifier: MIT (https://ncurl.xyz/s/o_o6DVqIR)
wget -O "/etc/conf.d/nomad" "https://ncurl.xyz/s/ymx8l_nHg"
wget -O "/etc/init.d/nomad" "https://ncurl.xyz/s/G1Vsr_7NR"
chown root:root "/etc/conf.d/nomad" "/etc/init.d/nomad"
chmod +x "/etc/init.d/nomad"
addgroup -S nomad
adduser -S -H -s "/bin/ash" -h "/opt/nomad" -g nomad -G nomad nomad
mkdir "/opt/nomad" "/etc/nomad.d"
chown nomad:nomad "/opt/nomad"
chown nomad:nomad "/etc/nomad.d"
echo "Done."
# Nomad OpenRC from Alpine Linux 3.17
# SPDX-License-Identifier: MPL-2.0
# https://pkgs.alpinelinux.org/package/v3.17/community/x86/nomad-openrc
# /etc/conf.d/nomad
nomad_opts="agent -server -config=/etc/nomad.d"
#
# If TLS is enabled on nomad then the health check defined in init.d (which
# runs "nomad agent-info") will fail unless it also makes use of TLS.
#
# In that situation uncomment the following definition and ensure
# it refers to the appropriate PEM files and URL.
#
#nomad_healthcheck_opts="-ca-cert=nomad-ca.pem -client-cert=cli.pem -client-key=cli-key.pem address=https://127.0.0.1:4646"
#!/sbin/openrc-run
# Nomad OpenRC from Alpine Linux 3.17
# SPDX-License-Identifier: MPL-2.0
# https://pkgs.alpinelinux.org/package/v3.17/community/x86/nomad-openrc
# /etc/init.d/nomad
name="Nomad"
description="An easy-to-use, flexible, and performant workload orchestrator"
description_healthcheck="Check health status"
description_reload="Reload configuration"
extra_started_commands="healthcheck reload"
command="/usr/sbin/${RC_SVCNAME}"
command_args="${nomad_opts}"
command_user="root:root"
supervisor=supervise-daemon
output_log="/var/log/${RC_SVCNAME}.log"
error_log="/var/log/${RC_SVCNAME}.log"
respawn_max=0
respawn_delay=10
healthcheck_timer=60
depend() {
need net
after cgroups docker firewall
}
start_pre() {
checkpath -f -m 0644 -o "$command_user" "$output_log" "$error_log"
}
healthcheck() {
$command agent-info ${nomad_healthcheck_opts} > /dev/null 2>&1
}
reload() {
start_pre \
&& ebegin "Reloading $RC_SVCNAME configuration" \
&& $supervisor "$RC_SVCNAME" --signal HUP
eend $?
}
@supersonictw
Copy link
Author

supersonictw commented Dec 1, 2024

Uninstaller here

rc-service nomad stop
rc-update del nomad
rm -rf /etc/nomad.d /opt/nomad /etc/conf.d/nomad /etc/init.d/nomad
rm /var/log/nomad.log
deluser nomad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment