Τοπική πηγή λογισμικού για PCLinuxOS

Σε μερικά τοπικά δίκτυα, αντί να σπαταλάται το bandwith της εταιρίας, καλό θα ήταν να κατεβαίνουν σε ενα μηχάνημα οι αναβαθμίσεις και μετά να μοιράζονται με το τοπικό δίκτυο στους υπόλοιπους υπολογιστές. Μην ξεχνάτε ότι οι ταχύτητες είναι μεγαλύτερες. Δεν θα μπω στο στήσιμο του δικτύου αλλά η βασική ιδέα είναι ένας υπολογιστής που τρέχει 24 ώρες, 7 μέρες την εβδομάδα. Δεν είναι απολύτως αναγκαίο, αλλά βοηθάει.

ΒΗΜΑΤΑ:
1) Θέστε την τοποθεσία (σκληρός δίσκος) που θα φιλοξενήσετε τις πηγές λογισμικού και σιγουρευτείτε ότι έχετε ελεύθερο χώρο στον δίσκο.
Μπορείτε να το φιλοξενήσετε στο /home/ftp/pub/linux. Εαν θέλετε μονο τις πηγές λογισμικού για τα standard (main extra nonfree kde gnome) χρειάζεστε περίπου 15gb. Εαν θέλετε να προσθέσετε SRPM (πηγαία rpms) τότε χρειάζεστε περίπου 30-40gb.

2) Επιλέξτε τις πηγές λογισμικού που βρίσκονται σε κοντινά σε εσάς. Αυτό είναι και το μεγαλύτερο κομμάτι της εγκατάστασης. Κατεβάστε τις αρχικές πηγές λογισμικού. Αυτή η γραμμή θα είναι διαφορετική και εξαρτάται από ποιά πηγή λογισμικού κατεβάζετε.

rsync -aP --no-motd --stats --delete --exclude=*testing --exclude=*kde4 --exclude=SRPM* spout.ussg.indiana.edu::pclinuxos/pclinuxos /apt/pclinuxos/2007/ /home/ftp/pub/linux


Μόλις τελειώσει, μπορείτε να τρέξετε αυτό το script που είναι στο /usr/local/bin με σύνδεσμο στο /etc/cron.daily ώστε να κάνει καθημερινή αναβάθμιση και να κρατάει λεπτομερές log αρχείο της μεταφοράς.

#!/bin/bash
#
#--------------[ To Do List ]--------------
#--
#--
#--
#--
#--
#----------------------------------------------------------
# Function to perform some housekeeping before exiting.
#----------------------------------------------------------
function cleanup {
#
# Did we create a temporary file?
if [ -f $TMPFILE ]; then
# YES, then delete it before we exit.
rm $TMPFILE
fi
# Terminate the script with a return code of 0 (normal termination) or any other number (abnormal termination).
exit $RETVAL
}
# name the file we are going to log our output to.
LOGFILE="/home/ftp/pub/rsync.log"
# Create a temporary file.
TMPFILE=`mktemp -t rsync.XXXXXXXXXX`
# Was the temporary file created without errors?
if [ $? -ne 0 ]; then
# NO, print a message to our log file then terminate.
printf "\n********** `date +'[%A %b %d %Y] - [%r]'` **********\n" >> $LOGFILE
printf "Repository update FAILED: Unable to create temporary file\n" >> $LOGFILE
RETVAL=1
cleanup
fi
# Set our file counter to 0
COUNT=0

# Call rsync to sync our repository with spout.ussg.indiana.edu.
# -a: This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to preserve almost everything.
# -P: Show progress. This isn't very useful in a non-interactive session, but its nice when we want to sync interactively.
# --no-motd: Most servers have an motd, we don't need to see it so have rsync ignore it.
# --stats: Give us some extra file transfer stats. Good during an interactive session.
# --exclude=: Ignore directories matching . In this case, testing, kde4 and SRPM (source rpms).
# --log-file=: Log output to the temporary file we created above.
rsync -aP --no-motd --stats --exclude=*testing --exclude=*kde4 --exclude=SRPM* --log-file=$TMPFILE spout.ussg.indiana.edu::pclinuxos/pclinuxos/apt/pclinuxos/2007/ /home/ftp/pub/linux 2>/dev/null
# get the return value from rsync and assign it to RETVAL for later use.
RETVAL=$?
# Did rsync terminate without errors?
if [[ $RETVAL -ne 0 ]]; then
# NO, there was a problem with rsync. Write a FAILED notice to our log file, then exit.
printf "\n********** `date +'[%A %b %d %Y] - [%r]'` **********\n" >> $LOGFILE
case $RETVAL in
1) REASON="Syntax or usage error";;
2) REASON="Protocol incompatibility";;
3) REASON="Errors selecting input/output files, dirs";;
4) REASON="Requested action not supported";;
5) REASON="Error starting client-server protocol";;
6) REASON="Daemon unable to append to log-file";;
10) REASON="Error in socket I/O";;
11) REASON="Error in file I/O";;
12) REASON="Error in rsync protocol data stream";;
13) REASON="Errors with program diagnostics";;
14) REASON="Error in IPC code";;
20) REASON="Received SIGUSR1 or SIGINT";;
21) REASON="Some error returned by waitpid()";;
22) REASON="Error allocating core memory buffers";;
23) REASON="Partial transfer due to error";;
24) REASON="Partial transfer due to vanished source files";;
25) REASON="The --max-delete limit stopped deletions";;
30) REASON="Timeout in data send/receive";;
35) REASON="Timeout waiting for daemon connection";;
*) REASON="Undefined error";;
esac
printf "Repository update FAILED with error code $RETVAL: $REASON\n" >> $LOGFILE
RETVAL=2
cleanup
else
# YES, rsync finished without errors.
# get the number of package files transferred.
TRANSFERRED=`cat $TMPFILE | grep -c .rpm`
# Were any files transferred durning this update?
if [ $TRANSFERRED -gt "0" ]; then
# YES, we had some files transferred.
# Add a note to the logfile detailing the current time and the number of files transferred.
printf "\n********** `date +'[%A %b %d %Y] - [%r]'` **********\n" >> $LOGFILE
printf "Repository update SUCEEDED with $TRANSFERRED files transferred.\n" >> $LOGFILE
printf "Number\tSection\t\tFilename\n" >> $LOGFILE
echo "-------------------------------------------" >> $LOGFILE
else
# NO, there were no files transferred durning this update.
# No need to add a note to the log file.
# Call the cleanup function which will terminate this script after some housekeeping.
RETVAL=0
cleanup
fi
# Since we had some files transferred, we will parse our temp file line by line to get the filenames.
cat $TMPFILE | while read line
do
# Does this line have .rpm in it (denoting a package file)
FILE=`echo $line | grep .rpm`
if [ ! -z "$FILE" ]; then
# YES, lets increment our counter by 1 then write that number along with the section and filename transferred to our log file.
COUNT=$(($COUNT+1))
FILE=`echo $FILE | awk '{ print $NF }'`
SECTION=`echo $FILE | cut -d'/' -f3`
FILENAME=`basename $FILE`
printf " $COUNT:\t$SECTION\t$FILENAME\n" >> $LOGFILE
fi
done
fi
RETVAL=0
cleanup


3) Τώρα που κατέβηκαν οι αναβαθμίσεις στην πηγή λογισμικού, είμαστε έτοιμοι. Πρέπει να τρέξουμε ένα ftp server για να είναι διαθέσιμα τα αρχεία σε όλους τους υπολογιστές. Αυτό μπορεί να γίνει με εγκατάσταση του vsftpd από τις πηγές λογισμικού.

5) Μετά από μελέτη στο vsftpd αρχείο παραμετροποίησης, ανοίξτε το /etc/vsftpd/vsftpd.conf και προσθέστε:

# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
# I want a read only anonymous ftp.
anonymous_enable=YES
anon_root=/home/ftp
anon_upload_enable=NO
anon_mkdir_write_enable=NO
anon_other_write_enable=NO
anon_world_readable_only=YES

cmds_allowed=PASV,PWD,LIST,TYPE,MKD,CWD,EXIT,QUIT,HELP,RETR

pasv_min_port=10450
pasv_max_port=10500

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

use_localtime=YES


6) Θέστε το vsftpd να ξεκινάει κατά την έναρξη του υπολογιστή.

7) Ανοίξτε το Synaptic στους άλλους υπολογιστές σας και πάντε το "settings" -> "repositories", ξετσεκάρετε την πηγή που έχει ήδη και προσθέστε νέα:

URI: 192.168.1.105/pub/linux
Distribution: pclinuxos/2007
sections: main extra nonfree kde gnome


Πατήστε "ΟΚ" και μετά "Reload". Τώρα πρέπει να έχετε την δικιά σας PCLinuxOS πηγή λογισμικού που θα είναι πάντα ενημερωμένη.

*ΣΗΜΕΙΩΣΗ: 192.168.1.105 είναι η IP διεύθυνση από το μηχάνημα που θέσατε να είναι αυτό που θα φιλοξενεί την πηγή λογισμικού.

ΠΗΓΗ
Local PCLinuxOS Repository

Δεν υπάρχουν σχόλια

Από το Blogger.