Hi I'm trying to understand how to add configuration commands in Dockerfile but so far I don't get any good results.
I wrote this line
RUN sed -i 'EnableSendfile Off' /etc/httpd/conf/httpd.conf
how would be the correct version?
Many thanks
I am wondering if the sed command works as your wrote it down.
RUN sed -i -e 's/this/that/g' filename
works fine, so it could be
RUN sed -i -e 's/EnableSendfile On/EnableSendfile Off/g' /etc/httpd/conf/httpd.conf
What kind of results or errors do you have?
Related
New to Docker and trying to get the cgi-bin working in a httpd image. My Dockerfile is as follows. The SED line adds the perl location to the first line of the example script that comes with the image:
FROM httpd:2.4.46
RUN sed -i '1c#!/usr/bin/perl' /usr/local/apache2/cgi-bin/printenv
I then build and run with:
docker build -t my-apache2 .
docker run -dit --name my-running-app -p 8080:80 my-apache2
I then navigate to localhost:8080/cgi-bin/printenv but instead of the script executing I get the code displayed as text. It appears the httpd image comes with ScriptAlias enabled by default. Any ideas please?
You also need to enable mod_cgid
FROM httpd:2.4.46
RUN sed -i '1c#!/usr/bin/perl' /usr/local/apache2/cgi-bin/printenv
RUN chmod +x /usr/local/apache2/cgi-bin/printenv
CMD httpd-foreground -c "LoadModule cgid_module modules/mod_cgid.so"
I'm trying to use the --immediate-submit on a PBSPro cluster. I tried using an in-place modification of the dependencies string to adapt it to PBSPro, similar to what is done here.
snakemake --cluster "qsub -l wd -l mem={cluster.mem}GB -l ncpus={threads} -e {cluster.stderr} -q {cluster.queue} -l walltime={cluster.walltime} -o {cluster.stdout} -S /bin/bash -W $(echo '{dependencies}' | sed 's/^/depend=afterok:/g' | sed 's/ /:/g')"
This last part gets converted into, for example:
-W depend=afterok: /g/data1a/va1/dk0741/analysis/2018-03-25_marmo_test/.snakemake/tmp.cyrhf51c/snakejob.trimmomatic_pe.7.sh
There are two problems here:
How can I get the dependencies string to output job ID instead of the script path? The qsub command normally outputs the job ID to stdout, so I'm not sure why it's not doing so here.
How do I get rid of the space after afterok:? I've tried everything!
As an aside, it would be helpful if there were some option to debug the submission or not to delete the tmp.cyrhf51c directory in .snakemake -- is there some way to do this?
Thanks,
David
I suggest to use a profile for this, instead of trying to find an ad-hoc solution. This will also help with debugging. E.g., there is already a pbs-torque profile available (https://github.com/Snakemake-Profiles/pbs-torque), probably there is not much to change towards pbspro?
I am trying to create a patch that users can use to remotely edit a file in a pre-defined way using sed, and I could do this manually on each computer, but it would take a long time.
The line I am struggling with is as follows:
host=[hostname]
port=[portnum]
ssh -t $host -p $port "cp ~/file1 ~/file1.bak ; sed -i \"s/fcn1('param1', $2)\n/fcn2('param2'):$zoom\n/g\" ~/file1"
This makes a backup of file1 and then edits a line in the file. I actually want to edit more than one line, but this line demonstrates the problems:
The command works, provided no $ signs are used within the sed command.
I have tried a number of ways of escaping these $ signs but cannot seem to find one that works.
I can use a . wildcard in the find, but obviously not in the replace string.
I would use single quotes for the sed command, in order to avoid expanding the $2, but single quotes are already used inside the command.
Does anyone have any ideas of how to overcome this problem? Thanks in advance for any suggestions!
This should work as well:
ssh -t $host -p $port "cp ~/file1 ~/file1.bak && sed -i \"s/fcn1('param1', \\\$2)/fcn2('param2'):\\\$zoom/g\" file1"
You need 3 back slashes as you have to escape the $ sign in the string passed in the remote bash to sed. And you have to escape that back slash and the $ sign when sending it over via ssh.
Building our own deb packages we've run into the issue of having to patch manually some scripts so they get the proper prefix.
In particular,
We're building mono
We're using official tarballs.
The scripts that end up with wrong prefix are: mcs, xbuild, nunit-console4, etc
An example of a wrong script:
#!/bin/sh
exec /root/7digital-mono/mono/bin/mono \
--debug $MONO_OPTIONS \
/root/7digital-mono/mono/lib/mono/2.0/nunit-console.exe "$#"
What should be the correct end result:
#!/bin/sh
exec /usr/bin/mono \
--debug $MONO_OPTIONS \
/usr/lib/mono/2.0/nunit-console.exe "$#"
The workaround we're using in our build-package script before calling dpkg-buildpackage:
sed -i s,`pwd`/mono,/usr,g $TARGET_DIR/bin/mcs
sed -i s,`pwd`/mono,/usr,g $TARGET_DIR/bin/xbuild
sed -i s,`pwd`/mono,/usr,g $TARGET_DIR/bin/nunit-console
sed -i s,`pwd`/mono,/usr,g $TARGET_DIR/bin/nunit-console2
sed -i s,`pwd`/mono,/usr,g $TARGET_DIR/bin/nunit-console4
Now, what is the CORRECT way to fix this? Full debian package creation scripts here.
Disclaimer: I know there are preview packages of Mono 3 here! But those don't work for Squeeze.
the proper way is to not call ./configure --prefix=$TARGET_DIR
this tells all the binaries/scripts/... that the installated files will end up in ${TARGET_DIR}, whereas they really should endup in /usr.
you can use the DESTDIR variable (as in make install DESTDIR=${TARGET_DIR}) to change (prefix) the installation target at install time (files will end-up in ${TARGET_DIR}/${prefix} but will only have ${prefix} "built-in")
I wrote a script to automatically add a ServerAlias to an Apache configuration file, then restart Apache, with a rather remedial understanding of sed and tr and probably shell scripting in general. This is what I came up with:
cp /etc/httpd/sites/site.conf tmphost &&
sed s/ServerName\ site.com/ServerName\ site.com^#ServerAlias\ sub.site.com/ \
tmphost |
tr '^#' '\n\t' >/etc/httpd/sites/site.conf &&
rm -f tmphost &&
apachectl restart
Basically I'm creating a copy, replacing the ServerName line with itself + the new alias, using tr to put in the newline and tab (sed was being weird about that?), overwriting the old configuration file, deleting the copy, then restarting Apache.
It works, but doesn't really make mama proud, if you know what I mean. Any ideas on how to clean that up?
If you want to add a ServerAlias line after ServerName line, why not use the 'append' command to add a line:
sed '/ServerName site.com/a\
ServerAlias sub.site.com' tmphost >/etc/httpd/sites/site.conf
There's a 'tab' at the start of the extra line, which you seem to need.
If you have GNU sed, you can do the edit in-place with the -i option and without the temporary file (but don't use the -i option if the file you are editing has multiple hard links, and probably not it if it is a symlink, either; see the comments below from William Pursell).
Note that you should wrap the code in:
trap "rm -f tmphost; exit 1" 0 1 2 3 13 15
...script manipulating tmphost...
rm -f tmphost
trap 0
so that the temporary file is not left around if the shell exits because of a signal. Of course, if you have an in-place alter, you don't need the temporary file at all.
I like the way with direct ServerAilas addition using sed :
sed -i "0,/^ServerName.\+/s//\0\nServerAlias sub.site.com/" /etc/httpd/sites/site.conf
apachectl reload