Moving the application installation directory for bgscripts
Overview
My bgscripts package in version 1.1-27 and before was installed in /usr/bgscripts. The more I thought about it, and the more I read the spec for FHS 3.0 (filesystem hierarchy standard) (PDF), the more I realized it should actually be in /usr/share/bgscripts. Moving the files in the build directory was easy.
Wrapper script
But despite my symlinks in /usr/bin, which were easy to update, I have many, many hard-coded pathname calls of my scripts everywhere. So to mitigate the problem, I wrote a fancy wrapper script for regular scripts, including bup, send, bgscripts.bashrc, rdp, and treesize. I needed to send myself a message with the various information about what script called the old location. I picked send.sh because that's what it's for-- sending emails. I slapped in a bunch of diagnostic information and wrote a call to the new location. `
!/bin/bash # Wrapper at legacy location for bgscripts. Sends alert and then
continues the process. # DETERMINE LOCATION OF FRAMEWORK while read flocation;
do if test -x ${flocation} && test "$( ${flocation} --fcheck )" -ge 20161212;
then frameworkscript="${flocation}"; break; fi; done <
Deep dive search
So, I wanted to conduct a deep-dive search of all shell scripts (defined by me
as everything ending in .sh, because I almost always use the extension) on all
systems that refer to framework.sh, which is going to be the big hangup. So I
whipped up this oneliner. sudo updatedb; locate .sh | grep -iE "\.sh$" | grep
-viE
"\/usr\/src|\/usr\/share|\/usr\/lib|\/home\/.*\/rpmbuild/|\/home\/work\/.*clean"
| xargs grep -iE "framework\.sh"
Now, an reading of my code shows that many
of my scripts do a lookup for framework.sh in various locations, including
./framework.sh, ~/framework.sh, /usr/local/bin/framework.sh, and so on. You
can observe this pattern in my wrapper script in this post. So the serach will
catch those, but I will recognize those blocks of code because they are just
the filename on a separate line (in a here-
doc) and as long as I see the
/usr/libexec/bgscripts/framework.sh final resting place of framework, I'll be
satisfied.
References
Weblinks
- Filesystem hierarchy standard 3.0 http://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html
- FHS 3.0 in pdf http://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.pdf
- Here document https://en.wikipedia.org/wiki/Here_document
Comments