Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for improving usability #78

Closed
exuvo opened this issue Feb 24, 2014 · 2 comments
Closed

Patch for improving usability #78

exuvo opened this issue Feb 24, 2014 · 2 comments

Comments

@exuvo
Copy link

exuvo commented Feb 24, 2014

This patch addresses point 2 in #45.
It automatically runs journalctl if the systemctl call fails. It should detect if running in a user terminal or not and skip appropriately. I've done some testing on my system (Arch linux) and it seems to work but more testing is probably good given that netctl is widely used. Diff is against 1.4.-2.

--- /usr/bin/netctl 2014-02-24 11:12:42.021776261 +0100
+++ netctl  2014-02-24 11:12:34.088473909 +0100
@@ -40,6 +40,10 @@
     shift
     set -- $(sd_escape "$@")
     systemctl $command $(printf 'netctl@%s.service\n' "$@")
+    if [ $? -ne 0 ] && [ -t 1 ]; then
+      echo Command failed, last 1 min of log:
+      journalctl -n -o cat -u $(printf 'netctl@%s.service\n' "$@") --since=-1m
+    fi
 }

 list() {
@exuvo
Copy link
Author

exuvo commented Feb 25, 2014

I realised that the previous patch does not return the systemctl return value, fixed in following patch:

--- /usr/bin/netctl 2014-02-25 13:56:56.820655496 +0100
+++ netctl  2014-02-25 13:56:46.454029902 +0100
@@ -40,6 +40,12 @@
     shift
     set -- $(sd_escape "$@")
     systemctl $command $(printf 'netctl@%s.service\n' "$@")
+    ret=$?
+    if [ $ret -ne 0 ] && [ -t 1 ]; then
+      echo Command failed, last 1 min of log:
+      journalctl -n -o cat -u $(printf 'netctl@%s.service\n' "$@") --since=-1m
+    fi
+    return $ret
 }

 list() {

@joukewitteveen
Copy link
Owner

This kind of behavior should come from systemctl, not from netctl. If you have problems with the output of systemctl in the case of failing units, complain with systemd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants