Daniele Lolli (UncleDan)'s picture
Long story short. I made a little script to fix permissions for Moodle and it turns out that it is useful tu use it also for turnker-moodle. As it needs little adaptations to be included in tkl main (and also as it can be useful also for the installed machine if you mess up something), am I allowed to download and run it directly form a the repo? something like: git clone MYREPO -o /scripts chmod +x /scripts/MYSCRIPT /MYSCRIPT -p1 -p2 -p3
Forum: 
Jeremy Davis's picture

Hi Uncle Dan, sorry for such a slow response...

I'm a bit bogged down with the v19. updated. It should have been released AGES ago, but I'm still battling with a few gnarly issues (primarily the installer).

I'm guessing you've probably worked it out by now, but bottom line yes, what you're doing is fine. Ultimately it doesn't really matter where you put it, but personally - assuming that it's a script you want accessible from everywhere - I like cloning repos like that into /usr/local/src and then linking to the executable in /usr/local/bin - then it will be in your PATH (so you don't need to put the full path or ./ prefix to run it).

E.g. I'd do something like this:

cd /usr/local/src
git clone MYREPO
ln -s /usr/local/src/MYREPO/MYSCRIPT  /usr/local/bin/MYREPO/MYSCRIPT

Also if you run the 'chmod +x MYSCRIPT' in your git repo and commit the change, the executable bit will be retained. Files in a git repo will inherit their owner and user group at clone time, but the read/write/execute permissions are saved in the repo.

FYI just in case you've heard that you should touch files in /usr - that is indeed (generally) correct as the contents of /usr directories are managed by the system (i.e. files from packages etc). However /usr/local is the exception. It can be user managed and that's where we put our custom scripts if they aren't packaged. It keeps them separate from system files but also keeps them all in the same spot. As I noted above /usr/local/bin is already in the PATH env var by default, so as long as the script is executable you can call the command from anywhere.

[update] - I just noticed that the last line of the command example above was incorrect/incomplete and have updated/fixed it now. FWIW the previous line would have created a link to the repo directory, not the actual script...

Add new comment