1. Список говнокодов пользователя wat3rs

    Всего: 1

  2. bash / Говнокод #7385

    −116

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    #!/bin/sh
    #
    # $1 is the mail account
    
    [ -n "$1" ] && {
    	
    	MAIL_PATH="/Mail/$1/mbox"
    	OUTPUT_MAIL_PATH="/mnt/flash/save/email/inbox/"
    	mkdir -p $OUTPUT_MAIL_PATH	
    	mv /var/spool/mail/root/* $MAIL_PATH
    
    	for j in `find $MAIL_PATH -name "msg.*"`
    	do
    	  MAIL_NAME=`basename $j`.eml
    	  NEW_MAIL="$OUTPUT_MAIL_PATH/$MAIL_NAME"
    	  mkdir -p "$OUTPUT_MAIL_PATH"
    	  
    	  [ ! -f "$NEW_MAIL" ] && {
    		  grep "^From:" $j | head -n 1 > $NEW_MAIL
    		  if grep "^Cc:" $j ; then
    		  	grep "^Cc:" $j | head -n 1 >> $NEW_MAIL
    		  fi
    		  grep "^To:" $j | head -n 1 >> $NEW_MAIL
    		  grep "^Subject:" $j | head -n 1 >> $NEW_MAIL
    		  grep "^Date:" $j | head -n 1 >> $NEW_MAIL
    		
    			if grep "^Content-Type: text/plain;" $j ; then
    				
    				LINE_NUM=`grep -n "^Content-Type: text/plain;" $j | cut -d: -f1`
    				
    				if grep "^Content-Type: text/plain;" $j | grep "charset=" ; then
    					TYPE=`grep  "Content-Type: text/plain;" $j | cut -d";" -f1`
    					echo "$TYPE" >> $NEW_MAIL
    					CHAR="charset="`grep  "Content-Type: text/plain;" $j | cut -d= -f2`
    					echo "$CHAR" >> $NEW_MAIL
    				else
    					grep "^Content-Type: text/plain;" $j >> $NEW_MAIL
    					x=$(($LINE_NUM+1))
    					sed -n "$x"p $j >> $NEW_MAIL
    				fi
    		
    				
    				x=$(($LINE_NUM-1))
    				BOUNDARY=`sed -n "$x"p $j`
    				
    				for i in `sed "/$BOUNDARY/s/.*/ffffuuuucccckkkk/" $j | grep -n "ffffuuuucccckkkk" | cut -d: -f1`
    				do
    					if [ "$i" -gt "$LINE_NUM" ] ; then
    						i=$(($i-1))
    						y=$(($LINE_NUM+3))
    						echo "Mail content start:" >> $NEW_MAIL
    						sed -n "$y,$i"p $j >> $NEW_MAIL			
    						break
    					fi
    				done
    				
    				if ! grep "Mail content start:" $NEW_MAIL ; then
    					echo "Mail content start:" >> $NEW_MAIL
    					y=$(($LINE_NUM+3))
    					x=`grep -c "^" $j`
    					sed -n "$y,$x"p $j >> $NEW_MAIL
    				fi
    				
    			else
    				echo "Fuck....."	
    			fi
    		}
    	done
    }

    /bin/mail.sh из прошивки букридера GreenBook

    wat3rs, 29 Июля 2011

    Комментарии (3)