Installing packages through bash scripting - bash

I have never written any bash scripts at this point and my understanding of them is still pretty green. I was curious after reformatting my Mac if it is possible to write a script that does the majority of installs in an automated fashion?
For instance I use homebrew so maybe a portion of the script could verify if this is on the Mac and if not then initiate the install. Then it could proceed with the list of brew install & brew cask installs.
This is something that after realizing how much I had installed and had to remember and still am remembering to install I think would be pretty cool to make...I just don't know if a) it's possible with the macOS or how-to (I'll read up on the how-to). I'm not even too sure if bash-scripts would be the thing to use for something like this or not. Thanks in advance for any information!

on an RPM based system I would eventually list the packages installed, backup the list and then chain it in a yum install command.
For instance:
yum list installed
A
B
C
then to reinstall
yum install A B C -y
Extremely easy and straight forward.
I do believe you can do the same with brew:
brew list
brew install based on the list
I hope this helps

Related

How to install libraries (mysql connector cpp) on Mac using terminal and make things simple as in the case of Ubuntu

I will share an example.
I had to install mysql connector c++ libraries for my project.
To install connector c++ on my Mac, i had to build it from the source code and it takes a lot of effort because you get errors sometimes and then it is troublesome, something which should have been done in a short time.
In case of Ubuntu, I just had to write one command in the terminal, and wow, everything just got done automatically.
apt-get install libmysqlcppconn7
Does anybody know any similar command in mac, using brew or macports?
I tried to find but I guess I didn't get any results to satisfaction.
And if there is not, can anyone guide me so that I can make it possible, like I think it's possible for mac, if it is possible in ubuntu.
Please guide me, an answer in a bit detail would be so much appreciated.
Probably the nearest thing to apt-get on a mac is brew
Once it is set up (and this isn't difficult) "brew install mysql-connector-c++" will install on the mac

Is there a way to install Homebrew via graphical interface?

For whatever reason, my place of work distrust installations via CLI.
Is there a GUI installation that can be installed that would keep the IT department happy?
Thanks in advance.
There’s Cakebrew, a GUI wrapper around Homebrew; but it doesn’t install Homebrew for you for now:
It is important to note that Cakebrew doesn't install Homebrew for you. To install Homebrew, please visit their website.
Installing Homebrew though Cakebrew is currently in the To-Do List =)
There’s no way to install Homebrew via GUI.

What do I need to install on my VPS server to work with CSS LESS?

It seems like there's a long list of things I need to install just to work with LESS, so I want to make sure I have this right:
To install LESS I need to install node.js/npm
To install node, I need to install Ruby
To install Ruby, I need to install Linuxbrew
To install Linuxbrew, I need to install Git
To install Git, I need to use/install Yum
FWI, I've never used the console much before, so this might be completely wrong, but it's what I've pieced together so far.

IPython3 for Mac OSX

I have Ipython installed but it runs on python 2.7.5 , I also have python 3.3 installed. How can I make changes such that Ipython runs on python 3.3 not 2.7.5?
You need to install pip for Python 3 - it's as easy as going to the pip-installer.org Installation page and following the instructions. Briefly, download get-pip.py and save it someplace, like your Downloads folder. Navigate there in Terminal, and run
sudo python3 get-pip.py
and you should soon have either a pip3 or pip-3.3 command (maybe both, I don't remember). You should now be able to run
sudo pip3 install ipython[all]
and hopefully all the dependencies will be installed as well. If installation chokes, use pip3 to install pyzmq, tornado, pyreadline, jinja2, pygments, and maybe a few others. Make sure you read the docs before you start, so you have an idea of what you're trying to achieve. IPython is large and quite complex, with many moving parts, so in the absence of a package manager (see below) it can take a bit of time before everything is up and running.
The Package Manager Way
There are other options, too. You can install Anaconda, a "Completely free enterprise-ready Python distribution for large-scale data processing, predictive analytics, and scientific computing" with over 100 packages, including IPython and its dependencies. By default, the Anaconda installer gives you Python 2.7, but you can use the conda command to install Python 3.
My personal favorite is to install Python 3 and IPython using MacPorts. Yes, it'll install Py3 all over again, but unless you're really starving for disk space (in which case you probably don't want to be installing large packages like IPython) it's no big deal. Using the port command, once the base MacPorts installation has been put in place, you can just run
sudo port install py33-ipython +pyqt4
and all the other dependencies will be taken care of, (hopefully) flawlessly, without your having to do anything else except wait for a long time while things like PyQt are compiled. You may also need to run sudo port install py33-ipython +notebook if you want the notebook, I don't recall if it's installed otherwise. BTW, you do need X11, Xcode, and the Xcode command-line tools for MacPorts, but they would likely be required if you do the first option as not all packages have binaries available for OS X. The excellent documentation walks you through everything, from installation to using the port command to maintaining your system. I would highly recommend modifying your ~/.profile (or ~/.bash_profile, ~/.bashrc, or equivalent for your shell) to add the MacPorts install directories (/opt/local/bin and /opt/local/sbin, by default) to the front of your path. Just add export PATH='/opt/local/bin:/opt/local/sbin:$PATH' to the end of the file.
A third alternative option is to use Homebrew. It's similar to MacPorts, in that the brew command is a type of package manager like port and conda, but in my experience it doesn't have as many packages, and doesn't quite work as seamlessly as port. However, my observations on StackOverflow, Ask Different and other fora seem to indicate that about 50% of people have great experiences with brew and don't like port, while the other half loves port over brew. YMMV.
I hope this helps. Good luck with your installation!

How do I install ack on OS X (10.8.4)?

I am new to OS X and I am unable to figure out how to install ack. The instructions here didn't help, because the command "install" is failing. Please guide me proper commands.
So far, I have downloaded ack 2.04 and placed it in the /usr/bin folder and then ran perl Makefile.PL successfully. The next command install isn't working for me.
If you use Homebrew you can simply do:
$ brew install ack
If you are new to OSX I highly recommend this approach because it makes installation of stuff like this MUCH easier. It is a package manager for OSX.
Homebrew link: http://brew.sh/
You can also use the MacPorts installer for OSX:
sudo port install p5.<nn>-app-ack
where <nn> is the version of your Perl installation (Ack is written in Perl). If you don't know the version of Perl you have installed, just type:
perl --version
and you'll know what you need for the port command. The Ack installation page has the information you need for this. More information about MacPorts can be found here.
Searching the web, you'll find LOTS of opinions about Homebrew versus MacPorts. I've used both; they both work (and both fail occasionally - installation of this kind is complex). You'll need to pick one or the other and stick with it as Homebrew doesn't play nicely with MacPorts (or vice versa, depending on your POV). Overriding choice for me is MacPorts as it has many more packages than Homebrew and it puts its stuff in /opt/local to stay out of the way of other programs. YMMV

Resources