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 && Freshly Installed One

05.05.2008
| 1090 views |
  • submit to reddit
        Test for a script that update a falcon repository manager with package installed in the system plus install new packets in the system and update in falcon

#!/bin/bash
# Checks if you have the right privileges
if [ "$USER" = "root" ];then
	# Checks if there is an argument
   	[ $# -eq 0 ] && { echo >&2 ERROR: You may enter as an argument a text file containing users, one per line. ; exit 1; }
   	# checks if there a regular file
   	[ -f "$1" ] || { echo >&2 ERROR: The input file does not exists. ; exit 1; }
	pack=$(cat $1)
   	apt-get update
	echo "update effettuato"
	apt-get -dy upgrade
	echo "download upgrade effettuato"
	apt-get -dy dist-upgrade
	echo "download dist-upgrade effettuato"
	apt-get -dy --force-yes install $pack
	echo "download install completato"
	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 dist-upgrade
	echo "dist-upgrade effettuato"
	apt-get -y -- force yes install $pack
	echo "install effettuato"
	apt-get clean
	echo "sistema aggiornato"
	exit 0
else
	echo "Errore, lo script dev'essere eseguito come root"
	exit 1
fi
exit 0