From a911344cc6abe9212264a761e342cf1c89b69eaa Mon Sep 17 00:00:00 2001 From: Pi Date: Mon, 25 Feb 2019 15:00:59 -0500 Subject: [PATCH] update smbclient to install the script and create the cron job --- roles/smbclient/files/smb-session.sh | 17 +++++++++++++++++ roles/smbclient/tasks/main.yaml | 8 ++++++++ 2 files changed, 25 insertions(+) create mode 100755 roles/smbclient/files/smb-session.sh diff --git a/roles/smbclient/files/smb-session.sh b/roles/smbclient/files/smb-session.sh new file mode 100755 index 0000000..6f73d3e --- /dev/null +++ b/roles/smbclient/files/smb-session.sh @@ -0,0 +1,17 @@ +#! /bin/bash + +file=$(i=$RANDOM +if [ $i -lt 16384 ]; then echo 'test_file_100M' +elif [ $i -lt 24566 ]; then echo 'test_file_200M' +elif [ $i -gt 29490 ]; then echo 'test_file_1G' +else echo 'test_file_500M'; +fi) + +if pgrep -f test_file >/dev/null +then + exit 0 +else + cp /media/smb/$file /home/pi/Documents/smb/all_files_$HOSTNAME.zip + cp /home/pi/Documents/smb/all_files_$HOSTNAME.zip /media/smb/ +fi + diff --git a/roles/smbclient/tasks/main.yaml b/roles/smbclient/tasks/main.yaml index b2e1edc..1af0b30 100755 --- a/roles/smbclient/tasks/main.yaml +++ b/roles/smbclient/tasks/main.yaml @@ -7,3 +7,11 @@ weekday: "1-5" job: "/usr/bin/perl -e 'sleep int rand 1199' && /home/pi/scripts/smb-session.sh" tags: smbtraff_cron +- name: copy smb-session.sh to scripts directory + copy: + src: "{{ role_path }}/files/smb-session.sh" + dest: /home/pi/scripts/smb-session.sh + owner: pi + group: pi + mode: a+x + tags: smbtraff_script