diff --git a/roles/independent-auto-usb-backup/README.md b/roles/independent-auto-usb-backup/README.md new file mode 100644 index 00000000..dddfce9f --- /dev/null +++ b/roles/independent-auto-usb-backup/README.md @@ -0,0 +1,6 @@ +# independent-auto-usb-backup +This tool role allows to make an automatic backup to an usb stick + +## More information +- https://unix.stackexchange.com/questions/67464/how-to-get-uuid-for-a-usb-drive +- https://unix.stackexchange.com/questions/65891/how-to-execute-a-shellscript-when-i-plug-in-a-usb-device \ No newline at end of file diff --git a/roles/independent-auto-usb-backup/meta/main.yml b/roles/independent-auto-usb-backup/meta/main.yml new file mode 100644 index 00000000..11dcdd3f --- /dev/null +++ b/roles/independent-auto-usb-backup/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: +- independent_user-administrator diff --git a/roles/independent-auto-usb-backup/templates/usb-auto-backup.rule.j2 b/roles/independent-auto-usb-backup/templates/usb-auto-backup.rule.j2 new file mode 100644 index 00000000..f843fc92 --- /dev/null +++ b/roles/independent-auto-usb-backup/templates/usb-auto-backup.rule.j2 @@ -0,0 +1 @@ +ATTRS{idVendor}=="152d", ATTRS{idProduct}=="2329", RUN+="/tmp/test.sh" \ No newline at end of file diff --git a/roles/independent-auto-usb-backup/templates/usb-auto-backup.sh.j2 b/roles/independent-auto-usb-backup/templates/usb-auto-backup.sh.j2 new file mode 100644 index 00000000..821e1d30 --- /dev/null +++ b/roles/independent-auto-usb-backup/templates/usb-auto-backup.sh.j2 @@ -0,0 +1,8 @@ +#! /bin/sh + +env >>/tmp/test.log +file "/sys${DEVPATH}" >>/tmp/test.log + +if [ "${ACTION}" = add -a -d "/sys${DEVPATH}" ]; then +echo "add ${DEVPATH}" >>/tmp/test.log +fi \ No newline at end of file