Upstart 스크립트에서 REGEX가 작동하지 않습니다.

Upstart 스크립트에서 REGEX가 작동하지 않습니다.

Upstart 스크립트의 경우 정규식은 항상 false를 제공하지만 스크립트를 수동으로 실행하면 작동합니다.

/etc/init/sync_remote_users.conf:

start on filesystem and net-device-up IFACE!=lo
stop on runlevel [016]
respawn
##?
respawn limit 20 5
##?

script
    exec opt/local/our-sync-pkg-2.0/sync_users start
end script

다음은 sync_users 코드입니다:

#!/bin/bash

for line in $(cat $DECRYPTED_PASSWORDS_FILE)
do
    if [[ !($line =~ ^[^-_][0-9a-zA-Z._-@]+\:[0-9a-zA-Z.\/$]{98}+$) ]]; then
        result=false;
   fi
done

답변1

코드는 잘 작동했습니다. 문제는 bash 스크립트라고 언급하지 않는 한 upstart 스크립트가 기본적으로 BASH 스크립트를 실행하지 않는다는 것입니다. 그래서 내 시작 스크립트를 다음과 같이 변경합니다.

start on filesystem and net-device-up IFACE!=lo
stop on runlevel [016]

script
    exec bash -c '/opt/local/our-sync-pkg-2.0/sync_users start'
end script

관련 정보