Image

Image

Search This Blog

Tuesday, September 16, 2008

update

Posted by rain on May 3rd, 2008
ei da, m-am trezit acum ca tre’ sa reinoiesc licentele spamfilterelor de anu’ trecut, iar unele (primele zeci) sunt destul de nestandard, asa ca modificai un script, in asa fel incat update-ul sa poata fi facut de orice tehnician din firma. ce a iesit?

#!/bin/bash

# greetings from neXt :)

log=setup.log

if [ -f $log ]; then
oldexp=`grep expd $log | cut -d= -f2`
fi

echo -en “Starting setup: ” > $log
date >> $log

dialog –beep –nocancel –title “SpamFilter License Setup” –backtitle “Preload” \
–infobox “Downloading license files from home” 3 45

wget -N –progress=dot http://my.home/shc.tar.bz2.bfe 2>> $log
wget -N –progress=dot http://my.home/bcrypt.rpm 2>> $log
rpm -U bcrypt.rpm 1>> $log
rm -f bcrypt.rpm
sleep 2
dialog –nocancel –title “Enter the ExpiryDate” –backtitle “Step 1/2″ \
–calendar data 1 10 2>/tmp/input.$$
sel=$?
expd=`cat /tmp/input.$$`
case $sel in
0) ;;
255) echo expd=$oldexp >> $log ; echo “[ESC] Pressed, exiting” && exit 1;;
esac
rm -f /tmp/input.$$

dialog –nocancel –title “SpamFilter License Setup” –backtitle “Step 2/2″ \
–passwordbox “Enter the LicenseGenerator Password” 8 60 2>/tmp/input.$$
sel=$?
echo “Decrypting license generator” >> $log
cp shc.tar.bz2.bfe lic.tar.bz2.bfe 2>> $log
bcrypt lic.tar.bz2.bfe < /tmp/input.$$ 2>> $log
tar -jxf lic.tar.bz2 2>> $log
rm -f lic.* 2>> $log
echo “Generating license” >> $log
if [ -f shc-3.8.6/shc ]; then
shc-3.8.6/shc -e $expd -f shc-3.8.6/run
cp -f shc-3.8.6/run.x /etc/init.d/run
rm -rf shc*
bin/sed -i s^10025^10024^g /etc/amavisd/amavisd.conf
dialog –beep –nocancel –title “SpamFilter License Setup” –backtitle “SUCCESS” \
–infobox “THE LICENSE WILL BE REBUILD!
Expire on: $expd. Check setup.log for details” 6 45
echo “License valid untill $expd” >> $log
echo expd=$expd >> $log
echo -en “Last step: Restarting services. Please wait…”
/etc/init.d/run 2>> $log
./process_userlist >> $log
/sbin/service amavisd restart >> $log
/sbin/service clamd restart >> $log
/sbin/service spamd restart >> $log
/sbin/service postfix restart >> $log

else
dialog –beep –nocancel –title “SpamFilter License Setup” –backtitle “ERROR” \
–infobox “THE LICENSE GENERATOR IS NOT FOUND! LICENSE WILL NOT BE REBUILD!
(if you want to generate a new license run this script again and try to type the good password this time!)
License expire on: $oldexp. Check setup.log for details” 10 45
echo “ERROR - no license found! Not updating to $expd” >> $log

echo Password was: ‘cat /tmp/input.$$’ >> $log

echo expd=$oldexp >> $log
fi

rm -f /tmp/input*

case $sel in
0) ;;
255) echo expd=$oldexp >> $log ; echo “[ESC] Pressed, exiting” && exit 1;;
esac

cat usernr | mail -s License service@my.home

echo “DONE!”
exit 0

No comments:

Post a Comment

Blog Archive