208
Chapter 15: Advanced Configuration
if [ "$COUNTER" -eq 5 ]
then
COUNTER=0
"$@"
sleep 2s
fi
done
15.1.7 Running custom scripts when a configurator is invoked
A configurator is responsible for reading the values in /etc/config/config.xml and making the appropriate changes live. Some
changes made by the configurators are part of the Linux configuration itself such as user passwords or ipconfig.
Currentlytherearenineteenconguratorseachoneresponsibleforaspecicgroupofconge.g.the"users"congurator
makes the user configurations in the config.xml file live. To see all the available configurators type the following from a
command line prompt:
# config
WhenachangeismadeusingtheManagementConsolewebGUItheappropriateconguratorisautomaticallyrun.This
can be problematic as if another user/administrator makes a change using the Management Console the configurator could
possibly overwrite any custom CLI/linux configurations you may have set.
The solution is to create a custom script that runs after each configurator has run. So after each configurator runs it will check
whether that appropriate custom script exists. You can then add any commands to the custom script and they will be invoked
after the configurator runs.
The custom scripts must be in the correct location:
/etc/config/scripts/config-post-
To create an alerts custom script:
# cd /etc/config/scripts
# touch config-post-alerts
# vi config-post-alerts
This script could be used to recover a specific backup config or overwrite a config or make copies of config files etc.
15.1.8 Backing-up the configuration and restoring using a local USB stick
The /etc/scripts/backup-usbscriptbeenwrittentosaveandloadcustomcongurationusingaUSBashdisk.Beforesaving
congurationlocally,youmustpreparetheUSBstoragedeviceforuse.Todothis,disconnectallUSBstoragedevicesexcept
for the storage device you wish to use.
Usage: /etc/scripts/backup-usbCOMMAND[FILE]
COMMAND:
check-magic--checkvolumelabel
set-magic--setvolumelabel
save[FILE]--savecongurationtoUSB
delete[FILE]--deleteacongurationtarbalfromUSB
list--listavailablecongbackupsonUSB
load[FILE]--loadaspeciccongfromUSB
load-default--loadthedefaultconguration
set-default[FILE]--setwhichlebecomesthe default
TherstthingtodoistocheckiftheUSBdiskhasalabel:
# /etc/scripts/backup-usb check-magic
Ifthiscommandreturns"Magicvolumenotfound",thenrunthefollowingcommand:
# /etc/scripts/backup-usb set-magic
To save the configuration:
# /etc/scripts/backup-usb save config-20May