#!/bin/bash # $HeadURL$ $LastChangedRevision$ # Properties MY_ID=system_hardware MY_PRIVATE_ATTRIBUTES="uname status helper" MY_PUBLIC_ATTRIBUTES="ram disk cpu" MY_ATTRIBUTES="$MY_PRIVATE_ATTRIBUTES $MY_PUBLIC_ATTRIBUTES" PARENT_ID=system MY_HELPER_IDS="$(ls | fgrep -v helper | xargs echo)" # Instantiate my attributes for MY_ATTRIBUTE in ${MY_ATTRIBUTES^^}; do eval "$MY_ATTRIBUTE="; done # Defaults for the questions we ask (should only used here) # Hooks edit_prologue() { # my attributes inherit ${MY_ATTRIBUTES^^} # my inherited attributes : # real locals debug 10 "edit_prologue: prompting for changes ..." if $VM_FLAG; then DFLT_RAM=256 DFLT_DISK=16 # 15500MB for root, 500MB for swap DFLT_CPU=1 else DFLT_RAM= DFLT_DISK= DFLT_CPU= fi question --force-ask=true RAM "memory (MB)" "$DFLT_RAM" "echo \"no help available\"" validate_positive_integer rationalise_positive_integer question --force-ask=true DISK "disk (GB)" "$DFLT_DISK" "echo \"no help available\"" validate_positive_integer rationalise_positive_integer question --force-ask=true CPU "CPUs (1-)" "$DFLT_CPU" "echo \"no help available\"" validate_positive_integer rationalise_positive_integer map_an_inherited_attribute_to_my_helpers } create_prologue() { map_an_inherited_attribute_to_my_helpers } delete_prologue() { map_an_inherited_attribute_to_my_helpers } list_prologue() { return 0 } map_an_inherited_attribute_to_my_helpers() { # my properties inherit MY_HELPER_IDS MY_ATTRIBUTES # my attributes inherit ${MY_ATTRIBUTES^^} # those inherited attributes i will use inherit VM_FLAG # real local # Sanity checks [ "X$VM_FLAG" = Xtrue -o "X$VM_FLAG" = Xfalse ] || internal "VM_FLAG: seems not to have been propogated" # Guts if $VM_FLAG; then MY_HELPER_IDS=vm else MY_HELPER_IDS=pm fi return 0 }