mycroes

There's always time to play

Friday, September 14, 2012

Provisioning HP printers

At the office we recently added another printer and since we mostly use HP printers I was looking for some way to ease configuration. Although HP network printers usually have telnet available, there is an easier way to supply a default configuration to all your printers, which will also serve as a single source for configuration setting updates. HP printers support getting a configuration file using TFTP. Telling the printer what file it should get is a matter of properly configuring DHCP. The following excerpt from my dhcpd.conf shows configuration for a single device:
host sales.print.domain.tld {
    hardware ethernet 00:11:22:33:44:55;
    option extensions-path "hp.conf";
}
You can combine this with other statements to provide a hostname to the printer as well and to give the printer a fixed IP or registering it's name in DNS. Although (some) HP printers should support a different server address for the TFTP server, I haven't been able to get that working, so I just set up tftpd-hpa on my DHCP-server. The contents of the configuration file are really simple, you can set the same settings as you can set using telnet, and there's an export command in the telnet service that will output the current settings in a way that it can be used as a configuration file. But here's a short example that shows how to disable some services:
slp-config      0
bonjour-config  0
ipx-config      0
appletalk       0
I used tabs for seperation of keys and values, but it should work with spaces as well. Just run export on your device to get a complete overview of all the settings to change. Now when your next new printer arrives, it's just a matter of adding the host to DHCP and you're done.

Tuesday, September 4, 2012

Run backup job with specified pool in Bacula

Unfortunately the run command in Bacula only has a few options, so it's not possible to actually pass a pool to the run command right away. However, there's a decent alternative, by performing the mod action automatically. The only thing to do is to find the menu entry for the pool you want:
$ echo -e "run job=Mack level=Full\nmod\n8\n." | sudo bconsole
Connecting to Director localhost:9101
1000 OK: mijlweg-dir Version: 5.0.3 (04 August 2010)
Enter a period to cancel a command.
run job=Mack level=Full
Using Catalog "MyCatalog"
Run Backup job
JobName:  Mack
Level:    Full
Client:   mijlweg-fd
FileSet:  Mack
Pool:     Default (From Job resource)
Storage:  LTO-5 (From Job resource)
When:     2012-09-04 22:14:04
Priority: 10
OK to run? (yes/mod/no): mod
Parameters to modify:
     1: Level
     2: Storage
     3: Job
     4: FileSet
     5: Client
     6: When
     7: Priority
     8: Pool
     9: Plugin Options
Select parameter to modify (1-9): 8
The defined Pool resources are:
     1: Default
     2: Monthly
     3: Ghost
Select Pool resource (1-3): .
Selection aborted, nothing done.
Job not run.
$ 
Don't assume the numbers here are equal to what you have, but actually run this command with a valid job identifier (I used Mack in the example). After that, make a small change to command to run the backup job:
$ echo -e "run job=Mack level=Full\nmod\n8\n2\nyes" | sudo bconsole
Connecting to Director localhost:9101
1000 OK: mijlweg-dir Version: 5.0.3 (04 August 2010)
Enter a period to cancel a command.
run job=Mack level=Full
Using Catalog "MyCatalog"
Run Backup job
JobName:  Mack
Level:    Full
Client:   mijlweg-fd
FileSet:  Mack
Pool:     Default (From Job resource)
Storage:  LTO-5 (From Job resource)
When:     2012-09-04 22:20:29
Priority: 10
OK to run? (yes/mod/no): mod
Parameters to modify:
     1: Level
     2: Storage
     3: Job
     4: FileSet
     5: Client
     6: When
     7: Priority
     8: Pool
     9: Plugin Options
Select parameter to modify (1-9): 8
The defined Pool resources are:
     1: Default
     2: Monthly
     3: Ghost
Select Pool resource (1-3): 2
Run Backup job
JobName:  Mack
Level:    Full
Client:   mijlweg-fd
FileSet:  Mack
Pool:     Monthly (From User input)
Storage:  LTO-5 (From Job resource)
When:     2012-09-04 22:20:29
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=12660
$ 
And there you go, backup running with specified pool!