Hot answers tagged

17 votes
Accepted

How to keep configuration files automatically during apt-get upgrade or install?

There are options you can pass through apt-get to dpkg that will handle the config choices. We usually do something like: apt-get install -y --no_install_recommends -o Dpkg::Options::='--force-...
user avatar
  • 5,647
5 votes
Accepted

Interference of Docker CMD with su: works with su-exec but not with su?

wrong argument order to su $ZOO_USER needs to be the first argument to su with the "$@" coming afterwards. su -c "$0" "$ZOO_USER" "$@" It is ok for the options to come before the username. It is a ...
user avatar
  • 1,728
4 votes
Accepted

docker: Error response from daemon: Conflict. The container name "/basexhttp" is already in use by container

You're attempting to create two different containers, each with the same name. Each time you execute docker run it will create a container, and you've named the containers the same with --name ...
user avatar
  • 2,800
3 votes
Accepted

How to create a "silent" MySQL docker container?

You can run the container in detached mode by passing -d or --detach with the run command: https://docs.docker.com/engine/reference/run/#detached-vs-foreground
user avatar
  • 870
3 votes
Accepted

Is \u the only way to output the user from .bashrc?

With the release of macOS Catalina (10.15) Apple has switched to Zsh as default shell (instead of Bash). Instead of setting PS1 in Bash you can set PROMPT in Zsh: PROMPT="${orange}%n"
user avatar
  • 306
3 votes
Accepted

How to pass Gitlab env var with sensitive characters to bash script?

Surprisingly indeed GitLab works weirdly with the env vars. It evaluates them internally, though it shouldn't in my view. Value set as (in project Settings > CI/CD > Variables): 'aaa$bbb*%' becomes '...
user avatar
  • 146
3 votes
Accepted

npm not found but installed from the shell script file in Dockerfile

The issue is that prereqs-ubuntu.sh uses bash to install the npm. While the RUN directive uses sh to run the commands. Where is the npm installed root@2cd4a6af90f4:/app# type npm npm is /root/.nvm/...
user avatar
  • 169
3 votes
Accepted

How to make the Jenkins agent build then start the server?

You are running into a conflict between jenkins nature of making sure everything is done before a job is complete and your desire for some long-running things to be asynchronous. There is no right ...
user avatar
  • 1,728
3 votes
Accepted

The right way to Ansiblically deploy environments directly from Github:

There is no "right" or "wrong". If the commands work when you type them in, then they work, and we won't keep you from doing it. Everything else is opinion. Sure, there are some best practices, for ...
user avatar
  • 4,726
3 votes

Interference of Docker CMD with su: works with su-exec but not with su?

The su-exec program in this script is actually the Alpine version created by Natanael Copa. It is installed from the OP's Dockerfile on line 6. The Alpine su-exec program is a substitute for gosu. ...
user avatar
3 votes

Access vault secret from bash script

The vault docs mention a -field parameter for the read subcommand. So you should be able to put this into a shell script: SECRET=$(vault read -field foo secret/mysecret) Other vault docs use the ...
user avatar
  • 1,728
3 votes
Accepted

Why does Jenkins Pipeline script returnStatus value not match status examined in shell?

There's a few things to note. First is that in the absense of a shebang being supplied, the actual interpreter that will be used is actually "sh", not "bash". Taking a look at the ...
user avatar
  • 130
2 votes

Docker exec environment different to container shell

Please refer to bash initialization process. https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html In your Dockerfile, at lines 12-14 you are patching files, but do not activate ...
user avatar
  • 166
2 votes
Accepted

Automating the creation of an Apache virtual-host file specifically

This has already been covered a bit in the comments, but I figured I'd lay out a more extensive answer. Is there a way to automate that / shorten the amount of lines code (the actual script-file is ...
user avatar
2 votes
Accepted

replacing values in shell script using sed

Negation to the rescue: sed -i "s/server.address=[^\ ].*\ /server.address=${SERVER_ADDRESS} /g" This is telling to search zero or more characters (.*) NOT matching whitespace ([^\ ]) up to the first ...
user avatar
  • 138
2 votes

Add mapping ip and host into /etc/hosts with docker

You could try to use docker compose and the docker compose "extra_hosts" tag, as described on the docker compose specification at https://docs.docker.com/compose/compose-file/. extra_hosts Add ...
user avatar
  • 121
2 votes
Accepted

Automatically write new bash history to change-log file

Try using GNU Screen or Tmux. These are called "screen multiplexers" but you'd get a number of benefits The commands you run will continue running even if you disconnect, or you have network related ...
user avatar
  • 136
2 votes
Accepted

How do I add my IP address to the start of my terminal using the bashrc file?

Well... you would need to know what IP address you actually want. Is it a public IP address? Is it a private subnet address? Do you only have 1 IP address? A few things you would need to figure out. ...
user avatar
  • 1,644
2 votes
Accepted

How can I use bash functions in makefile?

One possible issue is that the NVM install script only writes the commands to set itself up to either .bash_profile OR .bashrc. Depending on your systems configuration, it may only be setup for ...
user avatar
  • 63
2 votes
Accepted

cannot get bash prompt: Error response from daemon: Container foo is not running

Whoever created basex/basexhttp:latest does not seem to know Docker very well. They copied files necessary to a directory that was later configured as a volume, which means it can only be bound to an ...
user avatar
2 votes
Accepted

How can I get the Docker target platform inside the Build Environment / Dockerfile

This is typically done with a script, not the Dockerfile. The script (perhaps in bash or python) can run at build time to determine what environment it is in, and act accordingly. This can be included ...
user avatar
  • 3,098
2 votes

How to modify/allow firewall rules of a GCP instance directly from the CLI?

Most probably, you are using the wrong account. Find out which one you are currently using in CLI: gcloud config configurations list gcloud auth list If the selected configuration is wrong, fix it ...
user avatar
  • 146
1 vote
Accepted

SSH connection to jenkins server

Your configuration refers to a file that is local on your system, but does not exist on the jenkins server. The error message is trying to tell you this. /c/Users/D35N/Downloads/GitHubProjeckt/...
user avatar
  • 1,728
1 vote
Accepted

create entry-point script to get all env variables starting with VUE_APP_ and take it's value

While it's not clear what your trying to do (the script you have so far for the bit you are having trouble with would probably be handy), I think you are essentially just trying to parse your ...
user avatar
  • 1,644
1 vote

Exit a Makefile target called by parent without throwing an error

Makefile all: test dosomething test: @echo "hello" dosomething: @if [ "a" = "a" ]; then\ echo "world";\ exit 0;\ fi Running: make will return: hello world
user avatar
  • 12.6k
1 vote

How to pass Gitlab env var with sensitive characters to bash script?

This is not answering only the question but also a bit more (I put this here for reference): I found out a decent way to tackle this and some complications coming afterwards... (after hours and hours ...
user avatar
  • 111
1 vote

replacing values in shell script using sed

You can do this using perl For Example perl -pi -e "s/server.address=localhost/server.address=${SERVER_ADDRESS}/g" file_path This command change server address value localhost to vaariable value. ...
user avatar
  • 1,361
1 vote

shell script to pass values properties file in java

You should regenerate this file from a template using your configuration management system of choice. You could also write a shell script that uses a heredoc to do the same thing. But since we're in ...
user avatar
  • 1,728
1 vote

shell script to pass values properties file in java

You can use below. [user@xyz ~]$ hh='mysql.username=USERNAME';echo $hh | awk -F"=" '{OFS=FS}{ $2="Mango"; print }' mysql.username=Mango
user avatar
  • 189
1 vote
Accepted

shell script to pass values properties file in java

You can obtain old parameters from the properties file before using sed, e.g. # get old parameters $ export oldUsername=$(grep mysql.username $FILE | cut -d'=' -f2) $ export oldPass=$(grep mysql.pass ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible