the-teacher
the-teacher

Reputation: 607

Capistrano 3. To set bash shell on server instead csh

When cap3 try to execute comands on my FreeBSD server - I have an errors and my cap3 tasks doesn't work

DEBUG [0bb99d53] Command: if test ! -d /home/web_server/data/www/capistrano/site/shared/dumps; then echo "Directory does not exist '/home/web_server/data/www/capistrano/site/shared/dumps'" 1>&2; false; fi
DEBUG [0bb99d53]    if: Expression Syntax.
DEBUG [0bb99d53]    fi: Command not found.

And I know why - because my server use csh shell by default

% echo $0
-csh

Following cap3 variable doesn't work for me

set :shell, '/usr/local/bin/bash'
set :default_shell, '/usr/local/bin/bash'

How can I set shell for cap3 tasks?

Upvotes: 5

Views: 741

Answers (2)

Sander Visser
Sander Visser

Reputation: 4320

You could set the default shell to bash for the deploy user on your server.

chsh -s /usr/local/bin/bash [your_deploy_user]

This worked for me.

Upvotes: 1

tcsapunaru
tcsapunaru

Reputation: 158

My opinion is that you can attempt to use:

/bin/bash -c 'if test ! -d /home/web_server/data/www/capistrano/site/shared/dumps; then echo "Directory does not exist \'/home/web_server/data/www/capistrano/site/shared/dumps\'" 1>&2; false; fi'

From the Bash man page:

If the -c option is present, then commands are read from string. If there are arguments after the string, they are assigned to the positional parameters, starting with $0.

I did a test and it worked for me:

1@one:~>%bash -c "/bin/echo Hello; echo Goodbye"
Hello
Goodbye

Upvotes: 0

Related Questions