2

I'm writing scripts to automate the installation and configuration of my raspberry pi. My problem is that the official installation script of oh-my-zsh opens a new shell - the zsh. So that practically ends my script and i need a separate script for further configuration. I want my script to continue after the omz install.sh has finished.

script:

. ./functions.sh
echo "\n###### install zsh ######\n"


log "apt-get install -qqy zsh"

read -p "Enter Your Name: "  username
log "chsh -s /bin/zsh $username"

# this install.sh opens zsh and blocks proceeding of script
su - $username -c 'sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

# I want the script to continue here
echo "More commands"

Notes:

  • log is declared in functions.sh and will execute command and output command which was executed

1 Answer 1

3

If you set RUNZSH to no before running the installer, or run it with standard input not connected to a terminal, it won’t run the shell. In your case, adding < /dev/null at the end of the command feels like the simplest solution:

su - $username -c 'sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" < /dev/null'
2
  • 1
    Thanks, that works :) So with < /dev/null the standard input is connected to /dev/null which is not a terminal and therefore the shell won't run?
    – Philipp A.
    Jul 6, 2019 at 11:34
  • 1
    Yes, the script explicitly checks that its standard input is a terminal and disables two features if it isn’t: running chsh itself, and running zsh at the end of the installation process. Jul 6, 2019 at 11:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .