delexp.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. # SL
  3. # ==========================================
  4. # Color
  5. RED='\033[0;31m'
  6. NC='\033[0m'
  7. GREEN='\033[0;32m'
  8. ORANGE='\033[0;33m'
  9. BLUE='\033[0;34m'
  10. PURPLE='\033[0;35m'
  11. CYAN='\033[0;36m'
  12. LIGHT='\033[0;37m'
  13. # ==========================================
  14. # Getting
  15. MYIP=$(wget -qO- ipinfo.io/ip);
  16. echo "Checking VPS"
  17. IZIN=$( curl ipinfo.io/ip | grep $MYIP )
  18. if [ $MYIP = $MYIP ]; then
  19. echo -e "${NC}${GREEN}Permission Accepted...${NC}"
  20. else
  21. echo -e "${NC}${RED}Permission Denied!${NC}";
  22. echo -e "${NC}${LIGHT}Fuck You!!"
  23. exit 0
  24. fi
  25. clear
  26. hariini=`date +%d-%m-%Y`
  27. echo "Thank you for removing the EXPIRED USERS"
  28. echo "--------------------------------------"
  29. cat /etc/shadow | cut -d: -f1,8 | sed /:$/d > /tmp/expirelist.txt
  30. totalaccounts=`cat /tmp/expirelist.txt | wc -l`
  31. for((i=1; i<=$totalaccounts; i++ ))
  32. do
  33. tuserval=`head -n $i /tmp/expirelist.txt | tail -n 1`
  34. username=`echo $tuserval | cut -f1 -d:`
  35. userexp=`echo $tuserval | cut -f2 -d:`
  36. userexpireinseconds=$(( $userexp * 86400 ))
  37. tglexp=`date -d @$userexpireinseconds`
  38. tgl=`echo $tglexp |awk -F" " '{print $3}'`
  39. while [ ${#tgl} -lt 2 ]
  40. do
  41. tgl="0"$tgl
  42. done
  43. while [ ${#username} -lt 15 ]
  44. do
  45. username=$username" "
  46. done
  47. bulantahun=`echo $tglexp |awk -F" " '{print $2,$6}'`
  48. echo "echo "Expired- User : $username Expire at : $tgl $bulantahun"" >> /usr/local/bin/alluser
  49. todaystime=`date +%s`
  50. if [ $userexpireinseconds -ge $todaystime ] ;
  51. then
  52. :
  53. else
  54. echo "echo "Expired- Username : $username are expired at: $tgl $bulantahun and removed : $hariini "" >> /usr/local/bin/deleteduser
  55. echo "Username $username that are expired at $tgl $bulantahun removed from the VPS $hariini"
  56. userdel $username
  57. fi
  58. done
  59. echo " "
  60. echo "--------------------------------------"
  61. echo "Script are successfully run"