Mark2020H

Bash Script to start and stop x11vnc server

May 23rd, 2023
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.70 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # MD Harrington  
  3. # Menu for  using with X11Vnc  Server and Remmina  Place this on your  server that  wont to  remote into
  4. # SSH into this eg   <your logon name>@<IP addressof server>
  5. # Once in  chmod +x the script then  execute  using ./scriptname.sh  
  6. # open remmina on local host set up required  fields  in gui and  bingo  your screen  local host refects  remote host so
  7. # You can now work from anyway on the proviso they have  issued correct permissions  and set up port forwarding
  8. # Date today 08/10/2020
  9.  
  10. STD='\033[0;0;39m'        #reset
  11. IRed='\033[0;91m'         # Red
  12. IGreen='\033[0;92m'       # Green
  13. IYellow='\033[0;93m'      # Yellow
  14. IBlue='\033[0;94m'        # Blue
  15. IPurple='\033[0;95m'      # Purple
  16. ICyan='\033[0;96m'        # Cyan
  17. IWhite='\033[0;97m'       # White
  18.  
  19. #global variable
  20. CURRENTDATEONLY=`date +"%A, %b %d, %Y %H:%M:%S"`
  21.  
  22. pause(){
  23.    
  24.   read -p "Press [Enter] to continue..." p_EnterKey
  25. }
  26.  
  27.  
  28. one(){
  29.     echo "${IGreen}Starting X11Vnc Server${STD}"
  30.    
  31. ## Start up file for x11vnc server change  - allow for  your ip  
  32. ## for local  subnet  eg 192.168.100  end this last octed with a dot
  33. ## for multiple  hosts  then  seperate ip wih  ,  and change  -nevershared to -shared
  34. ## and change rfbport to autoport
  35.  
  36. x11vnc -auth guess  -forever  -rfbauth /home/mark/.vnc/passwd -rfbport 5900 -shared
  37.  
  38.  
  39.  
  40. pause
  41. }
  42.  
  43. # do something in two()
  44. two(){
  45.     echo "${IGreen}Stop X11Vnc Server${STD}"
  46.     ## stop X11 server
  47.  
  48.     x11vnc -R stop
  49.         pause
  50. }
  51.  
  52.  
  53. show_menus() {
  54.     clear
  55.     echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"  
  56.     echo -e "  M A I N - M E N U - V N C - S E R V E R "
  57.     echo -e "            MD HARRINGTON                 "
  58.     echo -e "${IRed}* Date : ${CURRENTDATEONLY} *${STD}"
  59.     echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  60.     echo -e "${ICyan}1. Start VNC Server ${STD}"
  61.     echo -e "${ICyan}2. Stop  VNC Server ${STD}"
  62.     echo -e "${ICyan}3. Exit altogether and Menu Application ${STD}"
  63.      
  64. }
  65. # read input from the keyboard and take a action
  66. # invoke the one() when the user select 1 from the menu option.
  67. # invoke the two() when the user select 2 from the menu option.
  68. # Exit when user the user select 3 form the menu option.
  69. read_options(){
  70.     local choice
  71.     read -p " Enter choice [ 1 - 3] " choice
  72.     case $choice in
  73.         1) one ;;
  74.         2) two ;;
  75.         3) exit 0 ;;
  76.         *) echo -e "${RED}Error...${STD}" && sleep 2
  77.     esac
  78. }
  79.  
  80.  
  81.  
  82. # ----------------------------------------------
  83. # Step #3: Trap CTRL+C, CTRL+Z and quit singles
  84. # ----------------------------------------------
  85. trap '' SIGINT SIGQUIT SIGTSTP
  86.  
  87. while true
  88. do
  89.  
  90.     show_menus
  91.  
  92.     read_options
  93. done
  94.  
  95.  
  96.  
Add Comment
Please, Sign In to add comment