detentosdoeb
(usa Red Hat)
Enviado em 05/03/2014 - 14:16h
Fala ai galera, tudo blz?
Pessoal estou com um problema aqui e até agora não consegui evoluir.
Estou utilizando o ks.cfg para instalar algumas máquinas e na sessão %post preciso adicionar uma cron para verificar alguns parâmetros periodicamente.
Meu problema:
O script não está "escrevendo" o que eu preciso na cron, ele está executando o comando que está no ks.cfg, vejam:
cat ks.cfg
%post --interpreter=/bin/bash
/bin/cat >> /etc/cron.daily/server_status.cron << EOF
#!/bin/sh
# Verify Permissions and Owners on passwd, shadow, group and gshadow Files
check_owner_and_group_etc_passwd=$(/bin/ls -ld /etc/passwd | /bin/awk '{print $3":"$4}')
if [ "$check_owner_and_group_etc_passwd" != "root:root" ];then
/bin/echo "======= New Event Recorded =======" >> $REPORT_OF_SERVER
/bin/echo $check_owner_and_group_etc_passwd >> $REPORT_OF_SERVER
/bin/chown root:root /etc/passwd
/bin/echo "Verify Owners and Groups on /etc/passwd report an error. This server_status script already execute '/bin/chown root:root /etc/passwd', please check" >> $REPORT_OF_SERVER
/bin/echo "====================================" >> $REPORT_OF_SERVER
fi
#
check_owner_and_group_etc_shadow=$(/bin/ls -ld /etc/shadow | /bin/awk '{print $3":"$4}')
if [ "$check_owner_and_group_etc_shadow" != "root:root" ];then
/bin/echo "======= New Event Recorded =======" >> $REPORT_OF_SERVER
/bin/echo $check_owner_and_group_etc_shadow >> $REPORT_OF_SERVER
/bin/chown root:root /etc/shadow
/bin/echo "Verify Owners and Groups on /etc/shadow report an error. This server_status script already execute '/bin/chown root:root /etc/shadow', please check" >> $REPORT_OF_SERVER
/bin/echo "====================================" >> $REPORT_OF_SERVER
fi
#
EOF
cat /etc/cron.daily/server_status.cron
#!/bin/sh
# Verify Permissions and Owners on passwd, shadow, group and gshadow Files
check_owner_and_group_etc_passwd=root:root
if [ "" != "root:root" ];then
/bin/echo "======= New Event Recorded =======" >>
/bin/echo >>
/bin/chown root:root /etc/passwd
/bin/echo "Verify Owners and Groups on /etc/passwd report an error. This server_status script already execute '/bin/chown root:root /etc/passwd', please check" >>
/bin/echo "====================================" >>
fi
#
check_owner_and_group_etc_shadow=root:root
if [ "" != "root:root" ];then
/bin/echo "======= New Event Recorded =======" >>
/bin/echo >>
/bin/chown root:root /etc/shadow
/bin/echo "Verify Owners and Groups on /etc/shadow report an error. This server_status script already execute '/bin/chown root:root /etc/shadow', please check" >>
/bin/echo "====================================" >>
fi
#
Vejam que por exemplo, os ifs estão vazios na cron! Como faço para corrigir isso? Preciso que ele escreva na cron "check_owner_and_group_etc_passwd=$(/bin/ls -ld /etc/passwd | /bin/awk '{print $3":"$4}')
if [ "$check_owner_and_group_etc_passwd" != "root:root" ];then"
e não que ele execute esse comando!
Vlew pessoal.