is it all the script does? moving stuff to restricted directories?
Code:deploy.sh: sudo mv $from $to $ ./deploy.sh
is it all the script does? moving stuff to restricted directories?
Code:deploy.sh: sudo mv $from $to $ ./deploy.sh
if your question is answered, mark the thread as [SOLVED]. Thx.
To post code or command output, use [code] tags.
Check your bash script here // BashFAQ // BashPitfalls
No it's more than just moving
i have to restart j boss server
service stop jboss
then check for the processes using
ps ax | grep jboss
kill all the other processes except Jboss
then start the jboss again..
then connect to mysql database in the server
then using mysqldump import database from the package
That's what i have to do
what about
Code:deploy.sh: mv jboss things mysql things ... $ sudo deploy.sh
if your question is answered, mark the thread as [SOLVED]. Thx.
To post code or command output, use [code] tags.
Check your bash script here // BashFAQ // BashPitfalls
how can a normal user can do that..
i mean if i run the script normally in bash shell($) rather than (#)
does it move the jboss things??
what i want to say is. in server there are alot of users right?? if every one of them runs this script to move a certain package since this script does it automatically where lies the security they may corrupt the system so i want to check weather they are sudo or not if sudo then proceed if not Authentication failure
Last edited by Mohan1289; October 26th, 2012 at 12:16 PM.
Code:#!/bin/bash id=$(/usr/bin/id -u) if [ $id -ne 0 ] ; then echo "You must use sudo to run this script" exit 1 fi # other stuff goes here... # mv # jboss things # mysql things # ... echo Done.If the user tries to use sudo and fails to authenticate, your script is not called. If sudo succeeds, then they are authenticated. If the user tries to execute the script without using sudo, then they get an error message. Isn't that what you want?Code:$ ./deploy.sh You must use sudo to run this script $ sudo ./deploy.sh Done.
Thank you but how can i kill all the remaining processes except Jboss?? how is that possible normally we will check with
ps ax | grep jboss
and then by using kill -9 and their pid's we will kill them but how can i do this here??
since the pid's are dynamic how can i kill all except jboss?
Can you provide some sample output from ps that shows the processes you want to kill and the process(es) you don't want to kill?
Also, -9 is a bit heavy handed. It would give the processes a chance to shutdown gracefully if a different signal were used. TERM is the default for kill, is it not working?
Maybe you can check using pgrep or pkill. They can take a regex pattern and the -u option allows you to specify a user.
Bookmarks