Article 5FVDQ doinst.sh improvements suggestion

doinst.sh improvements suggestion

by
opty
from LinuxQuestions.org on (#5FVDQ)
doinst.sh improvements suggestion:

Code:config() {
NEW="$1"
OLD="${NEW%.new}"
# If there's no config file by that name, mv it over:
if [ ! -r "$OLD" ]; then
mv "$NEW" "$OLD"
elif [ "$(md5sum < "$OLD")" = "$(md5sum < "$NEW")" ]; then
# toss the redundant copy
rm "$NEW"
fi
# Otherwise, we leave the .new copy for the admin to consider...
}"for infile in $1; do [...] done" variant seems pointless to me but I may be missing something. "md5sum < file" already used but not everywhere.

Code:preserve_perms() {
NEW="$1"
OLD="${NEW%.new}"
if [ -e "$OLD" ]; then
for cmd in ch{own,mod}; do
$cmd --reference="$OLD" "$NEW"
done
fi
config "$NEW"
}Maybe it should do more than just chown and chmod? (Due to "cp -a ${OLD} ${NEW}.incoming" and I saw even "touch -r ${NEW} ${NEW}.incoming".)

Some ideas by lopid from ##slackware-help at Freenode.latest?d=yIl2AUoC8zA latest?i=4xaUTGh9s3k:s_8C1M_I6dI:F7zBnMy latest?i=4xaUTGh9s3k:s_8C1M_I6dI:V_sGLiP latest?d=qj6IDK7rITs latest?i=4xaUTGh9s3k:s_8C1M_I6dI:gIN9vFw4xaUTGh9s3k
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments