merge_snippets.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. if [ $# -ne 1 ]; then
  3. echo -e "Usage:"
  4. echo -e " $ ./merge_snippets.sh new_hosts\n"
  5. exit 1
  6. fi
  7. new_hosts_file=$1
  8. if [ -f $new_hosts_file ]; then
  9. new_hosts_file=${new_hosts_file}".new"
  10. printf "" > $new_hosts_file
  11. fi
  12. export LC_ALL="C"
  13. printf "\
  14. ## __ __ \r\n\
  15. ## |__| _____ __ __ ┌─────┐ | | __ \r\n\
  16. ## | || || | || ──| ______ | |──┐┌─────┐.─────.| |_ .─────.\r\n\
  17. ## | || ─ || | || ─ | |______| | || ─ ||__ ──|| _||__ ──|\r\n\
  18. ## |__|| ┌──┘ \___/ |_____| |__|__||_____||_____||____||_____|\r\n\
  19. ## |__| \r\n\
  20. ## · lennylxx ·\r\n\
  21. ##\r\n\
  22. ## +------------------------- >>d(' _ ')b<< -------------------------+\r\n\
  23. ## | |\r\n\
  24. ## | Project: https://github.com/lennylxx/ipv6-hosts |\r\n\
  25. ## | Update : `date +"%a, %d %b %Y %T %z"` |\r\n\
  26. ## | |\r\n\
  27. ## +-------------------------------------------------------------------+\r\n\
  28. " >> $new_hosts_file
  29. unset LC_ALL
  30. printf "\r\n127.0.0.1 localhost\r\n" >> $new_hosts_file
  31. printf "::1 localhost ip6-localhost ip6-loopback\r\n\r\n" >> $new_hosts_file
  32. cat snippets/??_*.txt >> $new_hosts_file
  33. printf "\
  34. ## +-------------------------------------------------------------------+\r\n\
  35. ## | End of File |\r\n\
  36. ## +-------------------------------------------------------------------+\r\n\
  37. " >> $new_hosts_file
  38. exit 0