Automating Ubuntu development environment startup - LEMP Stack + Laravel. How to schedule a break between blocks?

Asked

Viewed 94 times

1

I am creating code to automate the startup of an Ubuntu development environment (LEMP STACK). Here I put Nginx Server + Mariadb + PHP7.0 + Laravel, ... , etc. The complete list with comments is HERE.

It works that way:

  1. Using any editor (gedit for example), create a file with any name and paste the code below. I create with the name sysinit.
  2. Open a terminal as root and run source sysInit.

Then the chosen applications are installed one by one without the need for human interaction.

Between one installation block and another I put one "clear" to clear the terminal. However I would like to pause a few seconds before going to the next block. Could anyone suggest how to do that?

The code is not yet in its final version, but I leave below for those who are interested. Note: the linux user is "Ila". Exchange "Ila" for "your user".

sudo apt-get update
sudo apt-get install -y figlet
clear

figlet LEMP_STACK
clear

figlet TREE
sudo apt-get install -y tree
clear

figlet Only_for_virtual_machine_users
figlet VIRTUALBOX_GUEST_DKMS
sudo apt-get install -y virtualbox-guest-dkms
clear

figlet Only_for_virtual_machine_users
figlet ADD_USER_TO_VBOXSF_GROUP
sudo groups ila
sudo usermod -aG vboxsf ila
sudo groups ila
clear

figlet Only_64bits
figlet GOOGLE_CHROME
sudo wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - 
sudo sh -c 'echo "deb https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install -y google-chrome-stable
clear

figlet SUBLIME_TEXT_3
sudo add-apt-repository -y ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install -y sublime-text-installer
clear

figlet NGINX
sudo apt-get install -y nginx
clear

figlet PHP_7.0
sudo apt-get install -y php7.0-dev
sudo apt-get install -y php7.0-cgi
sudo apt-get install -y php7.0-fpm
sudo apt-get install -y php7.0-mcrypt
sudo apt-get install -y php7.0-mbstring
sudo apt-get install -y php7.0-mysql
sudo apt-get install -y php7.0-curl 
sudo apt-get install -y php7.0-json
sudo apt-get install -y php7.0-xsl
sudo apt-get install -y php7.0-intl 
#sudo apt-get install -y libapache2-mod-php7.0
sudo apt-get install -y phpunit
clear

figlet GIT
sudo apt-get install -y git
clear
figlet GITK
sudo apt-get install -y gitk
clear
figlet GIT_GUI
sudo apt-get install -y git-gui
clear

figlet NODE_JS
sudo apt-get install -y nodejs
nodejs -v
figlet MAKING_NODE_JS_TO_NODE
cd /usr/bin/
ln -s nodejs node
node -v
clear

figlet NPM
sudo apt-get install -y npm
npm -v
clear

figlet BOWER
npm install -g bower  
bower -v
clear

figlet GULP
npm install -g gulp
gulp -v
clear

//Note, the key must be constantly updated from the oficial web site https://getcomposer.org/download/ to avoid error
figlet COMPOSER
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '61069fe8c6436a4468d0371454cf38a812e451a14ab1691543f25a9627b97ff96d8753d92a00654c21e2212a5ae1ff36') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/bin/composer
clear

figlet JAVA_9
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo apt-get install -y oracle-java9-installer
sudo apt-get install -y oracle-java9-set-default
java -version

figlet MYSQL_WORKBENCH
sudo apt-get install -y mysql-workbench
clear

figlet MARIA_DB_SERVER
sudo apt-get install -y mariadb-server
clear

figlet ADDING_ROOT_USER_TO_MARIA_DB
sudo mysql  -e "CREATE USER 'ila'@'localhost' IDENTIFIED BY '123'; GRANT ALL PRIVILEGES ON * . * TO 'ila'@'localhost'; FLUSH PRIVILEGES;select Host,User,Password from mysql.user;"
clear

figlet NODE_RED
sudo npm install -g node-red
clear

So that’s the ultimate code aversion:

sudo apt-get update
sudo apt-get install -y figlet
clear

figlet LEMP_STACK
sleep 5s
clear

figlet TREE
sudo apt-get install -y tree
sleep 5s
clear

figlet Only_for_virtual_machine_users
figlet VIRTUALBOX_GUEST_DKMS
sudo apt-get install -y virtualbox-guest-dkms
sleep 5s
clear

figlet Only_for_virtual_machine_users
figlet ADD_USER_TO_VBOXSF_GROUP
sudo groups ila
sudo usermod -aG vboxsf ila
sudo groups ila
sleep 5s
clear

figlet Only_64bits
figlet GOOGLE_CHROME
sudo wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - 
sudo sh -c 'echo "deb https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install -y google-chrome-stable
sleep 5s
clear

figlet SUBLIME_TEXT_3
sudo add-apt-repository -y ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install -y sublime-text-installer
sleep 5s
clear

figlet NGINX
sudo apt-get install -y nginx
sleep 5s
clear

figlet PHP_7.0
sudo apt-get install -y php7.0-dev
sudo apt-get install -y php7.0-cgi
sudo apt-get install -y php7.0-fpm
sudo apt-get install -y php7.0-mcrypt
sudo apt-get install -y php7.0-mbstring
sudo apt-get install -y php7.0-mysql
sudo apt-get install -y php7.0-curl 
sudo apt-get install -y php7.0-json
sudo apt-get install -y php7.0-xsl
sudo apt-get install -y php7.0-intl 
#sudo apt-get install -y libapache2-mod-php7.0
sudo apt-get install -y phpunit
sleep 5s
clear

figlet GIT
sudo apt-get install -y git
sleep 5s
clear

figlet GITK
sudo apt-get install -y gitk
sleep 5s
clear

figlet GIT_GUI
sudo apt-get install -y git-gui
sleep 5s
clear

figlet NODE_JS
sudo apt-get install -y nodejs
nodejs -v
sleep 5s

figlet MAKING_NODE_JS_TO_NODE
cd /usr/bin/
ln -s nodejs node
node -v
sleep 5s
clear

figlet NPM
sudo apt-get install -y npm
npm -v
sleep 5s
clear

figlet BOWER
npm install -g bower  
bower -v
sleep 5s
clear

figlet GULP
npm install -g gulp
gulp -v
sleep 5s
clear

//Note, the key must be constantly updated from the oficial web site https://getcomposer.org/download/ to avoid error
figlet COMPOSER
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '61069fe8c6436a4468d0371454cf38a812e451a14ab1691543f25a9627b97ff96d8753d92a00654c21e2212a5ae1ff36') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/bin/composer
sleep 5s
clear

figlet JAVA_9
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo apt-get install -y oracle-java9-installer
sudo apt-get install -y oracle-java9-set-default
java -version
sleep 5s
clear

figlet MYSQL_WORKBENCH
sudo apt-get install -y mysql-workbench
sleep 5s
clear

figlet MARIA_DB_SERVER
sudo apt-get install -y mariadb-server
sleep 5s
clear

figlet ADDING_ROOT_USER_TO_MARIA_DB
sudo mysql  -e "CREATE USER 'ila'@'localhost' IDENTIFIED BY '123'; GRANT ALL PRIVILEGES ON * . * TO 'ila'@'localhost'; FLUSH PRIVILEGES;select Host,User,Password from mysql.user;"
sleep 5s
clear

figlet NODE_RED - IoT
sudo npm install -g node-red
sleep 5s
clear
  • You can put a Sleep, but it doesn’t make much sense to reinvent the wheel. There are already many scripts that make it ready, we have Puppet Restcipes, chef, Docker containers, etc that already make virtually all this.

  • 1

    hi @gmsantos. I’m using this script for classes. Beginner students on linux. Surely Docker is a better option in a professional environment.

  • 1

    @gmsantos your answer worked. I did Sleep 5s. Post the answer.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.