'Best'??? Oh, boy, a quiz!!! ;)
How about a script to run via ssh and from /var/www/html (document root of the apache server)?
Something like the following ... feel free to Edit to taste!!!
Script called 'instmdl':
echo 'Two parameters: 1st is the moodle directory';
echo 'Moodle diretory: '$1;
echo 'Second is the branch: 19, 21, 22, 23, 24';
echo 'Git branch: '$2;
echo 'Will create '$1' directory and use MOODLE_'$2'_STABLE as branch.';
echo 'Pause. ENTER to continue.';
read $keypress;
git clone git://git.moodle.org/moodle.git $1;
cd $1;
pwd;
git branch -a;
git branch --track MOODLE_$2_STABLE origin/MOODLE_$2_STABLE;
git checkout MOODLE_$2_STABLE;
# one could add lines to create the data directory and the DB here
# cd admin/cli/;
# php install.php
# chown apache:apache ../../../$1 -R;
cd ../;
chown apache:apache $1 -R;
echo 'Done';
echo 'Create DB and data directory.'
To run:
Login as root user. Change into /var/www/html/ and issue:
source instmdl moodle19 19
Suggest trying out in a test directory of your server.
As far as the 'Bonus Question' ... Moodle 2.3 and 2.4 and 2.5 will upgrade addons/plugins inside Moodle when 'registered' with Moodle and your 2.x Moodle set to do updates.
'spirit of sharing', Ken