DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Automaticaly Update Falcon Repository With Packets Used By The Sistem

04.30.2008
| 1391 views |
  • submit to reddit
        Preliminary version of a script for the automated update of a falcon repository manager with the updated version of the packets installed on the system

#!/bin/bash
# Checks if you have the right privileges
if [ "$USER" = "root" ];then
	apt-get update
	echo "update effettuato"
	apt-get -dy upgrade
	echo "download upgrade effettuato"
	apt-get -dy dist-upgrade
	echo "download dist-upgrade effettuato"
	cd /var/cache/apt/archives
	if [ -d tmp ];
	then
	rm -R tmp/
	fi
	for k in $(ls *.deb); do
		mkdir tmp/
		cp $k tmp/
		cd tmp/
		ar x $k
		tar -xzf control.tar.gz ./control
		tempvar=$(cat control | grep Section | cut -d: -f2 | cut -d/ -f1)
		tempname=$(cat control | grep Package | cut -d: -f2)
		if [ "$tempvar" != "universe" ] || [ "$tempvar" != "multiverse" ] || [ "$tempvar" != "restricted" ]; 
		then
		temppath=$(echo "/var/www/falcon/pool/dapper/main") 
		else
		temppath=$(echo "/var/www/falcon/pool/dapper/$tempvar")
		fi		
		mv $k $temppath
		echo pacchetto $tempname spostato nella cartella $temppath
		cd ..
		rm -R tmp/
	done 
	cd /var/www/falcon/pool
	find -type f -name "*.deb" -exec {rename 's/_1%3a//g' *} \;
	echo "pacchetti rinominati"
	falcon update
	echo "falcon update effettuato"
	falcon clean
	echo "repository aggiornato"
	apt-get -y upgrade
	echo "upgrade effettuato"
	apt-get -y --force-yes dist-upgrade
	echo "dist-upgrade effettuato"
	apt-get clean
	echo "sistema aggiornato"
	exit 0
else
	echo "Errore, lo script dev'essere eseguito come root"
	exit 1
fi
exit 0