Mark2020H

Menu for using with X11Vnc Server and Remmina

Oct 8th, 2020 (edited)
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.52 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # MD Harrington  
  3. # Menu for  using with X11Vnc and Remmina
  4. # Date today 08/10/2020
  5.  
  6. STD='\033[0;0;39m'        #reset
  7. IRed='\033[0;91m'         # Red
  8. IGreen='\033[0;92m'       # Green
  9. IYellow='\033[0;93m'      # Yellow
  10. IBlue='\033[0;94m'        # Blue
  11. IPurple='\033[0;95m'      # Purple
  12. ICyan='\033[0;96m'        # Cyan
  13. IWhite='\033[0;97m'       # White
  14.  
  15. #global variable
  16. CURRENTDATEONLY=`date +"%A, %b %d, %Y %H:%M:%S"`
  17.  
  18. pause(){
  19.    
  20.   read -p "Press [Enter] to continue..." p_EnterKey
  21. }
  22.  
  23.  
  24. one(){
  25.     echo "${IGreen}Starting X11Vnc Server${STD}"
  26.    
  27. ## Start up file for x11vnc server change  - allow for  your ip  
  28. ## for local  subnet  eg 192.168.100  end this last octed with a dot
  29. ## for multiple  hosts  then  seperate ip wih  ,  and change  -nevershared to -shared
  30. ## and change rfbport to autoport
  31.  
  32. ##  ALL COMMANDS CAN BE FOUND ON THIS PAGE (X11VNC)  
  33. ##  https://linux.die.net/man/1/x11vnc
  34.  
  35. x11vnc -nevershared -forever  -rfbauth ~/.vnc/passwd  -allow 192.168.1. -rfbport 5902
  36.  
  37. pause
  38. }
  39.  
  40. # do something in two()
  41. two(){
  42.     echo "${IGreen}Stop X11Vnc Server${STD}"
  43.     ## stop X11 server
  44.  
  45.     x11vnc -R stop
  46.         pause
  47. }
  48.  
  49. three(){
  50.           echo "${IPurple}Quitting stopping VNC Server Thankyou ${STD}"
  51.           x11vnc -R stop
  52.           sleep 500
  53.             exit 0
  54.    
  55. }
  56.  
  57. show_menus() {
  58.     clear
  59.     echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"  
  60.     echo -e "  M A I N - M E N U - V N C - S E R V E R "
  61.     echo -e "            MD HARRINGTON                 "
  62.     echo -e "${IRed}* Date : ${CURRENTDATEONLY} *${STD}"
  63.     echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  64.     echo -e "${ICyan}1. Start VNC Server ${STD}"
  65.     echo -e "${ICyan}2. Stop  VNC Server ${STD}"
  66.     echo -e "${ICyan}3. Exit altogether and Menu Application ${STD}"
  67.    
  68. }
  69. # read input from the keyboard and take a action
  70. # invoke the one() when the user select 1 from the menu option.
  71. # invoke the two() when the user select 2 from the menu option.
  72. # Exit when user the user select 3 form the menu option.
  73. read_options(){
  74.     local choice
  75.     read -p " Enter choice [ 1 - 4] " choice
  76.     case $choice in
  77.         1) one ;;
  78.         2) two ;;
  79.         3) three ;;
  80.         *) echo -e "${RED}Error...${STD}" && sleep 2
  81.     esac
  82. }
  83.  
  84.  
  85.  
  86. # ----------------------------------------------
  87. # Step #3: Trap CTRL+C, CTRL+Z and quit singles
  88. # ----------------------------------------------
  89. trap '' SIGINT SIGQUIT SIGTSTP
  90.  
  91. while true
  92. do
  93.  
  94.     show_menus
  95.     read_options
  96. done
  97.  
  98.  
Add Comment
Please, Sign In to add comment