On a script, I need to have it enter in information into /etc config files. Typically, to prove a point I will just use echo "lalala" > file, but occasionally I rather it just change the information in it, helps in 2 things. A. I don't have conflicting information, and B. I can run the script more than once.
if grep --quiet "umask 077" /etc/profile; then
echo "umask is set"
else
sed -i 's@umask 022@umask 077@g' /etc/profile
fi
If umask 077 is in /etc/profile, then we are good. If not, it will find umask 022 and change it to umask 077.
Primarily where I write my fixes to things, that I can foresee needing again. InfoSec / Linux stuff.
Wednesday, December 26, 2012
Wednesday, December 12, 2012
SSH script to wait til machine is up to login
Keeping this around for notes, I actually have another version floating around, but couldn't remember where, so I put this up so I don't have to remember.
## Silly script that doesn't ssh until the machine is up.
## Matthew M. Conley 12/12/12
##
#!/bin/bash
ping -c 1 192.168.1.1;
if [ $? -eq 0 ]; then
ssh user@192.168.1.1
fi
a variable should work so you can just do pingssh.sh 192.16... enter your ip in. and have it load the ip. Thats how my other script runs. Change user to the user you login in as.
ping -c 1 $1;
if [ $? -eq 0 ]; then
ssh user@$1
fi
## Silly script that doesn't ssh until the machine is up.
## Matthew M. Conley 12/12/12
##
#!/bin/bash
ping -c 1 192.168.1.1;
if [ $? -eq 0 ]; then
ssh user@192.168.1.1
fi
a variable should work so you can just do pingssh.sh 192.16... enter your ip in. and have it load the ip. Thats how my other script runs. Change user to the user you login in as.
ping -c 1 $1;
if [ $? -eq 0 ]; then
ssh user@$1
fi
Subscribe to:
Posts (Atom)