]>
Commit | Line | Data |
---|---|---|
23f862b9 | 1 | #!/bin/bash |
61e8bcfd PK |
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 | ||
23f862b9 PK |
17 | |
18 | baseurl='http://grsecurity.net' | |
19 | ||
5859eb4a | 20 | curl_args='--ipv4 -s' |
21 | ||
23f862b9 PK |
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 | ||
5859eb4a | 42 | done < <(curl ${curl_args} "${baseurl}/test.php" | awk -v RS='"' '!(--p){print}/href=$/{p=1}' ) |
23f862b9 PK |
43 | |
44 | # grsecurity patches. | |
45 | for item in "${grsecurity_files[@]}"; do | |
46 | if ! [ -f "test/${item}" ]; then | |
47 | printf 'Downloading %s ...\n' "${item}" | |
5859eb4a | 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" | |
23f862b9 PK |
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. | |
61e8bcfd | 58 | if [ "${#new_grsecurity_patches[@]}" -gt '0' ]; then |
23f862b9 | 59 | printf 'Downloading changelog-test.txt ...\n' |
5859eb4a | 60 | curl ${curl_args} "${baseurl}/changelog-test.txt" > "${workdir}/test/changelog-test.txt" |
23f862b9 | 61 | git add "${workdir}/test/" && git commit "${workdir}/test/" -m \ |
61e8bcfd | 62 | "$(printf 'grsec-scrape autocommit. %s new patch(es).\n\n' "${#new_grsecurity_patches[@]}"; printf 'New patch: %s\n' "${new_grsecurity_patches[@]}" )" |
23f862b9 PK |
63 | git push |
64 | fi | |
65 | ||
66 | rm "${workdir}/lock" |