-
Notifications
You must be signed in to change notification settings - Fork 2
/
push_changes
executable file
·46 lines (40 loc) · 956 Bytes
/
push_changes
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
#!/bin/bash
# Template from https://github.com/seanbreckenridge/havecmd
declare script_name
script_name="$(basename "${BASH_SOURCE[0]}")"
havecmd() {
local BINARY ERRMSG
BINARY="${1:?Must provide command to check}"
if command -v "${BINARY}" >/dev/null 2>&1; then
return 0
else
ERRMSG="'${script_name}' requires '${BINARY}', could not find that on your \$PATH"
if [[ -n "$2" ]]; then
ERRMSG="${ERRMSG}. $2"
fi
printf '%s\n' "${ERRMSG}" 1>&2
return 1
fi
}
set -e
havecmd python3
havecmd git
havecmd realpath
set +e
declare this_dir
this_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
cd "${this_dir}" || {
echo "Couldn't 'cd' to '${this_dir}'" 1>&2
exit 1
}
main() {
while true; do
date
./update_from_hiyori "${1:-"$HOME/code/checker_mal/cache/"}"
git add ./cache
git commit -m "cache updates" && git push
sleep 90
done
}
# exit code of the main function is the exit code of the entire script
main "$@" || exit $?