diff --git a/buildpackage/bootstraps/bootstrap-install b/buildpackage/bootstraps/bootstrap-install old mode 100644 new mode 100755 index 856cd79273a7dd9412f0b35621d99833af736619..470dcecba2e302fbad42de4ba2d6b2e41bef589e --- a/buildpackage/bootstraps/bootstrap-install +++ b/buildpackage/bootstraps/bootstrap-install @@ -109,9 +109,15 @@ collect_information(){ cat ${AGENT_DIR}/client/run.sh printf "\n\n----------------------------------\n\n" - printf " agent.sh\n%b" \ + printf " update.sh\n%b" \ " ========\n\n" - cat ${AGENT_DIR}/agent.sh + cat ${AGENT_DIR}/update.sh + + printf " inventory.sh\n%b" \ + " ========\n\n" + printf "\n\n----------------------------------\n\n" + cat ${AGENT_DIR}/inventory.sh + printf "\n\n----------------------------------\n\n" printf " Collect agent log\n%b" \ @@ -224,16 +230,26 @@ if ! test -n "${PROJECTOR}" -o -f "/usr/sbin/projetor" -o \ # Remove any possible line containing a rule for seed_mec user before adding # root permissions in the sudoers file TMPFILE=$(mktemp) - sed '/^seed_mec[\t ]*ALL=(ALL/d' /etc/sudoers > "${TMPFILE}" - mv "${TMPFILE}" /etc/sudoers - chmod 440 /etc/sudoers - # Add root permissions to seed_mec user, without the need of password - if ! $(echo -e "seed_mec\tALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers) - then + sed '/^\(Defaults:\)\?seed_mec/d' /etc/sudoers > "${TMPFILE}" + + # Add root permissions to datasid + echo -e "seed_mec\tALL=(ALL) NOPASSWD: ALL" >> "${TMPFILE}" + + # Remove on Fedora the requirement of tty for sudo + if grep -q "Fedora" /etc/issue; then + echo -e 'Defaults:seed_mec\t!requiretty' >> "${TMPFILE}" + fi + + # Check if modified sudoers file is valid and apply it + if ! visudo -cf "${TMPFILE}" || ! mv "${TMPFILE}" /etc/sudoers \ + || ! chmod 440 /etc/sudoers; then + printf "FALHA!\n" >&3 printf "ERRO: Falha ao adicionar permissões de super-usuário %b" \ - "ao usuário seed_mec.\n" >&3 + "ao usuário seed_mec.\n" + rm -f "${TMPFILE}" exit 3 fi + rm -f "${TMPFILE}" fi # ------------------------------------------------------------------------------ diff --git a/collect/net/bandwidth.sh b/collect/net/bandwidth.sh index 8b2d250176149d3a54434def9acc122919370c36..3326fd456a39f30a1b5365874d3b8dca1d190117 100755 --- a/collect/net/bandwidth.sh +++ b/collect/net/bandwidth.sh @@ -28,7 +28,7 @@ function check_traffic_date() # If there is no TRAFFIC (probably its the first run), then just create a # new one. if ! test -f "$TRAFFIC"; then - echo $(date +%F) > $TRAFFIC + echo $(date +%F) > $TRAFFIC return fi @@ -46,6 +46,7 @@ function check_traffic_date() # Finally, create a new TRAFFIC (keeping the previous one as # PREVIOUS_TRAFFIC) if the dates doesnt match. if test $CURRENT_DATE -ne $TRAFFIC_DATE; then + mkdir -p "./previous" cp $TRAFFIC $PREVIOUS_TRAFFIC echo $(date +%F) > $TRAFFIC fi @@ -76,7 +77,7 @@ PROJECT=$PREFIX/../scripts/collect/project/source.int # Verify if this is not an UCA Classmate, UCA Server nor Projector ProInfo. If # it is, do not collect network data and exit. Also exit if the user is not in # the sudoers(1) -if test "$(bash $PROJECT)" != "0" || ! sudo -v &> /dev/null; then +if test "$(bash $PROJECT)" != "0" &> /dev/null; then exit 0 fi @@ -86,7 +87,7 @@ cd $PREFIX TRAFFIC="./traffic.txt" # Collected data on the last day before the machine is disconnected -PREVIOUS_TRAFFIC="./previous-traffic.txt" +PREVIOUS_TRAFFIC="./previous/traffic-$(date +%F).txt" # Stored interfaces from the last run INTERFACES="./interfaces.txt" @@ -99,8 +100,7 @@ IPTABLES=$(which iptables) test $? -ne 0 && IPTABLES="/sbin/iptables" test -x $IP || exit 1 -test -x $IPTABLES || exit 1 - +test -x $IPTABLES || (IPTABLES="/usr/sbin/iptables" && test -x $IPTABLES) || exit 1 #------------------------------------------------------------------------------ # Calculate bytes and packets counts and print to TRAFFIC