Wifi
Résolu
matser1973
-
matser1973 -
matser1973 -
Bonjour,
voilà:
j'ai deux ordinateur, un fixe et un portable, tout les deux sous slackware 12. connectés chez free.
j'ai voulu faire du portable un serveur de fichier afin de les sauvegarder sur bande, lecteur de bandes branché sur le fixe.mais là, c'est une autre histoire.
pour cela, j'ai désactivé le mode dhcp de ma freebox... et je n'ai plus de réseau!!!
j'ai configuré /etc/rc.d/rc.inet1.conf: j'y ai mis les adresses ip 192.168.0.1 sur le fixe et 192.168.0.2 sur le portable.
le problème: je n'ai plus de wifi sur le portable.
comment configure-t-on un réseau sans fils sous linux?
merci pour vos réponses...
voilà:
j'ai deux ordinateur, un fixe et un portable, tout les deux sous slackware 12. connectés chez free.
j'ai voulu faire du portable un serveur de fichier afin de les sauvegarder sur bande, lecteur de bandes branché sur le fixe.mais là, c'est une autre histoire.
pour cela, j'ai désactivé le mode dhcp de ma freebox... et je n'ai plus de réseau!!!
j'ai configuré /etc/rc.d/rc.inet1.conf: j'y ai mis les adresses ip 192.168.0.1 sur le fixe et 192.168.0.2 sur le portable.
le problème: je n'ai plus de wifi sur le portable.
comment configure-t-on un réseau sans fils sous linux?
merci pour vos réponses...
A voir également:
- Wifi
- Changer wifi chromecast - Guide
- Voir mot de passe wifi android - Guide
- Adresse mac wifi - Guide
- Volte wifi - Guide
- Dns wifi - Guide
4 réponses
Avec la commande iwconfig (pour configure l'ESSID et la clé wep). Sinon après c'est comme avec une interafce réseau classique :
- ifconfig pour configurer manuellement l'IP
- route pour ajouter des routes
- corriger /etc/resolv.conf pour configurer les DNS
- configurer les variables d'environnement http_proxy ftp_proxy etc... si tu passes par un proxy.
Exemple : carte wifi = eth1, IP = 192.168.0.1, passerelle = 192.168.0.254, Essid="Mon_EssiD", clé WEP = 1234567890ABCDEF, DNS = 11.22.33.44 : en root :
Pour plus d'informations sur ces commandes :
Commandes pour vérifier le comportement du réseau (à nous donner en cas de problème) :
Ceci dit à ta place je remettrais le DHCP en place, car elle est beaucoup plus simple, et il est possible d'attribuer à chaque fois la même IP à une machine (en se basant sur son adresse MAC, que tu peux obtenir avec la commande "ifconfig"). Cf l'interface de configuration de ta freebox sur le site de free. Bref, il n'y a donc pas vraiment d'intérêt à configurer manuellement ton réseau local.
Bonne chance
- ifconfig pour configurer manuellement l'IP
- route pour ajouter des routes
- corriger /etc/resolv.conf pour configurer les DNS
- configurer les variables d'environnement http_proxy ftp_proxy etc... si tu passes par un proxy.
Exemple : carte wifi = eth1, IP = 192.168.0.1, passerelle = 192.168.0.254, Essid="Mon_EssiD", clé WEP = 1234567890ABCDEF, DNS = 11.22.33.44 : en root :
iwconfig eth1 essid "Mon_EssiD" key 1234567890ABCDEF ifconfig eth1 192.168.0.1 route add default gw 192.168.0.254 eth1 echo "nameserver 11.22.33.44" > /etc/resolv.conf
Pour plus d'informations sur ces commandes :
man iwconfig man ifconfig man route man resolv.conf
Commandes pour vérifier le comportement du réseau (à nous donner en cas de problème) :
iwconfig ifconfig -a route -n cat /etc/resolv.conf host www.google.fr ping -c2 www.google.fr
Ceci dit à ta place je remettrais le DHCP en place, car elle est beaucoup plus simple, et il est possible d'attribuer à chaque fois la même IP à une machine (en se basant sur son adresse MAC, que tu peux obtenir avec la commande "ifconfig"). Cf l'interface de configuration de ta freebox sur le site de free. Bref, il n'y a donc pas vraiment d'intérêt à configurer manuellement ton réseau local.
Bonne chance
voici comment j'ai fait:
sur le fixe en ethernet:
j'ai ensuite ajouté 212.27.54.252 au fichier /etc/resolv.conf
sur le portable:
j'utilise une carte wifi pcmcia, revendue par free, donc pas de pkgtool.
j'ai installé cette carte avec le tarball RT61_Linux_STA_Drv1.1.0.0.tar.gz
puis suivre les instructions détaillées dans le fichier readme et faire aussi
(ce n'est pas précisé dans le readme mais il faut le faire quand-même)
j'ai ajouté la ligne "modprobe rt61" dans le fichier /etc/rc.d/rc.modules (je suis sous slackware).
tapez-la maintenant pour ne pas avoir à redémarrer l'ordinateur
effectuer les changements nécessaire dant /etc/rc.d/rc.inet1.conf et /etc/rc.d/rc.wireless.conf
puis /etc/rc.d/rc.wireless.conf
sur le protable (et aussi sur le fixe), les dossiers /home et racine ne sont pas sur la même partition. il faut les mettre tous les deux dans /etc/exports (sur le portable)
"192.168.0.1" est l'adresse IP de mon ordi fixe
voici les fichiers /etc/hosts, /etc/hosts.deny et /etc/hosts.allow
/etc/hosts
/etc/hosts.deny
/etc/hosts.allow
lancer le réseau (sur les deux ordis):
sur le fixe:
et voilà, mon portable est un serveur de fichiers et je peux le sauvegarder sur bande sans avoir à y brancher le lecteur de bande, lequel est branché sur le fixe.
en bonus:
mes scripts de sauvegarde:
sauve:
sauve-remote:
sur le fixe en ethernet:
$ su # pkgtool option setup option netconfig nom d'hôte : ordifixe nom de domaine : linux.local option static IP adresse IP : 192.168.0.1 masque de sous-réseau: 255.255.255.0 gateway: 192.168.0.254 oui pour nameserver nameserver: 212.27.53.252 accept exit
j'ai ensuite ajouté 212.27.54.252 au fichier /etc/resolv.conf
search linux.local nameserver 212.27.53.252 nameserver 212.27.54.252
sur le portable:
j'utilise une carte wifi pcmcia, revendue par free, donc pas de pkgtool.
j'ai installé cette carte avec le tarball RT61_Linux_STA_Drv1.1.0.0.tar.gz
$ tar zxvf RT61_Linux_STA_Drv1.1.0.0.tar.gz $ cd RT61_Linux_STA_Drv1.1.0.0
puis suivre les instructions détaillées dans le fichier readme et faire aussi
$ su #make install
(ce n'est pas précisé dans le readme mais il faut le faire quand-même)
j'ai ajouté la ligne "modprobe rt61" dans le fichier /etc/rc.d/rc.modules (je suis sous slackware).
tapez-la maintenant pour ne pas avoir à redémarrer l'ordinateur
$ su # modprobe rt61
effectuer les changements nécessaire dant /etc/rc.d/rc.inet1.conf et /etc/rc.d/rc.wireless.conf
# /etc/rc.d/rc.inet1.conf # # This file contains the configuration settings for network interfaces. # If USE_DHCP[interface] is set to "yes", this overrides any other settings. # If you don't have an interface, leave the settings null (""). # You can configure network interfaces other than eth0,eth1... by setting # IFNAME[interface] to the interface's name. If IFNAME[interface] is unset # or empty, it is assumed you're configuring eth<interface>. # Several other parameters are available, the end of this file contains a # comprehensive set of examples. # ============================================================================= # Config information for eth0: IPADDR[0]="" NETMASK[0]="" USE_DHCP[0]="" DHCP_HOSTNAME[0]="" # Config information for eth1: IPADDR[1]="" NETMASK[1]="" USE_DHCP[1]="" DHCP_HOSTNAME[1]="" # Config information for eth2: IPADDR[2]="" NETMASK[2]="" USE_DHCP[2]="" DHCP_HOSTNAME[2]="" # Config information for eth3: IPADDR[3]="" NETMASK[3]="" USE_DHCP[3]="" DHCP_HOSTNAME[3]="" # Default gateway IP address: GATEWAY="192.168.0.254" # Change this to "yes" for debugging output to stdout. Unfortunately, # /sbin/hotplug seems to disable stdout so you'll only see debugging output # when rc.inet1 is called directly. DEBUG_ETH_UP="no" ## Example config information for wlan0. Uncomment the lines you need and fill ## in your info. (You may not need all of these for your wireless network) IFNAME[4]="ra0" IPADDR[4]="192.168.0.2" NETMASK[4]="255.255.255.0" USE_DHCP[4]="" #DHCP_HOSTNAME[4]="icculus-wireless" #DHCP_KEEPRESOLV[4]="yes" #DHCP_KEEPNTP[4]="yes" #DHCP_KEEPGW[4]="yes" #DHCP_IPADDR[4]="" WLAN_ESSID[4]=<le nom de mon réseau, nomé sur le site de free> WLAN_MODE[4]=Managed ##WLAN_RATE[4]="54M auto" ##WLAN_CHANNEL[4]="auto" WLAN_KEY[4]="<ma clé WEP générée sur le site de free>" ##WLAN_IWPRIV[4]="AuthMode=WPAPSK EncrypType=TKIP WPAPSK=7B1ABEEB5D197741923ED26727569C365E31212096A0EAFAD563B268BAD01CAF TxRate=0" #WLAN_WPA[4]="wpa_supplicant" #WLAN_WPADRIVER[4]="ndiswrapper" ## Some examples of additional network parameters that you can use. ## Config information for wlan0: #IFNAME[4]="wlan0" # Use a different interface name nstead of # the default 'eth4' #HWADDR[4]="00:01:23:45:67:89" # Overrule the card's hardware MAC address #MTU[4]="" # The default MTU is 1500, but you might need # 1360 when you use NAT'ed IPSec traffic. #DHCP_KEEPRESOLV[4]="yes" # If you dont want /etc/resolv.conf overwritten #DHCP_KEEPNTP[4]="yes" # If you don't want ntp.conf overwritten #DHCP_KEEPGW[4]="yes" # If you don't want the DHCP server to change # your default gateway #DHCP_IPADDR[4]="" # Request a specific IP address from the DHCP # server #WLAN_ESSID[4]=DARKSTAR # Here, you can override _any_ parameter # defined in rc.wireless.conf, by prepending # 'WLAN_' to the parameter's name. Useful for # those with multiple wireless interfaces. #WLAN_IWPRIV[4]="AuthMode=WPAPSK EncrypType=TKIP WPAPSK=thekey TxRate=0" # Some drivers require a private ioctl to be # set through the iwpriv command. If more than # one is required, you can place them in the # IWPRIV parameter (space-separated, see the # example).
puis /etc/rc.d/rc.wireless.conf
# Wireless LAN adapter configuration # # Theory of operation : # # The script attempts to match a block of settings to the specific wireless # card inserted, the *first* block matching the card is used. # The address format is "hwaddr", with * as a wildcard. # 'hwaddr' is the unique MAC address identifier of the wireless card. # The MAC address is usually printed on the card, or can be found via ifconfig. # Some examples here use only half of the MAC address with a wildcard to # match a whole family of cards... # # All the Wireless specific configuration is done through the Wireless # Extensions, so we will just call 'iwconfig' with the right parameters # defined below. # Of course, you need to have iwconfig installled on your system. # To download iwconfig, or for more info on Wireless Extensions : # https://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html # # Note : you don't need to fill all parameters, leave them blank, in most # cases the driver will initialise itself with sane defaults values or # automatically figure out the value... And no drivers do support all # possible settings... # # -- This is a modified '/etc/pcmcia/wireless.opts' script -- # -- I added sections for Prism/GT and Atheros based cards -- # -- (supported by the prism54 and madwifi drivers) -- # -- 16/sep/2004 * Eric Hameleers -- # VERBOSE=1 case "$HWADDR" in ## NOTE : Comment out the following five lines to activate the samples below ... ## --------- START SECTION TO REMOVE ----------- ## Pick up any Access Point, should work on most 802.11 cards #*) # INFO="Any ESSID" # ESSID="any" # ;; ## ---------- END SECTION TO REMOVE ------------ # Here are a few examples with a few Wireless LANs supported... # The matching is done on the first 3 bytes of the MAC address # SMC2835W EZ Connect g 2.4GHz 54 Mbps Wireless Cardbus Adapter 00:04:E2:*) INFO="SMC2835W EZ Connect g 2.4GHz 54 Mbps Wireless Cardbus Adapter" # ESSID (extended network name) : My Network, any ESSID="any" # NWID/Domain (cell identifier) : 89AB, 100, off NWID="" # Operation mode : Ad-Hoc, Managed, Master, Repeater, Secondary, auto MODE="Managed" # Frequency or channel : 1, 2, 3 (channel) ; 2.422G, 2.46G (frequency) FREQ="" CHANNEL="7" # Sensitivity (cell size + roaming speed) : 1, 2, 3 ; -70 (dBm) SENS="" # Bit rate : auto, 1M, 11M,54M RATE="auto" # Encryption key : 4567-89AB-CD, s:password # Example for 40-bit encryption: #KEY="883e-aa67-21 [1] key 5501-d0da-87 [2] key 91f5-3368-6b [3] key 2d73-31b7-96 [4]" # Example for 104-bit encryption (aka 128-bit WEP): #KEY="d5ad2f05abd048ecf10b1c80c7" KEY="" # RTS threshold : off, 500 RTS="" # Fragmentation threshold : off, 1000 FRAG="" # Other iwconfig parameters : power off, ap 01:23:45:67:89:AB IWCONFIG="" # iwspy parameters : + 01:23:45:67:89:AB IWSPY="" # iwpriv parameters : set_port 2, set_histo 50 60 IWPRIV="" ;; # Multiband Atheros based 802.11a/b/g universal NIC cards 00:05:4E:*) INFO="Multiband Atheros based 802.11a/b/g universal NIC" # ESSID (extended network name) : My Network, any ESSID="" # Operation mode : Ad-Hoc, Managed, Master, Repeater, Secondary, auto MODE="Managed" # Frequency or channel : 1, 2, 3 (channel) ; 2.422G, 2.46G (frequency) FREQ="" CHANNEL="7" # Bit rate : auto, 1M, 11M,54M RATE="auto" # Encryption key : 4567-89AB-CD, s:password # Example for 40-bit encryption: #KEY="883e-aa67-21 [1] key 5501-d0da-87 [2] key 91f5-3368-6b [3] key 2d73-31b7-96 [4]" # Example for 104-bit encryption (aka 128-bit WEP): #KEY="d5ad2f05abd048ecf10b1c80c7" KEY="" # Other iwconfig parameters : power off, ap 01:23:45:67:89:AB IWCONFIG="" # iwspy parameters : + 01:23:45:67:89:AB IWSPY="" # iwpriv parameters : set_port 2, set_histo 50 60 IWPRIV="" ;; # Lucent Wavelan IEEE (+ Orinoco, RoamAbout and ELSA) # Note : wvlan_cs driver only, and version 1.0.4+ for encryption support 00:60:1D:*|00:02:2D:*) INFO="Wavelan IEEE example (Lucent default settings)" ESSID="Wavelan Network" MODE="Managed" #RATE="auto" KEY="s:secu1" # To set all four keys, use : #KEY="s:secu1 [1] key s:secu2 [2] key s:secu3 [3] key s:secu4 [4] key [1]" # For the RG 1000 Residential Gateway: The ESSID is the identifier on # the unit, and the default key is the last 5 digits of the same. #ESSID="084d70" #KEY="s:84d70" ;; # Cisco/Aironet 4800/3x0 # Note : MPL driver only (airo/airo_cs), version 1.3 or later 00:40:96:*|00:02:8A:*) INFO="Cisco/Aironet example (Cisco default settings)" ESSID="any" # To set all four ESSID, use iwconfig v21 and the same trick as above MODE="Managed" #RATE="11M auto" #KEY="d5ad2f05abd048ecf10b1c80c7" KEY="off" ;; # Samsung MagicLan (+ some other PrismII cards) # Note : Samsung binary library driver, version 1.20 or later 00:00:F0:*|00:02:78:*) INFO="Samsung MagicLan example (Samsung default settings)" ESSID="any" MODE="Managed" CHANNEL="4" RATE="auto" #KEY="883e-aa67-21 [1] key 5501-d0da-87 [2] key 91f5-3368-6b [3] key 2d73-31b7-96 [4]" #IWCONFIG="power on" ;; # Raytheon Raylink/WebGear Aviator2.4 # Note : doesn't work yet, please use for debugging only :-( 00:00:8F:*|00:00:F1:*) INFO="Raylink/Aviator2.4 example (Aviator default ad-hoc setting)" ESSID="ADHOC_ESSID" MODE="Ad-Hoc" RATE="auto" IWPRIV="set_framing 1" ;; # Old Lucent Wavelan 08:00:0E:*) INFO="Wavelan example (Lucent default settings)" NWID="0100" MODE="Ad-Hoc" FREQ="2.425G" KEY="off" ;; # Netwave (Xircom Netwave/Netwave Airsurfer) 00:80:C7:*) INFO="Netwave example (Netwave default settings)" NWID="100" KEY="00" ;; # Proxim RangeLan2/Symphony (what is the MAC address ???) XX:XX:XX:*) INFO="Proxim RangeLan2/Symphony example" NWID="0" MODE="Master" CHANNEL="15" IWPRIV="setsubchan 1" ;; # No Wires Needed Swallow 550 and 1100 setting (what is the MAC address ???) XX:XX:XX:*) INFO="NWN Swallow example" ESSID="session" KEY="0000-0000-00 open" ;; # Symbol Spectrum24 setting (what is the MAC address ???) XX:XX:XX:*) INFO="Symbol Spectrum24 example" ESSID="Essid string" ;; # Generic example (decribe all possible settings) *) INFO="Fill with your own settings..." # ESSID (extended network name) : My Network, any ESSID="<le nom du réseau>" # NWID/Domain (cell identifier) : 89AB, 100, off NWID="" # Operation mode : Ad-Hoc, Managed, Master, Repeater, Secondary, auto MODE="Managed" # Frequency or channel : 1, 2, 3 (channel) ; 2.422G, 2.46G (frequency) FREQ="" CHANNEL="" # Sensitivity (cell size + roaming speed) : 1, 2, 3 ; -70 (dBm) SENS="" # Bit rate : auto, 1M, 11M RATE="" # Encryption key : 4567-89AB-CD, s:password KEY="<ma clé WEP>" # RTS threshold : off, 500 RTS="" # Fragmentation threshold : off, 1000 FRAG="" # Other iwconfig parameters : power off, ap 01:23:45:67:89:AB IWCONFIG="" # iwspy parameters : + 01:23:45:67:89:AB IWSPY="" # iwpriv parameters : set_port 2, set_histo 50 60 IWPRIV="" ;; esac
sur le protable (et aussi sur le fixe), les dossiers /home et racine ne sont pas sur la même partition. il faut les mettre tous les deux dans /etc/exports (sur le portable)
# See exports(5) for a description. # This file contains a list of all directories exported to other computers. # It is used by rpc.nfsd and rpc.mountd. / 192.168.0.1(rw) /home 192.168.0.1(rw)
"192.168.0.1" est l'adresse IP de mon ordi fixe
voici les fichiers /etc/hosts, /etc/hosts.deny et /etc/hosts.allow
/etc/hosts
# # hosts This file describes a number of hostname-to-address # mappings for the TCP/IP subsystem. It is mostly # used at boot time, when no name servers are running. # On small systems, this file can be used instead of a # "named" name server. Just add the names, addresses # and any aliases to this file... # # By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1 # should NEVER be named with the name of the machine. It causes problems # for some (stupid) programs, irc and reputedly talk. :^) # # For loopbacking. 127.0.0.1 localhost 192.168.0.2 ordiport.linux.local ordiport 192.168.0.1 ordifixe.linux.local ordifixe # End of hosts.
/etc/hosts.deny
# # hosts.deny This file describes the names of the hosts which are # *not* allowed to use the local INET services, as decided # by the '/usr/sbin/tcpd' server. # # Version: @(#)/etc/hosts.deny 1.00 05/28/93 # # Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org # # ALL:ALL # End of hosts.deny.
/etc/hosts.allow
# # hosts.allow This file describes the names of the hosts which are # allowed to use the local INET services, as decided by # the '/usr/sbin/tcpd' server. # # Version: @(#)/etc/hosts.allow 1.00 05/28/93 # # Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org # # ALL:192.168.0.1 # End of hosts.allow.
lancer le réseau (sur les deux ordis):
$ su # /etc/rc.d/rc.inet1
sur le fixe:
$ su # mount 192.168.0.2:/ /mnt/nfs # mount 192.168.0.2:/home /mnt/nfs/home
et voilà, mon portable est un serveur de fichiers et je peux le sauvegarder sur bande sans avoir à y brancher le lecteur de bande, lequel est branché sur le fixe.
en bonus:
mes scripts de sauvegarde:
sauve:
#!/bin/sh # sauve, a backup script # Copyright (C) 2007 Mathieu SERPA # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # matser1973@free.fr list(){ IFS=$'\n'$'\r'$'\t' case "$1" in "-t") find /bin /boot /dev /etc /home /lib /opt /root /sbin /usr /var;; "-i") find /bin /boot /dev /etc /home /lib /opt /root /sbin /usr /var -daystart -mtime "$2";; *) echo usage: echo "sauve -t | -j nb_jours | -s nb_semaines" esac } sauve_incr1(){ case "$1" in 1) (list -i 7 && list -i 6 && list -i 5 && list -i 4 && list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 2) (list -i 14 && list -i 13 && list -i 12 && list -i 11 && list -i 10 && list -i 9 && list -i 8 && list -i 7 && list -i 6 && list -i 5 && list -i 4 && list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 3) (list -i 21 && list -i 20 && list -i 19 && list -i 18 && list -i 17 && list -i 16 && list -i 15 && list -i 14 && list -i 13 && list -i 12 && list -i 11 && list -i 10 && list -i 9 && list -i 8 && list -i 7 && list -i 6 && list -i 5 && list -i 4 && list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 4) (list -i 28 && list -i 27 && list -i 26 && list -i 25 && list -i 24 && list -i 23 && list -i 22 && list -i 21 && list -i 20 && list -i 19 && list -i 18 && list -i 17 && list -i 16 && list -i 15 && list -i 14 && list -i 13 && list -i 12 && list -i 11 && list -i 10 && list -i 9 && list -i 8 && list -i 7 && list -i 6 && list -i 5 && list -i 4 && list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; *) echo usage: echo "sauve -t | -j nb_jours | -s nb_semaines" esac } sauve_incr2(){ case "$1" in 1) (list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 2) (list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 3) (list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 4) (list -i 4 && list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 5) (list -i 5 && list -i 4 && list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 6) (list -i 6 && list -i 5 && list -i 4 && list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; *) echo usage: echo "sauve -t | -j nb_jours | -s nb_semaines" esac } case $1 in "-t")list -t|cpio -ovBH crc>/dev/st0;; "-s")sauve_incr1 $2;; "-j")sauve_incr2 $2;; *) echo usage: echo "sauve -t | -j nb_jours | -s nb_semaines" esac
sauve-remote:
#!/bin/sh # sauve-remote, a backup script # Copyright (C) 2007 Mathieu SERPA # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # matser1973@free.fr list(){ IFS=$'\n'$'\r'$'\t' SAVEDIR="$(pwd)" case "$1" in "-t") find /mnt/nfs/bin /mnt/nfs/boot /mnt/nfs/dev /mnt/nfs/etc /mnt/nfs/home /mnt/nfs/lib /mnt/nfs/opt /mnt/nfs/root /mnt/nfs/sbin /mnt/nfs/usr /mnt/nfs/var;; "-i") find /mnt/nfs/bin /mnt/nfs/boot /mnt/nfs/dev /mnt/nfs/etc /mnt/nfs/home /mnt/nfs/lib /mnt/nfs/opt /mnt/nfs/root /mnt/nfs/sbin /mnt/nfs/usr /mnt/nfs/var -daystart -mtime "$2";; *) echo usage: echo "sauve -t | -j nb_jours | -s nb_semaines" esac cd "$SAVEDIR" } sauve_incr1(){ case "$1" in 1) (list -i 7 && list -i 6 && list -i 5 && list -i 4 && list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 2) (list -i 14 && list -i 13 && list -i 12 && list -i 11 && list -i 10 && list -i 9 && list -i 8 && list -i 7 && list -i 6 && list -i 5 && list -i 4 && list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 3) (list -i 21 && list -i 20 && list -i 19 && list -i 18 && list -i 17 && list -i 16 && list -i 15 && list -i 14 && list -i 13 && list -i 12 && list -i 11 && list -i 10 && list -i 9 && list -i 8 && list -i 7 && list -i 6 && list -i 5 && list -i 4 && list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 4) (list -i 28 && list -i 27 && list -i 26 && list -i 25 && list -i 24 && list -i 23 && list -i 22 && list -i 21 && list -i 20 && list -i 19 && list -i 18 && list -i 17 && list -i 16 && list -i 15 && list -i 14 && list -i 13 && list -i 12 && list -i 11 && list -i 10 && list -i 9 && list -i 8 && list -i 7 && list -i 6 && list -i 5 && list -i 4 && list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; *) echo usage: echo "sauve -t | -j nb_jours | -s nb_semaines" esac } sauve_incr2(){ case "$1" in 1) (list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 2) (list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 3) (list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 4) (list -i 4 && list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 5) (list -i 5 && list -i 4 && list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; 6) (list -i 6 && list -i 5 && list -i 4 && list -i 3 && list -i 2 && list -i 1 && list -i 0)|cpio -ovBH crc>/dev/st0;; *) echo usage: echo "sauve -t | -j nb_jours | -s nb_semaines" esac } if [ "$(grep -i "192.168.0.2:/ " /etc/mtab)" != "192.168.0.2:/ /mnt/nfs nfs rw,addr=192.168.0.2 0 0" ]; then mount 192.168.0.2:/ /mnt/nfs fi if [ "$(grep -i "192.168.0.2:/home" /etc/mtab)" != "192.168.0.2:/home /mnt/nfs/home nfs rw,addr=192.168.0.2 0 0" ]; then mount 192.168.0.2:/home /mnt/nfs/home fi case $1 in "-t")list -t|cpio -ovBH crc>/dev/st0;; "-s")sauve_incr1 $2;; "-j")sauve_incr2 $2;; *) echo usage: echo "sauve-remote -t | -j nb_jours | -s nb_semaines" esac umount /mnt/nfs/home umount /mnt/nfs/