You are not logged in.

#1 2012-11-19 05:03:19

train_wreck
Member
Registered: 2011-10-22
Posts: 97

systemd startup script - half of the commands run, half don't??

i have a previous rc.local file which was a startup script on a router machine i have. it is designed to run tcpdump commands for the interfaces and output them to terminals tty9, tty10, and tty11. it worked perfectly...

i have since transitioned to systemd. I followed wiki instructions to make a oneshot service file and have enabled it. here is the file: (/usr/lib/systemd/system/startup.service)

[Unit]
Description=Startup Script
After=iptables.service

[Service]
Type=oneshot
ExecStart=/etc/scripts/startup

[Install]
WantedBy=multi-user.target

here is the script /etc/scripts/startup: (email addresses disquised)

#!/bin/bash
route add -net 10.11.12.0/24 gw 172.16.16.4
/usr/sbin/tcpdump -pnq -i external >> /dev/tty11 &
/usr/sbin/tcpdump -pnq -i internal >> /dev/tty10 &
/usr/sbin/tcpdump -pq -i wifi >> /dev/tty9 &
echo "$HOSTNAME system startup complete `date '+%r %x'`" | /usr/bin/mailx -c "xxxxx@gmail.com" -s "$HOSTNAME Startup Message" xxxxx@vtext.com

here is the output from the startup command with journalctl:

Nov 18 22:46:10 pLAN9-Gateway systemd[1]: Starting Startup Script...
Nov 18 22:46:10 pLAN9-Gateway systemd[1]: Starting OpenSSH Daemon...
Nov 18 22:46:10 pLAN9-Gateway systemd[1]: Started OpenSSH Daemon.
Nov 18 22:46:13 pLAN9-Gateway startup[409]: . . . message not sent.
Nov 18 22:46:13 pLAN9-Gateway systemd[1]: Started Startup Script.

the route add command runs, but nothing else does. as you can see, there is absolutley NOTHING helpful in the log, other than the completely useless "message not sent" output from mailx. running the startup script manually with "systemctl start startup" works fine.

iptables.service is setup to run After=netcfg.service, so I would assume that beucase the startup script runs after iptables, it should run after netcfg as well.

why aren't these commands running?

Offline

#2 2012-11-19 13:07:04

brain0
Developer
From: Aachen - Germany
Registered: 2005-01-03
Posts: 1,382

Re: systemd startup script - half of the commands run, half don't??

A oneshot service is killed once the main process returns (that's why it is called a "oneshot"). Your tcpdump processes are killed once startup returns.

Offline

Board footer

Powered by FluxBB