Since we’re posting update scripts, here’s mine:
cp config.php-dist config.php
Dangerous, you might be running on zfs but you are posting this to people who aren’t. If the patch fails then copy/paste users can loose their config. I’d add:
mv -v config.php config.php-orig
This:
diff config.php-dist-old config.php-dist > config.php.changes
if [ -s config.php.changes ]; then
could be simpler, the following works (in bash anyway, also in ksh IIRC):
if ! diff config.php-dist-old config.php-dist > config.php.changes; then
Also:
patch < config.php.patch
if [ $? -eq 0 ]; then
Again, could be more direct:
if patch < config.php.patch ; then
Lack of exit codes means cron and schedulers don’t know it failed:
echo patch problems, fix manually
exit
Just add a non-zero exit code so other scripts/schedulers can error check.
FWIW, I do something very similar and after updating the schema I loop thru the plugins from git and pull those as well.
Thanks for sharing your code.
R
e: and a warning for newb’s might help bootstrap them into your flow:
if [ ! -f config.php.patch ] ; then
echo "before using this script you need to bootstrap the patch like this:"
echo "diff -u config.php-dist config.php > config.php.patch"
fi
or something like that. You obviously don’t need that in your script but when you share it would help the next poor soul; which is you intention. Just some thoughts. Thx again.