auto-reboot.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. red='\e[1;31m'
  3. green='\e[0;32m'
  4. NC='\e[0m'
  5. bl='\e[36;1m'
  6. bd='\e[1m'
  7. MYIP=$(wget -qO- ifconfig.co);
  8. echo "Checking VPS"
  9. clear
  10. if [ ! -e /usr/local/bin/reboot_otomatis ]; then
  11. echo '#!/bin/bash' > /usr/local/bin/reboot_otomatis
  12. echo 'tanggal=$(date +"%m-%d-%Y")' >> /usr/local/bin/reboot_otomatis
  13. echo 'waktu=$(date +"%T")' >> /usr/local/bin/reboot_otomatis
  14. echo 'echo "Server successfully rebooted on the date of $tanggal hit $waktu." >> /root/log-reboot.txt' >> /usr/local/bin/reboot_otomatis
  15. echo '/sbin/shutdown -r now' >> /usr/local/bin/reboot_otomatis
  16. chmod +x /usr/local/bin/reboot_otomatis
  17. fi
  18. echo -e "═════════════════════════════════════════════\e[m" | lolcat
  19. echo -e " $bl [System Auto Reboot Menu] \e[m"
  20. echo -e "═════════════════════════════════════════════\e[m" | lolcat
  21. echo -e "$bd 1$bl] \e[m $bdSet Auto-Reboot Setiap 1 Jam"
  22. echo -e "$bd 2$bl] \e[m $bdSet Auto-Reboot Setiap 6 Jam"
  23. echo -e "$bd 3$bl] \e[m $bdSet Auto-Reboot Setiap 12 Jam"
  24. echo -e "$bd 4$bl] \e[m $bdSet Auto-Reboot Setiap 1 Hari"
  25. echo -e "$bd 5$bl] \e[m $bdSet Auto-Reboot Setiap 1 Minggu"
  26. echo -e "$bd 6$bl] \e[m $bdSet Auto-Reboot Setiap 1 Bulan"
  27. echo -e "$bd 7$bl] \e[m $bdMatikan Auto-Reboot"
  28. echo -e "$bd 8$bl] \e[m $bdView reboot log"
  29. echo -e "$bd 9$bl] \e[m $bdRemove reboot log"
  30. echo -e "══════════════════════════════════════════════\e[m" | lolcat
  31. echo -e "$bd Press CTRL+C to return\e[m"
  32. read -p " Select options from (1-9):" x
  33. if test $x -eq 1; then
  34. echo "10 * * * * root /usr/local/bin/reboot_otomatis" > /etc/cron.d/reboot_otomatis
  35. echo "Auto-Reboot has been set every an hour."
  36. elif test $x -eq 2; then
  37. echo "10 */6 * * * root /usr/local/bin/reboot_otomatis" > /etc/cron.d/reboot_otomatis
  38. echo "Auto-Reboot has been successfully set every 6 hours."
  39. elif test $x -eq 3; then
  40. echo "10 */12 * * * root /usr/local/bin/reboot_otomatis" > /etc/cron.d/reboot_otomatis
  41. echo "Auto-Reboot has been successfully set every 12 hours."
  42. elif test $x -eq 4; then
  43. echo "10 0 * * * root /usr/local/bin/reboot_otomatis" > /etc/cron.d/reboot_otomatis
  44. echo "Auto-Reboot has been successfully set once a day."
  45. elif test $x -eq 5; then
  46. echo "10 0 */7 * * root /usr/local/bin/reboot_otomatis" > /etc/cron.d/reboot_otomatis
  47. echo "Auto-Reboot has been successfully set once a week."
  48. elif test $x -eq 6; then
  49. echo "10 0 1 * * root /usr/local/bin/reboot_otomatis" > /etc/cron.d/reboot_otomatis
  50. echo "Auto-Reboot has been successfully set once a month."
  51. elif test $x -eq 7; then
  52. rm -f /etc/cron.d/reboot_otomatis
  53. echo "Auto-Reboot successfully TURNED OFF."
  54. elif test $x -eq 8; then
  55. if [ ! -e /root/log-reboot.txt ]; then
  56. echo "No reboot activity found"
  57. else
  58. echo 'LOG REBOOT'
  59. echo "-------"
  60. cat /root/log-reboot.txt
  61. fi
  62. elif test $x -eq 9; then
  63. echo "" > /root/log-reboot.txt
  64. echo "Auto Reboot Log successfully deleted!" | lolcat
  65. else
  66. echo "Options Not Found In Menu"
  67. exit
  68. fi