forked from dslotter/HamPi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_HamPi_playbook
executable file
·27 lines (21 loc) · 939 Bytes
/
run_HamPi_playbook
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
#!/usr/bin/env bash
#
# Copyright 2020, Dave Slotter (W3DJS). All rights reserved.
#
echo -n "Ansible Playbook Run started at: "
start_time=`date`
echo $start_time
# Compute the seconds since epoch for start date
t1=`date --date="$start_time" +%s`
curdate=`date +%Y-%m-%d`
echo "ansible-playbook -i hosts tasks/main.yml"
ansible-playbook -i hosts tasks/main.yml | tee --append ansible-output_${curdate}.txt
if [ -x /usr/local/bin/notify-send ]; then
export NOTIFY_SEND_URL="http://192.168.1.220:12345"
/usr/local/bin/notify-send -i /usr/share/icons/Adwaita/scalable/status/checkbox-checked-symbolic.svg "HamPi" "Ansible has finished."
fi
# Compute the seconds since epoch for end date
end_time=`date`
t2=`date --date="$end_time" +%s`
let diff_time=$t2-$t1
printf "Total time for running Ansible Playbook: %02d:%02d:%02d\n" $((diff_time/3600)) $((diff_time%3600/60)) $((diff_time%60)) | tee --append ansible-output_${curdate}.txt