bagu | Fodra m'expliquer comment mettre ca en oeuvre... d'autant plus que free ne prend pas en charge les commandes FTP_qqch
donc si comme je le crois ce script s'appuis dessus c mort.
Code :
- #!/bin/sh
- #########################################################
- # foomirror v0.3 #
- # #
- # foomirror has 3 modes: #
- # #
- # - foomirror on: #
- # create a redirection on the remote website to #
- # your computer's website #
- # This command can be put in the init scripts when #
- # the computer is switched on #
- # #
- # - foomirror off: #
- # create a mirror of your computer's website home #
- # page on the remote site #
- # This command can be put in the init scripts when #
- # the computer is switched off #
- # #
- # - foomirror all: #
- # create a full mirror of your website on the remote #
- # site #
- # #
- # foomirror uses ncftpput, which can be found here: #
- # http://www.ncftp.com/download/ #
- #########################################################
- # Copyright (c) 2001, Frederic Jolly aka Daemo0on #
- # jolly.frederic@fnac.net #
- # Based on an idea by Kadreg. #
- # #
- # This is free software, licensed under the GNU General #
- # Public License. #
- #########################################################
- # Disclaimer: #
- # This program is provided as is, without warranty of #
- # any kind. It works for me, but may not work for you #
- # or even destroy your web site, your house and the #
- # universe. #
- #########################################################
- # TODO: #
- # - "mirror all" mirrors only the files that have been #
- # modified since the last mirror #
- # - test if the ncftpput commands return no error #
- #########################################################
- # Some variables:
- #----------------
- MY_IP=$(/sbin/ifconfig ppp0 | sed -n '/inet/s/^[^:]*:\([^ ]*\) .*/\1/p')
- THE_DATE=$(date "+%d %B à %T" )
- # Here is your configuration:
- #----------------------------
- # ftp timeout in seconds
- THE_TIMEOUT=45
- # the remote host with you login and password
- THE_HOST=ftpperso.free.fr
- MY_LOGIN=quadaemon
- MY_PASS=xxxxxxxx
- # the path of your local website
- MY_WEBSITE=/local_path/to/your/home/site
- # your home page
- MY_PAGE=index.shtml
- # the other pages you want to mirror (or "" if none)
- OTHER_PAGES="tribune.log
- tribune.all.log"
- # REDIRECT_PAGE is the html page written on the remote site during the redirection
- # Don't forget to backslah the double quotes
- REDIRECT_PAGE=$(echo "
- <html>
- <head>
- <title>Ca arrive, patience.... Si, si, ....</title>
- <meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\">
- <meta http-equiv=\"refresh\" content=\"1; URL=http://$MY_IP\">
- <link rel=\"icon\" href=\"icon.jpg\">
- </head>
- <!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
- <body bgcolor=\"#ffffff\"><hr>
- Ne bougez pas, les petits électrons vont vous transporter vers ma machine.<br><br>
- Si ça ne marche pas, <a href=\"http://$MY_IP\">cliquez ici</a>.<br>
- Sinon, essayez <a href=\"http://quadaemon.dyndns.org\">ici</a>.<br>
- Et sinon, il vous reste le <a href=\"http://quadaemon.free.fr/index2.shtml\">mirroir</a>.<br>
- <br><i>Redirection powered by foomirror.</i><br>
- <hr>
- </body></html>" )
- # MIRROR_TEXT is the text added at the top of the mirrored page, with the first tag body
- # Don't forget to backslah the double quotes
- MIRROR_TEXT=$(echo "
- <body bgcolor=\"#ffffff\"><hr>
- Attention, cette page est un mirroir de mon site créée le $THE_DATE<br>
- Vous ne pouvez pas poster dans la tribune ni envoyer des mails à dyndns.org.<br>
- Patience, je vais bientôt allumer ma machine...<br><hr>" )
- # Nothing need to be modified under this line
- #--------------------------------------------
- FTPPUT_BIN=$(which ncftpput)
- if [ $? = 1 ]; then
- echo "Error: can't find ncftpput."
- exit 1
- fi
- FTPPUT=$(echo $FTPPUT_BIN -u $MY_LOGIN -p $MY_PASS -t $THE_TIMEOUT)
- # Find out how we were called.
- case "$1" in
- on)
- echo "Creating the redirection..."
- # Create the redirection page and upload it
- echo $REDIRECT_PAGE |\
- $FTPPUT -a -c $THE_HOST $MY_PAGE
- # Upload a copy of the home page
- echo "$THE_NEWPAGE1$MIRROR_TEXT$THE_NEWPAGE2" |\
- $FTPPUT -a -c $THE_HOST index2.shtml
- echo "Done."
- ;;
- off)
- echo "Mirroring..."
- # Create the mirror page and upload it
- THE_NEWPAGE1=$(sed -n '1,/<body/p' $MY_WEBSITE/$MY_PAGE | sed '$d')
- THE_NEWPAGE2=$(sed '1,/<body/d' $MY_WEBSITE/$MY_PAGE)
- echo "$THE_NEWPAGE1$MIRROR_TEXT$THE_NEWPAGE2" |\
- $FTPPUT -c $THE_HOST $MY_PAGE
- # Upload the others files
- for PAGE in $OTHER_PAGES
- do
- echo $PAGE
- $FTPPUT -V $THE_HOST . $MY_WEBSITE/$PAGE
- done
- echo "Done."
- ;;
- all)
- echo "Mirroring all the site..."
- echo "It can take a while..."
- $FTPPUT -m -R $THE_HOST . $MY_WEBSITE/*
- echo "Done."
- ;;
- *)
- echo "Usage: $0 [on|off|all]"
- exit 1
- ;;
- esac
|
|