Skip to content
Snippets Groups Projects
Commit b00af182 authored by Edileuton Henrique de Oliveira's avatar Edileuton Henrique de Oliveira
Browse files

agent: Add --uninstall and --version options to the agent installer

parent 8ef7b889
No related branches found
No related tags found
1 merge request!14Add Uninstall and Version Options
......@@ -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 \
......
......@@ -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
......
......@@ -125,7 +125,8 @@ 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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment