1

I typically record my steps when deploying systems, and I often will duplicate the server during its initial testing. For example, if I get a little too far in the weeds while I'm testing, I simply prefer to scratch the server after I get success. So easily enough I can get back to that point minus the extra steps I previously took that were unnecessary. I can't sleep right if I feel like I have unnecessary dependencies sitting around.

I haven't ran into a limit yet, but is there a point where BASH will give up on me waiting for me to finish. For example, if I create a script deploy.sh which contains a bunch of commands including editing files with nano, will bash endlessly wait for me to edit the file and save changes then continue the script? Like I can stop in the middle of script and get some sleep to return to it?

This is the equivalent of taking bash history and marking it up to be used later. Not really meant to take the place of an actual script with conditionals.

example deploy.sh

# Fix hosts file
sudo nano /etc/hosts

# Update System
sudo apt-get update ; sudo apt-get -y dist-upgrade

# Install Java from repo
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo apt-get -y install oracle-java8-installer

# Test JAVA
java -version

# Install build-essential, git
sudo apt-get -y install build-essential git

# Generate SSH key for github
ssh-keygen -t rsa -b 4096 -C "name@email.com"

# Check on ssh-agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

# Add SSH to github keys
cat ~/.ssh/id_rsa.pub

# Verify SSH access to github
ssh -T git@github.com

# Elastic Search Install
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb http://packages.elastic.co/elasticsearch/1.7/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-1.7.list
sudo apt-get update
sudo apt-get -y install elasticsearch

# Edit elasticsearch config (adjust cluster name, node name, and data path)
sudo nano /etc/elasticsearch/elasticsearch.yml

# Change paths ownership to elasticsearch
sudo chown -R elasticsearch:elasticsearch /mnt/data/elasticsearch

# Restart elasticsearch
sudo service elasticsearch restart

# Add elasticsearch to boot
sudo update-rc.d elasticsearch defaults 95 10

# Install Node 5.x
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
  • 3
    I would suggest to use sed and other scriptable tools to edit files instead of manually editing with nano. Then your script could run unsupervised and is more reproducible – Wayne_Yux Jun 3 '16 at 12:09
  • I don't disagree, @Wayne_Yux. Obviously more elaborate tools could be used, but I may never use this set of commands again. It is essentially bash history, so I made no extra attempt in the creation. – user508889 Jun 3 '16 at 12:14
  • Are you referring to the command script? – Videonauth Jun 3 '16 at 12:14
  • No, @Videonauth -- script as in, a set of commands. This is literally a cut and paste of my bash history into deploy.sh, and added the markups just for clarity. – user508889 Jun 3 '16 at 12:16
2

nano has no no timeout, the only timeout so far is set on ssh and sftp login tries. so as login you not stop directly ate the point where you have to enter login credentials, you're save.

  • I was thinking initially that the entire script would have an execution time limit. Like php has a default execution time of around 45 seconds. I knew if there was a limit, it was high. – user508889 Jun 3 '16 at 12:27
  • No limit in normal bash commands, except those who involve logging into ssh etc., the network related stuff may time out as well in some cases because of load dropping from the other side. – Videonauth Jun 3 '16 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy