]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - grsec-scrape
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / grsec-scrape
1 #!/bin/bash
2 # Copyright (c) 2011, Piotr Karbowski <piotr.karbowski@gmail.com>
3 # All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without modification, are
6 # permitted provided that the following conditions are met:
7 #
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.
16
17
18 baseurl='http://grsecurity.net'
19
20 curl_args='--ipv4 -s'
21
22 basename="${0##*/}"
23 scriptpath="$(readlink -f $0)"
24 workdir="${scriptpath%/${basename}}"
25
26 cd "${workdir}" || exit 1
27
28 if [ -f "${workdir}/lock" ]; then exit 2; fi
29 touch "${workdir}/lock"
30
31 while read line; do
32
33 if [[ "${line}" =~ grsecurity-[0-9\.\-]+\.patch$ ]]; then
34 grsecurity_files+=( "${line##*/}" )
35
36 fi
37
38 if [[ "${line}" =~ gradm-[0-9\.\-]+\.tar\.gz$ ]]; then
39 gradm_files+=( "${line##*/}" )
40 fi
41
42 done < <(curl ${curl_args} "${baseurl}/test.php" | awk -v RS='"' '!(--p){print}/href=$/{p=1}' )
43
44 # grsecurity patches.
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}" )
52 fi
53 done; unset item
54
55 date="$(date '+%d-%m-%Y %H:%M')"
56
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[@]}" )"
63 git push
64 fi
65
66 rm "${workdir}/lock"