2 # Copyright (c) 2011, Piotr Karbowski <piotr.karbowski@gmail.com>
5 # Redistribution and use in source and binary forms, with or without modification, are
6 # permitted provided that the following conditions are met:
8 # * Redistributions of source code must retain the above copyright notice, this
9 # list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above copyright notice, this
11 # list of conditions and the following disclaimer in the documentation and/or other
12 # materials provided with the distribution.
13 # * Neither the name of the Piotr Karbowski nor the names of its contributors may be
14 # used to endorse or promote products derived from this software without specific
15 # prior written permission.
18 baseurl
='http://grsecurity.net'
23 scriptpath
="$(readlink -f $0)"
24 workdir
="${scriptpath%/${basename}}"
26 cd "${workdir}" ||
exit 1
28 if [ -f "${workdir}/lock" ]; then exit 2; fi
29 touch "${workdir}/lock"
33 if [[ "${line}" =~ grsecurity-
[0-9\.\
-]+\.
patch$
]]; then
34 grsecurity_files
+=( "${line##*/}" )
38 if [[ "${line}" =~ gradm-
[0-9\.\
-]+\.
tar\.gz$
]]; then
39 gradm_files
+=( "${line##*/}" )
42 done < <(curl
${curl_args} "${baseurl}/test.php" | awk -v RS='"' '!(--p){print}/href
=$
/{p
=1}' )
45 for item in "${grsecurity_files[@]}"; do
46 if ! [ -f "test/${item}" ]; then
47 printf 'Downloading
%s ...
\n' "${item}"
48 curl ${curl_args} "${baseurl}/test/${item}" > "${workdir}/test/${item}"
49 printf 'Downloading
%s ...
\n' "${item}.sig"
50 curl ${curl_args} "${baseurl}/test/${item}.sig" > "${workdir}/test/${item}.sig"
51 new_grsecurity_patches+=( "${item}" )
55 date="$(date '+%d-
%m-
%Y
%H
:%M
')"
57 # If array have at least one element.
58 if [ "${#new_grsecurity_patches[@]}" -gt '0' ]; then
59 printf 'Downloading changelog-test.txt ...
\n'
60 curl ${curl_args} "${baseurl}/changelog-test.txt" > "${workdir}/test/changelog-test.txt"
61 git add "${workdir}/test/" && git commit "${workdir}/test/" -m \
62 "$(printf 'grsec-scrape autocommit.
%s new
patch(es
).
\n\n' "${#new_grsecurity_patches[@]}"; printf 'New
patch: %s
\n' "${new_grsecurity_patches[@]}" )"