diff --git a/roles/live2dev/templates/cron.j2 b/roles/live2dev/templates/cron.j2 index ab2bb938f578781e439571b135ed591d32a6defa..07cbb55a82cc21e36f4fab7c33e660075ec3e89c 100644 --- a/roles/live2dev/templates/cron.j2 +++ b/roles/live2dev/templates/cron.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 ~/sites