beta 296.1

The following changes have been made to a beta 296.1
* cron/crontab have been installed in the busybox
* I removed a number of useless busybox commands (saves flash)
* Start only 1 kloned prefork child (saves memory)

To update to the beta

# /etc_ro_fs/update-dev hah-beta.dbzoo.com

Member for

16 years 10 months

brett

14 years 12 months ago

So here is some food for thought we can create scripts that allow some level of BSC control and their behaviour can be adjusted using parameters.  This make a nice neat control interface.

We will create a scripts call "bsc" and put this in the /etc/cron directory - don't forget to chmod a+x this!

#!/usr/bin/lua

local args = require("pl.lapp") [[
  Various flags and option types
    -t (string)      xAPBSC Target
    -s (default on)  xAPBSC State
    -x               xAPBSC Text
]]
require("xap")

if args.t == false then
  print("Missing target")
  os.exit()
end

xap.init("dbzoo.livebox.cron","FF123400")
cmd = string.format([[
xap-header
{
class=xAPBSC.cmd
target=%s
}
output.state.1
{
id=*
]],args.t)

if args.s then
  cmd = cmd .. "state="..args.s .. "\n"
else
  cmd = cmd .. "state=on\n"
end

if args.x then
  cmd = cmd .. "text="..args.x.."\n"
end
cmd = cmd .. "}"

xap.sendShort(cmd)

 

NOW back to the crontab to crontrol some lights connected via the crontab we can do this

0 17 * * * /etc/cron/bsc -t dbzoo.livebox.controller:relay.1 -s on
0 21 * * * /etc/cron/bsc -t dbzoo.livebox.controller:relay.1 -s off

This will turn the lights on at 5pm every day and then off again at 9pm.

Again this is just me thinking out loud pipe up if you have other ideas but this is shaping up to be pretty flexible in my opinion. Albiet you need to write some code but hey that is what make is flexible.  I'll work on some nice control scripts I can supply in my next beta drop.

Brett

edit: fixed crontab entry I had them turning on at 17min past the hour and off again at 21min past.  Fine if you want disco lights to attract Santa.

Member for

16 years 10 months

brett

14 years 12 months ago

So I was thinking about crontab and the fact that I always sleep my computer when I'm done for the day.  With this entry on the HAH I can use the Wake-on-lan facility to make sure my work machine is always ready for me at 7am monday-friday.  note: requires beta 296.1 and cron setup.

# crontab -l
0 7 * * 1-5 ether-wake -i br0 3c:d9:2b:5b:67:c2
#

I'll let you know tomorrow if that worked :)

Member for

16 years 5 months

BoxingOrange

14 years 12 months ago

Here's a first stab at writing a script to use with the new cron functionality that will backup some files.

Create a file in /etc/cron and paste this into it, ie /etc/cron/hahbackup :-

 

#Create a backup file called /tmp/hahbackup.tar.gz
cd /
tar cvf - /etc/xap-livebox.ini /etc/passwd /etc/plugboard /etc/cron | gzip -9c > /tmp/hahbackup.tar.gz

Then chmod a+x /etc/cron/hahbackup, this makes it executable.

 

Edit your crontab, crontab -e, to run the script every day at 1am, * 1 * * 0-6 /etc/cron/hahbackup

To get all of the files out type :-

cd /
gunzip /tmp/hahbackup.tar.gz
tar xvf /tmp/hahbackup.tar

Or to get individual files :-

cd /
gunzip /tmp/hahbackup.tar.gz
tar xvf /tmp/hahbackup.tar <filename>

i.e. to restore your /etc/xap-livebox.ini file

cd /
gunzip /tmp/hahbackup.tar.gz
tar xvf /tmp/hahbackup.tar etc/xap-livebox.ini

Hope this helps, It's almost what Dean asked for in another post, you can obviously add any files that you think are important, and I'm sure Brett will have some constructive criticism.  Remember to keep the backup file somewhere safe.

Member for

16 years 10 months

brett

14 years 12 months ago

I'm afraid your crontab entry will run the backup every 1 minute from the hours 1am to 1:59am.

* 1 * * 0-6 /etc/cron/hahbackup

You need to use this

0 1 * * * /etc/cron/hahbackup

Brett

Member for

16 years 5 months

BoxingOrange

14 years 12 months ago

I knew there'd be something, I was thinking wrong place to store the backup file or something like that though.  

Member for

16 years 10 months

brett

14 years 12 months ago

Well if you want to get pedantic I can find more

cd /
gunzip /tmp/hahbackup.tar.gz
tar xvf /tmp/hahbackup.tar

All this can be done in one line and you don't have to uncompress to a temporary file first.

cd / && gzip -dc /tmp/hahbackup.tar.gz | tar -xvf -

I didnt test this.

Member for

16 years 5 months

BoxingOrange

14 years 12 months ago

That's great thanks, I'll give it a go.  Just using your e-mail script to get the HAH to send an e-mail when it's done :)