I'm working on a script that installs the new cross platform DNX runtime on an Ubuntu box. I'm scripting the whole installation, so that it runs unattended after provisioning the machine.
Here's the relevant part of the script:
#!/bin/bash
admin_username=$1
wget -q https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh -P /home/${admin_username}/dnvm
bash /home/${admin_username}/dnvm/dnvminstall.sh
source /home/${admin_username}/dnvm/dnvm.sh
dnvm ## <-- Error: post_deployment.sh: 34: post_deployment.sh: dnvm: not found
The script will execute as root on the machine after provisioning. The ${admin_username}
is passed in correctly - and /home/${admin_username}/dnvm/dnvm.sh
does exist on the filesystem after the dnvminstall.sh
execution.
The problem is that the dnvm
command is defined inside the dnvm.sh
file, but is not available in the calling script ( post_deployment.sh
) - after sourcing the file.
From what I've read - if I would have used bash /home/${admin_username}/dnvm/dnvm.sh
- it would have run that script in a subshell, not exposing any of the functions inside. But using source
should, right?
UPDATE
Below the excution trace of the script:
2016/05/18 07:19:33 Downloading DNVM installation script ...
2016/05/18 07:19:33 Running installation script ...
2016/05/18 07:19:33 Downloading dnvm as script to '/home/serveradmin/dnvm'
2016/05/18 07:19:33
2016/05/18 07:19:33 Appending source string to /home/serveradmin/.profile
2016/05/18 07:19:33 Type 'source /home/serveradmin/dnvm/dnvm.sh' to start using dnvm
2016/05/18 07:19:33 Sourcing DNVM commands ...
2016/05/18 07:19:33 Downloading coreclr DNX runtime ...
2016/05/18 07:19:33
2016/05/18 07:19:33 ---errout---
Extracting templates from packages: 100%
2016/05/18 07:19:33 + source /home/serveradmin/dnvm/dnvm.sh
2016/05/18 07:19:33 post_deployment.sh: 33: post_deployment.sh: source: not found
2016/05/18 07:19:33 + dnvm
2016/05/18 07:19:33 post_deployment.sh: 34: post_deployment.sh: dnvm: not found
With actual source:
...
echo "Sourcing DNVM commands ..."
set -x
source /home/${admin_username}/dnvm/dnvm.sh
dnvm
...
So then - it seems the command source
is not found. Which makes this question a duplicate of this question on StackOverflow. However - I don't have solution yet, because I need to use Ubuntu 14.04 ( only version supported in DNX right now ).