How to set input from bash script in an interactive shell? - mysql

So when I install percona mysql, I get the following.
I am trying to automate sql installation using a bash script but how do I enter into the input using bash script? Enter something > hit enter.

The preferred way of achieving this is using unattended mode by setting the following environment variable before calling apt install:
export DEBIAN_FRONTEND=noninteractive
This will not prompt the user for any input but instead use the default values for everything.
If you want to supply an answer to a configuration question different to the default value, use preseeding DebConf.

Related

'ALGOLIA_API_KEY' not recognized as an internal or external command

I am trying to run algolia for the first time but it seems that there is something wrong with my environment. I followed the detailed explanation here https://community.algolia.com/jekyll-algolia/getting-started.html.
I installed and configured everything that is needed from the previous steps but when I run the command
ALGOLIA_API_KEY=xxxxxxxxxxxxxx bundle exec jekyll algolia
I get an error:
'ALGOLIA_API_KEY' is not recognized as an internal or external command,
operable program or batch file.
I have been rereading the documentation for both jekyll and angolia but couldn't find anything that could be helpful.
Since you're running on Windows, you cannot set an environment variable for your command like you can do on UNIX.
As advised in this question, Setting and using variable within same command line in Windows cmd.exe, I believe you could use
set ALGOLIA_API_KEY=xxxxxxxxxxxxxx && bundle exec jekyll algolia

Root and instance creator password?

I use the Google Compute Engine Web Console to remote into my instance. I can perform root operations using "sudo", but what if I wanted to "su" to root?
I created a user "test", and now want to log-in as "test" -- this doesn't work as I have not yet generated SSH keys. Where do I find these keys for instance creator and/or root as well?
Also, I used a Debian image, but few commands appear to be installed by default. For instance, locate, updatedb, etc are missing? How do I get these?
You asked several questions in a single post; I'll answer them in order.
(1) I use the Google Compute Engine Web Console to remote into my instance. I can perform root operations using "sudo", but what if I wanted to "su" to root?
Use: sudo su -
(2) I created a user "test", and now want to log-in as "test" -- this doesn't work as I have not yet generated SSH keys. Where do I find these keys for instance creator and/or root as well?
You can ssh via gcloud compute ssh or by clicking on the "SSH" button on the web UI, and then run: sudo su test.
(3) Also, I used a Debian image, but few commands appear to be installed by default. For instance, locate, updatedb, etc are missing? How do I get these?
To install missing packages, you'll have to use the standard Debian command apt-get to install the packages, e.g.:
$ sudo apt-get install [name-of-package]
To find a package name using keywords, use:
$ apt-cache search [keyword]
Note: the first thing you want to do on a brand-new instance is to update your package metadata cache by running:
$ sudo apt-get update
https://cloud.google.com/solutions/set-up-postgres
The above link helped me get over a similar issue described above but in the postgres user setup context. Wasn't covered in any of the other posts so thought to share here.

Change default shell on nitrous.io box?

On a nitrous.io drogo box, how do I change the default shell to zsh when I ssh in? I do not have write access to /etc/passwd, and I cannot sudo.
You can't use zsh in the main console, but you could with tmux (which is already installed). You will just need to add this line into ~/.tmux.conf :
set-option -g default-shell /bin/zsh

Don't add command to MySQL CLI history

One can instruct Bash not to add a command to the CLI history by prepending the command with a space. How can one instruct the MySQL CLI interpreter to not add a command to the history? Prepending the command with a space does not have the desired effect.
You can run mysql with the -q option to skip use of the history file.

How to add path variable to job shell

I am setting up Jenkins to replace our current TeamCity CI build.
I have created a free-style software project so that I can execute a shell script.
The Shell script runs the mvn command.
But the build fails complaining that the 'mvn' command cannot be found.
I have figured that this is because Jenkins is running the build in a different shell, which does not have Maven on it's path.
My question is; how do I add the path so 'mvn' is found in my Shell script? I've looked around but can't spot where the right place might be.
Thanks for your time.
I solved this by exporting and setting the Path in the Jenkins Job configuration where you can enter shell commands. So I set the environments variable before I execute my Shell script, works a treat.
Some possible solutions:
You can call maven with an absolute path
You configure a global environment variable in the jenkins system settings with the absolute path to your maven instance, and use this in your script call (if you use the inline shell script, I don't know if those are substituted to a called script, you have to test)
You use a maven project and configure your maven instance in the jenkins system settings
ps.: Usually /bin/sh is chosen from Jenkins, if you want to switch to eg. bash, you can configure this in the jenkins system settings, in case you want to configure global environment variables.
You can use envInject plugin. It's very powerful.
I use it to install rbenv. And it can inject environment variables into your current job.
Another option to Dags suggestion is that if you're only using a single version of maven, on each slave server you could do either;
* add PATH=${PATH}:
* symlink mvn into /usr/bin with; sudo ln -s /usr/bin
I'm not at a Jenkins box at the moment, but I can find some more detailed examples if you'd like.
Jenkins is using sh by default and not bash.
This is my first time defining a jenkins maven job, and I also followed soem regular maven instructions (for running from command line...), and tried to update ~/.bashrc with M2_HOME, M2, PATH, but it didn't work because jenkins used sh and not bash. Then I found out that there is a simpler and better way built into jenkins.
After installing maven, I was supposed to configure my maven installation in jenkins.
To configure your maven installation in Jenkins:
login to jenkins web console
click Manage Jenkins --> Configure System
Under Maven, click the "Maven Installations..." button
a. Give it some name
b. and under MVN_HOME set the path to where you installed maven, for example "/usr/local/apache-maven/apache-maven-3.0.5"
Click Save button
Define a job with maven target
edit your job
Click "Add build step"
on Maven Version, enter the name you gave your maven installation (step #4 above)
set some goal like clean install