Commit 9d4639b4 authored by Klismann Smoger Mottin's avatar Klismann Smoger Mottin Committed by Lucas Manika Koeb

Package that installs the autoupgrade mechanism on LE 5

Signed-off-by: Klismann Smoger Mottin's avatarKlismann Smoger Mottin <ksm09@inf.ufpr.br>
parent 0b9ce7a8
#!/bin/bash
# gerar.sh
# Copyright (c) 2006 by Bruno Ribas <ribas@ufpr.br>
DIRTMP=$(mktemp -d)
VERSAO=$(cat VERSAO)
#arrumar versao
#$1 tipo de incremento
MAJOR=$(echo $VERSAO| cut -d'.' -f1)
MINOR=$(echo $VERSAO| cut -d'.' -f2)
REVISION=$(echo $VERSAO| cut -d'.' -f3)
case $1 in
Minor)
((MINOR++))
REVISION=0
;;
Major)
((MAJOR++))
MINOR=0
REVISION=0
;;
help)
echo "Uso: $0 Major|Minor|Revision"
echo ' Major - Altera versao Major'
echo ' Minor - Altera versao Minor'
exit
;;
*)
((REVISION++))
;;
esac
VERSAO="${MAJOR}.${MINOR}.${REVISION}"
echo "$VERSAO" > VERSAO
#Compila a documentacao do pacote no diretorio doc/
#cd doc/
#hevea -text *.tex
#hevea -text *.tex
#cd ../
cp -a pacote $DIRTMP
#Copia a documentacao compilada para dentro do pacote.
#cp doc/*.txt $DIRTMP/pacote/usr/share/doc/prd-*
cd $DIRTMP
find . -name ".git" -exec rm -rf {} \; &>/dev/null
sed -i -e "s/Version:/Version: $VERSAO/" pacote/DEBIAN/control
fakeroot dpkg -b pacote .
cd -
cp $DIRTMP/*deb .
rm -rf $DIRTMP
# vim:tabstop=4:shiftwidth=4:encoding=iso-8859-1
Package: le-autoupgrade
Priority: important
Section: main
Version:
Architecture: all
Depends: cron | anacron, apt, debianutils
Maintainer: LE Maintainer <le-maintainer@c3sl.ufpr.br>
Description: Cron script to upgrade school machines of Linux Educacional project
This package is part of the Linux Educacional Project.
#!/bin/bash
# Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of le-autoupgrade
#
# le-autoupgrade 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,
if [[ "$1" != "upgrade" ]]; then
crontab -l | grep -v "le-autoupgrade" | crontab -
fi
exit 0
#!/bin/bash
# Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of le-autoupgrade
#
# le-autoupgrade 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,
CRONLINE='0 * * * * /usr/local/sbin/le-autoupgrade'
if ! crontab -l | grep "le-autoupgrade"; then
cron="$(crontab -l)\n$CRONLINE"
printf "$cron\n\n" | crontab -
fi
exit 0
#!/bin/bash
#
# Copyright (C) 2012 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of le-autoupgrade
#
# le-autoupgrade 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.
# Settings
APTGET="apt-get --quiet -y --force-yes"
DIR_CONFIG="/etc/le-autoupgrade"
DIR_EXEC="$DIR_CONFIG/exec"
UPGRADING="/tmp/upgrading"
UPDATING="/tmp/updating"
PHYSIC_LOG="/var/log/le/le-autoupgrade.log"
LASTEXEC="/etc/le-autoupgrade/le-autoupgrade-lastexec"
ERROR=0
PATH="/sbin:/usr/sbin:$PATH"
NOW=$(date +%s)
LASTEXECTIME=$(cat $LASTEXEC)
ONEDAY=$(( 60 * 60 * 24 ))
if test -f $LASTEXEC && test $(( $NOW - $LASTEXECTIME )) -le $ONEDAY; then
exit 0
fi
# Prepare information in case of error
# Run a command passed as argument
function run {
echo "==$(date)==" >> $PHYSIC_LOG
$@ &> $PHYSIC_LOG
return $?
}
# sleep for a random interval of time (default 30min)
# (some code taken from cron-apt, thanks)
randomSleep()
{
randomSleepUpperLimit=1800
if [ -z "$RANDOM" ] ; then
# A fix for shells that do not have this bash feature.
RANDOM=$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -c"1-5")
fi
TIME=$(($RANDOM % $randomSleepUpperLimit))
echo "sleeping for $TIME seconds" >> $PHYSIC_LOG
sleep $TIME
return 0
}
# Force non-interactive Debconf mode
export DEBIAN_FRONTEND="noninteractive"
touch $UPGRADING
touch $UPDATING
# Check if there is a "dpkg --configure -a" error
run dpkg --configure -a
if run $APTGET update; then
rm -f $UPDATING
else
echo "Update failed!" >> $PHYSIC_LOG
fi
if ! test -f $UPDATING && randomSleep && run $APTGET dist-upgrade -d; then
rm -f $UPGRADING
else
echo "Upgrade failed!" >> $PHYSIC_LOG
fi
# Check if download and update were done succefully.
if [[ -f $UPGRADING ]] || [[ -f $UPDATING ]]; then
ERROR=1
# If we have downloaded sucefully, we can now do the upgrade
else
# Upgrade and check success
if ! run $APTGET dist-upgrade; then
ERROR=1
fi
# Run other packages scripts
for SCRIPT in $(run-parts --test "$DIR_EXEC" ) ; do
run $SCRIPT
done
if ! run $APTGET autoremove; then
ERROR=1
fi
date +%s > $LASTEXEC
fi
rm -f $UPGRADING
rm -f $UPDATING
C3SL - Centro de Computacao Cientifica e Software Livre
Adriano da Luz
Bruno Cesar Ribas
Carlos Carvalho
Cleide Luzia Bonfim Possamai
Eduardo Todt
Erik Alexandre Pucci
Juliana Bueno
Klismann Smoger Mottin
Laura Sanchez Garcia
Lucas Manika Koeb
Lucas Falcão Radaelli
Luis Carlos Erpen de Bona
Marcos Castilho
Michael Liang
Thiago Henrique Dos Santos Picharski
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment