Skip to content

Commit f5796f5

Browse files
committed
Add support for task scripts that are not dirs
Makes life a bit easier
1 parent 6eea69f commit f5796f5

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

configs/samples/failingtask

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
samples/helloworld
2+
samples/non_directory_task
23
samples/no_undo
34
samples/failingtask

provision.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ provision() {
3939
continue
4040
fi
4141

42-
if [ ! -d $ZDSP_TASK_DIR/$task ]; then
43-
fatal "task directory $ZDSP_TASK_DIR/$task not found"
42+
if [ -d $ZDSP_TASK_DIR/$task ]; then
43+
if [ ! -f $ZDSP_TASK_DIR/$task/do.sh ]; then
44+
fatal "task file $ZDSP_TASK_DIR/$task/do.sh not found"
45+
fi
46+
elif [ ! -f $ZDSP_TASK_DIR/$task ]; then
47+
fatal "task file $ZDSP_TASK_DIR/$task not found"
4448
fi
4549

46-
if [ ! -f $ZDSP_TASK_DIR/$task/do.sh ]; then
47-
fatal "task file $ZDSP_TASK_DIR/$task/do.sh not found"
48-
fi
4950
done
5051

5152
info "Running tasks"
@@ -73,8 +74,14 @@ provision() {
7374
provision `echo $task | sed s/^provision://g `
7475
fi
7576

76-
sed -i $'s/\r$//' $ZDSP_TASK_DIR/$task/do.sh
77-
bash $ZDSP_TASK_DIR/$task/do.sh
77+
if [ -f $ZDSP_TASK_DIR/$task ]; then
78+
scriptfile=$ZDSP_TASK_DIR/$task
79+
else
80+
scriptfile=$ZDSP_TASK_DIR/$task/do.sh
81+
fi
82+
83+
sed -i $'s/\r$//' $scriptfile
84+
bash $scriptfile
7885
if [ $? != 0 ]; then
7986
error "task $task failed. Rolling back."
8087
for task in `tac $ZDSP_CONFIG_DIR/$config | tail -n $num`; do

tasks/samples/non_directory_task

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
echo "This is a non-directory task"

0 commit comments

Comments
 (0)