1

I wrote a small installation script for my utilities set:

#!/bin/bash

set=(move-volume move-db dmove-copy-id dmove-config dmove-nginx-proxy)

for item in ${set[*]}
do
    wget -q -nv https://raw.githubusercontent.com/pavelsr/dmove/master/$item -O /usr/local/bin/$item
    chmod +x /usr/local/bin/$item
done

dmove-config
dmove-copy-id
echo "Setup complete! Do not forget to dmove-copy-id if you updated config"

Running installation script like:

curl -sSL https://raw.githubusercontent.com/pavelsr/dmove/master/install-dmove | sudo bash

But it just download files and doesn't execute code after done.

What could be wrong?

Paul Serikov
  • 2,550
  • 2
  • 21
  • 36
  • Is `/usr/local/bin` in your `PATH` environment variable? To check, run `export | grep PATH`. – chuckx Jun 10 '18 at 09:07
  • 1
    Run with `bash -x` to get a trace of the shell expansions and see how far it got. – cdarke Jun 10 '18 at 09:07
  • @chuckx, yes, it is `root@docker-2gb-blr1-01:~# export | grep PATH declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"` – Paul Serikov Jun 10 '18 at 09:08
  • @cdarke, seems like code is executed since I see `+ dmove-config` after running `bash -x`. Is it a problem with user input ? My `dmove-config` [contains](https://github.com/pavelsr/dmove/blob/master/dmove-config) `read -p` – Paul Serikov Jun 10 '18 at 09:13
  • OK, so it *is* executing beyond the loop. Yes, `read -p` could be an issue, do you get the prompt? – cdarke Jun 10 '18 at 09:15
  • @cdarke, no, I haven't got the prompt – Paul Serikov Jun 10 '18 at 09:16
  • OK, I would try entering the data for the `read` on the terminal when it appears to hang. Also, check that `dmove-config` is running correctly, again you can use the `bash -x` to run it. – cdarke Jun 10 '18 at 09:18
  • `echo -e "login@ip.addr\nfolder" | dmove-config` – Cyrus Jun 10 '18 at 09:20
  • 3
    Not sure if `set` is a good variable name to use... – Mark Setchell Jun 10 '18 at 09:20
  • @cdarke, `dmove-config` is running fine, `bash -x dmove-config` too. – Paul Serikov Jun 10 '18 at 09:25
  • It would be so much simpler to just bake all the commands into a single script, instead of having a script which downloads other scripts. – John Zwinck Jun 10 '18 at 09:32
  • @Cyrus, but I need an interactive promt during installation – Paul Serikov Jun 10 '18 at 09:38
  • @Cyrus, sure I can pass parameters directly to STDIN of `dmove-config` but it's not that expected. Since I decided to distribute my script among other users it's better to have interactive promt – Paul Serikov Jun 10 '18 at 09:48
  • Wrap the entire script in a `{ ...; }` block to ensure its not executed until it's completely downloaded. – that other guy Jun 10 '18 at 16:46

1 Answers1

2

Replace

dmove-config

with

dmove-config </dev/tty

to force dmove-config reading from tty and not waiting for data from your curl command.

Cyrus
  • 84,225
  • 14
  • 89
  • 153