Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # A menu driven shell script sample template
- ## ----------------------------------
- # Step #1: Define variables
- # ----------------------------------
- EDITOR=vim
- EDITOR=vim
- PASSWD=/etc/passwd
- RED='\033[0;41;30m'
- STD='\033[0;0;39m'
- # ----------------------------------
- # Step #2: User defined function
- # ----------------------------------
- pause(){
- read -p "Press [Enter] key to continue..." fackEnterKey
- }
- work(){
- echo "Copying Work SSH keys to .ssh folder"
- cd ~/ssh/work_gitlab/
- cp id_rsa id_rsa.pub ~/.ssh
- pause
- }
- personal(){
- echo "Copying Personal SSH keys to .ssh folder"
- cd ~/ssh/personal_gitlab/
- cp id_rsa id_rsa.pub ~/.ssh
- pause
- }
- # function to display menus
- show_menus() {
- clear
- echo "~~~~~~~~~~~~~~~~~~~~~"
- echo " M A I N - M E N U"
- echo "~~~~~~~~~~~~~~~~~~~~~"
- echo "1. Set Work SSH Keys"
- echo "2. Set Personal SSH Keys"
- echo "3. Exit"
- }
- # read input from the keyboard and take a action
- # invoke the one() when the user select 1 from the menu option.
- # invoke the two() when the user select 2 from the menu option.
- # Exit when user the user select 3 form the menu option.
- read_options(){
- local choice
- read -p "Enter choice [ 1 - 3] " choice
- case $choice in
- 1) work ;;
- 2) personal ;;
- 3) exit 0;;
- *) echo -e "${RED}Error...${STD}" && sleep 2
- esac
- }
- # ----------------------------------------------
- # Step #3: Trap CTRL+C, CTRL+Z and quit singles
- # ----------------------------------------------
- trap '' SIGINT SIGQUIT SIGTSTP
- # -----------------------------------
- # Step #4: Main logic - infinite loop
- # ------------------------------------
- while true
- do
- show_menus
- read_options
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement