WordPress: 3-way-development with Git without 3rd Party Software - wordpress

Maybe this question is too broad (I hope not) but I'm currently don't know, how to solve my WordPress Git Branching Model problem.
My plan was to create a branching model like this without using a BitBucket Server or Jenkins:
So I've started making a git init in the wp-content folder of my PROD (at this time only installation of WP) system.
After I was done with this, I've cloned the whole PROD page and created a staging subdomain. After cloning was completed, I've deleted the wp-content folder at the staging system and typed in a git clone <prod-path>/.git.
This worked great and after doing some changes (for testing purposes) at the staging version, I was able to push them back to the PROD. Until now, everything is logic and normal and worked very well.
After thinking some time, I've got the great (maybe stupid) idea, to do the same with a local DEV clone on my PC. So I've did the same like at the staging version before, but this time, I've cloned the staging wp-content clone (PROD clone) to my local DEV version.
For the first view, everything looked fine but after trying to push something to the Staging system, I've got rejected from the target staging Git:
remote: error: refusing to update checked out branch: refs/heads/development
remote: error: By default, updating the current branch in a non-bare repository
So I first thought, that it's very stupid what I did, because the staging is also a clone without a HEAD like on the PROD (I think).
So my question to you:
Do you have an idea, how I can keep this kind of Workflow without any 3rd party software, but with 2 clones that I can work on DEV, test on Staging and going live on PROD?
To say it with commands:
1. git push <to the staging>
2. git push <to the prod>
3. git merge <dev to master>
Update
This is the content of my bare hooks folder (there is no post-received, what should I do?):
/wp-content/.bare/hooks$ ls -la
total 56
drwxr-xr-x 2 wp_ftp psacln 4096 Apr 11 13:09 .
drwxr-xr-x 7 wp_ftp psacln 4096 Apr 11 13:20 ..
-rwxr-xr-x 1 wp_ftp psacln 478 Apr 11 13:09 applypatch-msg.sample
-rwxr-xr-x 1 wp_ftp psacln 896 Apr 11 13:09 commit-msg.sample
-rwxr-xr-x 1 wp_ftp psacln 3327 Apr 11 13:09 fsmonitor-watchman.sample
-rwxr-xr-x 1 wp_ftp psacln 189 Apr 11 13:09 post-update.sample
-rwxr-xr-x 1 wp_ftp psacln 424 Apr 11 13:09 pre-applypatch.sample
-rwxr-xr-x 1 wp_ftp psacln 1642 Apr 11 13:09 pre-commit.sample
-rwxr-xr-x 1 wp_ftp psacln 1492 Apr 11 13:09 prepare-commit-msg.sample
-rwxr-xr-x 1 wp_ftp psacln 1348 Apr 11 13:09 pre-push.sample
-rwxr-xr-x 1 wp_ftp psacln 4898 Apr 11 13:09 pre-rebase.sample
-rwxr-xr-x 1 wp_ftp psacln 544 Apr 11 13:09 pre-receive.sample
-rwxr-xr-x 1 wp_ftp psacln 3610 Apr 11 13:09 update.sample

but after trying to push something to the Staging system, I've got rejected from the target staging Git
It depends what is the "rejected" message.
If it is
remote: error: refusing to update checked out branch: refs/heads/development
remote: error: By default, updating the current branch in a non-bare repository
That means you need to have a subfolder "bare" within your staging repo:
cd staging
git init --bare . bare
echo /bare/>>.gitignore
git add .gitignore
git commit -m "Ignore nested bare repo /bare/"
git remote add bare bare
git config remote.bare.fetch '+refs/heads/*:refs/remotes/bare/*'
cd bare
git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
Then modify the bare/hooks/post-receive file in order for it to:
be executable
include the following content
post-receive hook in bare nested bare repository:
#!/bin/bash
unset GIT_DIR
cd ..
git --work-tree=. --git-dir=.git fetch bare
git --work-tree=. --git-dir=.git fetch --tags bare
if ! git --work-tree=. --git-dir=.git merge-base --is-ancestor master origin/master; then
echo "Reset non-bare master to bare master (forced update)"
git --work-tree=. --git-dir=.git reset --hard origin/master
else
echo "Update non-bare master with merge from origin/master"
git --work-tree=. --git-dir=.git pull --no-rebase origin master
fi
Finally, on your dev cloned repo:
cd dev
git config --unset-all remote.origin.pushurl
git config --add remote.origin.pushurl "/path/to/staging/bare"
That way, you are fetching from the Staging repo as usual, but are pushing to the bare nested Staging repo, and the hook will update said Staging content.

Related

R package builds & pkgbuild::compile_dll failing; New files in /tmp are not executable

I'm attempting to build a package and install R packages that use Rccp. These are failing because files in /tmp are not executable.
These problems arose after switching to a new Dell xps 13 pre-installed with Ubuntu 18.04. For the build, I've been using pkgbuild::compile_dll to compile some C code with Rccp. I only found out about the problem installing new packages while troubleshooting the problem with compile_dll. This confirmed that its not a problem with pkgbuild.
Here is the error message from compile_dll:
> pkgbuild::compile_dll()
Registered S3 methods overwritten by 'ggplot2':
method from
[.quosures rlang
c.quosures rlang
print.quosures rlang
Re-compiling spstan
─ installing *source* package ‘spstan’ ...
** using staged installation
ERROR: 'configure' exists but is not executable -- see the 'R
Installation and Administration Manual'
─ removing
‘/home/connor/tmp/RtmpC0EMxX/devtools_install_570e38f2a7e3/spstan’
Error in (function (command = NULL, args = character(),
error_on_status = TRUE, :
System command error
There's plenty of help out there for this it seems, except that none of the solutions are working for me. Here is what I've tried.
Remount /tmp as in
https://github.com/r-lib/devtools/issues/32
Remount /tmp and enable executable files be entering the following in the terminal:
sudo mount -o remount,exec /tmp
Which gives the following error message: mount point not mounted or bad option. Since /tmp isn't mounted separately on my computer, its part of the root filesystem, the above solution fails because /tmp can't be remounted.
Following the instructions from the R Installation and Administration Manual, make sure TMPDIR points to some temporary file system in which scripts are allowed to be executed. So I made a new tmp folder called ~/Rtmp and mounted it:
mkdir ~/Rtmp
mount -t tmpfs -o exec ~/Rtmp
Also adding the following line to my ~/.Renviron file:
TMPDIR=/home/connor/Rtmp
and adding the following line to /etc/fstab:
tmpfs /home/connor/Rtmp tmpfs exec 0 0
and then rebooting the computer before running pkgbuild::compile_dll() again. I get the same error message but I could confirm that R was using /Rtmp folder I directed it to.
Following some advice here https://ubuntuforums.org/showthread.php?t=2421441 change permissions on the /tmp folder recursively with
sudo chmod -R 777 ~/tmp
This also fails. The problem seems to be that compile_dll is creating a new script that it wants to run and the permissions on the folder aren't the default for new files that get added to it.
When I print out the permissions for /tmp, the script that is failing with compile_dll is listed without the same permissions as all the older files:
drwx------ 3 connor connor 4096 Jun 23 15:20 RtmpC0EMxX
drwxrwxrwx 9 root root 4096 Jun 23 09:53 RtmpGb3QiA
drwxrwxrwx 3 connor connor 4096 Jun 23 10:44 RtmpI9hu1U
drwxrwxrwx 2 connor connor 4096 Jun 23 10:41 RtmpIgi5su
drwxrwxrwx 2 connor connor 4096 Jun 23 10:07 RtmpK4p4Od
drwxrwxrwx 4 root root 4096 Jun 23 09:17 RtmppdbqeT
drwxrwxrwx 10 root root 4096 Jun 23 09:54 RtmpR4Cc9c
drwxrwxrwx 14 root root 4096 Jun 23 10:13 Rtmpuweyxz
drwxrwxrwx 2 connor connor 4096 Jun 23 10:07 RtmpwN9SbT
drwxrwxrwx 2 connor connor 4096 Jun 23 10:04 RtmpY7g0NK
So I'm still stuck. Am I doing something wrong here? Or do I need to start looking somewhere else for the source of the problem?

Symfony 4 Unable to write on cache/dev directory

I've setup a new symfony 4 project. This is running on vagrant for local development. Now I'm running into file permission issues.
Symfony itself says it should be any problem: Setting up or Fixing File Permissions.
If I run bin/console cache:clear, the code is running fine. But once I change my code, I'm getting the following error:
(1/1) IOException
Unable to write to the "/var/www/path_to_project/var/cache/dev" directory.
Running bin/console cache:clear again, code works fine. But changing the code again, same write issue again.
I tried to chmod +r 777 var/cache/dev, but that doesn't change a thing. How can I fix this?
Output for Ahmed bhs
$ ls -la var/
total 16
drwxrwxr-x 4 vagrant vagrant 136 Jan 7 11:41 ./
drwxrwxr-x 14 vagrant vagrant 476 Jan 7 12:30 ../
drwxrwxr-x 3 vagrant vagrant 102 Jan 7 12:57 cache/
drwxrwxr-x 2 vagrant vagrant 68 Jan 7 11:41 log/
$ id
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant),4(adm),24(cdrom),27(sudo),30(dip),33(www-data),46(plugdev),110(lxd),115(lpadmin),116(sambashare),998(rvm),1003(www-user)
EDIT
The problem wasn't symfony but the configuration of my vagrantfile.
Synced_folder had owner 'vagrant' while apache 'www-data'. Made all 'www-data' and now it is working fine. Totally not symfony related!
Try
sudo chmod -R 777 /var/www/path_to_project/var/cache/*
Run chmod -R 0777 var instead of running commands for separate folders.

Unable to extract tar file - tar: extract not authorized

I am working on Solaris 10 machine. In that i cannot able to untar my file. Logs are given below. Anyone please suggest what may be the issue? I can able to create tar file but unable to untar. :(
bash-3.2# ls -lrth ConfigCheck-120614-KL.out*
-rw-r--r-- 1 root root 144K Jun 12 17:15 ConfigCheck-120614-KL.out
-rwxrwxrwx 1 root root 146K Jun 16 16:49 ConfigCheck-120614-KL.out.tar
bash-3.2# tar xvf ConfigCheck-120614-KL.out.tar
tar: extract not authorized
bash-3.2# tar tvf ConfigCheck-120614-KL.out.tar
-rw-r--r-- 0/0 147377 Jun 12 17:15 2014 ConfigCheck-120614-KL.out
Solaris 11 tar will fail with that error message if you are running as uid 0 but do not have the Media Restore profile set up in the RBAC configuration.
Unless you're trying to restore from backup, you should normally be untarring files as a normal user, not root, to avoid accidentally overwriting critical system files.

What's the function of search_index file in graphite?

I'm playing with graphite, and I met a problem which is graphite is not showing any metrics, even though I have feed it some data, and the data is stored in whisper. I guess this is caused by search_index file.
daniel#ubuntu:/var/lib/graphite$ ls -lh
total 72K
-rw-r--r-- 1 www-data www-data 64K Jul 4 21:49 graphite.db
-rw-r----- 1 _graphite _graphite 0 Jul 5 23:17 search_index
drwxr-xr-x 2 www-data www-data 4.0K Feb 2 02:33 whisper
What's the purpose of this file, who generated it and how change the ownership of it? graphite can not read it because of permission.
graphite complains :
IOError: [Errno 13] Permission denied: '/var/lib/graphite/search_index'
It seems this search_index file is the index used by webapp of graphite. My problem was caused by conflict between graphite in ubuntu package repo and python PYPI repo. first I install graphite by 'apt-get install' and then I use 'pip install' to install graphite again. These 2 commands will install graphite at different places, and apt-get will installs graphite at standard python library path, this will cause some subtle conflict to graphite installed by pip.
Today, I installed it with pip only on a new machine, everything works OK.

403 Error on Stylesheet - Raspberry Pi Webserver

I keep seeing a 403 error for my stylesheet which is hosted on my Rasberry Pi (webserver). I ran ls -al and this is the result:
pi#raspberrypi ~/www $ ls -al
total 16
drwxr-xr-x 2 pi root 4096 Mar 17 20:18 .
drwxr-xr-x 12 root root 4096 Mar 15 16:44 ..
-rw-r--r-- 1 pi root 644 Mar 17 20:18 index.html
-rw------- 1 pi root 329 Mar 17 20:19 stylesheet.css
The index.html data shows up when I point my browser at the ip, but there is no formatting and whenever I try to acess the css file through looking at the source code it keeps telling me theres a 403 error :(
Can anyone help a brother out??
Cheers!
You need proper permissions for the www folder, and that depends on which webserver you are running. For apache on debian the user is www-data, if your webroot is ~/www and you are user pi try these commands
Change owner to apache user recursively
Change Permissions to read for all recursively
chown -R www-data:www-data /home/pi/www
chmod -R 644 /home/pi/www

Resources