0

I'm trying to write script to install s3fs-fuse, but i don't know how to change directory in a bash script. These are the script I want to automate

git clone https://github.com/s3fs-fuse/s3fs-fuse.git
cd s3fs-fuse
./autogen.sh
./configure
make
sudo make install
Casper
  • 117
  • 8

1 Answers1

2

That's how you do it -- when the script ends, the current directory reverts back to what it was when the script starts, so perhaps that's why you don't think it's working.

Add set -e to the beginning of the script. Otherwise, if any of those commands return an error, the script will just keep on running, moving on to the next command, and that is definitely not safe.

Michael - sqlbot
  • 22,658
  • 2
  • 63
  • 86
  • No I want to put these into a bash or sh file, these are part of something else. Apparently `cd` won't work – Casper Oct 23 '15 at 00:49
  • I'm afraid I don't understand what you mean by "these are part of something else" and "apparently `cd` won't work." Won't work, why? If you put `#!/bin/bash` before the top line of the text in your question, what you have written *is* a valid bash script. Save it as a file, `chmod +x` the file, and run it. – Michael - sqlbot Oct 23 '15 at 03:27
  • I mean I want to put all of these commands into a shell script file, which automatically run through all the steps, not me typing one by one – Casper Oct 23 '15 at 17:13
  • 1
    Unless I misunderstand your question, you are overestimating the difficulty of this task See: https://gist.github.com/sqlbot/228a68fc4c3c2823e5d0 for what your shell script would look like. – Michael - sqlbot Oct 23 '15 at 20:31
  • I would like to add that the manual will always install the newest master branch. It might be useful to Inser a `git checkout tags/` in between, to install an actual release. The latest release of s3fs is v1.80, from 29 May 2016. – M. Glatki Apr 03 '17 at 14:35
  • @M.Glatki, thank you. That is a *very* good point. I, myself, routinely use an older (stable) version of s3fs, which I keep on hand and don't get from github. I was really focused here on the creation of a bash script rather than on recommended practices for deploying s3fs. – Michael - sqlbot Apr 03 '17 at 14:54