LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash scripting chkconfig, chmod, and chown (https://www.linuxquestions.org/questions/linux-newbie-8/bash-scripting-chkconfig-chmod-and-chown-821320/)

abti 07-21-2010 02:28 PM

bash scripting chkconfig, chmod, and chown
 
I'm trying to write a simple(ler) bash script to does a mass changes in ~200 chmods, ~200 chowns, ~60 chkconfigs on 400+ systems. There's no real uniformity to any one of the three areas. I'm actually typing it in a very simplistic way...

===
sample code
===
#!/bin/bash

if [ ! $UID -eq 0 ]; then
echo "This script must be run as root."
exit 1
fi


/sbin/chkconfig nfs on
/sbin/chkconfig sendmail off

...

chmod 400 /etc/at.allow
chown root:root /etc/at.allow
chmod 600 /etc/at.deny
chown root:root /etc/at.deny
chown lp:sys /etc/cups/cupsd.conf

...


Again this is a simplified and truncated form of my script. Any help or advice would be appreciated!

catkin 07-21-2010 02:58 PM

Given ~400 systems, you might want to log the output from the script and diff it against expected output to identify any exceptions.

Perhaps pedantically, the command id -u is more robust than depending on $UID.


All times are GMT -5. The time now is 01:55 PM.