]> git.ipfire.org Git - ipfire-3.x.git/blob - tools/make-buildspy
Merge branch 'master' of ssh://ms@git.ipfire.org/pub/git/ipfire-3.x
[ipfire-3.x.git] / tools / make-buildspy
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2008 Michael Tremer & Christian Schmidt #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 build_spy() {
23 ## Do nothing if UUID is not set
24 [ -z "${UUID}" ] && return
25
26 ACTION=$1; KEY=$2; shift 2
27 VAL="$*"
28
29 DATA="uuid=${UUID}&action=${ACTION}"
30 if [ "${ACTION}" == "set" ]; then
31 DATA+="&key=${KEY}&val=\"${VAL}\""
32 elif [ "${ACTION}" == "error" ]; then
33 ## if we send an error we append
34 # the last 10 lines of $LOGFILE
35 LOG=$(tail -n 10 ${LOGFILE})
36 DATA+="&log=${LOG}"
37 fi
38
39 wget -q -O /dev/null --user-agent="${NAME}BuildSpy/${VERSION}" \
40 --post-data="${DATA}" \
41 http://build.ipfire.org/build.py
42 }
43
44 build_spy_send_profile() {
45 MEM_SIZE=$[ $(grep "^MemTotal:" /proc/meminfo | awk '{ print $2 }') * 1024 ]
46
47 CPU_CNT=$(grep "^processor" < /proc/cpuinfo | wc -l)
48 CPU_MHZ=$(grep "^cpu MHz" --max-count=1 /proc/cpuinfo | \
49 awk -F': ' '{ print $2 }')
50 CPU_MIPS=$[ $(grep "^bogomips" --max-count=1 /proc/cpuinfo | \
51 awk '{ print $3 }' | awk -F. '{ print $1 }') * ${CPU_CNT} ]
52 CPU_NAME=$(grep "^model name" --max-count=1 /proc/cpuinfo | \
53 awk -F': ' '{ print $2 }')
54
55 build_spy set hostname $(hostname -f || hostname)
56 build_spy set cpu_mhz $CPU_MHZ
57 build_spy set cpu_cnt $CPU_CNT
58 build_spy set cpu_mips $CPU_MIPS
59 build_spy set cpu_name $CPU_NAME
60 build_spy set mem_size $MEM_SIZE
61 build_spy set distcc ${DISTCC_PORT-3632}
62 }