PDA

View Full Version : /etc/yum/post-actions not working for me



Jeff Sadowski
24th October 2017, 03:22 PM
I installed yum postaction and tried to create my action as follows

I created the following script and ran it as root to create what I thought would run my
/home/scripts/post_upgrade_wall.sh after each dnf upgrade, update, install, remove
then to test I removed the link /bin/wall and copied the /home/scripts/wrapped/wall back to /bin/wall
then I kept running "dnf install links;dnf remove links"
but /bin/wall never get replaced as my /home/scripts/post_upgrade_wall.sh does
/etc/yum/post-actions/wall_check.sh is not being followed as documented.

/home/scripts/wall.sh

#!/bin/bash
yum_wrapper=/etc/yum/post-actions/wall_check.sh
post_upgrade_script=/home/scripts/post_upgrade_wall.sh
wrapped=/home/scripts/wrapped/wall
this_file=/home/scripts/wall.sh
if [ ! -f ${post_upgrade_script} ];then
echo "Creating upgrade script"
mkdir -p $(dirname ${post_upgrade_script})
cat << EOF > ${post_upgrade_script}
#!/bin/bash
if [ "\$(readlink /bin/wall)" != "${this_file}" ];then
echo "/bin/wall is not a soft link to ${this_file}"
if [ "\$(readlink /bin/wall)" = "" ];then
cp -f /bin/wall ${wrapped}
rm -f /bin/wall
ln -s ${this_file} /bin/wall
else
echo "/bin/wall is a link to \$(readlink /bin/wall)"
echo "Please copy it manually"
fi
fi
EOF
mkdir $(dirname ${yum_wrapper})
cat << EOF > ${yum_wrapper}
#!/bin/bash
*:any:${post_upgrade_script}
EOF
chmod +x ${yum_wrapper}
chmod +x ${post_upgrade_script}
fi
${post_upgrade_script}


input="$@"
if [ "${input}" = "" ];then
input=$(cat)
fi

logger -s "from ${BASH_SOURCE[0]} : $@" >/dev/null 2>&1
echo -e "${input}" | mutt -s "wall messages from $(hostname) at
$(date)" jeff.sadowski@gmail.com
echo -e "${input}" | ${wrapped}

Jeff Sadowski
24th October 2017, 05:13 PM
Simpler example

I installed yum-plugin-post-transaction-actions.noarch
then I created a file /etc/yum/post-actions/runme.sh



*:all:date > /tmp/ran.txt


chmod +x /etc/yum/post-actions/runme.sh

then I tried installing and removing links but I still don't see a /tmp/ran.txt

Am I not using this right?