How to write a cross platform setup script in Ruby - mysql

I am new to ruby and just beginning to understand It's potential. So I am trying to use it for my everyday tasks. One of those things would be the setup of a Webservice on a local machine for testing. It set up script should:
check out several projects from subversion repositories
install Hadoop (if it's not already installed), start the Server and execute a few commands in the hbase shell
install the JDK (if not installed)
install MySQL (if not installed) and execute some SQL to create and set up the DB
Install maven (if not installed) and run some maven tasks.
So here's the deal. I want this to be a cross platform installer - it should be able to install the Webservice on Windows, Linux or OsX.
Is it possible to implement this in Ruby and what gems could be useful for that task? Are there better ways to create such an installation routine?
Regards
R.

Have a look at Chef. It provides an automation framework for managing systems. It's written in Ruby and you use a mostly Ruby recipe DSL.
People package Cookbooks for managing groups of installation and configuration recipes, which are normally based around a piece of software.
Hadoop
MySQL
Maven
Java
You will run into issues bridging the gap between Windows and Unix. Although Chef does provide good Windows support these days most Chef/community cookbooks will support Linux primarily as they can rely on the underlying package manager which Windows lacks. Often you may end up finding/using separate Windows cookbooks specifically for the Windows install.
For when you do need to do a Windows install, look at using Chocolatey and it's cookbook which provides a unix like package interface for Windows so you don't need to worry about packaging up the software manually or dealing with random NSIS/MSI installer options.
If you do extend one of the Unix cookbooks to support Windows, be nice and contribute it back to the community.

Related

Portable MongoDB and MySQL/PostgreSQL binaries

I'm currently developing a Python application and I would like to know if there are any ways to pack MongoDB and MySQL (or Postgresql) into the application. By packing I mean taking those application binaries and distribute them with the application files.
For example, Metasploit PRO has some applications like nginx, postgresql, java, ruby, etc... under /opt/metasploit (they come with the application setup), and I would like to know if that could be done with any Linux application. And if so, how could I "choose" what binaries are needed? Would they work for any Debian distro? Can any application follow that procedure? Could it be done with MySQL and MongoDB?
P.D: I would like to do this to distribute one unique application instead of having to "obligate" the user to setup the databases independently, and for pure curiosity.
Thank you very much in advance!
MongoDB already distributes its binaries as standalone binaries in the sense that everything needed for the database (or shell tools) to run is included in the respective binary (mongo/mongos/mongod).
However, these binaries are OS (Linux distribution)-specific. Meaning, for example, they dynamically link against libssl and libcurl and you need to have the right versions of those libraries on the host system. So, for example, a MongoDB binary for Ubuntu 14.04 is likely to not work on Ubuntu 16.04.
As far as I know MongoDB does not support building for "generic linux". Only specific OSes like Ubuntu 16.04 are supported.
With that said, you could possibly build a "portable" MongoDB yourself if you accept some limitations, since its source code is available:
You need to figure out how to build MongoDB on some linux distribution that gives you the baseline glibc that would be compatible with all of your targets.
You may have to forego functionality like TLS connections, or figure out how to link against openssl statically (probably non-trivial).
This would be easier with older MongoDB versions (4.0, 3.6) since they have fewer system dependencies.
I think you can pack the required services and your application as Docker image or Virtual Machine box.
As my experience, I used to package the MongoDB and other Linux CLI tools with my NodeJS web application into a VM box using Vagrant. Or you can use Docker if you prefer container-based application.
If you use Vagrant, the provisioning feature may help you to setup the database before running the application. Check https://www.vagrantup.com/docs/provisioning

MySQL install from site vs Package manager/BREW MySQL

I was wondering why would anyone want to install MySQL via something like BREW or a package manager instead of going to http://www.mysql.com/downloads/ and just downloading the entire installer?
Is there any benefits or time saving capabilities when I install my local MYSQL setup via BREW?
Vs. using the site:
Using brew or your package manager saves you the time (you don't have to hunt around for a download on the site).
The site can deliver the software in one of many unpredictable ways (e.g., as anything from a script that installs things via your package manager or compiles from in situ resources), including ways that disrupt dependencies of other installed software (which is why installing via package manager is safer and why installing things in this way, around the package manager, should be avoided unless necessary).
Vs. your ordinary package manager:
brew doesn't need sudo; it doesn't write new software versions over old software versions on the system or break system dependencies. Indeed, one of brew's perks is installation into user-specific directories and version-specific subdirectories. You can think of it as a more flexible, power-usery version of the package manager.
brew can install things not packaged by your distro or newer versions of those things than are packages by your distro.
brew is also cross-platform (works on Windows, Linux, and macOS).

Create a Sideloading Windows 8 Modern App Installer

We have a Windows 8 Modern / Metro app that we wish to deploy outside the store. I have read a bunch of materials on getting a side loading license to allow this. However, we need to go beyond just copying the app over and running some PowerShell commands, we also need to install a particular hardware driver and make some registry keys.
Can anyone recommend an installer creator that can perform all of these tasks?
Out of curiosity, is it possible to distribute through the Windows Store and have it do more than just copy the app down, i.e. execute an installations script?
By design, the installation process for a Store app, whether downloaded from the Store or side-loaded, is not customizable. For Store downloads, this is done to guarantee that the app install won't create anything that cannot be reversed during an uninstall, e.g. create registry entries, copy files, and otherwise do things that can permanently alter the system.
For side-loading, although you cannot alter the specific package deployment process itself, you can use the Powershell deployment as just one step in an overall install process. You should be able to build such an installer with any number of existing Desktop application installer tools, which give you control over all steps in your install process including registry, drivers, running scripts, etc. So you'd just have the app package and PS scripts as part of the installer .msi or .exe, and executing the PS script is done from the installer.
(By the way, the Store/PS app install processes use the same API in Windows.Management.Deployment.PackageManager to do the work. This API can be used only from a full-trust process like the Store (a piece of system code) or Powershell running in an admin console, but is there so desktop apps can implement alternate install procedures directly.)

using mysql in lua script

I need to read a database table from inside a Lua script in pdns-recursor on a Scientific Linux 6.4 server which comes with Lua pre-loaded.
Apparently I have to use luarocks to install luasql. When I attempt to install luasql I get:
Checking Lua includes... lua.h not found
lua.h is not on the server.
I tried removing the installed version so I could install from binary but then that trashed the system which apparently uses the installed Lua for everything (yum, rpm, etc). Now I have to reload OS. How can I get MySQL access from embedded Lua?
Thanks in advance.
I assume that you have already checked yum to see if luasql is available through that; if not, you should first do that, and install it through yum if possible.
The immediate cause of the problem you're having is that luarocks automatically builds modules from source, which requires access to the lua headers. These are not needed simply to run programs that use Lua, so they are not installed as part of the normal Lua package. I'm not familiar with Scientific Linux, but you can probably get them by installing a package named lua-dev, lua-devel, lua-headers, or some variant thereof. You may also need the mySQL packages (both the libraries proper and the headers). Once you have those installed, give it another try.
You might also try LuaDist, which I find to be generally more polished than luarocks, and capable of automatically downloading more dependencies; in particular it probably will not require the lua headers installed, and can handle automatically downloading and installing lua itself from source. It does, however, require CMake installed.
If for some reason you can't install the required headers and can't get luarocks or luadist working, you can try downloading and building luaSQL by hand. The Lua headers can be found in the Lua 5.1 source package and LuaSQL 2.2. Assuming the Scientific Linux maintainers haven't excessively customized the version of lua they ship with it, the results should be compatible with the system Lua install.

Open Source Application Server Solution

A project with the following technologies and components has surfaced: to up a Web stack solution initially composed with Ubuntu, JDK, JBoss, Spring MVC 3.0+, and MySQL.
In planning this project, I have been struggling to find answers to the following questions for first steps, best practices, and sequence:
1) Does the JDK (and JBoss) need to be installed as ‘root’? (I have seen articles that mention it is not a good idea to operate in root unless absolutely necessary due to the fatal consequences.)
2) Does Ubuntu need to be installed as a Server in order to accomplish all this, or can it also be installed as a Desktop? I have not been able to determine if having a JBoss and MySQL need to be installed on top of Linux as a server.
3) Does Maven need to be used within Spring STS in order to get JBoss, and MySQL (and in the future Hibernate) to work successfully together?
4) My intent is to install in this order: a) Ubuntu -> b) Java -> c) JBoss -> d) Spring STS -> and e) MySQL. Are there any blatant conflicts in this sequence?
JBoss will require Java (recommend Java 7) before it will do anything. I don't think it really "installs" per-say, but rather just unpacks to some directory (even if you install from the package manager, it just really extracts itself). I question your need for Spring since JBoss and Java EE in general really does everything Spring does, and better now-a-days. Unless you have a specific requirement for Spring, I'd question this extra dependency.
For linux - in a high level, any OS can be a "server", all it needs is to be capable of serving things (web pages, ssh connections, etc). In M$ world, different "levels" of the OS have been specially designed based on anticipated task/workload. So for example, while Windows 7 can indeed run as a server, it was not designed for it and therefore may not be optimized or include helper utilities and tools to make life easier as a sys admin of the system. Windows Server on the other hand does include all the "normal" server tools and lots of goodies to make maintaining and setting the server up easier.
In linux land, this is no such thing. Linux is the kernel that talks back and forth with the bare metal, etc... and Distro makers will take that and build an OS around the kernel, basically just attaching any packages they feel their distro needs... such as wget, or cat, or any other standard userland apps, plus some non-standard such as mysql or java or whatever they want.
Now, some distributions of linux will tailor themselves at being "server" ready, while others will tailor themselves at being a desktop OS. The difference? It's really just whatever default packages the distribution maker decides to include or not. For example, the overwhelming majority of linux servers are run completely headless, and therefore there is absolutely no reason to have X11 and a huge bloated GUI environment installed and/or running on that system... it's pointless. Also, an "average joe" user does not need MySQL installed by default on his desktop system since it would only bloat his system and he likely won't ever use it.
So basically it comes down to default installed packages.
Some linux server distros take this further and exercise extreme caution when making updates, patches, or new releases in the name of stability and security, while on the other hand most desktop distros are more haphazard with their updates since if it breaks a home users web browser, it's probably not a huge deal... but if a server update breaks the webserver application stack, now that's a serious problem.
So you'll find server OS's like CentOS (based on upstream RHEL) are extremely slow to bring in the "latest and greatest" features that desktop OS's get early on. Their goal is high security and long term stability.
Now, for Ubuntu. While I certainty know a lot of folks run Ubuntu as their server OS choice (partly due to Amazon choosing Ubuntu as the default linux VM for their ECS cloud), but I'd really question this. Ubuntu is not focused on being a server. It's focused on being a great all-around desktop oriented OS. Yes the LTS version is meant for long term stability, but it's based out of a desktop OS, so it's still not the focus.
IMHO, I'd go with CentOS because it's free and completely binary compatible version of RHEL - and RHEL is the de-facto standard for enterprise-grade linux servers. Be aware though, the RHEL way of doing things is a bit different than the debian way -- so there is no apt-get, you must use yum install instead. Startup scripts are different and some ways of doing things are different, but really, once you know linux, you know linux.
EDIT: Also check into Jenkins - its a free opensource continuous integration system that runs on JBoss or Tomcat or any other container, and can automagically pull your code from a repo (github, git, svn, etc) and compile/package it then push it to live deployment. You setup your ANT or Maven build scripts, and it can kick off on a schedule or however you configure it.
EDIT EDIT: I'd also recommend using OpenJDK -- as it's likely included in your package manager (for just about every disto) and will be more updated than the oracle version if it's in your package manager too. I've found most "server" distros will have OpenJDK 7 while only having Oracle java 6 in their package managers. Also, installing it via the package manager will enable you to keep it updated a ton easier.
Installed as root, why not? Run as root, probably not a good idea.
If you want a desktop, install a desktop distrib. If you want a server, install a server distrib. This doesn't change what can and can't be run in the OS. It only changes what is installed by default.
Maven is a build tool. JBoss doesn't care how you build your app. All it cares about is if the application you deploy is a valid Java EE application.
No. You need an OS, so Ubuntu must come first. JBoss and (AFAIK) Spring STS need a JRE to run, as they're Java applications, so Java should be installed before them. MySQL is independent of JBoss, STS and Java, so you can install it whenever you want.
Note that if you're struggling just with this installation part, be prepared to suffer with the rest. Building a Java EE webapp is not a piece of cake, and you should probably find some experienced developer to help you, as it seems you're only beginning with Java.