nixpkgs-update/ups.sh

35 lines
748 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
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
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-15 08:19:40 +03:00
echo "$(date -Iseconds) SUCCESS" >> $LOG_FILE
OK_TO_PR_AT=$(date +%s -d "+15 minutes")
2018-02-26 04:17:42 +03:00
else
2018-03-15 08:19:40 +03:00
echo "$(date -Iseconds) FAIL" >> $LOG_FILE
2018-02-26 04:17:42 +03:00
fi
done