Trying to install Git and perform a pull with a single batch file - ruby

I have a situation where I need to deploy ruby code to lab devices. These machines are slow and very locked down (hard to get files to). They get re-imaged fairly often, but I am not allowed to bake the install into the image.
I've solved the problem by using the same open ports for Git code distribution to distribute my install files.
I have a long install process boiled down to 3 batch files, but if I could reduce it to one, it would make life a lot easier (not to babysit a lot of installs via VNC). I'm only mentioning all this for reference.
The problem:
I can't install git and then do a pull from command line without opening a new cmd prompt - I think it pertains to environment variables, but am not 100% sure.
I get "git is not recognized" blah blah blah if I don't break out at this point and start the next batch. Same deal when I install ruby and don't break out before starting the DevKit install.
Powershell is not an option (I'm only allowed to install Git, Ruby, and the support (DevKit, C++ redistributables, .Net Client 4) and some of the machines do not have it.
I did a version where I scripted reboots and moving the batches into startup progressively - it works, but some of the other machines are tied together in a way that makes rebooting an issue (please don't make me explain - it's complicated lol).
Is there a way to merge my 3 batch files and execute all steps without reboots?
Edit: I have tried starting the next batch from the first (Start... Call...), and even creating a scheduled task to execute the next step. Can't swear I haven't made any mistakes, but they all seem to inherit the initial conditions and don't recognize the "git" command unless a new cmd prompt is opened.

Related

Is there a way to prevent a bash script from running certain commands if the script has to be run again?

I have a bash script that works at the moment. It gets an image and JDK 8 from a link and then runs a installer for the JDK 8 to move on to setting up another piece of software.
As I was debugging the script, I kept finding myself having to delete directories and even the java installation because when I introduce a fix and rerun the script, I have to wait for everything to download again and I have to worry about duplicate files messing up my current logic -which can probably be improved, but I'll go to the StackExchange Code Review site later.
At the moment, I would like to know what approaches there are to prevent commands -like downloading the JDK and running the JDK installer script all over again and others- from running again.
What kind of general approaches are out there for cases such as these?
For the JDK download and running the installer, I did think of simply checking for the existing of java on the system and if there is then bash would not not to run those commands.
However, there are other commands I do not want run and I do want to simply check, for example, the existence of certain files to prevent wget-ing them all over again and moving them -causing duplicates. (Should I maybe suck it up and do that anyway as that might be best practice?)
I did also think of perhaps, at each successful command, outputting like a 1 to a text file and mapping each line in that text file to the commands run in the script (like using an if statement to see if that command had a 1 or not in the text file) and if it was a 0, then the script would know only to run that command and never the 1s.
That sounded clunky to me and I am pretty sure that is not a good approach.

How to execute innosetup installer from third party silently and without it attempting to install dependencies?

I have an installer from a third party. Through trial and error I discovered it was an innosetup installer. When I call it with the /silent flag it installs just fine, until it executes installers for 3 dependencies (direct X is one, for example) which then require user input to cancel. I want to be able to run the installer and have it either install the dependencies silently or not at all. When going through the installer GUI normally it does give me 3 checkboxes at the end on the last page of the wizard (before I would hit the Finish button) that allows me to choose whether or not to install the dependencies. Is there a way of doing this that I don't know about? From my research it seems impossible without knowing the types and components available (and executing the installer with the /help or /? options had no effect) and I will probably need to get a new installer from the third party. The only other option I can think of would be to have some sort of timeout that after a certain period of time of inactivity from the installer I kill the install process (since the files I was interested in had already been installed at that point I think).
Checkboxes on the finish page sound like postinstall [Run] entries. There is no way to influence the selection of these from the command line, except that the original setup author can choose to have a different set of options selected for interactive install vs. silent install. (Or they might have extended the /LOADINF option to work with these, although this is unlikely.)
Given that this is a third-party installer, your best bet is to contact the original vendor and see if you can get them to change the default silent selection, or to add an additional command-line parameter to change the defaults.
Failing that, you could consider using a program such as AutoIt to auto-click the wizard GUI when run non-silently.
(If the things that it's trying to install really are dependencies, though, then you probably should let it install them. And it should be installing those silently too anyway.)
Killing the install process after a specified time seems like an excellent recipe for disaster.
Those are probably [Tasks] within InnoSetup's install, which you may be able to deselect by passing /tasks="" in the command line (along with the /silent). Here is a list of command line options: http://www.jrsoftware.org/ishelp/topic_setupcmdline.htm . Adding /suppressmsgboxes may help also.
It seems it is impossible to do what I wish without knowing more about the structure of their setup. I was however successful in solving my original problem by killing the third party installer after waiting a specified amount of time (which I got from reading this question).

Using SVN for the first time

Not sure if I should be asking here or Server Fault.
Anyhow, I recently started a project at a new job that has SVN installed. I didn't use it even though I was given SSH access with some keygen thing. But now I've done some reading online for beginner's and I'm having a tough time getting past "which svn" after I input a command through SSH. I guess that tells me the path to the repository (which is /usr/bin/svn) but I don't even know how to get to that directory (I'm using Terminal on Mac OS X).
All this makes me feel pretty stupid, since I've never really had to use the terminal to do web projects before and this is my first experience with SVN via SSH (Hell, first time using SSH even).
I have been googling and reading for a weekend now, but I figured someone on here probably has a good idea of where to find the files or to check which are under SVN etc. I think my main problem is finding out how to use the terminal to "get" to the folder I want to be working on.
I did read up on the commands to check if a file is under SVN, check out, update, commit, etc. I would just like to know how to get to these files to do that. Sorry for the noob question and thanks in advance
Bonus points if someone explains the benefits of SSH (I totally understand the benefits of SVN and would love to learn it properly)
You're likely better off using a subversion client. Two of the most popular ones for OS X are http://versionsapp.com and http://zennaware.com/cornerstone/index.php (lately my dev friends seem to like cornerstone more.)
These should let you do all (or nearly all) SVN functions, but by using a GUI. You'll still want to learn the terminology. Take a look at http://svnbook.red-bean.com/en/1.6/svn.basic.html
You want SVN+SSH as it's more secure, but that shouldn't mean you have to use the command line.
Well there is no need to go to the /usr/bin even though svn resides there. /usr/bin is a standard location which is automatically included when the system tries to resolve the location of a file. You should be able to just start using SVN commands like:
svn checkout ...
The benefits of using SVN and SSH are separate questions all together.
svn list --verbose http://host_name/svn_dir will give you a list of the current versioned projects (including revision number and modified date)
svn checkout http://host_name/svn_dir/repository_name projectx will checkout the repo (creating a working copy on your local machine)
I'd recommend the manual here, even if you don't read it to start with and just use it as your first reference point when needed.

How to write an automated script to install a new cms

Does anyone know where I would begin to write an automation script to install a CMS to my wwwroot folder and create the database for it? For this round it would be for DNN on in a windows environment.
I am looking for methods to speed up our development process in the office.
Many thanks!
First write a (textual) script of what you need to do.
Then convert these steps to automated steps.
The exact steps depend on the database and webserver you are using and on how you want everything to be configured, so get these steps clear before you start scripting.
Queries you need to execute can be put in separate files (usually with .sql extension). Most databases allow running those files from the command line.
Most other commands, like creating folders and such can be run from the command line as well. If you can run it in the command window, you can put it in a batch file as well to run everything at once, so you can translate all possible steps to a line (or group of lines) in a .bat script.
Identify the prerequisites, and generally they windows patches, db/sql server etc.
Determine how to install all the prerequisites from the command line.
Create your database manually and then script it out using something like sql server management studio or a third party tool such as the RedGate Sql Tool Belt.
Read up on how to install the CMS from the command line
Automate the installation of the above using a script language, such batch, Powershell, VB script etc.
Once you've got to step 5 you can ask more specific questions on particular aspects of this.

Ruby redmine svn post-commit hook is extremally slow

I use the following post-commit hook for svn:
"path\to\ruby.exe" "path\to\redmine\script\runner" "Repository.fetch_changesets; Rails.logger.flush" -e production
It works correctly, but it takes about 1-2 minutes.
I also thought that a lot of time is required for first commit, but successive commit takes the same amount of time.
Is it possible to improve such behavior?
I know about slow behavior of Ruby on Windows, about 3 times, but in my case it is much more longer.
Configuration is following: Windows Vista, redmine 1.1.1, Ruby 1.8.7 with RubyGems 1.8.7, all packages installed and testing is performed on the same PC.
The problem is that script/runner starts up a new Rails process from scratch each time it's run, which will make your commit pause. So 3 commits == 3 startups and 3 shutdowns.
There are a few things you can do to improve this:
Run the script/runner process in the background so it doesn't slow down your commit. On Linux you can do this by adding an & at the end of the command but I don't remember how to do it on Windows
Instead of fetching changesets on each commit you can run it regularly through cron or a scheduled task. The rake task redmine:fetch_changesets is built for this purpose, it will iterate through each project and run fetch_changesets for you.
The command you are running goes through every project and fetches the changes. If you know the project identifier you can change the query so it only gets the changes for the project you are working on:
script\runner "Project.find('your-project').try(:repository).try(:fetch_changesets); Rails.logger.flush"
Replace 'your-project' with the project identifier (found in most of the urls in Redmine). The try parts are used to make sure you don't get an empty record.
Use the web service to fetch changesets instead of script/runner. The web service will use an existing Ruby process so it should already be loaded and the only slow down will be while Redmine downloads and processes the changes. This can also be used with the first option (i.e. background a web service request). Docs: http://www.redmine.org/projects/redmine/wiki/HowTo_setup_automatic_refresh_of_repositories_in_Redmine_on_commit
Personally, I just run a cronjob every hour (#2). Having the Repository view current isn't that important to me. Hope this gives you some ideas.

Resources