When I run a startup service script, it appears to be using /bin/csh instead of /bin/sh
The relevant line in /etc/passwd
The script - edited for clarity:
Returns the following
The error running the rbenv command does not occur if I interactively log into the shell, which is using sh.
The relevant line in /etc/passwd
Code:
mastodon:*:1060:1060:User &:/home/mastodon:/bin/sh
The script - edited for clarity:
Code:
#!/bin/sh
# $FreeBSD$
# PROVIDE: mastodon_sidekiq
# REQUIRE: DAEMON postgresql
# KEYWORD: shutdown
. /etc/rc.subr
name="mastodon_sidekiq"
start_cmd="start"
stop_cmd="stop"
rcvar=mastodon_sidekiq_enable
pidfile="/var/run/${name}.pid"
desc="Mastodon Sidekiq Service"
load_rc_config ${name}
start() {
PATH=/home/mastodon/.rbenv/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
/bin/mkdir -p /var/run/mastodon
/usr/sbin/chown mastodon:mastodon /var/run/mastodon
/usr/bin/su mastodon -c "echo $PATH && ps -p $$ && echo $SHELL && env"
/usr/bin/su mastodon -c 'mycommand="$(rbenv init - su)" && eval $mycommand'
}
stop() {
/bin/kill -9 `cat /var/run/mastodon/${name}_supervisor.pid`
/bin/kill -15 `cat /var/run/mastodon/${name}.pid`
}
run_rc_command "$1"
Returns the following
Code:
root@mastodon:/usr/local/etc/rc.d # /usr/local/etc/rc.d/mastodon_sidekiq restart
/home/mastodon/.rbenv/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
PID TT STAT TIME COMMAND
67915 4 SJ 0:00.01 /bin/sh /usr/local/etc/rc.d/mastodon_sidekiq restart
/bin/csh <----------------------------- Why is this the result of 'echo $SHELL'?
SHELL=/bin/sh
GROUP=wheel
MACHTYPE=x86_64
EDITOR=vi
PWD=/usr/local/etc/rc.d
LOGNAME=root
HOME=/home/mastodon
LANG=C.UTF-8
RC_PID=67915
OSTYPE=FreeBSD
TERM=xterm-256color
HOST=mastodon.brendans-bits.com
USER=mastodon
SHLVL=2
PAGER=less
MM_CHARSET=UTF-8
VENDOR=amd
PATH=/home/mastodon/.rbenv/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
BLOCKSIZE=K
MAIL=/var/mail/root
HOSTTYPE=FreeBSD
REMOTEHOST=192.168.101.2
_=/usr/bin/env
su: eval: line 1: syntax error near unexpected token `('
su: eval: line 1: `export PATH="/home/mastodon/.rbenv/shims:${PATH}" export RBENV_SHELL=su command rbenv rehash 2>/dev/null rbenv() { local command command="${1:-}" if [ "$#" -gt 0 ]; then shift fi case "$command" in rehash|shell) eval "$(rbenv "sh-$command" "$@")";; *) command rbenv "$command" "$@";; esac }'
The error running the rbenv command does not occur if I interactively log into the shell, which is using sh.