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>

cups 426 update required

Con cups avevo il fastidioso problema che se provavo a gestire la stampante da remoto, mi si presentava prima la pagina html:

cups “426 update required” redirect…

e poi il processo di cups si bloccava brutalmente, tanto che per killarlo dovevo usare kill -9 pid.

Stamattina mi son rotto e, indagando meglio, ho scoperto che bastava commentare l’opzione Encryption required e aggiungere l’opzione DefaultEncryption Never :

[~] sudo cat /etc/cups/cupsd.conf
.....
.....
DefaultEncryption Never   # --> add this!
<Location /admin>
#  Encryption Required    # --> Comment here
 Order allow,deny
.....
.....
 </Location>

Non è proprio una soluzione pulita ma nel mio caso va più che bene perchè gestisco tutto da rete locale.

Update 25/10/09 : aggiunta l’opzione DefaultEncryption Never

rtorrent scaricare alcuni file di un torrent

  • entriamo in rtorrent
  • selezioniamo il file in download, e premiamo il tasto freccia destra
  • Andiamo sul menu File list e ancora freccia destra
  • selezioniamo il/i file che non vogliamo scaricare, e premiamo per ognuno la barra fino a quando la priorità non si setta su off

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