I have a bash script (script1.sh) where I perform a git clone.
Then, from that repository, I run a another script (script2.sh) which runs fine.
I run script2.sh just fine, but the git repo is non existant. Any folder just isn't there. If I run the git clone on the command line, it clones it just fine.
Why is my script no git cloning my repo correctly?
How I run the first script.
sudo bash script1.sh
git clone http://mygit-thing.com/myrepository.git localfolder
#run script from the repo
sudo bash localfolder/script2.sh
~ Some unrelated unix commands
This could solve your problem replace your
home=/home/ubuntu folder=$home/localfolder git clone http://mygit-thing.com/myrepository.git $folder #run script from the repo bash $folder/script2.sh
if it does not work, it is maybe possible that you are not allowed to write on
$home because of your current user permissions or because your fs is read-only You can check that by executing
mount without option, it will list all mounted fs.
Another point, sudoing from inside a script is not recommended. Currently you are basically sudoing on a sudo. If you want to be sure the right user is executing your script, you better check the current id than doing nested sudo.