diff --git a/roles/live2dev/templates/update.j2 b/roles/live2dev/templates/update.j2 index 9973d7b498c4f921ae11c8d4022e0e7131ec64f8..963de680b33fc4e6b2f2ae7eb6bb9486ef288e33 100644 --- a/roles/live2dev/templates/update.j2 +++ b/roles/live2dev/templates/update.j2 @@ -1,10 +1,14 @@ #!/bin/bash -if [[ "${USER}" != "{{ item }}" ]]; then - echo "This script should be run as {{ item }}, please sudo first" - echo "sudo -u {{ item }} -s /bin/bash" - echo "${0}" - exit +# $LOGNAME is set to {{ item }} when this script is run via cron and is +# unset when run via a terminal +if [[ "${LOGNAME}" != "{{ item }}" ]]; then + if [[ "${USER}" != "{{ item }}" ]]; then + echo "This script should be run as {{ item }}, please sudo first" + echo "sudo -u {{ item }} -s /bin/bash" + echo "${0}" + exit + fi fi cd /home/{{ item }}/sites