make it both client and server

main
Ayush Mukherjee 3 years ago
parent 38056ee6c7
commit 765e5a902f

@ -19,6 +19,20 @@ if [ "$#" -eq 1 ] && [ "$1" == "-client" ]; then
fi fi
# create config dir
mkdir -p /etc/nomad.d && chmod 700 /etc/nomad.d
# write common nomad config
cat >/etc/nomad.d/nomad.hcl <<EOF
datacenter = "dc1"
data_dir = "/opt/nomad"
EOF
chmod 640 /etc/nomad.d/nomad.hcl
chown nomad:nomad /etc/nomad.d/nomad.hcl
if [ $nomaduser == "nomad" ]; then
# write systemd conf # write systemd conf
cat >/etc/systemd/system/nomad.service <<EOF cat >/etc/systemd/system/nomad.service <<EOF
[Unit] [Unit]
@ -27,12 +41,9 @@ Documentation = https://nomadproject.io/docs/
Wants = network-online.target Wants = network-online.target
After = network-online.target After = network-online.target
Wants = consul.service
After = consul.service
[Service] [Service]
User = $nomaduser User = root
Group = $nomadgroup Group = root
ExecReload=/bin/kill -HUP \$MAINPID ExecReload=/bin/kill -HUP \$MAINPID
ExecStart=/usr/bin/nomad agent -config /etc/nomad.d ExecStart=/usr/bin/nomad agent -config /etc/nomad.d
KillMode=process KillMode=process
@ -48,41 +59,32 @@ OOMScoreAdjust=-1000
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
# create config dir
mkdir -p /etc/nomad.d && chmod 700 /etc/nomad.d
# write common nomad config
cat >/etc/nomad.d/nomad.hcl <<EOF
datacenter = "dc1"
data_dir = "/opt/nomad"
EOF
chmod 640 /etc/nomad.d/nomad.hcl
chown nomad:nomad /etc/nomad.d/nomad.hcl
if [ $nomaduser == "nomad" ]; then
# write server config # write server config
cat >/etc/nomad.d/server.hcl <<EOF cat >/etc/nomad.d/server.hcl <<EOF
server { server {
enabled = true enabled = true
bootstrap_expect = 1 bootstrap_expect = 1
} }
ui { client {
enabled = true enabled = true
} }
consul {
address = "127.0.0.1:8500"
}
EOF EOF
chmod 640 /etc/nomad.d/server.hcl chmod 640 /etc/nomad.d/server.hcl
chown nomad:nomad /etc/nomad.d/server.hcl chown nomad:nomad /etc/nomad.d/server.hcl
else
#else
# write client config # write client config
cat >/etc/nomad.d/client.hcl <<EOF # cat >/etc/nomad.d/client.hcl <<EOF
client { #client {
enabled = true # enabled = true
} #}
EOF #EOF
chmod 640 /etc/nomad.d/client.hcl # chmod 640 /etc/nomad.d/client.hcl
chown nomad:nomad /etc/nomad.d/client.hcl # chown nomad:nomad /etc/nomad.d/client.hcl
fi fi

Loading…
Cancel
Save