Before anybody asks, no I do not intend to use systemd for my main
systems.  But my current build is using it, to keep up to date with
the LFS-dev book.

 For much of what I run, the service and other unit files come from
Armin's systemd-units tarball.  But there are a few things which are
unique to my systems, and one thing for which I didn't find a system
file, so in the end I had to hack one based on fedora and arch.

 The first of those things is that I run smartd (from
smartmontools).  All the interesting things happen in
/etc/smartd.conf.  I start it on every boot, and it sends an email
message to my server to (hopefully) tell me the drive is ok.
I've attached smartd.service.

 The second thing is probably more unusual - I run the kernel's
cpufreq, and until now I've had a bootscript to set it for normal
use, or occasionally I turn everything up to 11 - good for warming
up the room with my phenom ;-)  And theoretically I can also change
it to 'powersave'.

 Over the last couple of years, things got more interesting: First
I got SMP machines and discovered that I had to set the scaling
governor for each CPU.  Then the Sandy Bridge setup changed - the
current driver does not do ondemand, only performance (and that
works like ondemand :).  After that I was checking my phenom because
it seemed to be taking a long time to build things, and discovered
that I wanted to play about with the sampling_down_factor when I put
it into ondemand mode [ and that setting is lost when the governor
changes ].  So, my generic .in script from which I create the
installed file has quite a lot of baggage.

 With the move to systemd, I now have two files - a script which
I've called cpufreq.sh, and the service file.  The service file just
sets the normal scaling governor when I boot [ systemd seemed to
default to "everything flat out" before I sorted this out ], the
script allows root to change the governor if required and retains
powersave in case I ever get round to putting BLFS on a netbook.

 Attaching cpufreq.service and cpufreq.sh

 The other thing I do is run iptables, because we dropped
tcp-wrappers.  My iptables settings are quite different from the
example in the book, but on my non-systemd builds they live in
/etc/rc.d/rc.iptables, as in BLFS, and get driven by the bootscript.

 All I need to do is start the script, and perhaps flush all the
settings.  Again, a service file, and separate scripts to reload
(yeah, it is technically load, I'll fix that when I actually add it
to my own buildscripts) and to flush - I've commented out references
to nat and mangle because I don't have them.  Attaching
iptables.service, iptables-reload, iptables-service.  The commands
in those scripts are lifted verbatim from the BLFS bootscripts.

 Hope these act as examples of how to do things - there may well be
better ways.  Along the way, I had to use systemctl daemon-reload
before it would find a new service file, and again before it would
notice the changes in that file.

ĸen
-- 
das eine Mal als Tragödie, dieses Mal als Farce
[Unit]
Description=Self Monitoring and Reporting Technology (SMART) Daemon
After=syslog.target

[Service]
ExecStart=/usr/sbin/smartd -n $smartd_opts
ExecReload=/bin/kill -HUP $MAINPID
StandardOutput=syslog

[Install]
WantedBy=multi-user.target
[Unit]
Description=CPUFreq Options

[Service]
Type=oneshot
ExecStart=/usr/sbin/cpufreq.sh
TimeoutSec=0
RemainAfterExit=YES

[Install]
WantedBy=multi-user.target

Attachment: cpufreq.sh
Description: Bourne shell script

[Unit]
Description=Iptables firewall

[Service]
Type=oneshot
ExecStart=/usr/sbin/iptables-reload
ExecStop=/usr/sbin/iptables-flush
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

#!/bin/bash
if [  -x /etc/rc.d/rc.iptables ]; then
        echo "starting iptables"
        /etc/rc.d/rc.iptables
else
        echo "missing rc.iptables"
        false
fi
#!/bin/bash

# taken from the 'clear' option of the BLFS iptables bootscript
        /sbin/iptables --policy INPUT   ACCEPT
        /sbin/iptables --policy OUTPUT  ACCEPT
        /sbin/iptables --policy FORWARD ACCEPT
        /sbin/iptables           --flush
#       /sbin/iptables -t nat    --flush
#       /sbin/iptables -t mangle --flush
        /sbin/iptables           --delete-chain
#       /sbin/iptables -t nat    --delete-chain
#       /sbin/iptables -t mangle --delete-chain

-- 
http://lists.linuxfromscratch.org/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to