Skip to content
Snippets Groups Projects
Commit 86a6f498 authored by Diego Giovane Pasqualin's avatar Diego Giovane Pasqualin
Browse files

Merge branch 'add_uninstall_version_options' of /home/git/repositories/minicom/datasid

parents 354e0fc7 5bcea2e3
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,7 @@ FILES = bin/datasid-agent.sh bin/datasid-client.sh \
bin/datasid-check.sh bin/datasid-netmon.sh \
bin/datasid-network-usage.sh \
bin/datasid-builtin-wget \
bin/datasid-uninstall.sh \
conf/datasid.conf \
gen-scripts/collected-data/agent-version.tree \
gen-scripts/collected-data/point-info.tree \
......
......@@ -86,7 +86,7 @@ function checkUpdate()
function schedule()
{
if test -f "${CONFDIR}/pointInfo"; then
MIN=$(( 10#$(grep idpoint ${CONFDIR}/pointInfo | awk -F'=' '{print $2}' | sed "s/[^0-9]//g") % 60 ))
MIN=$(( 10#$(grep idponto ${CONFDIR}/pointInfo | awk -F'=' '{print $2}' | sed "s/[^0-9]//g") % 60 ))
else
MIN=$(( $RANDOM % 60 ))
fi
......
#!/bin/bash
# Copyright (C) 2004-2013 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of datasid
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# Delete the crontab of datasid
crontab -u datasid -r
# Delete user datasid
userdel datasid
# Delete group datasid
groupdel datasid 2> /dev/null
rm -rf "/opt/datasid"
exit 0
\ No newline at end of file
......@@ -102,9 +102,34 @@ exit_with_message() {
exit $1
}
# Print the agent version
agent_version() {
if test -f "${DATASID_HOME}/conf/version"; then
cat "${DATASID_HOME}/conf/version" >&3
else
echo $VERSION >&3
fi
exit 0
}
# Uninstall the agent
uninstall() {
if test -d "${DATASID_HOME}"; then
if bash "${DATASID_HOME}/bin/datasid-uninstall.sh"; then
printf "Agente desinstalado com sucesso\n" >&3
exit 0
fi
else
printf "Agente não instalado\n" >&3
exit 1
fi
}
# These variables will be replaced when generating the installation package
PKG_MD5=
PKG_LINE=
VERSION=
# Set variables
DATASID_HOME="/opt/datasid"
......@@ -121,6 +146,14 @@ fi
# Save stdout to file descriptor 3 and redirect all output to $LOGFILE
exec 3>&1 &> ${LOGFILE}
case "$1" in
-v|--version)
agent_version
;;
-u|--uninstall)
uninstall
;;
esac
printf "Iniciando instalação do agente DATASID. Tenha certeza de %b%b%b\n" \
"estar conectado à Internet. Além disso, para o agente funcionar \n" \
......@@ -271,11 +304,14 @@ printf "Executando o agente pela primeira vez... " >&3
export FIRST_EXECUTION=1
# Run the agent and check if its execution was alright, exiting in case of error
su -c "bash ${DATASID_HOME}/bin/datasid-agent.sh" datasid
RETVAL=$?
if test ${RETVAL} -ne 0; then
if ! su -c "bash ${DATASID_HOME}/bin/datasid-agent.sh" datasid; then
printf "FALHA!\n" >&3
printf "ERRO: Falha na execução do novo agente (${RETVAL}).\n"
printf "ERRO: Falha na execução do novo agente (${RETVAL}).\n" >&3
#Check internet conection
if ! ping -q -w 1 -c 1 \
`ip r | grep default | cut -d ' ' -f 3` > /dev/null 2>&1; then
printf "Não há conexão com a internet!\n" >&3
fi
collect_information
exit 6
fi
......@@ -286,7 +322,7 @@ printf "OK!\n" >&3
exec >&3 3>&-
printf "\nO agente DATASID foi instalado com sucesso. %b%b" \
"Em caso de dúvidas, acesse o portal do DATASID:\n" \
"datasid.c3sl.ufpr.br\n"
"Em caso de dúvidas, acesse o portal do SIMMC:\n" \
"simmc.c3sl.ufpr.br\n"
exit 0
......@@ -22,6 +22,7 @@
# These variables will be replaced when generating the package
PKG_MD5=
PKG_LINE=
VERSION=
# Set variables
if test -z "${DATASID_HOME}"; then
......
......@@ -86,7 +86,7 @@ parse_options() {
output=
version=
input=
bootstrap="bootstrap/bootstrap-install"
bootstrap="bootstrap/install"
# parse command line options into the global variables above
parse_options "$@"
......@@ -111,13 +111,22 @@ mkdir -p $tempdir/data
tempfile=$(mktemp /tmp/datasid.XXXXXXXX)
tar --directory "$tempdir" -czf "$tempfile" .
rm -rf "$tempdir"
if test $bootstrap = "bootstrap/install"; then
mkdir -p "$(dirname $0)/agent-files/"
cp "$(dirname $0)/$bootstrap" "$(dirname $0)/agent-files/"
mv $tempdir "$(dirname $0)/agent-files/"
rm -rf "$(dirname $0)/agent-files/datasid"
mv "$(dirname $0)/agent-files/$(basename $tempdir)" "$(dirname $0)/agent-files/datasid"
else
rm -rf $tempdir
fi
pkgmd5=$(md5sum "$tempfile" | cut -d' ' -f1)
pkgline=$(( $(wc -l "$bootstrap" | cut -d' ' -f1) + 1 ))
sed "s/PKG_LINE=/PKG_LINE=${pkgline}/g; \
s/PKG_MD5=/PKG_MD5=\"${pkgmd5}\"/g" \
s/PKG_MD5=/PKG_MD5=\"${pkgmd5}\"/g; \
s/VERSION=/VERSION=\"${version}\"/g" \
"$bootstrap" > "$output"
cat "$tempfile" >> "$output"
......
AC_PREREQ([2.65])
AC_INIT([datasid-agent], [1.0.1], [datasid@c3sl.ufpr.br])
AC_INIT([datasid-agent], [1.0.2], [datasid@c3sl.ufpr.br])
AC_CONFIG_SRCDIR([src/client.c])
AC_CONFIG_HEADERS([config.h])
AC_PREFIX_DEFAULT([/opt])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment