SHARE
TWEET

Untitled

a guest Jun 17th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # A menu driven shell script sample template
  3. ## ----------------------------------
  4. # Step #1: Define variables
  5. # ----------------------------------
  6. EDITOR=vim
  7. EDITOR=vim
  8. PASSWD=/etc/passwd
  9. RED='\033[0;41;30m'
  10. STD='\033[0;0;39m'
  11.  
  12. # ----------------------------------
  13. # Step #2: User defined function
  14. # ----------------------------------
  15. pause(){
  16.   read -p "Press [Enter] key to continue..." fackEnterKey
  17. }
  18.  
  19. work(){
  20.         echo "Copying Work SSH keys to .ssh folder"
  21.         cd ~/ssh/work_gitlab/
  22.         cp id_rsa id_rsa.pub ~/.ssh
  23.                 pause
  24. }
  25.  
  26. personal(){
  27.         echo "Copying Personal SSH keys to .ssh folder"
  28.         cd ~/ssh/personal_gitlab/
  29.         cp id_rsa id_rsa.pub ~/.ssh
  30.                 pause
  31. }
  32. # function to display menus
  33. show_menus() {
  34.         clear
  35.         echo "~~~~~~~~~~~~~~~~~~~~~"
  36.         echo " M A I N - M E N U"
  37.         echo "~~~~~~~~~~~~~~~~~~~~~"
  38.         echo "1. Set Work SSH Keys"
  39.         echo "2. Set Personal SSH Keys"
  40.         echo "3. Exit"
  41. }
  42. # read input from the keyboard and take a action
  43. # invoke the one() when the user select 1 from the menu option.
  44. # invoke the two() when the user select 2 from the menu option.
  45. # Exit when user the user select 3 form the menu option.
  46. read_options(){
  47.         local choice
  48.         read -p "Enter choice [ 1 - 3] " choice
  49.         case $choice in
  50.                 1) work ;;
  51.                 2) personal ;;
  52.                 3) exit 0;;
  53.                 *) echo -e "${RED}Error...${STD}" && sleep 2
  54.         esac
  55. }
  56.  
  57. # ----------------------------------------------
  58. # Step #3: Trap CTRL+C, CTRL+Z and quit singles
  59. # ----------------------------------------------
  60. trap '' SIGINT SIGQUIT SIGTSTP
  61.  
  62. # -----------------------------------
  63. # Step #4: Main logic - infinite loop
  64. # ------------------------------------
  65. while true
  66. do
  67.  
  68.         show_menus
  69.         read_options
  70. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top