nixpkgs-update/ups.sh

48 lines
938 B
Bash
Raw Normal View History

#!/usr/bin/env bash
2018-02-26 04:17:42 +03:00
set -euxo pipefail
LOG_FILE=~/.nix-update/ups.log
2018-03-17 17:57:57 +03:00
mkdir -p "$(dirname $LOG_FILE)"
2018-02-26 04:17:42 +03:00
touch $LOG_FILE
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2018-03-18 08:04:34 +03:00
GITHUB_TOKEN="$(cat "$SCRIPT_DIR"/github_token.txt)"
export GITHUB_TOKEN
ARGUMENTS=$(cat packages-to-update.txt)
2018-02-26 04:17:42 +03:00
2018-03-22 08:00:31 +03:00
# shellcheck source=setup-nixpkgs.sh
source "$SCRIPT_DIR/setup-nixpkgs.sh"
2018-03-18 08:04:34 +03:00
echo "
$(date -Iseconds) New run of ups.sh" >> $LOG_FILE
2018-02-26 04:17:42 +03:00
OK_TO_PR_AT=0
2018-02-26 04:17:42 +03:00
IFS=$'\n'
for a in $ARGUMENTS
do
unset IFS
2018-03-15 08:19:40 +03:00
echo "$(date -Iseconds) $a" >> $LOG_FILE
2018-03-22 21:14:04 +03:00
if eval "$SCRIPT_DIR/up.sh $a $OK_TO_PR_AT 3>>$LOG_FILE"
2018-02-26 04:17:42 +03:00
then
2018-03-22 21:14:04 +03:00
RESULT=$?
2018-02-26 04:17:42 +03:00
else
2018-03-22 21:14:04 +03:00
RESULT=1
2018-02-26 04:17:42 +03:00
fi
2018-03-22 21:14:04 +03:00
case "$RESULT" in
0)
echo "$(date -Iseconds) SUCCESS" >> $LOG_FILE
OK_TO_PR_AT=$(date +%s -d "+15 minutes")
;;
1)
echo "$(date -Iseconds) FAIL" >> $LOG_FILE
;;
*) exit 1
;;
esac
2018-02-26 04:17:42 +03:00
done