OpenShift WordPress Theme Developer workflow - linux

I create a application with Cartridges,
PHP 5.4
MySQL 5.5
phpMyAdmin 4.0
I commit my WP file, plugin and themes into GIT.
In my .gitignore, i added
wp-content/uploads
I did go through the book "Getting Started with OpenShift", as the book chapter 8 said
“The other directory available to you is the OpenShift data directory,
which is currently at $OPENSHIFT_HOMEDIR/app-root/data. We use the
environment variable OPENSHIFT_DATA_DIR to point to this location. ”
“The data directory is where your application should store its files
and put configuration settings, download themes, or generally anything
you want to survive restarts and Git pushes.”
Excerpt From: Steven Pousty and Katie J. Miller. “Getting Started With OpenShift.”
I access to SSH. When I upload my media in WordPress, It is store inside
$OPENSHIFT_REPO_DIR/php/wp-content/uploads/2014/05/1.jpg
1.How do I pointed it to?
$OPENSHIFT_DATA_DIR/uploads
If that is the case, in my .openshift/action_hooks/deploy file, I had added this script
if [ ! -d ${OPENSHIFT_DATA_DIR}uploads ]; then
mkdir ${OPENSHIFT_DATA_DIR}uploads
fi
ln -sf ${OPENSHIFT_DATA_DIR}uploads ${OPENSHIFT_REPO_DIR}php/wp-content/
However, the soft link script does not did it job, during my GIT PUSH, it shows the following error.
remote: ln: target `/var/lib/openshift/[ID]/app-root/runtime/repo/php/wp-content/' is not a directory: No such file or directory
my guess is, the $OPENSHIFT_REPO_DIR/php/wp-content/uploads/2014/05/1.jpg , the uploads folder already removed before the script do it job.
How do I keep the uploads folder content in such a situation. OpenShift expert kindly help in this matter.

After I had few attempt of the build script, I finally found out what is my problem.
To answer my own questions
How do I point it.
Create a symlink. During the GIT push, it will definitely delete your uploads folder ($OPENSHIFT_REPO_DIR/wp-content/uploads/).
This is the code you should use, just remove the php folder after the repo.
if [ ! -d ${OPENSHIFT_DATA_DIR}uploads ]; then
mkdir ${OPENSHIFT_DATA_DIR}uploads
fi
ln -sf ${OPENSHIFT_DATA_DIR}uploads ${OPENSHIFT_REPO_DIR}wp-content/
I hope it's help.

This file has plenty of examples
https://github.com/openshift/wordpress-example/blob/master/.openshift/action_hooks/deploy
The problem is that with every git push we are going to overwrite that directory.
I think a better idea is with every build rsync contents from your repo over to the data directory where it expects to find the themes (rather than doing the symlink)

Related

How to install minishift in a customized directory in linux

While trying to start minishift, it automatically updates the cache in the home directory.
/home/abc/.minishift/cache/.....
However I want minishift to use a custom directory instead of the default home directory as I am running out of space
Can this be achieved by changing any parameters during ./minishift start
Tried codeready containers too, but it copies in the default home directory..
FATA Failed to copy embedded 'crc_libvirt_4.5.1.crcbundle' from /opt/data/crc-linux-1.13.0-amd64/crc to /home/abc/.crc/cache/crc_libvirt_4.5.1.crcbundle: write /home/abc/.crc/cache/crc_libvirt_4.5.1.crcbundle: no space left on device
I found the answer to this :
export MINISHIFT_HOME=/opt/softwares/
echo 'export MINISHIFT_HOME=/opt/softwares/' >> ~/.bashrc
This helped in solving the redirecting the installation from home to customized directory.
Similar for crc installation as well.
As noted, you should use Code Ready Containers (CRC) and not minishift. This is a known issue and is being tracked here: code-ready/crc/issues/817.
The current workaround seems to be to create the directory where you want it to be and then create a symlink to ~/.crc:
mkdir -p /opt/crc
ln -s /opt/crc/ ~/.crc

Remove a git fork on server

For school we use git to submit things. Every question here seems to be dealing with GitHub and isnt answering my specific question.
In our lab we were attempting to download the files but the prof was having issues on his end. He was asking me to try some commands etc. Anyways we did this:
ssh csci fork csci/Labs csci/$USER/Labs
git clone csci:csci/$USER/Labs
And it worked but the files had issues or something. He said he will get the sys admin to fix it. Then today he told me I need to delete my version on the server and just do it over again. I asked if I can just rm -r the folder but he said I need to delete the one on the git server - he said he doesnt know the command but I should be able to look it up.
I tried
git remote remove csci/Labs
but that did not work. I already deleted the local folder (before he told me about it actually) using rm -r Labs, and saying yes to the delete this git file warnings or whatever. So Im not sure where to go from here to delete it.
A repository is just a directory with working copy (though it is optional) and .git, so deleting the directory deletes the repository. To delete a remote repository you need to have access to the remote filesystem.
Try to run which should work also.
rm -rf .git

Set SVNs working copy to public_html on cPanel server with external repos

When I do php programming, I tend to edit in-place on the (development) server (cpanel VPS, not local) via a text editor that has built in sFTP. I like this because there isn't 100 thinkgs you have to do to "publish" the changes, you save (via FTP) and reload the page.
I want to get the source into SVN mostly so I can track other people's edits.
I currently use tortoiseSVN on my windows machine to access hosted SVN repos (csvdude/codison) for non web projects so I'm familiar with that. Linux SVN, not so much.
My thought here (open to other ideas) is that I want the public_html folder on the server to be the working copy (Is there a problem with this?). People can make edits as they would via sFTP and then the working copy would be committed to the external SVN repo, possibly on a late night cron..hoping I can set it up to auto-add and commit.
So aside from thoughts on the idea, I'm curious how to set up the linux svn client to commit to external repos a la tortoiseSVN. It seems all the tutorials I see set up a local repo.
Additionally I'm worried when I check out with public_html dir as the working copy that it will overwrite everything. (yes I have backups...)
Any input or suggestions would be awesome.. Thanks.
I created a new repo on my hosted SVN service.
I manually created a public_html folder using the repo browser.
On the cPanel server:
cd /home/[account]/
svn checkout https://svnservice.com/my_repo/public_html
I set up an ignore list for directories in public_html I didn't want in the repo.
Then you can add files and directories to the repo
cd public_html
svn add [directory] // adds directory for commit
svn add --force . // adds all new files without ignoring the ignore list
In hindsight, I think the import command would have done something similar, I just didn't quite understand it enough.
This is a useful command as well:
svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm % // removes files from repo that no longer exist in the working copy
EDIT: One thing I should mention is to make sure your .htaccess blocks access to .svn directories or it could expose source code.

gitweb not loading repositories through symlinks

I have gitweb on localhost and a sample project for which I've executed the git init git add and so on. I create a symlink with sudo ln -s /media/dir/project/.git/ /var/cache/git/project.git but it doesn't work and I still get 404 - no project found at localhost/gitweb.
The only way I can only bring the project info titles such as description, ..., then without project info, only the 4 sorting options, is to copy the git physically to /var/cache/git/project.git/ though some files won't be copied. This is the only way I could only not receive the not found error.
I manipulated the /etc/gitweb.conf and /etc/apache2/conf.d/gitweb in anyway, but it didn't help.
(I'm using apache 2.2 under Kubuntu 11.10)
Thanks so much for your helps!
Check the permissions on all of the directories in the symlink path. Whatever user your cgi is running as needs at least +x on all the parent dirs and +r on the .git directory and files.

Exporting files from hook in bare git repository

So, my situation is the following: I want to maintain my website using emacs-muse mode. For transferring the website (and version control), I want to use git. So I would create a hook in the remote (bare) repository that automatically copies the HTML subdir to the web directory. How can I do that from a hook? Also note that the whole directory contains a lot of files, so I can't export the whole directory.
Any help welcome.
You can use git archive, as it takes a path command. So, in your post-update hook you can do something like
git archive $SHA HTML | (cd dir/where/html/should/go && tar x)
this first creates a tarball of the subdir, and pipes that tarball to a tar command to untar it in the specified directory
(just a suggestion, as it may not be applicable in your exact configuration)
You might consider adopting this Web-Focused Git Workflow which, instead of copying, does push your repo directly on the web directory.
(From Joe MALLER)
Less complicated: Using Git to maintain your website (Daniel MIESSLER):
Daniel MIESSLER has an updated version of that same process:
Other suggestions are available at this SO question, like this post-update script mentioned in the Git FAQ.

Resources