Saturday, 28 July 2018

  A Local Devuan Package Mirror

 (( with Xinetd and approx ))


  Verbose Version


A shorter simpler version is also available (one post earlier).

About the packages:

===================

------

approx

------

Description::

  A caching proxy server for Debian archive files

    - Package: approx
    - Version: 5.10-1
    - Installed-Size: 4709
    - Maintainer: Eric Cooper
    - Architecture: i386
    - Depends: libc6 (>= 2.17), libpcre3, adduser,
    bzip2, curl, rsyslog | system-log-daemon, xz-utils

Homepage: http://git.debian.org/?p=pkg-ocaml-maint/packages/approx.git

Tags::
     admin::package-management, implemented-in::ocaml,
     interface::daemon,  network::server,
     protocol::http, suite::debian,
     use::downloading, use::proxying

Section::  admin
Size::     1024368
Filename:: pool/DEBIAN/main/a/approx/approx_5.10-1_i386.deb

------

xinetd

------

A daemon for services.

*Xinetd* is a more extensible, flexible, backwardly compatible
replacement for the classic inetd super-server.

Essentially it stands in front of daemons/services and brokers access and
system resource allocations.

Inetd is (still) a viable alternative and please note that
in use Xinetd will accommodate inetd config files .
(we are not doing that here though)

Package: xinetd
Description ::
 
  replacement for inetd with many enhancements

Version::   1:2.3.15.3-1
Maintainer: Salvo 'LtWorf' Tomaselli
Homepage: https://github.com/openSUSE/xinetd
Architecture:: i386

Recommends ::

  rsyslog | system-log-daemon, logrotate, update-inetd

Tags ::

  interface::daemon, network::server, network::service, role::program

Section:: net

Filename:: pool/DEBIAN/main/x/xinetd/xinetd_2.3.15.3-1_i386.deb

Size: 140624

Installation


Is as easy as ::

  $ sudo apt-get install approx xinetd


Configuration


For practical uses there are three parts to this process.

1. configure approx_
   Approx provides the engine fo the caching service
   - /etc/approx/approx.conf
    
2. configure xinetd_
   xinetd makes the service available.
  
   - create /etc/xinetd.d/approx
   - tweak /etc/services_ (optional)
   - tweak /etc/networks_ (optional)

3. configure clients apt_


  
---------

1 Approx_

---------


::
   ~$ apropos approx
   approx (8)           - proxy server for Debian archive files
   approx-import (8)    - copy local .deb files into the approx cache
   approx.conf (5)      - configuration file for approx proxy server


file /etc/approx/approx.conf


approx.conf is the primary configuration file for the
location and structure of the package cache.


The first line is by far the most important.
The others are examples or defaults.

::

   ## /etc/approx/approx.conf
  
   devuan     http://deb.devuan.org/merged

   #vivaldi   http://repo.vivaldi.com/stable/deb
   #spotify   http://repository.spotify.com
   #naibed    http://mirror.internode.on.net/pub/debian
   #ubuntu    http://mirror.internode.on.net/pub/ubuntu
  
  
   # The following are the default parameter values, so there is
   # no need to uncomment them unless you want a different value.
   # See approx.conf(5) for details.

   ## set the port number in  /etc/xinetd.d/approx ##

   #$cache              /var/cache/approx
   #$interval   60
   #$max_rate   unlimited
   #$max_redirects 5
   #$user               approx
   #$group              approx
   #$syslog     daemon
   #$pdiffs     true
   #$offline    false
   #$max_wait   10
   #$curl_path  /usr/bin/curl
   #$verbose    false
   #$debug              false

   # end of working example

That's it really.
see: man approx.conf


    The single active line in the above example has implications.
    The others are examples of using approx to
    *also* mirror other distros or repositories.

So to *break this down* a little more.

::

   devuan     http://deb.devuan.org/merged


When approx receives a request with _devuan_ as the final path of the URI it

* acts as a proxy
* and caches the requested .deb packages
  under a file tree starting at::
     
    /var/cache/approx/devuan

To produce that request, the following pattern is followed in your sources.list(s)


**deb http://REMOTE.URL/devuan stable main contrib non-free**

(or deb-src)
 
This also facilitates hosting other *deb* based distributions
or smaller repositories.

So using the above #disabled examples,
requests for ubuntu or Debian would be cached under their own trees.

e.g. ::
 
  /var/cache/approx/ubuntu
  /var/cache/approx/vivaldi
  /var/cache/approx/naibed

 
Cache Note:
...........

These identifiers may be any simple unique string.
e.g. ::

  naibed
debian drawkcab
I haven't fully tested / studied / hacked or used the approx-import tool. It will, with some understandable bastardly efficiency write over any /var/cache/approx/debian (or even DEBIAN) pool ... your Thesis etal So we are avoiding that by calling debian naibed ... this should be transparent to your users of course.
---------

2 Xinetd_

---------


man pages ::

  ~$ apropos xinetd
  xinetd (8)      - the extended Internet services daemon
  xinetd.conf (5) - Extended Internet Services Daemon configuration file
  xinetd.log (5)  - xinetd service log format
  itox (8)        - converts inetd.conf style configuration files to xinet...
  xconv.pl (8)    - inetd.conf to xinetd.conf converter
 


note
....

*You should not need to manually evoke itox or xconv.pl
unless you are moving away from inetd (classic).
Xinetd seems to cope quite well without human conversion
but you may find otherwise .*



configuration
-------------


The default /etc/xinitd.conf does little other than point to an include directory. It is in that directory that we will describe the network service for approx.

xinitd.d/approx
---------------

Create the configuration at /etc/xinetd.d/approx .

The example_ file will need adjustment to these at least:

-  bind =  10.1.1.10  an address *available on the server*
   and *visible from the rest your Local Area Network*.
   
-  only_from = 10.0.0.0/8  to allow access from *your networks*.
   hint ::

     ip r
  
     ip r | awk '{print $1}'
            (or)
     ip r | cut -d " " -f 1
        
- set "port = 9999"  to another if you need or want to. 
- see /etc/services_ and /etc/networks_ below for some convienient alternatives.

approx starts and stops with its own user and group; approx .
These  were set up when installed.
     

example_
--------

::
  
   ## /etc/xinitd.d/approx  -*- conf -*-
   ## description: approx is a caching Debian package proxy


   service approx
   {
   id           = approx
   disable      = no
   only_from    = 127.0.0.1/8 10.1.1.1/8
   protocol     = tcp
   socket_type  = stream
   wait         = no
   bind         = 10.1.1.10   
   port         = 9999
   user         = approx
   server       = /usr/sbin/approx
   #    server_args  = ""
   #    cps                 = 30
   #    instances   = 20
   #    per_source  = 10
   #    max_load    = 3.0
   #    nice        = 12
   #    log_type     = FILE /var/log/approx-xinetd.log
   #    log_on_success = HOST DURATION
   #    log_on_failure = HOST USERID

   }
  
see more at::
 
  /usr/share/doc/xinetd/examples/empty.conf and sample.conf.gz (zless)
  /usr/share/doc/approx/examples/approx.xinetd
 

services
........

Optionally you may add an entry to /etc/services
e.g.

::
   approx          9999/tcp       # approx deb package proxy

xinitd and other applications will use this entry if there is no other configuration option set.

  
networks
........


Optional and convenience for netstat and xinetd reports.

::

   default         0.0.0.0
   loopback        127.0.0.0
   link-local      169.254.0.0
   MYLAN           10.0.0.0
   OTHERLAN        172.16.0.0

This file is accessed (read) by many tools, mostly for reporting network spans in text format. Xinitd will search this file for network names if given. In particular ::

  only_from    = 127.0.0.1/8 10.1.1.0/8 172.16.0.0

may be written as ::
 
  only_from  = loopback MYLAN OTHERLAN

see: man xinetd.conf
------------------------

3. Clients Configuration

------------------------

apt

...

All that needs attention on the clients is to set up

/etc/sources.list or /etc/sources.list.d/files.list
::
  
   deb http://10.1.1.10:9999/devuan stable main contrib non-free
   deb-src http://10.1.1.10:9999/devuan stable main contrib non-free

It is also possible to set a proxy under /etc/apt/apt.conf.d/
and use standard sources.lists. This is particulaly useful for mobile devices.
However it does mean you have to be carefull to keep the final URI path unique.

e.g.
Create a file under /etc/apt/apt.conf.d/
say 00-homelan-proxy or 00-package-proxy

The contents should be adjusted to match your network but approximately ::

  // /etc/apt/apt.conf.d/00-package-proxy
  // use this proxy when at home
  Aquire::http::proxy "http://10.1.1.10:9999";
  // use this at Bilbo Baggins's
  // Acquire::http::proxy "http://cacher.bilbonet:3128";
  // Only one enabled please.
 


address resolution
..................


/etc/hosts may or may not be convenient.
::
  
   127.0.0.1    localhost
   10.1.1.10    cache.mynet cache


A Local Deb Package Mirror

     (( with Devuan xinetd and approx ))


There are a number of ways to build a shareable "mirroring cache" of packages on a non public Network. This saves bandwidth, time, and possibly enables disconnected use with some small tweaks.
This post is a shorter description of one possible process. There is a longer even more verbose version one post later.

e.g. These proxies all scale to small enterprise level at least.
I have used them all successfully at some time or other.

  * squid-deb-proxy - Squid proxy configuration to optimise package downloads
  * apt-cacher-ng - caching proxy server for software repositories
  * approx - caching proxy server for Debian archive files


The squid approach (? probably ?) supports multiple connections better than the last two. Though thats just a guess, for more industrial uses its worth at least a look. It works OK on a home LAN but not on any machine you reboot a lot.
Waiting for squid to shutdown can get "old" quite quickly.


This Walk through documents setting up a HTTP based proxy using
*approx_ and xinetd_*.

Features of this approach include:

  - Reliable and _low_ maintenance
  - Small and light enough for home use
  - efficient enough for enterprise level deployment.
    Should scale up to 100's of LAN clients including virtual systems.
    (depends on hardware and bandwidth)

  - Tunable access by network space or whitelist
    and optionally time of day. (xinetd)
    (No need to worry your iptables or other filtering.)
  - Tunable system loads and concurrency.  (xinetd)
   
  - A simply structured *pool based mirror*  under /var/cache/approx  (default).
  - Readily and cleanly supports other Debian type systems
    and 3rd party repositories
 
  - Low standby resource demand (xinetd)
  - Fast start up and shut down. (xinetd)

  - Logs flexibly. To file or syslog. ( approx and / or xinetd )

The downsides are:
  - editing the clients sources.list . (though there are options around that even)
  - setting up xinetd the first time may be an issue. 
  - this is not a simple apt-get install  and walk away.
_You_ will have to create at least one new file and edit all your clients sources.lists.

However its really not difficult take your time and test as you go.

The Shortest Version

root@yours~# apt-get install xinetd approx

The Short Version

Adjust values to suit network(s) and remote repositories.

root@yours~# apt-get install xinetd approx

 1. edit the servers
/etc/approx/approx.conf
::
    devuan http://deb.devuan.org/merged



 2. edit a clients sources.list. e.g.
/etc/apt/sources.list.d/01-stable.list
    (? disable the rest while you test ?)
    *The client can be the same machine as the server.*
   
 ::
    deb http://10.1.1.10:9999/devuan stable  main contrib non-free

 3. create xinetd approx service file at
/etc/xinetd.d/approx
   
 ::
    # /etc/xinetd.d/approx
    service approx
    {
    id           = approx
    disable      = no
    bind         = 10.1.1.10   
    port         = 9999
    only_from    = 127.0.0.1/8 10.1.1.1/8
    protocol     = tcp
    socket_type  = stream
    wait         = no
    user         = approx
    server       = /usr/sbin/approx
    }

4. Restart xinetd

::
   root@yours~#  /etc/init.d/xinetd  restart

   (or)

   root@yours~#  service xinetd restart

check xinetd has enabled your new service ::

    you@yours~$  netstat -tan | grep 9999
   
    you@yours~$  nc 10.1.1.10 9999

        "get foo"

        HTTP/1.1 400 Bad Request
        Server: approx/5.10 Ocamlnet/4.1.2


(yes that *nc get*  is deliberately broken)

    you@yours~$  CTL c
  
to close the "conversation".

5. check default logging (and any errors like the one above)

::
  you@yours~$  tail -f /var/log/daemonlog

something like: *Nethttpd: Bad request line*

6. simple test from the configured client

::
   root@yours~# apt-get update

see:    /var/cache/approx/

next:
The Long Version includes more options and some alternatives.

References:

Devuan
Xinetd
Approx

Thursday, 5 April 2018

Xorg Goes Out Of Action (again)

Trouble running xorg as normal user ?
Finding nothing useful in the X logs ?
Does startx or xinit work for root but not for you ?
Does your "Display Manager" (slim or {g,x,k}dm* or lightdm)
startup fine but fail to allow you to log in ?

You may be using devuan or debian or arch or even NetBSD .

Try this it _may_ help:
log in to a real terminal / console .

( something like )
ctl+alt+F2

try: you@yourhost~$ startx

No go ?  Then try this:
you@yourhost~$ mv ~/.xinitrc ~/xinintrc.copy

Now again: you@yourhost~$ startx

If that works :
1/ You need to ask your window manager / session manager
to run any apps you had auto starting in .xinitrc.
2/ You will also have to select _your_ desktop from the
display managers options or set the system default ...

ELSE Still no go ?

Bummer leave everything above done as is.
Next check that :
Your using xwrapper to allow X to create and destroy sockets on your behalf.
you@yourhost~$ man Xwrapper.conf
Its a short man page have a quick look.
see: /etc/X11/Xwrapper.conf
This has to exist and is activating the following settings :
#######################
#allowed_users=anybody
allowed_users=console
needs_root_rights=auto
#######################
See the man page for other options.

Try startx again if still no go you may have to install the Xwrapper:

Note / aside / man-splainer :

This apparently is now considered legacy or rather the assumption that your
using the systemd auth chain seems to be the thing to do.
So you could drink the grey gruel cordial ... or

You may need to install ""legacy"" versions of xorg
e.g.
you@yourhost~$ apt-cache search xorg | grep wrap
==> xserver-xorg-legacy
(so go install that )
So now at least you can startx or xinit or X -query from a console.
Which is all I need.
Try lightdm if you need a Graphical Login / Display manager ...
If you need xdmcp may Gandalf help you :)
Do feel free to pass on my best wishes to the XDG Systemd *kits mafia .

They seem to also have broken PAMs auth chain ...
Hey bloat obfuscation and spaghetti is always better than simple and clean. Also BSDz are cool too.
The Hairiest shirt of all is NetBSD and it works fine !
Its quite possibly about and past time we had a proper minimal Linux distro. Devuan is cool though has the assumption that the "only" thing wrong is systemd.
FWIW I have no need or want for systemd in _any_ aspect:
- I like and even use runlevels or even simple rc.d
- Its fine for it to be in place it just need not be compulsory.

Thursday, 26 September 2013

MAJURO DECLARATION FOR CLIMATE LEADERSHIP

Following is an hand formatted copy of the Majuro Declaration for Climate Leadership.

The Majuro Declaration Web Site. The Canonical Source for information.
http://www.majurodeclaration.org/the_declaration

MAJURO DECLARATION FOR CLIMATE LEADERSHIP

1.   Climate change has arrived. It is the greatest threat to the livelihoods, security and well-being of the peoples of the Pacific and one of the greatest challenges for the entire world.

2.   There is an overwhelming scientific consensus that escalating greenhouse gas emissions continue to cause the sharp rise in average global temperatures over the past century, the alarming acidification of our oceans, the rapid loss of polar sea ice, sea-level rise, and the striking incidence of more frequent and extreme weather events all over the world.

3.   On 9 May 2013, atmospheric concentrations of carbon dioxide measured near the summit of Mauna Loa in Hawaii exceeded 400 parts per million for the first time since measurements began. In crossing this historic threshold, the world entered a new danger zone. Unless we quickly change course, global average temperatures are projected to rise by 4C or more above pre-industrial levels by the end of the Century, resulting in unprecedented human and environmental impacts.

4.   We,, the Leaders of the Pacific Islands Forum, underline the need for urgent action at all levels to reduce greenhouse gas emissions commensurate with the science and to respond urgently and sufficiently to the social, economic and security impacts of climate change to ensure the survival and viability of all Pacific small island developing States, in particular low-lying atoll States, and other vulnerable countries and regions worldwide.

5.   At the same time, we recognize that the necessary energy revolution and economic transformation to low carbon development is an unprecedented opportunity to enhance our security, protect and ensure the sustainability of our natural resources and environment, and to improve our people's health.

Our Responsibility to Act

6.   We confirm the responsibility of all to act to urgently reduce and phase down greenhouse gas pollution in order to avert a climate crisis for present and future generations.

7.   The responsibility of all to act falls to every government, every company, every organization and every person with the capacity to do so, both individually and collectively.

Our Commitment to be Climate Leaders

8.   We commit to be Climate Leaders.

9.   To lead is to act. In supporting this Declaration, a government, economic entity, company, civil society organization or individual commits to demonstrate climate leadership through action that contributes to the urgent reduction and phase down of greenhouse gas pollution.

10.   Recognizing our unique vulnerability to climate change, the predicted catastrophic impacts on the security and livelihoods of our people, and the significant benefits that come with our transition to renewable, clean and sustainable energy sources, we, the Leaders of the Pacific Islands Forum, confirm our climate leadership in the form of the commitments listed at the end of this Declaration. We also want to do more.

11.   We call on our partners to enhance, accelerate and ensure the effective delivery of their support for the design and implementation of the commitments of the Pacific small island developing States.

12.   We also call on others, in particular our Post-Forum Dialogue Partners, to contribute to the urgent reduction and phase down of greenhouse gas pollution.

13.   This Declaration is a platform for an upward spiral of action to urgently reduce and phase down greenhouse gas pollution. Those who support this Declaration are strongly encouraged to continue to scale-up their efforts by submitting for listing further specific commitments that contribute more than previous efforts to the urgent reduction and phase down of greenhouse pollution.

14.   In addition, we commit to accelerate and intensify our efforts to prepare for and adapt to the intensifying impacts of climate change, and to further develop and implement policies, strategies and legislative frameworks, with support where necessary, to climate-proof our essential physical infrastructure, adapt our key economic sectors and ensure climate-resilient sustainable development for present and future generations.

15.   This Declaration will be presented by the Chair of the Pacific Islands Forum to the Secretary-General of the United Nations as a contribution to his efforts to catalyze ambitious climate action and mobilize political will for a universal, ambitious and legally-binding climate change agreement by 2015.

16.   This Declaration and the actions under it are intended to complement, strengthen and augment processes under way and commitments already made, including those under the United Nations Framework Convention on Climate Change and its Kyoto Protocol.

17.   We agree to review the status and implementation of this Declaration at the 45th Pacific Island Forum Leaders' meeting.

Adopted in Majuro, the Republic of the Marshall Islands, on this, the 5th day of September, 2013.

The primary site for this declaration and some related information.

  • Canonical Information
  • Signatories Commitments

    Note this section reformatted for web use.
    1. Australia
    2. Cook Islands
    3. Federated States of Micronesia
    4. Kiribati
    5. Nauru
    6. New Zealand
    7. Niue
    8. Palau
    9. Papua New Guinea
    10. Republic Of The Marshall Islands
    11. Samoa
    12. Solomon Islands
    13. Tonga
    14. Tuvalu
    15. Vanuatu

    Australia
    Subject Of CommittmentTarget or actionWhere reflectedYear
    Emissions Reductions

    Australia will unconditionally reduce its emissions by 5% below 2000 levels by 2020, and by up to 15% by 2020 if there is a global agreement which falls short of securing atmospheric stabilisation at 450 ppm carbon dioxide equivalent (CO2-eq) under which major developing economies commit to substantially restrain emissions and advanced economies take on commitments comparable to Australia's.

    Australia will reduce its greenhouse gas emissions by 25% on 2000 levels by 2020 if the world agrees to an ambitious global deal capable of stabilising levels of greenhouse gases in the atmosphere at 450 ppm CO2-eq or lower.

    Letter of 27 January 2010 from Australia's Minister for Climate Change and Water to UNFCCC Executive Secretary: http://climatechange.gov.au/sites/climatechange/files/files/UNFCCC-letter-Jan-2010.pdf

    2010
    Renewable Energy 20% of electricity generation from renewables by 2020.

    Australian Government,Department of Industry, Innovation, Climate Change, Science, Research, and Tertiary Education website, at http://www.climatechange.gov.au/reducing-carbon/renewable-energy/renewable-energy-target

    The 15 Signatory Nations
    Cook Islands
    Subject Of CommittmentTarget or actionWhere reflected Year
    Renewable Energy

    50% of inhabited islands electricity needs to be provided by renewable energy in 2015, and 100% by 2020, through implementing the Cook Islands Renewables Energy Chart with key strategies that:

    1. Ensure the use of proven renewable electricity technology options

    2. Ensure the policy and regulatory environment is aligned with the 50% by 2015 and 100% by 2020 renewable energy goal

    3. Ensure ongoing education, awareness and advocacy for renewable energy and energy efficiency

    4. Strengthen the required capacity to implement the Cook Islands renewable energy targets

    UNFCCC prototype NAMA registry, available at
    https://unfccc.int/cooperation_support/nama/items/6982.php

    Barbados Declaration on Achieving Sustainable Energy for All in Small Island Developing States (SIDS), available at
    http://www.undp.org/content/dam/undp/library/Environment%20and%20Energy/Climate%20Change/Barbados-Declaration-2012.pdf

    2013
    2012
    The 15 Signatory Nations
    Federated States of Micronesia
    Subject Of Committment Target or action Where reflected Year
    Emissions reductions
    Renewable Energy
    • Decrease the import and use of imported petroleum fuels by 50% by 2020.
    • 10% of electricity in urban centres and 50% in rural areas will be generated using renewable energy sources by 2020.
    • FSM will have a net gain of area covered by forests between now and 2020.
    • FSM will have a net gain of area and health status of coral reefs between now and 2020
    • FSM will remain a net importer of GHG through 2020.
    FSM Strategic Development Plan (2004-2013), pp. 301-305, available at http://www.mra.fm/pdfs/news_StrategicPlan.pdf 2004
    The 15 Signatory Nations
    Kiribati
    Subject Of Committment Target or action Where reflected Year
    Renewable Energy Fuel reduction target for electricity generation in Kiribati by 2025:
    1. South Tarawa: 45%
    2. Kiritimati: 60%
    3. Rural public infrastructure: 60%
    4. Rural public and private institutions: 100%
    IRENA profile on Kiribati, available at http://www.irena.org/REmaps/countryprofiles/kiribati.pdf
    The 15 Signatory Nations
    Nauru
    Subject Of Committment Target or action Where reflected Year
    Renewable Energy 50% of electricity generation to by provided by renewable energy by 2020.

    Long-term milestone - Viable power generating capacity including alternative renewable energy sources by 2025.
    Barbados Declaration on Achieving Sustainable Energy for All in Small Island Developing States (SIDS), available at http://www.undp.org/content/dam/undp/library/Environment%20and%20Energy/Climate%20Change/Barbados-Decl
    2012
    The 15 Signatory Nations
    New Zealand
    Subject Of Committment Target or action Where reflected Year
    Emissions reduction Reduce emissions by 5 per cent below 1990 levels by 2020 http://www.beehive.govt.nz/release/new-zealand-commits-2020-climate-change-target 2012
    Emissions reduction New Zealand is prepared to take on a GHG emissions reductions target of between 10 per cent and 20 per cent below 1990 levels by 2020,if there is a comprehensive global agreement. This means that:
    • 1. The global agreement sets the world on a pathway to limiting temperature rise to no more than 2C;
    • 2. Developed countries make comparable efforts to those of New Zealand;
    • 3. Advanced and major emitting developing countries take action fully commensurate with their respective capabilities;
    • 4. There is an effective set of rules for land use, land-use change and forestry (LULUCF); and
    • 5. There is full recourse to a broad and efficient international carbon market.
    UN document FCCC/SB/2011/Inf.1/Rev.1, p.6, available at http://unfccc.int/resource/docs/2011/sb/eng/inf01.pdf 2010
    Emissions reduction The Emissions Trading Scheme is New Zealand?s primary tool to help reduce New Zealand?s emissions and help New Zealand meet its international obligations under the United Nationals Framework Convention on Climate Change (UNFCCC). The NZ ETS has ensured New Zealand will meet its binding emissions reduction commitment under the first commitment period of the Kyoto Protocol. It will be a key tool to help NZ meet its 2020 target and any future targets, and will continue to develop through a series of independent reviews. http://www.climatechange.govt.nz/emissions-trading-scheme/ 2008
    Renewable energy New Zealand quantitative renewable energy targets are:
    • 1. 90% of electricity generation from renewable sources by 2025 (in an average hydrological year), providing this does not affect security of supply
    • 2. By 2025, utilise up to 9.5 PJ per year of energy from woody biomass or direct use geothermal additional to that used in 2005.
    New Zealand Energy Strategy 2011-2021 and New Zealand Energy Efficiency and Conservation Strategy 2011-2016 http:www.med.govt.nz/sectors-industries/energy/strategies 2011
    The 15 Signatory Nations
    Niue
    Subject Of Committment Target or action Where reflected Year
    Renewable energy 100 % of electricity generation from renewables by 2020. IRENA country profile for Niue, available at http://www.irena.org/REmaps/countryprofiles/pacific/niue.pdf 2011
    The 15 Signatory Nations
    Palau
    Subject Of Committment Target or action Where reflected Year
    Energy Access
    Renewable Energy

    Deliver clean, secure and affordable energy for all citizens of Palau while treating the environment responsibly.
    Respond to the risk of climate change by adaptation to changes and by mitigation through reducing greenhouse gases caused by the production an\ d use of energy.
     

    Barbados Declaration on Achieving Sustainable Energy for All in Small Island Developing States (SIDS), available at http://www.u\ ndp.org/content/dam/undp/library/Environment%20and%20Energy/Climate%20Change/Barbados-Declaration-2012.pdf 2012
    Energy Efficiency

    A vision for a reliable and resilient energy sector delivering sustainable low emission energy services by:

    1. Providing clear policy direction on the future of Palau's energy sector

    2. Appropriate regulations to secure energy services at competitive prices

    3. Maximizing cost efficient energyefficiency and renewable energy resources and conservation of energy while safeguarding the environment

    4. Promoting environmentally sustainable energy technologies with the aim to substitute fossil fuels

    5. Supporting consumers through the transition towards renewable energy

    Renewable Energy 20% contribution of renewable energy to the energy mix by 2020. 30% reduction in energy consumption though energy efficiency and conservation Palau Strategic Action Plan Energy Sector, p.9, available at
    http://www.rep5.eu/files/pages/file/Palau/ESSAP%20Final%20Draft.\ pdf
    2009
    The 15 Signatory Nations
    Papua New Guinea
    Subject Of Committment Target or action Where reflected Year
    Emissions reduction Decrease GHG emissions at least 50% before 2030 while becoming carbon neutral before 2050 UN Document FCCC/AWGLCA/2011/INF.1, pp. 38-40, available at http://unfccc.int/resource/docs/2011/awglca14/eng/inf01.pdf 2011
    The 15 Signatory Nations
    Republic Of The Marshall Islands
    Subject Of Committment Target or action Where reflected Year
    Emissions Reduction

    Renewable Energy

    Energy Efficiency

    Energy Access
    Pursuant to the Republic of Marshall Islands 2009 National Energy Policy and Energy Action Plan, the 2011 National Climate Change Policy Framework and Joint National Action Plan (for climate change adaptation, energy security and disaster risk reduction), and the Green Energy Micronesia initiative:
    • 1. A 40% reduction in CO2 emissions below 2009 levels by 2020;
    • 2. Electrification of 100% of urban households and 95% of rural outer atoll households by 2015;
    • 3. The provision of 20% of energy through indigenous renewable resources by 2020;
    • 4. Improved efficiency of energy use in 50% of households and businesses, and 75% of government buildings by 2020;
    • 5. A 20% efficiency improvement in transportation sector fuel use by 2020;
    • 6. Feasibility studies and internationally supported financing plans for innovative "game-changing" renewable energy and sustainable development opportunities including Majuro atoll waste-to-energy and Kwajalein/Ebeye atoll OTEC plants undertaken by 2015
    Barbados Declaration on Achieving Sustainable Energy for All in Small Island Developing States (SIDS), available at: http://www.un\ dp.org/content/dam/undp/library/Environment%20and%20Energy/Climate%20Change/Barbados-Declaration-2012.pdf 2012
    Emissions reductions 40% reduction of CO2 emissions below 2009 levels by 2020, pursuant to the 2009 National Energy Policy and Energy Action Plan, and with subject to the provision of adequate international support. UN Document FCCC/AWGLCA/2011/INF.1, p. 30, available at http://unfccc.int/resource/docs/2011/awglca14/eng/inf01.pdf 2010
    The 15 Signatory Nations
    Samoa
    Subject Of Committment Target or action Where reflected Year
    Renewable Energy

    Energy Efficiency

    1. To reduce the growth rate in the volume of imported fossil fuels by 10% by 2016. The high level indicators for this overarching goal/objective are:
      a. Energy Sector Plan launched and implemented with at least 75% of targets achieved by 2016;
      b. Increase in the contribution of RE to total energy consumption by 10% by 2016;
      c. Increase in the supply of RE for energy services by 10% by 2016;

    2. Increase Public and Private investment on Renewable Energy in transport fuels and electricity generation.

    3. Energy regulatory function established.

    Barbados Declaration on Achieving Sustainable Energy for All in Small Island Developing States (SIDS), available at http://www.un\ dp.org/content/dam/undp/library/Environment%20and%20Energy/Climate%20Change/Barbados-Declaration-2012.pdf

    http://www.mof.gov.ws/Portals/195\ /Energy/Samoa%20Energy%20Sector%20Plan-Final%20Version-Master.pdf
    2012
    The 15 Signatory Nations
    Solomon Islands
    Subject Of Committment Target or action Where reflected Year
    Energy Access
    Renewable Energy
    Energy Efficiency

    1. Replace current use of imported fossil fuel for electricity generation by 100% by Year 2030

    2. Increase access to reliable, affordable and stable electricity grid by 50% from the current 12% by Year 2030

    3. Reduce the price of electricity by half the present tariff rate by 2020

    4. Increase access to Solar-Home-Systems by remote rural dwellers located far from electricity grid from current 8.7% to 30% by Year 2020.

    Rio+20 website, indicating voluntary commitment by Solomon Islands under the Barbados Declaration on Achieving Sustainable Energy for All in Small Island Developing States (SIDS), available at: http://www.uncsd2012.org/index.php?page=view&type=1006&menu=1\ 53&nr=250

    Renewable Energy 50% of electricity generation from renewables by 2015. IRENA country profile for Solomon Islands, available at http://www.irena.org/REmaps/countryprofiles/pacific/SolomonIs\ lands.pdf
    The 15 Signatory Nations
    Tonga
    Subject Of Committment Target or action Where reflected Year
    Renewable Energy

    Energy Efficiency

    Energy Access

    1. To reduce Tonga's greenhouse gas emissions and improve energy security through 50% renewable energy mix in the Energy Transformation sector by the end of the Tonga Energy Roadmap 2010-2020 [TERM] implementation period.

    2. To improve efficiency of electricity supply and demand sides by 18% by the end of the TERM implementation period.

    3. All Tongans shall access to clean, reliable and affordable energy services by the end of TERM implementation period.

    Establish phased, comprehensive set of action plans to put in place a long-term institutional arrangement, which provides strong leadership and coordination of energy sector activities.

    Barbados Declaration on Achieving Sustainable Energy for All in Small Island Developing States (SIDS), available at http://www.un\ dp.org/content/dam/undp/library/Environment%20and%20Energy/Climate%20Change/Barbados-Declaration-2012.pdf 2012
    The 15 Signatory Nations
    Tuvalu
    Subject Of Committment Target or action Where reflected Year
    Renewable Energy

    Energy Efficiency

    1. Power Generation - 100% renewable energy between 2013 and 2020

    2. Implementation Principles
      - Solar PV 60 - 95% of demand
      - Wind 0 - 40% of demand (if feasible)
      - Biodiesel 5% of demand (import)

    Energy Efficiency - improvements of 30% of current annual demand of Funafuti.

    Barbados Declaration on Achieving Sustainable Energy for All in Small Island Developing States (SIDS), available at http://www.un\ dp.org/content/dam/undp/library/Environment%20and%20Energy/Climate%20Change/Barbados-Declaration-2012.pdf 2012
    The 15 Signatory Nations
    Vanuatu
    Subject Of Committment Target or action Where reflected Year
    Renewable Energy 100% of energy from renewables.
    40% of power generation through renewables by 2015
    65% of power generation through renewables by 2020
    RENA country profile for Vanuatu, available at http://www.irena.org/REmaps/countryprofiles/pacific/vanuatu.pdf
    The 15 Signatory Nations

    Saturday, 14 September 2013

    Thorium Based Nuclear Power Is An Option

    This page is not meant to be an in depth study of Thorium Reactors. Its an introduction to the fact that they have existed and are about to exist again. They have many benefits, and are a much more useful and manageable process than any current solid fuel Uranium based reactors.

    You know those times , online usually, when some often well intentioned fellow traveller says that nuclear is the only truly green option ....

    You / they / we may have read this
    Treating the Symptom

    Which doesn't really make a great case for keeping the current stock of Reactors. Or believing that a new crop has all bases covered.

      The core arguments include;
    • carbon capture is cool but not up to it.
    • safer than coal.
    • new reactors are safer than old designs

    Well, assuming that the usage case implies a very high density fuel (as implied by Nukes), ask them why Thorium is not an option worth exploring.
    If your going to exploit some of the most dangerous stuff in the solar system you may as well get it as right as it can be.
    The safe operation of such potentially dangerous production, supply and disposal processes
    should be intrinsically safe.
    What are you going to be doing 200 years from now ?

    The World Nuclear Association, has a page on thorium.
    Wikipedia does as well. With references and cross links.
    Thorium Nuclear power

    Norway has a start and they have an abundance of North Sea Hydrocarbons.

    This blended method can be readily used in rod type reactor... well maybe you wouldn't retrofit .. no idea how hard that would be.

    Then there are Liquid (fluoride) Salt type reactors, a much better long term and scalable solution.
    Liquid fluoride Thorium Reactor

    Its all right there with references .

    Finally point out that they are weighting the "base load" thing , and the "energy density" thing, mythologies way too highly in any case.
    But hey, there are places it makes some sort of sense:
    Norway India and China think so.

    • Places with high population densities and low access to space and renewable energy, are one.
    • Places where Nuclear and associated grid / support structures are already in place. These reactors can even help consume (some of) the waste.

    Tuesday, 2 April 2013

    Building and Installing E17 from stable release

    When edje wont build

    Summary:
    check for previous (obsolete) installs for EFL and E17 development packages.

    Its April 2013 as I write this.
    Over Easter  I finally got around to _successfully_ building the latest Released (stable) version from the Enlightenment Main Site .
    See:
    The Released page.

    Now this is (should be) straight forward enough essentially you build the Enlightenment Foundation Libraries then build the desktop manager/shell  (E17) and away you go. The usual caveats around building from source apply of course. You will need quite few other dev libraries that you may or may not have in place.


    If you get all the way to edje and then it breaks, before you waste a heap of time manually relinking and checking $PATH and permissions, reading all the ./configure --help(s) ... and grepping through code tracing the linkages ...
    googling around in circles ...

    Do yourself a favour purge all the packaged development libs and apps or simply move them out of the way.

    I had only purged e17-dev and this was not enough.

    ((DOH) Well of course it wasn't I was building the Foundation Libraries, the desktop (e17) may be treated as a nice side effect :)

    I had totally forgotten I had installed the Debian prepacked versions months ago for reasons I now only vaguely remember.

    Here is list of them for Debian (.deb) based distros I expect they will be very similar for others.

      libedje-dev - libedje headers and static libraries
     libeet-dev - Enlightenment DR17 file chunk reading/writing library      development files
    libefreet-dev - Development files for libefreet and libefreet-mime
    libelementary-dev - Development files for libelementary
    libevas-dev - Enlightenment DR17 advanced canvas library development files
    e17-dev - Enlightenment headers, static libraries and documentation

    I suspect its the edje and possibly the e17 devs that cause issues that are not resolved by the $PREFIX settings at build time.

    The symptom is that edje wont build as its compile gets pointed to old versions of its precursors. (dependencies)


    ./configure wont warn you about this :)

    So as your going to be building from source anyway you may as well --purge them. Some equivalent to :

    apt-get remove --purge libedje-dev libeet-dev libefreet-dev libelementary-dev libevas-dev e17-dev


    I haven't looked into the details but will note that most ./configure (s) appear to have options that would also solve the issue ... I can't see the point having them as they are way out of date and now (soonish)  not needed.

    Other thoughts and notes:
      Use the released tarballs at least at first, getting the developers latest stuff is quite massive and probably in a rapid state of flux in any case.
    (Lets not talk about WTF is going on with VCS ...)
    In any case you will need to gather some familiarity before doing SVN or bzr <-> git.


    So with this in mind or some functional equivalent as you see fit go ahead and start again :)

    I will post a step through next post.
    Its quite doable following the instructions at the main site.
    (and avoiding the developers docs which may lead you to dark places)




    Sunday, 17 February 2013

    Neuromorphic engineering - Wikipedia, the free encyclopedia

    Place holder....
    RN Future Tense had a piece on the "Human Brain Project" which in itslef is notabale, humans have been working on Artificial Intelligence" natural language Processing etal for ... hmmmm hundreds of years. ( depending where you draw that line)
    [ say the middleish 1800's ]


    quote
    http://goparallel.sourceforge.net/neuromorphic-chips-ultimate-parallel-processors/

    Spin states are inherent to electrons, which are constantly spinning, imparting a momentum to their electrical charge which can be oriented “up” or “down”. Such spin-polarized electrons can be used to encode digital ones and zeros using much less energy than just piling up charge on a capacitor. Ideally, a single electron could be used to store a digital one as “up” spin and a digital zero as “down” spin, enabling the ultimate downsizing for parallel processors to one-bit-per-electron. And for intrinsically parallel applications, such as emulating the billions of neurons in the human brain, the super low power achieved by spin-polarized digital encodings could enable the ultimate parallel processing applications of the future.
    /quote

    Neuromorphic engineering - Wikipedia, the free encyclopedia:

    Ah the holy Grail.. Analogue and Digital together....
    In the Algorithm and the storage.

    http://goparallel.sourceforge.net/neuromorphic-chips-ultimate-parallel-processors/

    The memristors and "spin"  are the partial breakthrough here.

    Hmmm maybe the singularity is closer than I thought !

    tags:
    Quantum Computing,  memristors,  Analogue Computing


    'via Blog this'

    Friday, 15 February 2013

    Some Commented Erlang


    Was pondering the whole von Neumann bottleneck cf. Quantum computing  .....

     (LOL not really)

    Was reading this python doc on function programming  a  (longish) while back ...

    Decided to go snorkling into concurrent programming  etal. ...
    So  l o n g   s t o r y  short :
    The intention is to learn some sound(er) principles from a number of places and apply them to my work generically where possible, after all why not, it's all good..

    FWIW I'll drop some stuff more or less randomly here and make some arrogant pontifications later :)

    The  primary languages of exploration are Erlang and Python so far... possibly C soonish.
    (thats more than I need or possibly  even deserve :)

    Turns out I have accidentally  learnt (a lot) from python anyhow [gasp!] , and even applied some rudiments  to my standard bash approach. [ bigger gasp :>]

    IMHO Erlang seems to have an _undeserved_ "hairy" reputation. 

    Here is a commented (day 2 level)  Erlang module.

    I extended it slightly and added comments that helped me.
    Perhaps they may help somebody else.


    Mostly from an  excellent Erlang course ,.



    -module(mathStuff).
    -export([factorial/1, area/1]).

    %% from www.erlang.org/course/sequential_programming.html
    %% (not original) -author('pete@ruthie.tux').

    %%%% area :: calculate square circle or triangle areas 
    %%%% match atom  to evaluate Variables

    area({square, Side}) -> % this tuple made of: {atom, Variable} 
        Side * Side;
    area({rectangle, Length, Width}) -> % this made of {atom, Variable, Variable}
        Length * Width;
    area({circle, Radius}) -> % well almost PI is NAN (here we only do radii)
        3.14 * Radius * Radius;
    area({triangle, A, B, C}) ->
        S = (A + B + C)/2,
        math:sqrt(S*(S-A)*(S-B)*(S-C));
    %% that must be inside -> out eval ... like "normal"
    area(Other) ->
        {woops_invalid_tuple_content, Other}. % any un matched atom spit error

    %%%% single parameter only exported at module head ?  
    %%%% Its OK we require {a, {tuple, as}} input parameter(s)

    %% return the factorial of the single parameter
    %%  disallow div by 0 ! It really hurts. (fire extinguisher required)
    %%  a guarded function  in two clauses
    factorial(N) when N > 0 ->
        N * factorial(N - 1);
    factorial(0) -> 1.




    The code would live in a module (file) named mathStuff.erl and be compiled from
     the erl shell or whatever method (emacs etc) you like.


    e.g.

    ~/ erl


    Eshell V5.9.1  (abort with ^G)
    1> c(mathStuff.erl).
    {ok,mathStuff}
    2>

    (on a perfect day :)
    It will compile the x.erl file > x.beam file.
    Everything is named the same.
    There are header (.hrl z :) files as well and includes may have records, even "macros"  etc ... just haven't got to them yet.


    From an erl shell (and the same directory for simplicity) you can call this like so:


    61> mathStuff:area({triangle, 3, 4, 5}).
    6.0

    (the 61st thing I had done in the shell)
    So the area of the triangle is 6 whatevers ... great :)

    We asked the module mathStuff for its exported function area() to "process" (->)
    the tuple  {triangle, 3, 4, 5}

    or


    62> mathStuff:factorial(3).
    6


    63> mathStuff:factorial(6).
    720



    Random Observations so far.

     module:foo() is way more readable than most anything else I have seen.
    (yeah I know you can intit to whatever candy you like in most languages.)

    Erlangs reads reasonably easily even after just an hour or two.. once you see where "output" is coming from.  There need be no print() though there is a thing similar to "printf".

    One of the ideas is to have no side-effects
    (and bounce / break on invalid input.)

    Actually a core idea is to NOT muck about (as much) with allocated memory.
    This language cleans up ASAP as well.



    Lots to grok if you haven't seen Erlang before but its actually elegant and simple.
    If you are used to python you wont have issue with the function structures think of them as
    if elseifs or case switch statements ... though you wont for long. :)

    A function is simply a collection of clauses to match and ends with a full stop.

    Think of the fullstop  as "complete ! Now Grunge".

    Yep there are Objects. (well not formal classes (yet) but I guess you could )
    (go use python or java or C++ or Perl)

    Variables Must Have At Least The First Letter Capitalised.
    Variables once bound are not reset (per instance) if you try it crashes the function.
    (and quite loudly too :)


    So there are no i++ (or "normal" loops) for example., and no need.

    Emacs has very good support for the language. And you can run a shell in a second window.
    (and learn elisp someday)


    The  Erlang Docs site has excellent documentation about the hows and whys.
    If nothing else browse the site and contemplate:
      concurrency parallelism 
      "threads" Processes 
      imperative VS declarative . 
      functional programming [1]  
    (or not :)



    And yep I did div/0 , not a good look.
    Mind you I've seen worse runaways.

    apt-cache search erlang
    (or whatever your nix does)
    [1] see also: the extended python docs (comes with a full install) about this.
    Its what got me wondering about it all.



    Erlang and the ancient " 3, 4, 5, [6]" rule

    Finally got round to starting to learn  Erlang.
    So far all good and great for my head... possibly even my "coding".
    Actually its a Neat language. Well worth learning if only for the conceptual journey.

    So I was doing a "just above beginner" type exercise and playing around and having lots of
     AH HA / OH NO moments (as ya do).
    When I realised that another "Rule" that has been incredibly useful to me for more than 30 years can safely be extended .

    The ancient (seriously like pre pyramid ancient) 3:4:5 triangle rule can run one more increment. ( to um 6 ).
    see:
    http://www.wikihow.com/Use-the-3-4-5-Rule-to-Build-Square-Corners
    For a more fullsome grok.

    That is
    a triangle of any nominal units (say cubits or rake handles or even meters :) when layed out with:

     side A @ 3 Units
     side B @ 4 Units
     side C at 5 Units

     Will give you a perfect 90 degree (and thereby 2 X 45 degree) corner(s).

    This is really useful when laying out large objects or building sites or for basic surveying contour mapping, cutting large sheets ... etc.
    I have used it many times indoors and out.

    Those same numbers give sane ratios of measurement but reducing the 4 to 2 .
    (um later maybe !)
    simply put :
    Try to design large things so the dimension divide by 2 and or 3.
    [ no,  just try it, you'll see when you try to buy materials :]

    The next step is that that same triangle will have an area of 6 Units. 

    Man how did I miss that ! (DOH)

    So now its the 3,4,5,6 rule for me :)

    The *ping* moment happened when I was contemplating  "guarding" a function that just happened to be about the area of a triangle and had another clause about circles.
    (with some earth building mentally back-grounding I expect)

    The human brain (or what I pass off as one) is great at associating random stuff into places it has no business being, (in engineering terms).



    p.s.
    Oh and, of course,  there is also the 5,4,3 rule ... sheeze shouda known !
    (for Ethernet Networking)
    5 4 3 (2 1) rule

    Friday, 14 October 2011

    Dennis Ritchie

    Dennis Ritchie has passed on.
    The R from "K and R".


    Its hard to over state the contribution this man has made to humanity.
    For C alone he should have received some equivalent to a joint Nobel
    prize.

    The language itself, its open culture, its generalised nature and
    downstream tool-set (notably compilers) remain central among the great
    enabling technologies.

    Dennis Ritchie was fundamental in the creation of not just a Coding
    Language but an idea or meme that underwrites almost everything we now
    consider the modern world.

    That same technology and those same simple concepts are the foundation
    of GNU, Open Source, and of course its offspring Linux, the BSDz,
    Creative Commons ...

    Brilliant engineering and genius design.
    Truly a Master and a Giant on who's shoulders we presume to stand.

    May his ideas live forever.
    His genius is still vibrant and well.

    We should all shout him a quiet beer in whatever cosmic bar we may next find him.

    Friday, 12 August 2011

    A silly script

    Scripting Stuff

    I spent some time writing this script, mostly because I wanted something "real" to try parameter substitution on.

    Secondary aims were "dealing" with stupidly named files efficiently.
    (turns out that Simple is Best.. LOL. What a surprise)

    Lessons/Tensions :
    Control Potential User Input firmly.
    Example :
    don't expect SOME_VAR=${VAR##*/} to survive user or any human input.
    (or to sanely process input generated by things like browsers file managers , user-land tools in general.
    ditto anything that feed a "for" loop.

    Solutions:
    Either sanitise / (sanity check) / correct and risk breaking the "Rule Of Least Surprise" for the user. (and how can you know what will be surprising)
    Or use a strong and simple output naming scheme.

    Especially if later access is desirable.

    When feeding a loop examine alternative procedural paths...
    Is it really so bad to not load an array or fat variable when you can process NOW and live with all the guff in the input file names. (even if it means writing out to file)

    The rest of the parameter sub stuff went fine though :)
    Its exactly the same as say: mkdir foo-{one,two,three,four}
    (well more or less :)


    So I ended up using known good techniques that I have used for eons and relearnt why I
    used them in the first place.

    e.g.

    find ${TARGET_DIR:-$(pwd)} -name ${SUFFIX:-jpg} -type f -print0 -exec file -iL '{}' \;

    Is sort of cool and I guess efficient, "atomic/granular" enough etc ....
    But (me type bad) fragile when a user can ask for the suffix to contain spaces or dots or heaven knows what. Certainly can not be trusted to feed a for loop without serious amount of even more obfuscate stuff. Its also tricky to contain the path as I wanted to at that point in the process.

    (that would process sub directories for example and always returns 0)

    Simpler is:
    if [ ! -f "*.$SUFFIX" ]; then
    this foo
    else
    that foo
    fi

    (or ls *.$SUFFIX)

    Which is way more maintainable as well :)

    _As Long as each returned "string" is dealt with down stream of the for THING rule._
    i.e. no need to clean or contain the "Broken \file(1) name.suff"

    In short:

    Its better to eat humble pie now than later :)

    ## example script: still less than elegant but working just fine ###
    ## Its way too big here.. interestingly it doesn't feel big under emacs :)
    ## use as you will or not ...


    #!/bin/bash
    # -*- shell-script -*-
    ####################################################
    # This script was written so I could test some
    # bash parameter subsitution out. (and find foo (but there I failed))
    # As a side effect and quite orthogonally (lol) it:
    # Creates an XML file that you feed to the GNOME background manager
    # That (XML) file describes a desktop background slide show.
    ####################################################

    # housekeeping
    VERSION=1.0
    APP=$(basename $0 .sh)
    APP_V="$APP-$VERSION"
    # change this to you or something
    AUTHORS="Peter Gossner"
    MAINTAINERS=$AUTHOR
    CONTACT_MAIL="Peter Gossner "
    # copyright year(s)
    CPT_YEARS="2011"

    # configure Default Durations
    D_STATIC=600 #CL -s -S
    D_TRANSIT=5 #CL -t -T
    # configure supported image suffix (and assumed types)
    IMAGE_SUFXS="jpg png svg" #CL -f -F

    # auto configs
    # start animation time this is parsed by gnome on startup (I think)
    # yep it is see: ~/.gconf/gnome/background/%gconf.xml
    # and probably other places... wonders about %name.xml ....

    ST_YEAR=" $(date +%Y)"
    ST_MONTH=" $(date +%m)"
    ST_DAY=" $(date +%d)"
    ST_HOUR=" $(date +%H)"
    ST_MIN=" $(date +%M)"
    ST_SEC=" 00"
    # I heart my date all up :)

    # directory of images to work with
    IMAGE_DIR="$(pwd)" #CL -d -D

    # error returns
    E_PERM=84
    E_OPTERROR=85
    E_BADDIR=86
    E_INTERNAL=87


    # utes
    PS="$$"
    INSTALL="/usr/local/bin"

    main(){
    # main control here
    # called after file is parsed (see eof)

    commandLineOptions "$@"
    defineVariables
    checkDir
    initXmlFile
    gatherSuffixList
    closeXmlFile "$LoopFile"

    echo -e "$APP completed.
    You would feed > >
    \" $IMAGE_DIR/$XML_FILE \"
    > > to gnomes background tool.\nHave a nice $(date +%A)"

    }

    commandLineOptions(){
    # gather user options
    while getopts "d:D:f:F:is:S:t:T:hHvV" OPTION
    do
    case $OPTION in
    d | D)
    # directory to gather images from
    IMAGE_DIR="$OPTARG"
    printf "%s \n" "-$OPTION setting image directory = $OPTARG"
    # make sure we have at least a slightly sane input"
    if [ "$IMAGE_DIR" == "" ] || [ "$IMAGE_DIR" == "." ] ; then
    IMAGE_DIR="$(pwd)"
    printf "%s \n" "-$OPTION !ouch! Resetting: $OPTARG to $IMAGE_DIR"
    fi
    ;;
    f | F)
    #limit images search to this list of image suffixes
    IMAGE_SUFXS="$OPTARG"
    echo -e "-$OPTION exclusive file suffixes = $OPTARG\n"
    ;;
    i )
    INSTALL=${OPTARG:-/usr/local/bin}
    installScript
    ;;


    s | S)
    # seconds to be static for
    D_STATIC="$OPTARG"
    echo -e "-$OPTION holding images static for $OPTARG secs\n"
    ;;
    t | T)
    # seconds to transition between images
    D_TRANSIT="$OPTARG"
    echo -e "-$OPTION transition images over $OPTARG secs\n"
    ;;
    h)
    helpOptions
    exit 0
    ;;
    H)
    helpMan
    exit 0
    ;;
    v | V)
    echo -e "$APP version $VERSION\nLegalese:\nReleased under terms and conditions of the GPL version 3 or later.\n$APP_V by $AUTHORS $CPT_YEARS\nContact: $CONTACT_MAIL"
    exit 0
    ;;
    * )
    echo -e "\t unknown option or invalid (missing) argument given \n"
    usages
    exit $E_OPTERR
    ;;
    esac
    shift $(( $OPTIND -1 ))
    OPTIND=1
    done
    }


    helpOptions(){
    echo -e "\n$APP_V
    Usage:
    ${0##*/}
    Options:
    -H more information and instructions
    -h options in conventional format. (this page)
    -i /directory/path/to/install/this script to. [default: $INSTALL ]
    -f or -F \"quoted list of formats (only)\". [defaults: $IMAGE_SUFXS ]
    -d or -D /path/to/directory/of/images/to/process. [default: ./]
    -s or -S nnn (seconds to hold each image static) [default $D_STATIC]
    -t or -T nnn (transition / crossfade time in seconds) [default $D_TRANSIT]
    -v or -V version and legals

    Examples:
    (access system wide and have the images in place for that)
    ~$ sudo ./$APP -s 300 -t 10 -d /usr/share/backgrounds/myFavsSlideShow

    (slides in home directory, default timings, jpg and png files only)
    ~$ ./$APP -d ~/MyOtherSlideShow -f \"jpg png\"

    "

    }

    helpMan(){
    # the manual
    echo -e "
    $APP_V

    ==========================================
    \"Help and Info\"
    ==========================================

    $APP creates an XML file that slideshows images.
    You may feed this to the gnome desktop background system.
    e.g. \"system\" > \"appearance\" > \"background\" > \"add\"

    $APP uses full path names to the image directory.
    Its just a plain old shell script that outputs plain old text.
    Feel free to edit either to taste.

    Instructions / Guidelines
    ==========================
    The XML structure is that used by the example supplied
    in your default GNOME install:
    It is not formally defined by any XML prolog
    or distant \"normative\" schema or DTD.
    (I did not look too hard )
    see: /usr/share/backgrounds/cosmos/ for the original

    Simply:
    - mkdir myCoolSlideShow (or whatever)
    - cp or mv or ln -s create:
    jpg png or svg images to populate that directory
    - (optionally) rename or prepend some string to
    place them in the order you would like.
    e.g.
    1-image-name.jpg
    2-anotherImageName.jpg
    3-yetSomeOtherSnap.png
    4-whatIdidLastSummer.svg
    - (optionally) ${0##*/} -i $INSTALL
    - cd to \"myCoolSlideShow\" and $APP
    (for defaults)
    - load the xml file with the background tool
    - admire your near cinematic skills ;>
    - watch your system grind away at rescaling all those svg files !
    the transitions seem to produce the highest load (-t)
    endnote:
    There is probably a GUI tool that does this easier and betterer.
    Search with your installer suite of choice.
    ( I was just brushing up on my BASH really :)

    " | more
    # this was so cute I couldn't resist
    helpOptions | more
    exit 0
    }

    usages(){
    echo -e "$APP -[[hHvV][tTsSfFDD \"argument\"]]\n\ttry:\n\t$APP -h (for options help)\n\t$APP -H for \"more\" information"
    exit $E_OPTERROR
    }

    checkDir(){
    # image directory access and write
    if [ -z $IMAGE_DIR ] || [ "$IMAGE_DIR" == "" ]; then
    bailout $E_INTERNAL "Target image directory is not set, or has been hand set to \"\""
    fi

    if [ ! -d $IMAGE_DIR ] ; then
    bailout $E_BADDIR "No such place as : $IMAGE_DIR"
    elif [ ! -x $IMAGE_DIR ] ; then
    bailout $E_BADDIR "Access refused to $IMAGE_DIR"
    else
    # echo "OK: $IMAGE_DIR exists"
    START_DIR=$(pwd)
    # move into the working directory
    cd $IMAGE_DIR || bailout $E_PERM "Unable to cd to $IMAGE_DIR"
    FILE_PATH="$(pwd)"
    fi
    }

    initXmlFile(){
    if [ -e $XML_FILE ]; then
    echo -e "Note: $XML_FILE exists. Backing it up."
    cp --backup=numbered $XML_FILE $XML_FILE.prev || bailout $E_PERM
    fi
    # clears any existing file
    echo -e "$XML_OPEN" > $XML_FILE || bailout $E_PERM

    for P in $ST_{YEAR,MONTH,DAY,HOUR,MIN,SEC} ;
    do
    # with indent
    echo -e " $P" >> $XML_FILE
    done
    # no indent
    echo -e "
    " >> $XML_FILE
    }

    defineVariables(){
    # build up "prerun" list of variables
    FILE_LIST=""
    REJECT_LIST=""
    IMAGE_DIR=${IMAGE_DIR?-$(pwd)}
    XML_FILE=$APP-slides.xml
    # ${foo##*/} works except when the user puts a trailing slash
    # so twice check or just use the clean app name

    # users real user name
    if [ -z $SUDO_USER ]; then
    RUNBY="$USER"
    else
    RUNBY="$USER for $SUDO_USER" || RUNBY="$USERNAME"
    fi
    # TODO a tidyup on output indents
    #XML strings
    XML_START="\n\n"
    XML_CLOSE="\n
    \n"
    STATIC_OPEN=" \n $D_STATIC"
    STATIC_CLOSE="
    "
    TRANSIT_OPEN=" \n $D_TRANSIT"
    START=" \n$ST_YEAR\n$ST_MONTH\n$ST_DAY\n$ST_HOUR\n$ST_MIN\n$ST_SEC\n\n"

    XML_OPEN="$XML_START\n"

    # forcing clean return
    return 0
    }

    gatherSuffixList(){
    # this all got too silly with file so ls and globs to the rescue...
    # simple safe list
    ti=0 ; mi=0 ; ri=0

    for S in $IMAGE_SUFXS ;
    do
    # the intention here is Short Circuit on no match for file suffix
    any="$( ls ./*.$S )"
    s_any=$?
    if [ -z "$any" ] || [ "$s_any" != "0" ]; then
    echo "no $S suffix files found"
    continue
    else
    # not really required huge bloat :)
    files_ok="TRUE"
    fi

    case $S in
    jpeg | jpg | JPG )
    magicMatch="image/jpeg"
    ;;
    svg | SVG )
    magicMatch="image/svg"
    ;;
    png | PNG )
    magicMatch="image/png"
    ;;
    gif | GIF )
    magicMatch="image/gif"
    ;;
    * )
    echo "Achtung : no test available for suffix \"$S\" "
    bailout ${E_OPTERROR:-85} "This is probably a commandline typo \n.\t Equally it may be an unsupported file suffix."
    ;;
    esac

    for I in *.$S ; do
    (( ti++ ))
    checking="$(file -iL "$I")"
    matching="$(echo $checking | grep $magicMatch)"


    if [ "$?" == "0" ]; then
    (( mi++ ))

    FILE_LIST="$FILE_LIST\n"$I""
    addToXMLfile "$I"
    else
    (( ri++ ))
    echo -e "Note: rejecting $I
    fails basic file type \"magic\" tests\n
    $checking\n
    $I should have: $magicMatch as part of its \"magic\" \n"

    REJECT_LIST="$REJECT_LIST\n$checking\ndoes not match $magicMatch"
    fi
    done
    done

    echo "$RUNBY FYI: matched $mi and rejected $ri of $ti files found"
    return 0
    }

    addToXMLfile(){

    FILE="$IMAGE_DIR/$1"

    # capture/store the first image for start and end (loop)
    if [ "$mi" -eq "1" ]; then
    LoopFile="$FILE"
    echo -e "$STATIC_OPEN

    $FILE$STATIC_CLOSE
    $TRANSIT_OPEN
    $FILE" >> $XML_FILE
    else
    echo -e "
    $FILE\n

    $STATIC_OPEN
    $FILE
    $STATIC_CLOSE
    $TRANSIT_OPEN
    $FILE" >> $XML_FILE
    fi
    return 0
    }

    closeXmlFile(){
    # add the return back to the first image
    # and close of the xml structure

    if [ "$ti" -gt "1" ]; then
    echo -e "$LoopFile


    \n" >> $XML_FILE

    else
    # CLUNK clunk Clunkity clunk
    rm -fv $XML_FILE
    bailout $E_BADDIR "$APP unable to find images to work with"
    fi
    return
    }

    installScript(){
    # simple installer
    if [ ! -d $INSTALL ];
    then
    mkdir -pvm 2755 $INSTALL || bailout $E_PERM "Unable to make install directory. Try\n sudo $0 -I ?"
    else
    echo "Installing $APP to $INSTALL"
    fi

    cp -fv $0 $INSTALL/${0##*/} || bailout $E_PERM ":Try \" sudo $0 -$OPTION $INSTALL \"\n "
    chmod u+x $INSTALL/${0##*/}
    exit 0
    }


    bailout(){
    # # error returns
    # E_PERM=84
    # E_OPTERROR=85
    # E_BADDIR=86
    # E_INTERNAL=87 # feet off the ground see: AU cricket

    E_NO=$1
    echo -e "\nNOTE: $APP process $PS exiting prematurely\n\tPerhaps the following trace may assist.\n\t[line number] [at function (aka. sub routine)] [of filename]"
    # give some sort of backtrace
    caller 0
    caller 1
    case $E_NO
    in
    1)
    echo -e "$APP_V General Error"
    ;;
    84)
    echo -e "Permissions Error. Perhaps you need root ?"
    ;;
    85)
    echo -e "Probable command line option error"
    ;;
    86)
    echo -e "Directory access error ?"
    ;;
    87)
    echo -e "$APP_V INTERNAL error. (my bad)"
    ;;
    *)
    echo -e "Unspecified Operational Error. Possibly unforeseen (unplaned) use ?"
    esac

    if [ ! -z "$2" ]; then
    echo -e "Error: $@"
    else
    echo "Error $1"
    fi

    exit $E_NO
    }


    main "$@"

    # formal exit with last returned value
    exit

    # The flaming end
    # crickey what a mess


      A Local Devuan Package Mirror  (( with Xinetd and approx ))   Verbose Version A shorter simpler version is also available (one ...