Replicated CLI Alias


#1

The Replicated easy install script will automatically set up the replicated CLI and replicatedctl CLI aliases. However, if a server is automatically upgraded from a version before 2.9.0, then the replicatedctl alias will not be automatically installed. Likewise, if your customer performed a manual installation, then neither Replicated CLI versions will be available as an alias.

Depending on the scheduler Replicated is running with, run the following shell scripts as sudo to set up the replicated and replicatedctl aliases:

Replicated Scheduler

cat > /usr/local/bin/replicated <<-EOF
#!/bin/sh

# test if stdout is a terminal
if [ -t 1 ]; then
sudo docker exec -it replicated replicated "\[email protected]"
else
sudo docker exec replicated replicated "\[email protected]"
fi
EOF
chmod a+x /usr/local/bin/replicated
cat > /usr/local/bin/replicatedctl <<-EOF
#!/bin/sh

# test if stdout is a terminal
if [ -t 1 ]; then
sudo docker exec -it replicated replicatedctl "\[email protected]"
else
sudo docker exec replicated replicatedctl "\[email protected]"
fi
EOF
chmod a+x /usr/local/bin/replicatedctl

Swarm Scheduler

cat > /usr/local/bin/replicated <<-EOF
#!/bin/sh

# test if stdout is a terminal
if [ -t 1 ]; then
sudo docker exec -it "\$(sudo docker inspect --format "{{.Status.ContainerStatus.ContainerID}}" "\$(sudo docker service ps "\$(sudo docker service inspect --format "{{.ID}}" replicated_replicated)" -q | awk "NR==1")")" replicated "\[email protected]"
else
sudo docker exec "\$(sudo docker inspect --format "{{.Status.ContainerStatus.ContainerID}}" "\$(sudo docker service ps "\$(sudo docker service inspect --format "{{.ID}}" replicated_replicated)" -q | awk "NR==1")")" replicated "\[email protected]"
fi
EOF
chmod a+x /usr/local/bin/replicated
cat > /usr/local/bin/replicatedctl <<-EOF
#!/bin/sh

# test if stdout is a terminal
if [ -t 1 ]; then
sudo docker exec -it "\$(sudo docker inspect --format "{{.Status.ContainerStatus.ContainerID}}" "\$(sudo docker service ps "\$(sudo docker service inspect --format "{{.ID}}" replicated_replicated)" -q | awk "NR==1")")" replicatedctl "\[email protected]"
else
sudo docker exec "\$(sudo docker inspect --format "{{.Status.ContainerStatus.ContainerID}}" "\$(sudo docker service ps "\$(sudo docker service inspect --format "{{.ID}}" replicated_replicated)" -q | awk "NR==1")")" replicatedctl "\[email protected]"
fi
EOF
chmod a+x /usr/local/bin/replicatedctl

Kubernetes Scheduler

cat > /usr/local/bin/replicated <<-EOF
#!/bin/sh

# test if stdout is a terminal
if [ -t 1 ]; then
kubectl exec -it "\$(kubectl get pods -l=app=replicated -l=tier=master -o=jsonpath='{.items..metadata.name}')" -c replicated -- replicated "\[email protected]"
else
kubectl exec "\$(kubectl get pods -l=app=replicated -l=tier=master -o=jsonpath='{.items..metadata.name}')" -c replicated -- replicated "\[email protected]"
fi
EOF
chmod a+x /usr/local/bin/replicated
cat > /usr/local/bin/replicatedctl <<-EOF
#!/bin/sh

# test if stdout is a terminal
if [ -t 1 ]; then
kubectl exec -it "\$(kubectl get pods -l=app=replicated -l=tier=master -o=jsonpath='{.items..metadata.name}')" -c replicated -- replicatedctl "\[email protected]"
else
kubectl exec "\$(kubectl get pods -l=app=replicated -l=tier=master -o=jsonpath='{.items..metadata.name}')" -c replicated -- replicatedctl "\[email protected]"
fi
EOF
chmod a+x /usr/local/bin/replicatedctl