cupsd.conf

[~] sudo cat /etc/cups/cupsd.conf
#
# 25-10-09: update for works to cups 1.4.1-1
#           (remember to blacklist usblp module)
#
LogLevel info
SystemGroup printadmin root sys admin
# Allow remote access
Port 631
Listen /var/run/cups/cups.sock
# Enable printer sharing and shared printers.
Browsing On
BrowseOrder allow,deny
BrowseAllow all
BrowseRemoteProtocols CUPS
BrowseAddress @LOCAL
BrowseLocalProtocols CUPS
DefaultAuthType Basic
DefaultEncryption Never
<Location />
 # Allow shared printing and remote administration...
 Order allow,deny
 Allow @LOCAL
</Location>
<Location /admin>
 # Allow remote administration...
 Order allow,deny
 Allow @LOCAL
</Location>
<Location /admin/conf>
 AuthType None
 # Allow remote access to the configuration files...
 Order allow,deny
 Allow @LOCAL
</Location>
<Policy default>
 # Job-related operations must be done by the owner or an administrator...
 <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job CUPS-Move-Job>
 Require user @OWNER @SYSTEM
 Order deny,allow
 </Limit>
 # All administration operations require an administrator to authenticate...
 <Limit Pause-Printer Resume-Printer Set-Printer-Attributes Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After CUPS-Add-Printer CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default CUPS-Add-Device CUPS-Delete-Device>
 AuthType Default
 Require user @SYSTEM
 Order deny,allow
</Limit>
 # Only the owner or an administrator can cancel a job...
 <Limit Cancel-Job>
 Order deny,allow
 Require user @OWNER @SYSTEM
 </Limit>
 <Limit All>
 Order deny,allow
 </Limit>
</Policy>

smb.conf per stampante condivisa

[~] cat /etc/samba/smb.conf       

[global]
allow hosts = 192.168.0.2/7
security = share
workgroup = MSHOME
server string = marinz@muletto.it
printcap name = cups
printing = cups
load printers = yes

[banca_dati]
    path=/media/banca_dati
    available=yes
    browsable=yes
    public=yes
    writable=yes
    guest ok=yes

[printers]
    comment = lexmark
    path = /var/spool/samba
    available=yes
    public=yes
    browseable = yes
    guest ok = yes
    writable = yes
    printable = yes

[LEXMARK]
    comment = Lexmark X1110
    printer=lexmarkX1110
    path = /var/spool/samba
    available=yes
    public=yes
    printing = cups
    printable = yes
    user client driver = yes
    guest ok = yes
    writable = yes

 

Commenti

  • Ho spostato la stampante sul muletto che è acceso tutto il giorno, in questo modo posso stampare anche dal portatile da dove voglio tramite la wireless.
  • Cups è semplicemente stupendo: nei client è sufficiente avviare il servizio, che pensa a tutto lui, perchè autorileva e autoaggiunge le stampanti che trova condivise :)
  • Samba molto meno: me la sono cavata con la configurazione sopra, e occorre anche installare il driver di stampa nei client win$

pinga.sh

Ho scritto questo script: in pratica, tenta di spedire ad ogni minuto (l’ho inserito nel crontab) un pacchetto di ping verso gli IP di una lan (contenuti in un file): se nessun pc risponde (ipotizzo che tutti i pc siano spenti), esegue un’azione, mentre se anche uno solo risponde (e quindi è acceso), ne esegue un’altra.

—–

Nel mio specifico, ho messo questo script nel muletto, perchè in questo periodo lo sto usando per scaricare dei torrent.

Come sapete, i torrent si scaricano velocemente, quindi se non avete una adsl veloce, è molto probabile che si saturi la banda.

Nel mio caso, ho una adsl minimale (640/256), un router che la gestisce, e 2 pc collegati in lan.

Quando il muletto è attivo, la navigazione da quei pc è molto problematica, se non impossibile.

Se sono in casa, non ci sono problemi: mi collego velocemente al server e disattivo il processo rtorrent. E se non ci sono?? Ecco allora l’idea dello script.

In questo modo, il muletto in pratica “si arrangia”: se qualcuno accende un pc, arresta il download (nel mio caso, esegue uno script che ho chiamato stop) , e solo quando tutti i pc sono spenti, lo riprende eseguendo go.

Semplice ma molto, molto comodo :-)

Trovate i file nella sezione “Backup“.

how to: rtorrent con screen e ssh

Link:

  1. Configurazione host remoto:
    1. yaourt -S rtorrent screen
    2. cp /etc/screenrc ~/.screenrc
    3. nano .screenrc
      .....
      .....
      screen -t rtorrent rtorrent # rtorrent always start with screen
    4. [~] nano .rtorrent.rc
      
      # Maximum and minimum number of peers to connect to per torrent.
      #min_peers = 40
      max_peers = 250
      
      # Same as above but for seeding completed torrents (-1 = same as downloading)
      #min_peers_seed = 10
      max_peers_seed = 250
      
      # Maximum number of simultanious uploads per torrent.
      #max_uploads = 8
      
      # Global upload and download rate in KiB. "0" for unlimited.
      download_rate = 0
      upload_rate = 10
      
      # Default directory to save the downloaded torrents.
      directory = /media/banca_dati/torrent
      
      # Default session directory. Make sure you don't run multiple instance
      # of rtorrent using the same session directory. Perhaps using a
      # relative path?
      session = /media/banca_dati/torrent/in_download_torrent
      
      # Watch a directory for new torrents, and stop those that have been
      # deleted.
      #schedule = watch_directory,5,5,load_start=./watch/*.torrent
      #schedule = untied_directory,5,5,stop_untied=
      schedule = watch_directory,10,10,load_start=/media/banca_dati/watch_torrent/*.torrent
      schedule = untied_directory,5,5,"remove_untied="
      #schedule = tied_directory,5,5,start_tied=
      schedule = low_diskspace,60,60,"close_low_diskspace=100M"
      
      # Port range to use for listening.
      port_range = 17594-17594
      
      # Start opening ports at a random position within the port range.
      #port_random = no
      
      # Check hash for finished torrents. Might be usefull until the bug is
      # fixed that causes lack of diskspace not to be properly reported.
      check_hash = yes
      
      # Set whetever the client should try to connect to UDP trackers.
      #use_udp_trackers = yes
      
      # Encryption options, set to none (default) or any combination of the following:
      # allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
      #
      # The example value allows incoming encrypted connections, starts unencrypted
      # outgoing connections but retries with encryption if they fail, preferring
      # plaintext to RC4 encryption after the encrypted handshake
      #
      #encryption = allow_incoming,enable_retry,prefer_plaintext
      encryption = allow_incoming,try_outgoing,enable_retry
      
      # Enable DHT support for trackerless torrents or when all trackers are down.
      # May be set to "disable" (completely disable DHT), "off" (do not start DHT),
      # "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
      # The default is "off". For DHT to work, a session directory must be defined.
      #
      # dht = auto
      
      # UDP port to use for DHT.
      #
      # dht_port = 6881
      
      # Enable peer exchange (for torrents not marked private)
      #
      # peer_exchange = yes
      
      #
      # Do not modify the following parameters unless you know what you're doing.
      #
      
      # Hash read-ahead controls how many MB to request the kernel to read
      # ahead. If the value is too low the disk may not be fully utilized,
      # while if too high the kernel might not be able to keep the read
      # pages in memory thus end up trashing.
      #hash_read_ahead = 10
      
      # Interval between attempts to check the hash, in milliseconds.
      #hash_interval = 100
      
      # Number of attempts to check the hash while using the mincore status,
      # before forcing. Overworked systems might need lower values to get a
      # decent hash checking rate.
      #hash_max_tries = 10
      
      on_finished = rm_torrent,"execute=rm,$d.get_tied_to_file="
      on_finished = move_complete,"execute=mv,-u,$d.get_base_path=,/media/banca_dati/torrent/Completati/ ;d.set_directory=/media/banca_dati/rtorrent/Completati/"
      [~]
    5. [~] nano /etc/rc.d/rtorrent
      #!/bin/bash
      
      . /etc/rc.conf
      . /etc/rc.d/functions
      
      case "$1" in
        start)
          stat_busy "Starting rtorrent"
          su <utente linux> -c 'screen -d -m rtorrent' &> /dev/null
          if [ $? -gt 0 ]; then
            stat_fail
          else
            add_daemon rtorrent
            stat_done
          fi
          ;;
        stop)
          stat_busy "Stopping rtorrent"
          killall -w -s 2 /usr/bin/rtorrent &> /dev/null
          if [ $? -gt 0 ]; then
            stat_fail
          else
            rm_daemon rtorrent
            stat_done
          fi
          ;;
        restart)
          $0 stop
          sleep 1
          $0 start
          ;;
        *)
          echo "usage: $0 {start|stop|restart}"
      esac
      exit 0
      
      [~]
  2. Avvio:
    1. Host remoto (tramite ssh):
      1. [~] nano rtorrentqueuemanager.py
        #!/usr/bin/env python
        
        import glob
        import stat
        import os
        import shutil
        import time
        
        #change the parametes
        watch = "/media/banca_dati/watch_torrent"
        session = "/media/banca_dati/torrent/in_download_torrent"
        queue = "/media/banca_dati/torrent/coda_torrent"
        max_downloads = 1
        
        while True:
            time.sleep(60)
            sfiles = glob.glob(session + "/*.torrent")
            oldesttime = 0
            oldestfile = ""
            if len(sfiles) < max_downloads :
                qfiles = glob.glob(queue + "/*.torrent")
                for i in qfiles :
                    ftime = os.stat(i)[stat.ST_MTIME]
                    if oldesttime == 0 or ftime < oldesttime :
                        oldesttime = ftime
                        oldestfile = i
                if oldestfile != "" :
                    shutil.move(oldestfile, watch)
        
        [~]
      2. sudo /etc/rc.d/rtorrent start
      3. sudo python rtorrentqueuemanager.py &
    2. host locale:
      1. echo "ssh -p <porta> -t <utente>@<IP> 'screen -r'" > rtorrent_connetti.sh
      2. nano .bashrc
        .....
        # control+s con screen e rtorrent:
        # http://libtorrent.rakshasa.no/wiki/RTorrentUserGuide#Addingandremovingtorrents
        #
        stty stop undef
        stty start undef
        .....
        .....
        
      3. bash rtorrent_connetti.sh

il mio muletto

Sono riuscito a reperire un vecchio pc (dato per finito :-) ) con queste caratteristiche:

  • hdd 30 gb
  • 512 mb ram
  • cpu amd athlon xp

Sono andato a vedere i consumi, la cpu succhia tra i 35 e 45w, lasciando inconfigurati audio e video e facendolo partire in init3 i consumi dovrebbero rimanere bassi (spero).

Non sto qui a scrivere il classico how-to perchè sarebbe un copia e incolla delle (davvero ottime) guide del wiki, preferisco invece scrivere 2 righe su come l’ho configurato.

  • ho creato 3 partizioni, le classiche /, /home e /media/dati, tutte in ext4;
  • /var/log e /tmp montati in ram con tmpfs;
  • ssh per il controllo remoto e manutenzione, è comodissimo, riesco a far tutto, riavviare, spegnere (sarebbe interessante riuscire anche ad accenderlo :-) ), anche lanciare applicazioni grafiche tramite il forwarding di X;
  • yacpi per monitorare  temperatura e frequenza della cpu;
  • amuled e amulegui configurati ad hoc;
  • rtorrent per i torrent, seguendo il wiki l’ho configurato come demone e da remoto riesco a gestirlo e a vedere lo stato dei download; ho anche scritto questo mini how-to;
  • samba e nfs4 per lo sharing delle directory;
  • nella notte mi scarica i pacchetti di aggiornamento (anche degli altri pc),
    crontab -l
    .....
    01 00 * * * pacman -Syuw --noconfirm
    01 05 * * * pacman -Syuw --noconfirm -b /media/dati/database_pacman_aspire/
    * * * * * /bin/bash /home/marinz/battery_script.sh
    00 06 * * * /bin/bash /home/marinz/inf_me.sh
    * * * * * /bin/bash /home/marinz/pinga.sh
  • frequenza della cpu settata al minimo.

Per ora non mi viene in mente nient’altro.

Non ho trovato grossi problemi, le guide sul wiki sono davvero complete e scritte bene, anzi penso d’aver perso più tempo ad aspettare il download dei pacchetti che non a configurare il sistema.

Se avete suggerimenti non esitate a commentare.

Si potrebbe anche aprire un topic sul forum con le caratteristiche dei muletti degli arcieri :-D

Last update: 8/07/09

Configurazione di un server ftp: vsftpd

Per prima cosa installiamo il pacchetto con pacman:

pacman -S vsftpd

una volta installato occorre modificare il file di configurazione /etc/vsftpd.conf, ad esempio in questo modo (qui trovate la guida completa delle funzioni disponibili):


anonymous_enable=NO
anon_upload_enable=NO
anon_mkdir_write_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
log_ftp_protocol=YES
xferlog_file=/var/log/vsftpd.log
#xferlog_std_format=YES
ascii_upload_enable=YES
ascii_download_enable=YES
ls_recurse_enable=NO
listen_port=21
connect_from_port_20=NO
listen=YES
background=YES
# definiamo una chroot() jail
chroot_local_user=YES
check_shell=NO
userlist_deny=NO
userlist_enable=YES
userlist_file=/etc/vsftpd.user_list
local_max_rate=20000
max_clients=3
banner_file=/etc/welcome.banner
#SSL:
#ssl_enable=YES
#ssl_tlsv1=YES
#force_local_data_ssl=NO
#force_local_logins_ssl=YES
#rsa_cert_file=/usr/share/ssl/certs/vsfpd.pem
#ssl_sslv2=NO
#ssl_sslv3=NO
#allow_anon_ssl=NO

Nell’esempio sopra viene consentito l’accesso solamente agli utenti presenti nel file /etc/vsftpd.user_list (in questo caso “utente”):

cat /etc/vsftpd.user_list:
utente

Gli utenti definiti in quel file ovviamente devono essere anche utenti del sistema, quindi ad esempio per creare un nuovo utente “utente” possiamo usare lo script adduser e nel campo “Home directory [ /home/fg ]” possiamo mettere ad esempio come percorso una directory che chiameremo ftp nella nostra partizione dati, così da non avere problemi con lo spazio su disco (il percorso di default sarebbe infatti /srv/ftp).
Una volta creato utente e directory, creiamo dentro a “ftp” una cartella “utente” con i seguenti permessi:

chmod -R 775 .../utente
chown utente .../utente
chgrp users .../utente

modifichiamo /etc/hosts.allow:

#
# /etc/hosts.allow
#

vsftpd: ALL

ed infine, dopo aver aperto la porta sul firewall o configurato a dovere il router, lanciamo il demone:

/etc/rc.d/vsftpd start

Se tutto è andato a buon fine ci si dovrebbe riuscire a connettere anche da firefox con l’indirizzo nella forma ftp://utente@IP.
Se invece per qualche ragione il server non dovesse partire, per capire il tipo di errore (che comunque per esperienza vi dico che al 99% è nel file di configurazione) consiglio di eseguirlo con il classico /usr/sbin/vsftpd