I try to execute a shell script during the build in Jenkins but i get an : "access denied" when i try to create a new folder.
I try to launch a php script in the shell script and i get access denied as well
I launched Jenkins from the .war file.
My question is how to give access to the shell script or user that execute to write in a specific folder?
I cannot put the chmod to 777 of this folder (too dangerous).
Easy fix/hack is to change the permissions on the folder Jenkins is trying to write to to 777.
chmod 777 foldername
Long term I would figure out what user Jenkins is running as and either change the folder ownership to that user or add Jenkins to whatever group the folder permissions are a part of.
I finally launched my script through an url with the curl command, and this worked fine.
It's not really a nice solution to the problem but i didn't find any other work around ;)
Related
I have two issues I need help with on bash, linux and s3cmd.
First, I'm running into linux permission issue. I am trying to download zip files from a s3 bucket using s3cmd with following command in a bash script.sh:
/usr/bin/s3cmd get s3://<bucketname>/<folder>/zipfilename.tar.gz
I am seeing following error: permission denied.
If I try to run this command manually from command line on a linux machine, it works and downloads the file:
sudo /usr/bin/s3cmd get s3://<bucketname>/<folder>/zipfilename.tar.gz
I really don't want to use sudo in front of the command in the script. How do I get this command to work? Do I need to give chown permission to the script.sh which is actually sitting in a path i.e /foldername/script.sh or how do I get this get command to work?
Two: Once I get this command to work, How do I get it to download from s3 to the linux home dir: ~/ ? Do I have to specifically issue a command in the bash script: cd ~/ before the above download command?
I really appreciate any help and guidance.
First, determine what's failing and the reason, otherwise you won't find the answer.
You can specify the destination in order to avoid permission problems when the script is invoked using a directory that's not writeable by that process
/usr/bin/s3cmd get s3:////zipfilename.tar.gz /path/to/writeable/destination/zipfilename.tar.gz
Fist of all ask 1 question at a time.
For the first one you can simply change the permission with chown like :
chown “usertorunscript” filename
For the second :
If it is users home directory you can just specify it with
~user
as you said but I think writing the whole directory is safer so it will work for more users (if you need to)
Im writing shell script to take backup of nagios (/usr/local/nagios) directory. I'm unable to compress it from my home directory because its a root folder. i cannot use sudo as it asks for password. Is there any better way to zip /ussr/local/ files without comprimising security?
Someone please help.
Thank you!
Do it in a cron job owned by root.
Create this script and save it as /etc/cron.daily/nagios-backup:
#!/bin/sh
cd /usr/local
tarball="/home/kart/nagios-$(date +%Y-%m-%d).tgz"
tar -pzcf "$tarball" nagios
chmod 400 "$tarball"
Make sure that script is executable (sudo chmod 755 /etc/cron.daily/nagios-backup) and it'll run every night, dumping that log to a dated tarball file in /home/kart. The tarball will not be readable to you without using sudo (since your account can't normally see the contents and you requested preserving security).
My question is how I can make one folder accessible when script running.
In this case lets call there is bob who copying his folder by using script to specific location and there is jeff who also sharing the same group as bob also he copying his file to there with using script.
The problem is that when I set file group they need write and execute permission and when I gave to them they are able to see each other file content if they know full path of the file.
To stop that I am thinking to completely deleting all permission on folder and only giving the permission when script running and doing copying process.
But problem is that when those users run the script and script try to chmod the file permission they are not going to be able to because they don't have enough permission to do it. Also if I add them on sudoers, they are going to be able to chmod and change anything as they want to change.
So I am so confused about how I can make the script change permission of folder and when copying completed turn back to previous permission
You should add a sudoers entry to allow ALL or the selected group to run a given script that does the copy to a restricted directory, with NOPASSWD to avoid the password prompt.
Then the users invoke
$ sudo /path/to/copy-to-restricted-dir files*
but users don't have access to restricted directory nor to chmod.
I have a unix shell script file whose owner is "xyz" when run deletes some specific files.
I want to trigger this script to delete files in some other directory where the owner for the files to be deleted is different from the owner of the script. Is this possible? Is this possible to run this script as different user so that it can delete those new files?
EDIT : I use Autosys to periodically trigger this script.
You can chmod the files that need to be deleted first if you have sufficient rights. Afterwards your script, no matter what user it executes, will succeed.
Examples : http://en.wikipedia.org/wiki/Chmod
Usually you use sudo for that:
sudo -u ANOTHER_USER /path/to/the/script.sh
However, your current account needs proper permissions to do so. You can configure those permissions using the file /etc/sudoers.
You'll find a ton of articles out there how to use sudo. This for example: http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:Ch09:_Linux_Users_and_Sudo
I am very new to using the terminal and using tomcat.
I had already installed tomcat yesterday and it was working, however today when I turn on my computer again, it is not working, I am assuming I need to start it up again , but I don't know how.
Can somebody explain to me or write the code to start it up please?
Thanks in advance!
This works!
Make all Tomcat's bin shell scripts executable for files under apache-tomcat-7.0.30/bin
The code is:
chmod a+x *.sh
After that Run from tomcat/bin with the script:
./startup.sh
Here's the instructions for the catalina.sh shell script that controls Tomcat.
The Tomcat control scripts resides under the bin directory inside the
Tomcat home (Where you have Tomcat installed). For the Unix or Unix
flavored operating systems the scripts with extention ".sh" needs to
be executed
catalina.sh provides a lot of options/controls, but startup.sh can be used to simply start it.
Under some circumstances the startup scripts do not execute because the execute permission has not been set. If this is the case you can change the execute permission to the scripts by typing the following:
cd ../bin
chmod 750 *.sh
This signifies read, write, and execute permissions for the owner, read and execute permissions for the group, and no permissions for others.