Advertisement
dimaslanjaka

Menu

Oct 4th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.19 KB | None | 0 0
  1. #!/bin/bash
  2. # A menu driven shell script sample template
  3. ## ----------------------------------
  4. # Step #1: Define variables
  5. # ----------------------------------
  6. EDITOR=vim
  7. PASSWD=/etc/passwd
  8. RED='\033[0;41;30m'
  9. STD='\033[0;0;39m'
  10.  
  11. # ----------------------------------
  12. # Step #2: User defined function
  13. # ----------------------------------
  14. pause(){
  15.   read -p "Press [Enter] key to continue..." fackEnterKey
  16. }
  17.  
  18. one(){
  19.     #echo "one() called"
  20.         sudo reboot
  21. }
  22. two(){
  23.     #echo "two() called"
  24.         sudo pkill miner && sudo /home/ubuntu/cpuminer-multi/minerd -a cryptonight -o stratum+tcp://xmr.pool.minergate.com:45560 -u candrarisky1922@gmail.com -p x -t 1
  25. }
  26.  three(){
  27. #fix mdadm.conf no array
  28. sudo echo "ARRAY <ignore> devices=/dev/sda" >> /etc/mdadm/mdadm.conf
  29. sudo update-initramfs -u
  30. sudo apt-get update
  31. }
  32. four(){
  33. sudo echo "/home/ubuntu/cpuminer-multi/minerd -a cryptonight -o stratum+tcp://xmr.pool.minergate.com:45560 -u candrarisky1922@gmail.com -p x -t 1" > /etc/init.d/zminer.sh
  34. sudo chmod +x /etc/init.d/zminer.sh
  35. sudo chmod ugo+x /etc/init.d/zminer.sh
  36. sudo update-rc.d zminer.sh defaults
  37. }
  38.  
  39.  
  40. # function to display menus
  41. show_menus() {
  42.     clear
  43.     echo "~~~~~~~~~~~~~~~~~~~~~"   
  44.     echo " M A I N - M E N U"
  45.     echo "~~~~~~~~~~~~~~~~~~~~~"
  46.     echo "1. Reboot"
  47.     echo "2. Start Miner"
  48.     echo "3. Fix mdadm.conf No Array"
  49.     echo "4. Install Miner Every Boot"
  50.     echo "5. Exit"
  51. }
  52. # read input from the keyboard and take a action
  53. # invoke the one() when the user select 1 from the menu option.
  54. # invoke the two() when the user select 2 from the menu option.
  55. # Exit when user the user select 3 form the menu option.
  56. read_options(){
  57.     local choice
  58.     read -p "Choose Options" choice
  59.     case $choice in
  60.         1) one ;;
  61.         2) two ;;
  62.         3) three ;;
  63.         4) four ;;
  64.         5) exit 0;;
  65.         *) echo -e "${RED}Error...${STD}" && sleep 1
  66.     esac
  67. }
  68.  
  69. # ----------------------------------------------
  70. # Step #3: Trap CTRL+C, CTRL+Z and quit singles
  71. # ----------------------------------------------
  72. trap '' SIGINT SIGQUIT SIGTSTP
  73.  
  74. # -----------------------------------
  75. # Step #4: Main logic - infinite loop
  76. # ------------------------------------
  77. while true
  78. do
  79.  
  80.     show_menus
  81.     read_options
  82. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement