Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines
Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.
REPEAT: Do NOT report bugs for outdated packages!
https://wiki.archlinux.org/title/Bug_reporting_guidelines
Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.
REPEAT: Do NOT report bugs for outdated packages!
FS#23469 - /etc/rc.d/postfix start fails if called from a script
Attached to Project:
Arch Linux
Opened by Nico Schottelius (telmich) - Sunday, 27 March 2011, 21:24 GMT
Last edited by Gaetan Bisson (vesath) - Monday, 28 March 2011, 22:41 GMT
Opened by Nico Schottelius (telmich) - Sunday, 27 March 2011, 21:24 GMT
Last edited by Gaetan Bisson (vesath) - Monday, 28 March 2011, 22:41 GMT
|
DetailsDescription:
[root@kr .cdist]# cat /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote # # The following code is imported from output of /home/users/nico/oeffentlich/rechner/projekte/cdist/conf/type/__process/gencode-remote # /etc/rc.d/postfix start [23:16] kr:cdist% ssh root@localhost "/var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote" :: Starting Postfix [BUSY] [FAIL] Using the rc.d script directly works: [23:17] kr:cdist% ssh root@localhost "/etc/rc.d/postfix start" :: Starting Postfix [BUSY] [DONE] [23:21] kr:cdist% cdist is the usable configuration management (replaces puppet, cfengine, etc.), which generates scripts that are executed on the target host, which may contain arbitrary code as defined in the types (by the user). Thus this use case will increase pretty much soon, as cdist gets more popular right now. Additional info: * package version(s) * config and/or log files etc. Steps to reproduce: - create script that contains /etc/rc.d/postfix start - shutdown postfix - run ssh yourhost "yourscript" |
This task depends upon
Closed by Gaetan Bisson (vesath)
Monday, 28 March 2011, 22:41 GMT
Reason for closing: Fixed
Additional comments about closing: postfix-2.8.2-2 in [extra]
Monday, 28 March 2011, 22:41 GMT
Reason for closing: Fixed
Additional comments about closing: postfix-2.8.2-2 in [extra]
[23:30] kr:type% cdist-deploy-to localhost
...
Checking code-remote for __process/cups ...
Executing code-remote for __process/cups ...
:: Starting CUPS Daemon [BUSY] [DONE]
Add "#!/bin/sh" as the first line of your file "/var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote", and do "chmod 755" to it; then try again.
regarding #!/bin/sh probably already clearified, as the cdist script is executed with sh -e in front.
[root@kr ~]# cat /var/lib/cdist/out/object/__process/cups/.cdist/code-remote
#
# The following code is imported from output of /home/users/nico/oeffentlich/rechner/projekte/cdist/conf/type/__process/gencode-remote
#
/etc/rc.d/cups start
[root@kr ~]# ls -lh /var/lib/cdist/out/object/__process/cups/.cdist/code-remote
-rwx------ 1 root root 161 27. Mär 23:30 /var/lib/cdist/out/object/__process/cups/.cdist/code-remote
Regarding postfix: Yes, I'm definitely sure, for two reasons: 1) cdist checks for a process running before it tries to start it 2) ps aux| grep postfix -> empty
Could you remove the "&> /dev/null" from the postfix rc.d script and try running it via cdist, so that we could see some helpful error message?
Checking code-remote for __process/usr/lib/postfix/master ...
Executing code-remote for __process/usr/lib/postfix/master ...
:: Starting Postfix [BUSY] [FAIL]
Checking code-local for __package_pacman/zsh ...
Executing code-local for __package_pacman/zsh ...
Checking code-remote for __package_pacman/zsh ...
Executing code-remote for __package_pacman/zsh ...
Saving cache to /home/users/nico/oeffentlich/rechner/projekte/cdist/cache/localhost ...
cdist 1.5.0pre: Successfully finished run on localhost
[13:34] kr:cdist% ssh root@localhost "head -n11 /etc/rc.d/postfix"
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
PID=`pgrep -f /usr/lib/postfix/master`
start() {
stat_busy "Starting Postfix"
# [ -z "$PID" ] && /usr/sbin/postfix start &> /dev/null
[ -z "$PID" ] && /usr/sbin/postfix start
[13:35] kr:cdist%
I manually changed /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote to contain only the following:
[root@kr ~]# cat /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote
/etc/rc.d/postfix start
[root@kr ~]#
Calling it via ssh now gives me:
[13:43] kr:cdist% ssh root@localhost "/var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote"
:: Starting Postfix [BUSY] [FAIL]
Having another script containing the same content works, though:
[root@kr ~]# cat /root/postfix-test
/etc/rc.d/postfix start
[root@kr ~]# ls -lh /root/postfix-test
-rwx------ 1 root root 24 28. Mär 13:39 /root/postfix-test
[root@kr ~]#
[13:44] kr:cdist% ssh root@localhost "/root/postfix-test"
:: Starting Postfix [BUSY] [DONE]
[13:45] kr:cdist%
No diff:
[root@kr ~]# diff -u /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote /root/postfix-test
[root@kr ~]#
Same permissons:
[root@kr ~]# ls -l /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote /root/postfix-test
-rwx------ 1 root root 24 28. Mär 13:39 /root/postfix-test
-rwx------ 1 root root 24 28. Mär 13:43 /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote
[root@kr ~]#
[root@kr ~]# cp /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote /root/postfix-test2
[13:52] kr:cdist% ssh root@localhost "/root/postfix-test2"
:: Starting Postfix [BUSY] [DONE]
# copying it over works.
[root@kr ~]# /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote
:: Starting Postfix [BUSY] postfix/postfix-script: starting the Postfix mail system
[DONE]
[root@kr ~]#
[root@kr ~]# ln -s /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote /root/
[13:54] kr:cdist% ssh root@localhost "/root/code-remote"
:: Starting Postfix [BUSY] [DONE]
[14:01] kr:cdist%
[root@kr ~]# cp /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/FOO
[14:01] kr:cdist% ssh root@localhost "/var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/FOO"
:: Starting Postfix [BUSY] [FAIL]
Linking into the same directory as well:
[root@kr ~]# ln -s /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/FOO2
[root@kr ~]#
[14:03] kr:cdist% ssh root@localhost "/var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/FOO2"
:: Starting Postfix [BUSY] [FAIL]
# One level higher does not work as well:
[root@kr ~]# ln -s /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote /var/lib/cdist/out/object/__process/usr/lib/postfix/master/FOO3
[14:04] kr:cdist% ssh root@localhost "/var/lib/cdist/out/object/__process/usr/lib/postfix/master/FOO3"
:: Starting Postfix [BUSY] [FAIL]
# Linking to cdist top level dir works though:
[root@kr ~]# ln -s /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote /var/lib/cdist/FOO4
[14:05] kr:cdist% ssh root@localhost "/var/lib/cdist/FOO4"
:: Starting Postfix [BUSY] [DONE]
This definitely indicates some problem with either the directory structure or naming or permissions.
[14:06] kr:cdist% ssh root@localhost "/var/lib/cdist/out/FOO5"
:: Starting Postfix [BUSY] [DONE]
[root@kr ~]# ln -s /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote /var/lib/cdist/out/object/FOO6
[14:08] kr:cdist% ssh root@localhost /var/lib/cdist/out/object/FOO6
:: Starting Postfix [BUSY] [DONE]
[14:09] kr:cdist%
[root@kr ~]# ln -s /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote /var/lib/cdist/out/object/__process/FOO7
[14:09] kr:cdist% ssh root@localhost /var/lib/cdist/out/object/__process/FOO7
:: Starting Postfix [BUSY] [DONE]
Further linking attempts:
[14:10] kr:cdist% ssh root@localhost /var/lib/cdist/out/object/__process/usr/FOO8
:: Starting Postfix [BUSY] [DONE]
[14:11] kr:cdist% ssh root@localhost /var/lib/cdist/out/object/__process/usr/lib/postfix/FOO9
:: Starting Postfix [BUSY] [DONE]
[14:11] kr:cdist% ssh root@localhost /var/lib/cdist/out/object/__process/usr/lib/postfix/FOO9
:: Starting Postfix [BUSY] [DONE]
[14:11] kr:cdist% ssh root@localhost /var/lib/cdist/out/object/__process/usr/lib/postfix/master/FOO10
:: Starting Postfix [BUSY] [FAIL]
[14:12] kr:cdist%
Got it! It stops working between FOO9 and FOO10.
The "only" question left is, why.
[root@kr ~]# mkdir -p /tmp/usr/lib/postfix/master/
[root@kr ~]# ln -s /var/lib/cdist/out/object/__process/usr/lib/postfix/master/.cdist/code-remote /tmp/usr/lib/postfix/master/FOO11
[root@kr ~]#
[14:12] kr:cdist% ssh root@localhost /tmp/usr/lib/postfix/master/FOO11
:: Starting Postfix [BUSY] [FAIL]
[14:13] kr:cdist%
PID=`pgrep -f /usr/lib/postfix/master`
Use pgrep -f -x, please.
I'll cleanup the rc.d script and make it use pidof rather than pgrep.