Installing and upgrading help

Installing and updating via GIT - themes and plugins help

 
Picture of Ryan B
Installing and updating via GIT - themes and plugins help
 

Hi all,

I've previously had Moodle 2.7 running on Bluehost shared hosting, but I just got my own server setup today with Ubuntu Server. I have physical access to it as well as SSH access. I've got Moodle set up according to the step-by-step instructions (https://docs.moodle.org/27/en/Step-by-step_Installation_Guide_for_Ubuntu), but I'm confused about one point about the git repository and the live site.

Just like the instructions, I've put a git reposity in /opt/, and I've got the live site in /var/www/html. I want to install some themes and plugins, but I'm curious as to the specific procedures for installing them and updating Moodle, because of this section (https://docs.moodle.org/27/en/Step-by-step_Installation_Guide_for_Ubuntu#Step_5:_Copy_local_repository_to_.2Fvar.2Fwww.2Fhtml.2F) about copying the local repository to the live site, and includes the explanation.

I understand how it works - I use git to update the repository, then I copy the new files over to the live site. But how about themes and plugins? The way I read the explanation, I should copy a theme, let's say Essential, to the repository. Then I edit the /opt/moodle/.git/info/exclude file and add the line

/theme/essential

Then I can either copy the repository over to the live site again, or I can download the theme to the live site. Either way, the exclude will make sure that the /theme/essential folder isn't erased/removed during a git pull, right?

So, ideally, I should download all necessary themes and plugins, put them in the repository, write the excludes, and then update the repository and copy it over to the live site. Do I have that right, or am I all messed up?


Thanks.

 
Average of ratings: -
Picture of Howard Miller
Re: Installing and updating via GIT - themes and plugins help
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

I'll tell you what *I* do... like everything else it's far from the only way. 

- Create the new *core* Moodle site using git (no problem hopefully). I'm assuming you cloned from a public Moodle git repository, so 'origin' will point to the Moodle repo. 
- Now consider that by adding plugins you are actually creating a customised version of the site, so lets make a branch for that...

git checkout -b ryan29

...(I'm assuming you are using 2.9 but it doesn't matter)
- so then just add the plugins you want however you like (I download the zip files and unpack them)
- If you now run

git status

...you will see you have a bunch of new files to commit, so in the root of your Moodle install...

git add .
git commit -m 'ryan29: adding all my themes and plugins'

- notice what I did not do is to add anything to .gitignore or whatever, no need.
- Now, if I want to update to the latest version of 2.9..

git fetch --all
git merge origin/MOODLE_29_STABLE

- If I want to update any plugins, I set the permissions for the site to 0777, I update through the web interface and then put it back to 0755 again, and then...

git add .
git commit -m 'ryan29: updating my plugins to the latest version'

That's all there is to it.

 
Average of ratings: Useful (1)
Picture of Ryan B
Re: Installing and updating via GIT - themes and plugins help
 

- Now consider that by adding plugins you are actually creating a customised version of the site, so lets make a branch for that...

git checkout -b ryan29


Do I do this in the /opt/moodle directory or a completely new directory?

Basically, I would be making two git repositories. One for the original moodle and one for my use with plugins.

I can then add plugins/themes/whatever, update the original, and merge all the changes. Is that about right?

Sounds interesting. I may have to try that. Thanks.

 
Average of ratings: -
Picture of Ryan B
Re: Installing and updating via GIT - themes and plugins help
 
I've been doing some research on git all day. It seems like you need to make this git repository in the /var/www/html/ folder, right? That way it's already present on the web.

However, that's problematic for me, as I have not yet figured out how to give myself SFTP access to that directory (I can't transfer files).

I've been following the "Git for Developers" moodle page (https://docs.moodle.org/dev/Git_for_developers#General_workflow), but since I only have SFTP access to my /home directory, I have to upload the plugins and themes there, and then copy it all the /var/www/html directory for it to go live. However, that presents a problem, as all my settings (after installing Moodle) are reset (they aren't present in the git repository).

This is all new to me - using Bluehost was relatively easier, but I didn't have the control I do now. So I'm battling a few battles here:
1) How to get SFTP access to the /opt/moodle or the /var/www/html directories
2) How to establish a workflow of pulling from Moodle Git, working on a branch, merging the changes, and pushing it live to the /var/www/html directory without resetting the installation.
 
Average of ratings: -
Picture of Howard Miller
Re: Installing and updating via GIT - themes and plugins help
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Right... there's a few problems here as I see it.

1. You have limited access to your host and/or may not have the ability to execute git commands on your host. If you don't have command line access then this is likely, so I am going to assume that we are doing all the git stuff to maintain your Moodle stuff on a 'local' PC and then upload it to the host. However, it doesn't matter where you do the git stuff - directly in the /var/www/html folder is undoubtedly easiest but only from the point of view it removes the upload step. Anyway...

2. Everything above assumes you are performing the git commands from the 'root' of your Moodle folder. Where the config.php file lives. 

So, I would 'create' your custom Moodle instance somewhere where you do have full control and then SFTP to your host. There are git packages for all operating systems. I'm not a Windows user at all so my commands are for command line Linux but the principles will be the same. 

You don't need multiple repos for Moodle. Remember, when you clone Moodle from github (or wherever) you get *all* the branches and all their history right there. The only thing you are really interested in is your own version. So, create a new branch for that, build up the options you need and commit your changes to your branch. Then SFTP it to the host. The only issue you might have is that the .git directory will be big and will slow down your upload. If your SFTP client can do this you might want to exclude it completely (you don't need it on the host)

HTH

 
Average of ratings: Useful (1)
Picture of Ryan B
Re: Installing and updating via GIT - themes and plugins help
 

Thanks for helping me through it.

It took me a good afternoon of going through git tutorials, googling, reading on these forums and a few others, but I have it setup the way you described earlier.

Setting it up in the /var/www/html folder was easy, then just changing permissions to upload plugins via SFTP, changing permissions back, then committing the changes. Works like a charm.

One question more, if you don't mind. I'm currently using Moodle 2.7, so I'm changing everything in MOODLE_27_STABLE. If I want to upgrade to 2.8 or 2.9, what would be the procedure? Would it be as simple as changing the branch and pulling everything?

Thanks again.

 
Average of ratings: -
Picture of Howard Miller
Re: Installing and updating via GIT - themes and plugins help
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Unfortunately not, if you are moving Moodle branches then you pretty much need to start again as there will likely be updated versions of everything. 

The only exception would be if you had made core changes then you can track down the commits and cherry-pick them (might mean conflicts and might not work) but my advice is only to make core changes when its totally the last resort.

My git repository has hundreds of branches all with different versions of Moodle plus various mixes of addons - for different projects, clients etc. 

 
Average of ratings: Useful (1)
Picture of Ryan B
Re: Installing and updating via GIT - themes and plugins help
 

I just realized one thing. I've just got the basics of git down, and everything seems to be working well. However, when I run

> git status

I see the following:

> On branch Moodle27
> Your branch is ahead of 'origin/MOODLE_27_STABLE' by 1 commit.
> (use "git push" to publish your local commits)
> nothing to commit, working directory clean


Should I use git push? That would push my changes to the origin/MOODLE_27_STABLE, right? It doesn't automatically merge them, but it's more like a request for them to merge mine into theirs. There shouldn't be any reason why I need to do that, right?

Thanks again.

 
Average of ratings: -
Picture of Howard Miller
Re: Installing and updating via GIT - themes and plugins help
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

You know when I said, create your own branch for your own changes before adding anything? wink

What you are doing is 'tracking' the MOODLE_27_STABLE branch on Moodle's remote git repository. You have then changed something and committed it. If you had write access to that site, pushing it would change core Moodle (!!). You don't - which is just as well big grin

This is why you would first create and switch to (git checkout -b myownbranch) your own branch before making any local changes. 

What you could do as well is to get your own Github account and then push your branch there. This gives you a backup. 


HTH

 
Average of ratings: Useful (1)