Advertisement
Guest User

Untitled

a guest
Nov 9th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. trim() {
  2. local var="$*"
  3. var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
  4. var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
  5. echo -n "$var"
  6.  
  7. var="acl ip"
  8. var2=" myip "
  9.  
  10.  
  11.  
  12. ips=($(hostname -I))
  13.  
  14. i=3000
  15.  
  16. for ip in "${ips[@]}"
  17. do
  18.  
  19. if [ $ip != "127.0.0.1" ]
  20. then
  21.  
  22. COUNTER=3000
  23.  
  24.  
  25.  
  26. mystring="$var$i$var2$ip"
  27. mystring2="tcp_outgoing_address $ip ip$i"
  28.  
  29. string1+=" $mystring $mystring2 "
  30.  
  31. get_ips+="$ip:#"
  32.  
  33.  
  34. mystring="$var$i$var2$ip"
  35. mystring2="tcp_outgoing_address $ip ip$i"
  36.  
  37. string1+=" $mystring $mystring2 "
  38.  
  39. get_ips+="$ip:#"
  40.  
  41.  
  42. sed -i -e "$ i $mystring" "/etc/squid/squid.conf"
  43.  
  44.  
  45. sed -i -e "$ i $mystring2" "/etc/squid/squid.conf"
  46.  
  47.  
  48.  
  49.  
  50. echo " $((i++)) "
  51.  
  52. fi
  53.  
  54.  
  55. done
  56.  
  57. range=5;
  58. number="";
  59. for i in {0..03}; do
  60. r=$RANDOM;
  61. let "r %= $range";
  62. number="$number""$r";
  63. done;
  64.  
  65. user="cli"
  66. user+="$number"
  67.  
  68. this=""
  69.  
  70.  
  71. length=8
  72.  
  73.  
  74.  
  75.  
  76. char=(0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z)
  77.  
  78. max=${#char[*]}
  79. for (( i = 1; i <= $length ; i++ ))do
  80.  
  81. let rand=${RANDOM}%${max}
  82.  
  83. password="${password}${char[$rand]}"
  84.  
  85. done
  86.  
  87. echo $password
  88.  
  89.  
  90. echo "$user:$password" >> /root/password.txt
  91. htpasswd -b /etc/squid/passwd $user $password
  92. echo $ips
  93.  
  94. get_final=" ${get_ips//#/$number:$user:$password n}"
  95.  
  96.  
  97.  
  98. rm -rf /root/ips
  99. echo "$get_final" >> /root/ips
  100. sed -r 's/s+//g' /root/ips
  101.  
  102.  
  103. thishost=$(hostname)
  104.  
  105.  
  106. echo $thishost
  107. rm -rf /root/email
  108. echo -e "$thishost" >> /root/email
  109.  
  110.  
  111.  
  112. sed -i 's/./@/' /root/email
  113.  
  114.  
  115. sed -c -i "s/(http_port * *).*/1$number/" /etc/squid/squid.conf
  116.  
  117. value=`cat /root/email`
  118.  
  119.  
  120. value2=`cat -e /root/ips`
  121.  
  122.  
  123.  
  124. trim $get_final
  125.  
  126.  
  127. echo -e $words
  128.  
  129. trim $value2
  130. echo ${value2//[[:blank:]]/}
  131.  
  132. service squid restart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement