~pieq/checkbox/add-30suspend-1reboot-cycles-support

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh

. /etc/default/plainbox-ci-mailer
[ -z "$SUBMIT_CGI" ] && exit 1
RELEASE=$(lsb_release -ds)
IP=$(ip addr show dev eth0 |grep "inet " |cut -f 6 -d " ")
HOST=$(hostname)

notification() {
    if [ -f $CHECKBOX_SERVER_CONF ]; then
        curl -F mini_ci_notification_installed="CheckBox NG CI testing run has installed on $RELEASE server $HOST $IP" $SUBMIT_CGI
    elif [ -f $CHECKBOX_DESKTOP_XDG ]; then
        curl -F mini_ci_notification_installed="CheckBox NG CI testing run has installed on $RELEASE desktop $HOST $IP" $SUBMIT_CGI
    else
        curl -F mini_ci_notification_installed="CheckBox NG CI testing run installation has something wrong on $RELEASE $HOST $IP" $SUBMIT_CGI
    fi
}

mailer() {
    if [ -f $CHECKBOX_UPSTART_LOG ]; then
        MESSAGE=$CHECKBOX_UPSTART_LOG
        # workaround for 14.04.1 and 14.04.2 will get tag 14.04.3
        # because the package base-files update its information
        RELEASE=$(awk {'print $2'} /var/log/installer/media-info)
        SUBJECT="CheckBox NG CI testing run for $RELEASE server"
    elif [ -f $CHECKBOX_DESKTOP_LOG ]; then
        MESSAGE=$CHECKBOX_DESKTOP_LOG
        SUBJECT="CheckBox NG CI testing run for $RELEASE desktop"
    else
        MESSAGE="Something failed and CheckBoxNG didn't even start."
        SUBJECT="FAILED CheckBoxNG CI testing run for $RELEASE"
    fi
    IP=$(ip addr show dev eth0 |grep "inet " |cut -f 6 -d " ")
    HOST=$(hostname)
    SUBJECT="$SUBJECT - $HOST $IP"
    if [ -f "$MESSAGE" ] ; then
        dpkg --list "checkbox*" "plainbox*" >> $MESSAGE
        curl -F subject="$SUBJECT" -F plainbox_output=@$MESSAGE $SUBMIT_CGI
    else
        curl -F subject="$SUBJECT" -F plainbox_output="$MESSAGE" $SUBMIT_CGI
    fi
    sleep 10
    shutdown -h now
}

case "$1" in
   notification)
      notification
   ;;
   mailer)
      mailer
   ;;
   *)
      echo "Usage: $0 {notification|mailer}"
   ;;
esac