description_of_script.sh.txt 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/bin/bash
  2. read -p "Enter package name: " name
  3. echo "Package name is $name"
  4. read -p "Enter path for package source files: " dir_path
  5. #read -p "Enter start year: " year_s
  6. #read -p "Enter end year: " year_e
  7. year_s=2005
  8. year_e=2018
  9. mkdir $dir_path/$name
  10. cd $dir_path/$name
  11. for year_dir in `seq $year_s $year_e`
  12. do
  13. mkdir $year_dir
  14. cd $year_dir
  15. month_list="03 07"
  16. for month_dir in $month_list
  17. do
  18. mkdir $month_dir
  19. cd $month_dir
  20. day_list="15 28"
  21. for day_of_month in $day_list
  22. do
  23. day_mom=`curl -q "https://snapshot.debian.org/archive/debian/?year=$year_dir&month=$month_dir" | grep $year_dir$month_dir$day_of_month | awk -F'"' '{print $2}' | awk -F '/' '{print $1}'| tail -n 1`
  24. echo "deb [trusted=yes] http://snapshot.debian.org/archive/debian/$day_mom/ stable main" > sources_$day_mom.list
  25. echo "deb-src [trusted=yes] http://snapshot.debian.org/archive/debian/$day_mom/ stable main" >> sources_$day_mom.list
  26. echo "deb [trusted=yes] http://snapshot.debian.org/archive/debian/$day_mom/ stable/updates main" >> sources_$day_mom.list
  27. echo "deb-src [trusted=yes] http://snapshot.debian.org/archive/debian/$day_mom/ stable/updates main" >> sources_$day_mom.list
  28. cp sources_$day_mom.list /etc/apt/sources.list -f
  29. apt-get update
  30. apt-get source --download-only --allow-unauthenticated $name
  31. sleep 5
  32. done
  33. cd $dir_path/$name/$year_dir
  34. done
  35. cd $dir_path/$name
  36. done
  37. cd $dir_path/
  38. chmod 777 $name -R
  39. Description of script "script.sh"
  40. ------------
  41. read -p "Enter package name: " name
  42. echo "Package name is $name"
  43. read -p "Enter path for package source files: " dir_path
  44. #read -p "Enter start year: " year_s
  45. #read -p "Enter end year: " year_e
  46. year_s=2005
  47. year_e=2018
  48. ------------
  49. In this section i've will be entered name of package that we want to be downloaded and are declared years that will be parsed for that.
  50. ------------
  51. mkdir $dir_path/$name
  52. cd $dir_path/$name
  53. ------------
  54. In this section we create directory and will chage work directory in that location.
  55. ------------
  56. for year_dir in `seq $year_s $year_e`
  57. do
  58. ------------
  59. Here we start the loop (will be parsed all years that are in sequence between variables year_s and year_e)
  60. ------------
  61. mkdir $year_dir
  62. cd $year_dir
  63. month_list="03 07"
  64. ------------
  65. here, script will create direcotry for every year that was parsed and we declare a string type variable for months that will be parsed (03 - march and 07 - july)
  66. ------------
  67. for month_dir in $month_list
  68. do
  69. mkdir $month_dir
  70. cd $month_dir
  71. day_list="15 28"
  72. ------------
  73. Here in second loop we parse months that are declared in variable month_list and will create directory for every month and work directory will be change in this path. We declare vlariable for days that will be parse in every months.
  74. ------------
  75. for day_of_month in $day_list
  76. do
  77. day_mom=`curl -q "https://snapshot.debian.org/archive/debian/?year=$year_dir&month=$month_dir" | grep $year_dir$month_dir$day_of_month | awk -F'"' '{print $2}' | awk -F '/' '{print $1}'| tail -n 1`
  78. echo "deb [trusted=yes] http://snapshot.debian.org/archive/debian/$day_mom/ stable main" > sources_$day_mom.list
  79. echo "deb-src [trusted=yes] http://snapshot.debian.org/archive/debian/$day_mom/ stable main" >> sources_$day_mom.list
  80. echo "deb [trusted=yes] http://snapshot.debian.org/archive/debian/$day_mom/ stable/updates main" >> sources_$day_mom.list
  81. echo "deb-src [trusted=yes] http://snapshot.debian.org/archive/debian/$day_mom/ stable/updates main" >> sources_$day_mom.list
  82. cp sources_$day_mom.list /etc/apt/sources.list -f
  83. apt-get update
  84. apt-get source --download-only --allow-unauthenticated $name
  85. sleep 5
  86. done
  87. ------------
  88. In third loop we parse every day declared in day_list variable (15 and 28) and we declare variable day_mom wich actualy is that folder that will indicate location of sources files. For that we use grep, awk and tail commands on output of command curl -q url_name
  89. After we find day_mom (day momment for a better remember) we generate a new sources.list file with new repository for all years, months and days declared, we copy this new file in /etc/apt/ and we repalce existed one (for this section this script must be run as root). After that we will update repositoryes (apt-get update)
  90. and we download source of desired package.
  91. ------------
  92. done
  93. cd $dir_path/$name/$year_dir
  94. done
  95. cd $dir_path/$name
  96. done
  97. cd $dir_path/
  98. chmod 777 $name -R
  99. ------------
  100. In this section all loops will be closed and pwath will be changed in up with one directory
  101. chmod 777 $name -R - this line will change rights for package directory name in full rights for all users.