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

can the systemd messages be disabled? #56

Open
bigguiness opened this issue Apr 6, 2018 · 4 comments
Open

can the systemd messages be disabled? #56

bigguiness opened this issue Apr 6, 2018 · 4 comments

Comments

@bigguiness
Copy link

I have a systemd service that uses config-pin to load the cape-universal overlay and then uses a file with config-pin to configure the pins. When it starts I get a bunch of noise in the systemd journal like:

Apr 06 10:11:21 beaglebone sudo[547]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/bash -c echo cape-universal > /sys/devices/bone_capemgr.*/slots
Apr 06 10:11:21 beaglebone sudo[547]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 06 10:11:22 beaglebone sudo[547]: pam_unix(sudo:session): session closed for user root
Apr 06 10:11:23 beaglebone sudo[789]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/bash -c echo low > /sys/class/gpio/gpio66/direction
Apr 06 10:11:23 beaglebone sudo[789]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 06 10:11:23 beaglebone sudo[789]: pam_unix(sudo:session): session closed for user root
Apr 06 10:11:23 beaglebone sudo[803]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/bash -c echo gpio > /sys/devices/ocp.3/P8_07_pinmux.14/state
Apr 06 10:11:23 beaglebone sudo[803]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 06 10:11:23 beaglebone sudo[803]: pam_unix(sudo:session): session closed for user root

There are similar messages for each direction/state setting.

Is there anyway to suppress these messages? They add a lot of noise to the journal.

Thanks

@bigguiness
Copy link
Author

I figured out a solution to avoid the noise in the journal.

The following patch first checks the id or the user. If it's root, the "sudo -A" is removed from the various "bash -c "echo ..." commands. If the if is non-root, the "sudo -A" is used.

Regards


--- config-pin.orig 2018-05-08 09:05:19.399629072 -0700
+++ config-pin 2018-05-08 09:11:12.341035364 -0700
@@ -1,5 +1,11 @@
#!/bin/dash

+if ! id | grep -q root; then

  • SUDO="sudo -A"
    +else
  • SUDO=
    +fi

Some important directories for use later

OCPDIR=/sys/devices/ocp.*
GPIODIR=/sys/class/gpio
@@ -879,7 +885,7 @@
# Expand filename using shell globbing
for FILE in $SLOTS ; do
echo_std Loading $DTBO overlay

  •   		sudo -A bash -c "echo $DTBO > $SLOTS" || (echo_err "Error loading device tree overlay file: $DTBO" && exit 1)
    
  •   		$SUDO bash -c "echo $DTBO > $SLOTS" || (echo_err "Error loading device tree overlay file: $DTBO" && exit 1)
      		sleep 1
      	done
      fi
    

@@ -1014,7 +1020,7 @@
eval GPIO="$${PIN}_GPIO"
FILE="$GPIODIR/gpio$GPIO/direction"
if [ -e $FILE ] ; then

  •   		sudo -A bash -c "echo $DIR > $FILE" || (echo_err "Cannot write gpio direction file: $FILE" && exit 1)
    
  •   		$SUDO bash -c "echo $DIR > $FILE" || (echo_err "Cannot write gpio direction file: $FILE" && exit 1)
      	else
      		echo_err "WARNING: GPIO pin not exported, cannot set direction or value!"
      	fi
    

@@ -1024,13 +1030,13 @@
# Expand filename using shell globbing
for FILE in $OCPDIR${PIN}_pinmux/state ; do
echo_dbg "echo $MODE > $FILE"

  •   		sudo -A bash -c "echo $MODE > $FILE" || (echo_err "Cannot write pinmux file: $FILE" && exit 1)
    
  •   		$SUDO bash -c "echo $MODE > $FILE" || (echo_err "Cannot write pinmux file: $FILE" && exit 1)
      	done
      else
      	# Expand filename using shell globbing
      	for FILE in $OCPDIR/${PIN}_pinmux.*/state ; do
      		echo_dbg "echo $MODE > $FILE"
    
  •   		sudo -A bash -c "echo $MODE > $FILE" || (echo_err "Cannot write pinmux file: $FILE" && exit 1)
    
  •   		$SUDO bash -c "echo $MODE > $FILE" || (echo_err "Cannot write pinmux file: $FILE" && exit 1)
      	done
      fi
    
    fi

@bigguiness
Copy link
Author

Well... that did't post well... Not sure how this Markdown stuff works...

@bigguiness
Copy link
Author

Maybe this will work...

`--- config-pin.orig 2018-05-08 09:05:19.399629072 -0700
+++ config-pin 2018-05-08 09:11:12.341035364 -0700
@@ -1,5 +1,11 @@
#!/bin/dash

+if ! id | grep -q root; then

  • SUDO="sudo -A"
    +else
  • SUDO=
    +fi

Some important directories for use later

OCPDIR=/sys/devices/ocp.*
GPIODIR=/sys/class/gpio
@@ -879,7 +885,7 @@
# Expand filename using shell globbing
for FILE in $SLOTS ; do
echo_std Loading $DTBO overlay

  •   		sudo -A bash -c "echo $DTBO > $SLOTS" || (echo_err "Error loading device tree overlay file: $DTBO" && exit 1)
    
  •   		$SUDO bash -c "echo $DTBO > $SLOTS" || (echo_err "Error loading device tree overlay file: $DTBO" && exit 1)
      		sleep 1
      	done
      fi
    

@@ -1014,7 +1020,7 @@
eval GPIO="$${PIN}_GPIO"
FILE="$GPIODIR/gpio$GPIO/direction"
if [ -e $FILE ] ; then

  •   		sudo -A bash -c "echo $DIR > $FILE" || (echo_err "Cannot write gpio direction file: $FILE" && exit 1)
    
  •   		$SUDO bash -c "echo $DIR > $FILE" || (echo_err "Cannot write gpio direction file: $FILE" && exit 1)
      	else
      		echo_err "WARNING: GPIO pin not exported, cannot set direction or value!"
      	fi
    

@@ -1024,13 +1030,13 @@
# Expand filename using shell globbing
for FILE in $OCPDIR${PIN}_pinmux/state ; do
echo_dbg "echo $MODE > $FILE"

  •   		sudo -A bash -c "echo $MODE > $FILE" || (echo_err "Cannot write pinmux file: $FILE" && exit 1)
    
  •   		$SUDO bash -c "echo $MODE > $FILE" || (echo_err "Cannot write pinmux file: $FILE" && exit 1)
      	done
      else
      	# Expand filename using shell globbing
      	for FILE in $OCPDIR/${PIN}_pinmux.*/state ; do
      		echo_dbg "echo $MODE > $FILE"
    
  •   		sudo -A bash -c "echo $MODE > $FILE" || (echo_err "Cannot write pinmux file: $FILE" && exit 1)
    
  •   		$SUDO bash -c "echo $MODE > $FILE" || (echo_err "Cannot write pinmux file: $FILE" && exit 1)
      	done
      fi
    
    fi
    `

@bigguiness
Copy link
Author

Nope... If you need the patch please let me know and I will email it to you.

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

1 participant