Skip to content

Instantly share code, notes, and snippets.

@lattejed
Last active June 14, 2019 10:04
Show Gist options
  • Save lattejed/019f7b048b50a500a5bc665c9c633bef to your computer and use it in GitHub Desktop.
Save lattejed/019f7b048b50a500a5bc665c9c633bef to your computer and use it in GitHub Desktop.
#!/usr/bin/bash
sudo echo
echo "Enter the following:"
echo "User - the user that runs the Tezos node"
echo "Protocol - the current protocol e.g., 004-Pt24m4xi"
echo "Signer key alias - e.g., my_signer_key"
echo
read -p "User: " NODE_USER
read -p "Protocol: " PROTOCOL
read -p "Signer key: " SIGNER_KEY
export NODE_USER=$NODE_USER
export PROTOCOL=$PROTOCOL
export SIGNER_KEY=$SIGNER_KEY
sudo -E bash -c 'cat << EOF > /etc/systemd/system/tezos-node.service
[Unit]
Description = Tezos Node
Wants = network-online.target
After = network-online.target
[Service]
User = $NODE_USER
Group = $NODE_USER
WorkingDirectory = /home/$NODE_USER
ExecStart = /home/$NODE_USER/tezos/tezos-node run --rpc-addr 127.0.0.1 --history-mode full
Restart = on-failure
[Install]
WantedBy = multi-user.target
RequiredBy = tezos-baker-$PROTOCOL.service tezos-endorser-$PROTOCOL.service tezos-accuser-$PROTOCOL.service
EOF'
sudo -E bash -c 'cat << EOF > /etc/systemd/system/tezos-accuser-$PROTOCOL.service
[Unit]
Description = Tezos Accuser
Wants = network-online.target
BindsTo = tezos-node.service
After = tezos-node.service
[Service]
User = $NODE_USER
Group = $NODE_USER
WorkingDirectory = /home/$NODE_USER
ExecStartPre = /bin/sleep 5
ExecStart = /home/$NODE_USER/tezos/tezos-accuser-$PROTOCOL run
Restart = on-failure
[Install]
WantedBy = multi-user.target
EOF'
sudo -E bash -c 'cat << EOF > /etc/systemd/system/tezos-baker-$PROTOCOL.service
[Unit]
Description = Tezos Baker
Wants = network-online.target
BindsTo = tezos-node.service
After = tezos-node.service
[Service]
User = $NODE_USER
Group = $NODE_USER
WorkingDirectory= /home/$NODE_USER
ExecStartPre = /bin/sleep 5
ExecStart = /home/$NODE_USER/tezos/tezos-baker-$PROTOCOL run with local node /home/$NODE_USER/.tezos-node $SIGNER_KEY
Restart = on-failure
[Install]
WantedBy = multi-user.target
EOF'
sudo -E bash -c 'cat << EOF > /etc/systemd/system/tezos-endorser-$PROTOCOL.service
[Unit]
Description = Tezos Endorser
Wants = network-online.target
BindsTo = tezos-node.service
After = tezos-node.service
[Service]
User = $NODE_USER
Group = $NODE_USER
WorkingDirectory= /home/$NODE_USER
ExecStartPre = /bin/sleep 5
ExecStart = /home/$NODE_USER/tezos/tezos-endorser-$PROTOCOL run $SIGNER_KEY
Restart = on-failure
[Install]
WantedBy = multi-user.target
EOF'
echo "Enabling services"
sudo systemctl enable tezos-node.service
sudo systemctl enable tezos-accuser-$PROTOCOL.service
sudo systemctl enable tezos-endorser-$PROTOCOL.service
sudo systemctl enable tezos-baker-$PROTOCOL.service
echo "Starting services"
sudo systemctl reload-or-restart tezos-node.service
sudo systemctl reload-or-restart tezos-accuser-$PROTOCOL.service
sudo systemctl reload-or-restart tezos-endorser-$PROTOCOL.service
sudo systemctl reload-or-restart tezos-baker-$PROTOCOL.service
echo
echo "You can check the status of these services with:"
echo "systemctl status tezos-*.service"
echo
echo "If any of these services has failed to start, try running:"
echo "sudo systemctl reload-or-restart --all tezos-*.service"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment