I've been hacking /etc/profile tonight.
Barry's original does the job, but it's repetitive (lines 66-75) and does
NOT absorb as vars all the "default*" scripts modern Puppies have at
/usr/local/bin.
I tried using referenced variables (something like "${!DEFAULTTHINGY}")
with names derived from the file names and got nowhere.
So I used sort of a create-the-variable-on-the-rebound kind of script.
Read the comments in the script and you'll see what I mean.
We create a separate file from the listing of /usr/local/bin/default*,
process it and then incorporate it at the top of profile.local -- which we
have to create if we don't have it already. No big deal, though.
This is the top of my new /etc/profile.local now:
Code: Select all
# /etc/profile.local
. /tmp/default-execs.tbl
(...)
PATH, various LANG variables, etc.
Then we can remove lines 66-79 in /etc/profile.
CAUTION: FOR EXPERIENCED USERS ONLY. DO NOT USE THIS SCRIPT
IF YOU DO NOT KNOW WHAT YOU ARE DOING.
Code: Select all
#!/bin/bash
# /root/my-applications/bin/essai2.sh
# (Renommer comme vous voulez / Rename as you like.)
#
# Pour remplacer les énoncés "DEFAULT" dans /etc/profile /
# To replace the "DEFAULT "statements in /etc/profile
#
# Please read the embedded comments.
#
# (c) musher0, 16 Dec. 2018. GPL3.
####
cd /usr/local/bin
ls --file-type default* | grep -vE "changer|handler|imageeditor" > /tmp/default-execs # | wc -l # 29 au total
# There are 29 practical "default*" execs in XenialPup-706's /usr/local/bin
# the user can readily use. YMMV depending on your Pup.
# That's more than BarryK's original set.
# We leave imageditor out because it's a symlink for defaultpaint;
# changer, you may leave in, but handler should stay out to avoid accidents.
> /var/default-execs.tbl # formerly /tmp/default-execs.tbl
while read line;do
echo "export ${line^^}=/usr/local/bin/$line" >> /var/default-execs.tbl
done < /tmp/default-execs
rm -f /tmp/default-execs
cd -
# Then we create profile.local if non-existent and/or incorporate
# . /var/default-execs.tbl
# at the top.
#
# If we have a memory lapse we can run
# more /var/default-execs.tbl
# to refresh our memory.
that, if you can't remember, e.g., which screenshot utility you have on
this Pup, you open a console, you type
Code: Select all
$DEFAULTSCREENSHOT
~~~~~~~~~
Edit, the following day:
/tmp/default-execs.tbl replaced by /var/default-execs.tbl in the above,
since we are dealing here with long-term variables.
I also incorporated a short form of the above edited script in /etc/profile.
(Please see attached zip file.) This way, should /var/default-execs.tbl
be erased (stuff in /var is not intended to be stored there for ever and
ever; longer than in /tmp, but not forever), /etc/profile can recreate
it and /profile.local, pick up the fresh copy.
End of edit.
~~~~~~~~~
You could as well type < defaultscreenshot > directly, I suppose.
FWIW. I hope this can be useful if only as an exercise.
~~~~~~~~~
Edit, the following day:
Why did BarryK do it like that, anyway? He is using these
$DEFAULTEXECS in some of his other scripts, I suppose?
End of edit.
~~~~~~~~~
Any constructive comments welcome.
BFN.