Hello,

        I have written a bash script that automatically process the
licq-daily archive and install this periodically in the your local
machine.

        I´m sending this to the community, bcoz of i think that i could
colaborate with the projetct and help to improve the download test
script.

        Requirements:
        -------------

        - wget, the download tool.
        - compile tools (that could be already installed if you had at
          least one succesfull compile of the licq).
        - sudo (you must install it bcoz of the make install section)

                After u install it, put this line into the /etc/sudoers 
                file, replacing the your login name at the start of the
                line:

        joel    ALL=(ALL) NOPASSWD: APM, ALL

                The NOPASSWD tell sudo to don´t ask your password.

        - basic tools (bash, tar, libbzip2, find)
        - cron, to schedule periodically (optional, if u want to do this
          task automatically every day, by example)

        The Script
        ----------

He is the bash script, that i have under /usr/local/bin, with execute
permissions:

###########################
#!/bin/sh
WORK_DIR="/usr/local/src"
DAILY_URL="http://www.rhrk.uni-kl.de/~dmuell/licq/licq-daily.tar.bz2";
LOCAL_FILE="licq-daily.tar.bz2"

get () {
        #Puxa arquivo, desativando o cache para năo pegar o arquivo do
proxie
        wget -Coff -O $WORK_DIR/$LOCAL_FILE $DAILY_URL || exit 1
}

findrecent () {
        #Acha o dir mais recente (baseado em que o icq constroi
diretorios com os nomes das datas diários)
        cd $WORK_DIR;
#       BUILD_DIR=`ls -d * | grep "licq-[0-9]\+" | sort | tail -1` ||
#       exit 1
        BUILD_DIR=`tar tvfj licq-daily.tar.bz2 | sed
"s/.*\(licq-[0-9]\+\).*/\1/g" | uniq`
}

build () {
        #Extrai arquivo
        cd $WORK_DIR || exit 1
        tar xvfj $LOCAL_FILE || exit 1;

        #Constroi o licq
        cd $WORK_DIR/$BUILD_DIR || exit 1
        ./configure || exit 1
        make || exit 1

        #Controi o gui do licq
        cd $WORK_DIR/$BUILD_DIR || exit 1
        cd plugins/qt-gui || exit 1
        ./configure || exit 1
        make || exit 1

        #Constroi o plugin de console do licq
        cd $WORK_DIR/$BUILD_DIR || exit 1
        cd plugins/console || exit 1
        ./configure || exit 1
        make || exit 1
}

install() {
        cd $WORK_DIR/$BUILD_DIR || exit 1
        sudo make install || exit 1
        cd $WORK_DIR/$BUILD_DIR || exit 1
        cd plugins/qt-gui || exit 1
        sudo make install || exit 1
        cd $WORK_DIR/$BUILD_DIR || exit 1
        cd plugins/console || exit 1
        sudo make install || exit 1
}

restart() {
        WHOAMI=`whoami`
        if [ `ps aux | grep licq | grep qt-gui | grep $WHOAMI | wc -l`
-gt 0 ]; then
                killall licq;
                sleep 2
                licq -p qt-gui &
        else
                echo "Năo foi encontrado nenhum licq rodando.";
        fi
}

#Start
case "$1" in
  get)
        get
        ;;
  build)
        findrecent && build
        ;;
  install)
        findrecent && install
        ;;
  last)
        findrecent
        echo $BUILD_DIR
        ;;
  restart)
        restart
        ;;
  full)
        get && findrecent && build && install && restart
        ;;
  *)
        TEMP=`basename $0`
        echo "Licq Daily Download Utility - By JOel";
        echo "--------------------------------------";
        echo "$TEMP {get|build|install|last|full}"
        echo "  get     - get the licq-daily archive of licq download
site";
        echo "  build   - compile licq , libqt-gui and libconsole"
        echo "  install - install licq (needs root privileges through SUDO)"
        echo "  restart - restart licq if the licq is running"
        echo "  last    - shows the directory of the last extract"
        echo "  full    - get, build, install and restart"
        ;;
esac

###########################

        You could see that the script could do individual tasks if do
you want like that way, but the "full" option could be the option that
could be perfect to do the full task.

        If do you want to schedule it every day, you mast add it to the
your crontab file, through "crontab -e":

        In my example, i run it every day at the 7:00am. Add this line
to the crontab to run this way:

0 7 * * * /usr/local/bin/licq-daily full > /home/joel/tmp/licq-daily.log 2>&1 || echo 
"Licq Daily process FAILED"

If will send an e-mail just if the compile fail, otherwise if will just
do the your work, and you will start the licq when u arrive at your
computer :)

        Any doubts, sendme an email.

        []s

-- 
Joel Franco Guzmán
[EMAIL PROTECTED]


-------------------------------------------------------
This SF.NET email is sponsored by: AMD - Your access to the experts
on Hammer Technology! Open Source & Linux Developers, register now
for the AMD Developer Symposium. Code: EX8664
http://www.developwithamd.com/developerlab
_______________________________________________
Licq-main mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/licq-main

Reply via email to