Skip to content

Commit 2b8e53c

Browse files
committed
Make cron test installation work even when the user's crontab is empty.
1 parent 8bae40c commit 2b8e53c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

psij-ci-setup

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,17 @@ cron_install() {
5757
echo "The following line will be installed in your crontab:"
5858
echo "$LINE"
5959
echo "================================================================"
60-
{ crontab_list && echo "$LINE"; } | crontab -
60+
61+
CRT_CRONTAB=`crontab -l 2>&1`
62+
if [ "$?" != "0" ]; then
63+
if echo "$CRT_CRONTAB" | grep "no crontab for" >/dev/null 2>&1 ; then
64+
CRT_CRONTAB=""
65+
else
66+
echo "Error updating crontab: $CRT_CRONTAB"
67+
exit 2
68+
fi
69+
fi
70+
{ echo "$CRT_CRONTAB"; echo "$LINE"; } | crontab -
6171

6272
declare -x | egrep -v "^declare -x (BASH_VERSINFO|DISPLAY|EUID|GROUPS|SHELLOPTS|TERM|UID|_)=" >psij-ci-env
6373
}

0 commit comments

Comments
 (0)