PDA

View Full Version : [SCRIPT] Install f-prot on demand from web for local user



Fabianx
03-29-2003, 08:20 PM
Hi, a new script from me. Only non-interactive/automatic mode for now.

But after installation, you can do a . $HOME/.bashrc or just open a new shell and then run f-prot, run check-updates.sh or man f-prot.

So its fully functional. I think this will be especially great, if used in combination with persistant-home!

So you can have your f-prot together with your home-directory on a usb memory stick and take it everywhere you want, without having to remaster. And you can update f-prots virii-definitions just easily with 'check-updates.sh'. And you have a new f-prot on your mem-stick.

You need to upgrade whole f-prot ?

No problem, just rm -rf $HOME/software/f-prot/ and install it again with this script.

Enjoy! Hope you like that! Comments wanted! Especially from knoppix-doc.sf.net-webmaster. (You can take this script to your documentation of f-prot, it (your doc) gave me the idea, anyway ;-))

cu

Fabian



#
# Install f-prot - useful in combination with persistant home
#
# GPL
#
# Author: Fabian Franz <knx-f-prot@fabian-franz.de>
#

mkdir -p $HOME/software/
cd $HOME/software/
wget ftp://ftp.f-prot.com/pub/linux/fp-linux-sb.tar.gz
tar xzf fp-linux-sb.tar.gz

mkdir -p $HOME/man/man8
mkdir -p $HOME/bin

ln -fs $(pwd)/f-prot/f-prot.sh $HOME/bin/f-prot
ln -fs $(pwd)/f-prot/check-updates.sh $HOME/bin/check-updates.sh
ln -fs $(pwd)/f-prot/man8/f-prot.8 $HOME/man/man8/
ln -fs $(pwd)/f-prot/man8/check-updates.sh.8 $HOME/man/man8/

# Setting up Manpath & PATH for f-prot

cp $HOME/.bashrc $HOME/.bashrc.templ
cat $HOME/.bashrc.templ | grep -v "export MANPATH=\$HOME/man" | grep -v "export PATH=\$HOME/bin/"> $HOME/.bashrc
echo "export MANPATH=\$HOME/man/:\$MANPATH" >> $HOME/.bashrc
echo "export PATH=\$HOME/bin/:\$PATH" >> $HOME/.bashrc
rm -f $HOME/.bashrc.templ

# Fix pathes

cp f-prot/f-prot.sh /tmp/f-prot.$$
sed 's%/usr/local/f-prot/%'$(pwd)'/f-prot/%g' /tmp/f-prot.$$ > f-prot/f-prot.sh

cp f-prot/check-updates.sh /tmp/f-prot.$$
sed 's%/usr/local/f-prot/%'$(pwd)'/f-prot/%g' /tmp/f-prot.$$ > f-prot/check-updates.sh
rm -f /tmp/f-prot.$$

# cleanup

rm -f fp-linux-sb.tar.gz

aay
03-29-2003, 11:27 PM
Nice Job Fabian.

Tigren
03-30-2003, 03:10 AM
did this work for u or aay? i tried all the scripts 'cept for the dvd one, and none worked... any help?

Stephen
03-30-2003, 03:25 AM
The flash install script worked except I did not have xterm installed so the wget failed dowloaded the flash file and everything went fine from HD. Have not tried the others. Also changed the /home/knoppix parts to the user name I am using.

probono
03-30-2003, 08:09 AM
You are very productive in making great install scripts, so my question is: where are the theoretical limitations of this way of installing software? Could one even write such a script to install, let's say, a KDE app in this way? Or could one even have a .deb to installscript converter? Just making up ideas...

Fabianx
03-30-2003, 11:02 AM
did this work for u or aay? i tried all the scripts 'cept for the dvd one, and none worked... any help?

I don't like to flame and will not flame this time, but this bug report does say nothing.

What does not work ?
Did you . ~/.bashrc ?
Enough space on ramdisk ? (e.g. /ramdisk/home/knoppix)

Also please read:
http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

on howto report bugs efficiently..

Thank you! I really want to fix any bugs, but I can't if I don't know WHAT went wrong!

cu

Fabian

Fabianx
03-30-2003, 11:14 AM
You are very productive in making great install scripts, so my question is: where are the theoretical limitations of this way of installing software? Could one even write such a script to install, let's say, a KDE app in this way? Or could one even have a .deb to installscript converter? Just making up ideas...

You can install everything from source this way, because source lets you decide WHERE to install it ...

With other things it is more difficult ...

As you can forget all programs that expect certain files in /usr/share ...

Hm, those would also be possible with some symlink juggling, but I try it another way ...

Having everything in /home/knoppix/bin, lib and man ...

cu

Fabian

PS: Its almost the same work for each package ...

Fabianx
03-30-2003, 12:02 PM
Hi!

This script will auto-scan all partitions wiht certain options and put the resulting report into /virus.txt.

Enjoy!

cu

Fabian



#!/bin/bash
#
# F-Prot Autoscan
#
# GPL
#
# Author: Fabian Franz <knx-fprot@fabian-franz.de>
#
# Idea by: Robert Long
#

# Mount all partitions
for i in $(cat /etc/fstab | grep -v "#" | awk '{ print $2}' | egrep "hd|sd"); do sudo mount -o ro $i; done

# Run f-prot
f-prot $(cat /etc/fstab | grep -v "#" | awk '{ print $2}' | egrep "hd|sd") -all -ai -archive -dumb -packed -list -report=/virus.txt

# Unmount them
for i in $(cat /etc/fstab | grep -v "#" | awk '{ print $2}' | egrep "hd|sd"); do sudo umount $i; done

roberto
04-04-2003, 08:58 AM
Hello all... THESE ARE WONDERFUL

Ive spent the better part of 7 days trying to find the username of the person i ran into in #knoppix.... Fabian you are wonderful... ok enough of the plugging and gloating.... Please e-mail me when you get this fabian otherwise meet up sometime in #knoppix



toast

[edit] I am looking to put these items on the site for download and inclusion into the documents... I am also trying to find a way to get this to the point of using a GUI... please post back to me @ the sourceforge site or by e-mail... this invitation is open to all...

roberto
07-15-2003, 07:19 AM
Thanks to the persistant interest from the users of knoppix and the interest invested into this project by FabianX there has been a script created so that you can install f-prot onto knoppix without having to remaster the disc. unfortunately the script has been outdated a slight bit when frisk Intl. (maker of F-prot) changed the name of the file on their ftp server. the f-prot scripts can be copied from here:
http://www.knoppix.net/forum/viewtopic.php?t=1515&highlight=fprot

there is another script on that page that would be wise to check out as it is another wonderful addition.

and it can be run directly from cd as it is a live script.

BUT: in the section where it says:

mkdir -p $HOME/software/
cd $HOME/software/
wget ftp://ftp.f-prot.com/pub/linux/fp-linux-sb.tar.gz
tar xzf fp-linux-sb.tar.gz

that MUST be changed... f-prot changed the ftp filename recently as they restructured their server entries... after being changed it should read:

mkdir -p $HOME/software/
cd $HOME/software/
wget ftp://ftp.f-prot.com/pub/linux/fp-linux-ws.tar.gz
tar xzf fp-linux-ws.tar.gz

and at the end change the following section:

# cleanup

rm -f fp-linux-sb.tar.gz

to read:

# cleanup

rm -f fp-linux-ws.tar.gz

warmest reguards,

roberto (aka toast)

p.s. the edits in final version should look like this:

#!/bin/bash
#
# Install f-prot - useful in combination with persistant home
#
# GPL
#
# Author: Fabian Franz <knx-f-prot@fabian-franz.de>
#

mkdir -p $HOME/software/
cd $HOME/software/
wget ftp://ftp.f-prot.com/pub/linux/fp-linux-ws.tar.gz
tar xzf fp-linux-ws.tar.gz

mkdir -p $HOME/man/man8
mkdir -p $HOME/bin

ln -fs $(pwd)/f-prot/f-prot.sh $HOME/bin/f-prot
ln -fs $(pwd)/f-prot/check-updates.sh $HOME/bin/check-updates.sh
ln -fs $(pwd)/f-prot/man8/f-prot.8 $HOME/man/man8/
ln -fs $(pwd)/f-prot/man8/check-updates.sh.8 $HOME/man/man8/

# Setting up Manpath & PATH for f-prot

cp $HOME/.bashrc $HOME/.bashrc.templ
cat $HOME/.bashrc.templ | grep -v "export MANPATH=\$HOME/man" | grep -v "export PATH=\$HOME/bin/"> $HOME/.bashrc
echo "export MANPATH=\$HOME/man/:\$MANPATH" >> $HOME/.bashrc
echo "export PATH=\$HOME/bin/:\$PATH" >> $HOME/.bashrc
rm -f $HOME/.bashrc.templ

# Fix pathes

cp f-prot/f-prot.sh /tmp/f-prot.$$
sed 's%/usr/local/f-prot/%'$(pwd)'/f-prot/%g' /tmp/f-prot.$$ > f-prot/f-prot.sh

cp f-prot/check-updates.sh /tmp/f-prot.$$
sed 's%/usr/local/f-prot/%'$(pwd)'/f-prot/%g' /tmp/f-prot.$$ > f-prot/check-updates.sh
rm -f /tmp/f-prot.$$

# cleanup

rm -f fp-linux-ws.tar.gz

Incubii
07-30-2003, 04:41 AM
Howdy. Ive actually modified the old fprot script to use dialogs. I dont have the net so i dont know if this works, so let me know! So here it is anyway. just modify what is needed from the post above :)



#!/bin/bash
#
# install_fprot - Install fprot. Userful in combination with persistant home
# Author Fabian Franz <knx-f-prot@fabian-franz.de>
# Allan Stones <incubii@surfy.net>
# Licensed under the GPL
#
VERSION="1.0"
FPROT_NAME="fp-linux-sb.tar.gz"
FPROT_DIR="$HOME/software/f-prot/"
FPROT_DL_PATH="ftp://ftp.f-prot.com/pub/linux/"
[ -z "$HOME" ] && HOME="/home/knoppix"
INTERACTIVE="yes"

clean_exit()
{
[ -n "$TMP" ] && rm -f "$TMP"
}

function setup_dialog()
{
# Set up dialog
XDIALOG_HIGH_DIALOG_COMPAT=1
export XDIALOG_HIGH_DIALOG_COMPAT

TMP="/tmp/install_fprot.tmp$$"

DIALOG="dialog"
[ -n "$DISPLAY" ] && [ -x /usr/bin/Xdialog ] && DIALOG="Xdialog"

[ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n

MAX=4 # number of steps

case "$LANGUAGE" in
*)
BT="F-Prot-Installation"
T1="Installation of F-Prot (Step 0/$MAX)"
ET="Installation failed"
ST="Installation succeeded"
MESSAGE0="This script installs the F-Prot Antivirus from the internet or from a directory of your choice.\n\nAuthors: Fabian Franz <knx-flash@fabian-franz.de>\n Allan Stones <incubii@surfy.net>"
MESSAGE1="Shall F-Prot be downloaded from the internet?"
MESSAGE2="Please insert the directory name, where $FPROT_NAME can be found."
MESSAGE3="PATH not found. The script will be terminated."
MESSAGE4="F-Prot Antivirus was successfully installed."
MESSAGE5="Script aborted by user"
MESSAGE6="ERROR occured during installation."
;;
esac
N=1; # Step 1
}

while [ $# -ne 0 ];
do
case "$1" in
"-ni"|"--non-interactive")
INTERACTIVE="no"
;;
"-i"|"-interactive")
INTERACTIVE="yes"
;;
"-h"|"--help")
echo "Usage: install_fprot [OPTION]..."
echo " -i, --interactive - Interactive Dialog mode (default)"
echo " -h, --help - This help"
echo " -l, --location <directory> - Where to find the flashplugin"
echo " -ni, --non-interactive - Non interactive install mode"
echo " if not given it is downloaded"
echo " from the internet"
echo " -v, --version - Display Version information"
exit 1
;;
"-l"|"--location")
FPROT_PATH=$2
;;
"-v"|"--version")
echo "install_fprot.sh Version 1.0 for Knoppix 3.2 (03-03-2003)"
echo "---------------------------------------------------------"
echo "Authors: Fabian Franz <knx-f-prot@fabian-franz.de>"
echo " Allan Stones <incubii@surfy.net>"
echo ""
echo "Description: This script installs the F-Prot"
echo " Antivirus from the internet or"
echo " from a directory of your choice."
echo ""
echo "Licensed under the GPL"
exit 1
;;
*)
echo "install_fprot.sh does not recognise this commandline argument."
exit 1
;;
esac
shift
done


[ "$INTERACTIVE" = "yes" ] && setup_dialog

if [ -n "$DIALOG" ]; then
#Introduction Message
$DIALOG --backtitle "$BT" --title "${T1/0/$N}" --msgbox "$MESSAGE0" 15 70
N=$(($N+1))

#Shall F-Prot be downloaded from the internet?
$DIALOG --backtitle "$BT" --title "${T1/0/$N}" --yesno "$MESSAGE1" 15 70
# Grab result of yesno box
EXIT_CODE=$?
N=$(($N+1))


case $EXIT_CODE in
0) # Yes, then download from net
cd /tmp
if [ $DIALOG = "dialog" ]; then
wget $FROT_DL_PATH
else
xterm -e wget $FROT_DL_PATH
fi
N=$(($N+1))
;;
1) # No, then select path where file is located
cd /tmp
$DIALOG --backtitle "$BT" --title "${T1/0/$N}" --inputbox "$MESSAGE2" 15 70 "$FPROT_PATH" 2>$TMP
EXIT_CODE=$?
case $EXIT_CODE in
0) # Yes
N=$(($N+1))
FROT_PATH=$(<$TMP)
if [ -e $FROT_PATH/$FROT_NAME ]; then
cp $FROT_PATH/$FROT_NAME /tmp
else
$DIALOG --backtitle "$BT" --title "$ET" --msgbox "${MESSAGE3/PATH/$FROT_PATH/$FROT_NAME}" 15 70 # error!
exit 1
fi
;;
1) # Aborted by user
$DIALOG --backtitle "$BT" --title "$ET" --msgbox "$MESSAGE5" 15 70
exit 1
;;
255) # Error
$DIALOG --backtitle "$BT" --title "$ET" --msgbox "$MESSAGE6" 15 70
exit 1
;;
esac
;;
255) # Error occured during installation
$DIALOG --backtitle "$BT" --title "$ET" --msgbox "$MESSAGE6" 15 70
exit 1
;;
esac

# Now we should have a /tmp/$FROT_NAME

if [ -e /tmp/$FROT_NAME ];
then
mkdir $HOME/software
cp /tmp/$FROT_NAME $HOME/software
cd $HOME/software
tar xzf $FROT_NAME
mkdir -p $HOME/man/man8
mkdir -p $HOME/bin

ln -fs $(pwd)/f-prot/f-prot.sh $HOME/bin/f-prot
ln -fs $(pwd)/f-prot/check-updates.sh $HOME/bin/check-updates
ln -fs $(pwd)/fprot/man8/f-prot.8 $HOME/man/man8/
ln -fs $(pwd)/fprot/man8/check-updates.sh.8 $HOME/man/man8/

# Setting up Manpath & PATH for f-prot
cp $HOME/.bashrc $HOME/.bashrc.templ
cat $HOME/.bashrc.templ | grep -v "export MANPATH=\$HOME/man" | grep -v "export PATH=\$HOME/bin/"> $HOME/.bashrc
echo "export MANPATH=\$HOME/man/:\$MANPATH" >> $HOME.bashrc
echo "export PATH=\$HOME/bin:\$PATH" >> $HOME/.bashrc
rm -rf $HOME/.bashrc.templ

# Fix paths
cp f-prot/f-prot.sh /tmp/f-prot.$$
sed 's%/usr/local/f-prot/%`$(pwd)`/f-prot/%g' /tmp/f-prot.$$ > f-prot/f-prot.sh

cp f-prot/check-updates.sh /tmp/check-updates.$$
sed 's%/usr/local/f-prot/%`$(pwd)`/f-prot/%g' /tmp/check-updates.$$ > f-prot/check-updates.sh

RC=$?
cd ..
#cleanup
rm -rf /tmp/f-prot.$$
rm -rf /tmp/check-updates.$$
rm -rf fp-linux-sb.tar.gz
rm -rf /tmp/f*


else # /tmp/$FROT_NAME not found
$DIALOG --backtitle "$BT" --title "$ET" --msgbox "${MESSAGE3/PATH/tmp/$FROT_NAME}" 15 70 # error!
exit 1
fi
$DIALOG --backtitle "$BT" --title "$ST" --msgbox "$MESSAGE4" 15 70
else # non interactive
cd /tmp
if [ -n "$FROT_PATH" ];
then
cp $FROT_PATH/$FROT_NAME /tmp
else
wget $FROT_DL_PATH
fi
if [ -f /tmp/$FROT_NAME ];
then
cp /tmp/$FROT_NAME $HOME/software
cd $HOME/software
tar xzf $FROT_NAME
mkdir -p $HOME/man/man8
mkdir -p $HOME/bin

ln -fs $(pwd)/f-prot/f-prot.sh $HOME/bin/f-prot
ln -fs $(pwd)/f-prot/check-updates.sh $HOME/bin/check-updates
ln -fs $(pwd)/fprot/man8/f-prot.8 $HOME/man/man8/
ln -fs $(pwd)/fprot/man8/check-updates.sh.8 $HOME/man/man8/

# Setting up Manpath & PATH for f-prot
cp $HOME/.bashrc $HOME/.bashrc.templ
cat $HOME/.bashrc.templ | grep -v "export MANPATH=\$HOME/man" | grep -v "export PATH=\$HOME/bin/"> $HOME/.bashrc
echo "export MANPATH=\$HOME/man/:\$MANPATH" >> $HOME.bashrc
echo "export PATH=\$HOME/bin:\$PATH" >> $HOME/.bashrc
rm -rf $HOME/.bashrc.templ

# Fix paths
cp f-prot/f-prot.sh /tmp/f-prot.$$
sed 's%/usr/local/f-prot/%`$(pwd)`/f-prot/%g' /tmp/f-prot.$$ > f-prot/f-prot.sh

cp f-prot/check-updates.sh /tmp/check-updates.$$
sed 's%/usr/local/f-prot/%`$(pwd)`/f-prot/%g' /tmp/check-updates.$$ > f-prot/check-updates.sh

RC=$?
cd ..
#cleanup
rm -rf /tmp/f-prot.$$
rm -rf /tmp/check-updates.$$
rm -rf fp-linux-sb.tar.gz
rm -rf /tmp/f*

else
echo "Error accessing /tmp/$FROT_NAME"
exit 1
fi
fi

exit 0 # Success!


[Edited by Fabianx to have it as code]