Koozali.org: home of the SME Server

How to template-custom run-only-once commands?

Hasan Muhammad

How to template-custom run-only-once commands?
« on: January 07, 2004, 11:36:33 PM »
In the post at...
  http://forums.contribs.org/index.php?topic=19388.msg76802#msg76802
Derek L told us...
  How to keep a service from starting at boot?
which is....

# /sbin/e-smith/db configuration setprop atalk status disabled
# /sbin/e-smith/signal-event console-save

Replace "atalk" with the name of the service you want to disable.

To see service status:

/sbin/e-smith/config show (service name) or blank for all

 
How would we 'template-custom'   such 'run-only-once'  commands
so that there would be a permanent record of changes to the default installation?

[%sig%]

Hasan Muhammad

Re: How to template-custom run-only-once commands?
« Reply #1 on: January 08, 2004, 10:03:14 PM »
Haven't figured out how to template configuration change that occurs only once, but the following solution does...

a) effect templating of some actions that occurs each time the server is rebooted (hopefully not often)
b) because the configuration changes are inside of /etc/e-smith/templates-custom then the changes are documented in source code, which is my objective (quick-and-dirty versus building a rpm)

Note:  The first file below is an example of how to use the templates-custom directory to create a new file (versus modifying an existing file), but the file is created with default ownership and persmissions.

Anybody know how to setup templates such that expanding the templates can also change the ownership/permissions?

Anyway...

--The (partial) Solution----------------------------------------------------------------------------------------
1) create a file...
/etc/e-smith/templates-custom/etc/e-smith/events/actions/disable-some-services-on-boot
with the following content...
(note this example expands to a shell script, but the strange beginning and ending lines also allows a perl script inside a template to be expanded)

{                                       # DO NOT CHANGE THESE First Two  LINES
$OUT=<<'EOF_SCRIPT';                    # DO NOT CHANGE THESE First Two  LINES
#!/bin/sh

        /sbin/e-smith/config setprop tinydns status disabled # per each service
        /sbin/e-smith/signal-event console-save

        exit 0

EOF_SCRIPT
$OUT =~ s/(.+)\n$/$1/s;                 # DO NOT CHANGE THESE Last Three LINES
}
{
# VERY IMPORTANT
#
# besure to chmod 554 this_file after running expand-template the first time
}


2) create a file...
/etc/e-smith/templates-custom/etc/e-smith/events/actions/disable-some-services-on-boot
with the following content...

{
exec('[ -a /etc/e-smith/events/local/S08disable-some-services-on-boot ] || ln -s /etc/e-smith/events/actions/disable-some-services-on-boot /etc/e-smith/events/local/S08disable-some-services-on-boot');
}

3) run these commands

 /sbin/e-smith/expand-template /etc/e-smith/events/actions/disable-some-services-on-boot

chmod 554 /etc/e-smith/events/actions/disable-some-services-on-boot

 /sbin/e-smith/expand-template /etc/e-smith/events/local/S08disable-some-services-on-boot

[%sig%]