create a shell script to clone and install - bash

The following is what I am trying to acheive:
git clone git_project_url
cd git_project_url
./install.sh /usr/local
This library is requirement for a project and I want to install this library into the already existing install script..
So basically, I am guessing.. the idea is to clone the project into tmp..
and then install it into that specific location... and well halt if the install fails for any particular reason..
How do I automate this in a shell script.
Thanks

Write your shell script like this:
git clone git_project_url &&
cd git_project_url &&
./install.sh /usr/local
If either of the first two commands (git or cd) fails the remaining commands won't be executed.
This won't change the behaviour of ./install.sh however. If it continues running after encountering errors when you run it from the shell prompt, it will also continue to run after errors when you in this script.

Related

How to install patchutils on Windows 10

I already have Git and Git Bash installed. I find it inconvenient to create an "interdiff" between two patch files in Git Bash using only git commands. I would like to install patchutils, so that I can use the interdiff command -- and thus create interdiffs using the patch files directly, without committing code first.
How do I install patchutils such that I can use it from Git Bash? I tried npm install patchutils, but no success.
Another approach to this issue would be to use MSYS2 instead of "Git Bash".
MSYS2 has its own Git package, and it has a PatchUtils package:
https://packages.msys2.org/base/patchutils

vs code git error: Git: /usr/bin/bash: init: No such file or directory

EDIT: I've rebooted my computer, and the issue is fixed. I have no idea why it fixed it.
In vs code on windows, when I try to Initialize Repository, I get the error
However, it used to worked fine. It changed when I tried to install Ubuntu on Windows following this video. Git is installed, and the path is in the .json file.
I'll recommend you to install git in ubuntu by apt
The git.path you've specified is to bash, not git. There's probably some wrapper that invokes that binary using git, and so when you type git init, you're really invoking bash init, which asks bash to run the script named init. Since it doesn't exist, your command is failing.
You should set git.path to a path to a Git binary, and not a bash binary.

Updated Git but still showing old version

I downloaded and installed Git 1.8.4.2 from this link: http://git-scm.com/downloads. However, when I run git --version from the Terminal I get:
[~/workspace/ruby]: git --version
git version 1.7.4.4
I've tried restarting the terminal and my computer. I then tried using the info at https://code.google.com/p/git-osx-installer/wiki/Uninstall. I did the following in the terminal from within /usr:
sudo rm -rf /usr/local/git
sudo rm /etc/paths.d/git
sudo rm /etc/manpaths.d/git
I then ran the new git .dmg file again but am still getting 1.7.4.4 when I run git --version. I suppose there's something going on here with the Mac filesystem that I don't understand. Any help would be greatly appreciated!
Run the command:
which git
You'll probably see /usr/bin/git -- the Apple supplied version. This will be because /usr/bin appears in your PATH environment variable before /usr/local/git/bin. You can verify this by running the command:
echo $PATH
If that is the case then run this command:
export PATH=/usr/local/git/bin:$PATH
and then try git --version again. You should now get 1.8.4.2. This hasn't fixed it permanently yet though. You'll need to add the export PATH=... line to your ~/.bashrc so that it gets set for every shell.

How to install, compile, and utilize Rebar in Windows 8

Is this possible?
All tutorials I've come across on how to build and use Rebar involve Unix commands, and I'm a most unfortunate Windows user. I'd really like to avoid installing Cygwin if I can help it.
For example, to build Rebar you get:
$ git clone git://github.com/rebar/rebar.git
$ cd rebar
$ ./bootstrap
Recompile: src/getopt
...
Recompile: src/rebar_utils
==> rebar (compile)
Congratulations! You now have a self-contained script called "rebar" in
your current working directory. Place this script anywhere in your path
and you can use rebar to build OTP-compliant apps.
What is the windows-cmd equivalent?
Any links or tutorial below to offer step by step instructions on how to utilize rebar in windows shell would be greatly appreciated.
UPDATE:
After manually downloading and extracting Rebar to my directory located at:
C:\erlang\rebar
I go to the windows shell and enter:
SET PATH=C:\Program Files\erl5.10.1\bin
This is the 'bin' folder located inside the directory holding erlang.exe
Next I enter:
C:\erlang\rebar>bootstrap.bat
Compiled! :)
There should be a bootstrap.bat script in the rebar directory. You don't need cygwin for this to work, but you will need Erlang installed and on the path.
I assume you have erlang istalled already and added to your path.
You can just download the Git and install it. Then open the git bash and type
git clone https://github.com/rebar/rebar.git
once cloned it to your desired location then you can run the command by going inside the rebar directory.
./bootstrap
Now it will work just fine and tell you that you have the rebar file compiled in your current working directory.
Nice you are good to go with using rebar for your project.
You can also just invoke path\to\erlang-install\bin\escript.exe bootstrap from a (Windows) command shell.
bootstrap is just an e(rlang) script.
You can download and install Git for Windows
Then, use it to run the same exact instructions:
git clone git://github.com/rebar/rebar.git
cd rebar
./bootstrap
and everything should work fine.

The git user is unable to execute bundle during GitLab installation

I am trying to install GitLab on a Debian Wheezy and experiencing an issue I don't understand.
Following the install guide for version 5.0:
step 1: was run as explained
step 2: I used rvm (multi-user install) instead (ruby-1.9.3-p392)
steps 3 to 5: were run as explained (MySQL chosen)
step 6: everything works fine until the "Install Gems" section, where I get the following error:
/home/git/gitlab$ sudo -u git -H bundle install --deployment --without development test postgres
sudo: unable to execute /usr/local/bin/bundle: No such file or directory
I run this as my normal user (in the sudo and rvm groups), and the git user is not a sudoer.
I think that the line sudo gem install bundler, in step 2, does not grant the git user to execute bundle properly, but I don't know how to fix this.
I probably did something wrong but cannot figure out what it is, as I tried to respect the standard instructions as close as possible.
Any clue about this? Thanks, I am losing hope...
For information, I have written to the GitLab mailing-list about this problem but did not get any answer. Moreover, last time I asked something similar on ServerFault, I have been advised to post on StackOverflow instead... hence this question :)
When I do $ which bundle, I get /usr/local/rvm/gems/ruby-1.9.3-p392/bin/bundle.
The git user has been created with the --disabled-login flag and thus I cannot login as git to run bundle.
When I do $ sudo -u git bundle, I get
sudo: unable to execute /usr/local/bin/bundle: No such file or directory
That means git user has not /usr/local/rvm/gems/ruby-1.9.3-p392/bin in its PATH, and you cannot modify its .profile or .bashrc because of the --disabled-login flag.
It seems that running sudo -i -u git bundle instead of sudo -u git bundle does the trick
That is the safest route, and will execute the command as git, but will simulate first an initial login, using the PATH defined in .profile and .bashrc of user root.
See "How does sudo search the path for executable?" for more.
On my local machine after upgrade from 6.4 to 7.7 I had such issue.
The compilation of ruby was made under root account.
So need permissions to read compiled ruby and installed bundle.
chmod ugo+rx /usr/local/bin/bundle
chmod -R ugo+rX /usr/local/lib/ruby/
In production mode You could be more strict.

Resources