2

In the following script in Upstart, I'm unable to read /etc/shadow in pre-script phase, unless I use $(echo mypass | sudo -S cat /etc/shadow | grep myusername)

The script works fine if I provide my sudo pass, but I'm wondering if there is a way to do this without having to write my pass in the conf file?

# node-example.conf
description     "Starting Node with Upstart and Forever"

start on filesystem or runlevel [2345]

stop on runlevel [06]

expect fork

respawn 

respawn limit 5 30

console output

setuid myusername

env HOME=/home/myusername

env ARGS_FILE=/etc/shadow

. /etc/shadow

script

cd $HOME

exec forever start -a -l /tmp/forever.log -o /tmp/forever.stdout.log -e /tmp/forever.stderr.log --watch --watchDirectory /home/myusername/myapp/server /home/myusername/myapp/server/server.js

end script

pre-start script

ori='myusername:$6$P...'

**# cur=$(echo mypass | sudo -S cat /etc/shadow | grep myusername) -> this works**

**cur=$(cat $ARGS_FILE | grep myusername) -> this doesn't work**

if [ "$ori" = "$cur" ]

then encfs code

else rm -rf somefile

fi

end script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.