AWS : Bitnami : UNYSON : Cannot create temporary directory - amazon-web-services

I am facing the below issue-
WordPress 5.7.2 <> Tyring to install the required extension for UNYSON framework...and getting below error -
Install Extension Install theme compatible extensions
Downloading the "Shortcodes" extension...
Cannot create temporary directory:
Cannot create temporary directory: Return to the Extensions page
Tried - sudo chown -R bitnami:daemon /opt/bitnami/wordpress/wp-content/plugins
Still no luck...Please help.

I am able to fix the error using by adding the line.
define('WP_CONTENT_DIR', realpath(ABSPATH . './wp-content/'));
under the lines,
if ( ! defined( 'ABSPATH' ) ) { define( 'ABSPATH', __DIR__ . '/' );}
in wp-config.php.
Final code looks like this
if ( ! defined( 'ABSPATH' ) ) { define( 'ABSPATH', __DIR__ . '/' );}
define('WP_CONTENT_DIR', realpath(ABSPATH . './wp-content/'));

Let's reset the WordPress permissions:
sudo chown -R bitnami:daemon /opt/bitnami/wordpress
sudo chown -R bitnami:daemon /bitnami/wordpress/
sudo chmod -R g+w /opt/bitnami/wordpress
sudo chmod -R g+w /bitnami/wordpress/
sudo chmod 644 /bitnami/wordpress/wp-config.php
Can you install the WordPress' plugin now?

I solved the problem.
Just go to the linux's command line, access the config archive using:
vim /opt/bitnami/wordpress/wp-config.php
Then find this piece of code:
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
Press ' i ' to insert a new line of code right below that one, and write:
define('WP_CONTENT_DIR',realpath(ABSPATH.'/wp-content/'));
As a result you must have:
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
define('WP_CONTENT_DIR',realpath(ABSPATH.'/wp-content/'));
/**
* The base configuration for WordPress
*
Then just press 'ESC' to stop editing, then :W to save - or write - the code, and lastly :Q to quit the file.
Now you must be able to run the installation/ update successfully

Related

if condition to folder branch in Jenkinsfile

I have branch folder "feature-set" under this folder there's multibranch
I need to run the below script in my Jenkinsfile with a condition if this build runs from any branches under the "feature-set" folder like "feature-set/" then run the script
the script is:
sh """
if [ ${env.BRANCH_NAME} = "feature-set*" ]
then
echo ${env.BRANCH_NAME}
branchName='${env.BRANCH_NAME}' | cut -d'\\/' -f 2
echo \$branchName
npm install
ng build --aot --output-hashing none --sourcemap=false
fi
"""
the current output doesn't get the condition:
[ feature-set/swat5 = feature-set* ]
any help?
I would re-write this to be primarily Jenkins/Groovy syntax and only go to shell when required.
Based on the info you provided I assume your env.BRANCH_NAME always looks like `feature-set/
// Echo first so we can see value if condition fails
echo(env.BRANCH_NAME)
// startsWith better than contains() based on current usecase
if ( (env.BRANCH_NAME).startsWith('feature-set') ) {
// Split branch string into list based on delimiter
List<String> parts = (env.BRANCH_NAME).tokenize('/')
/**
* Grab everything minus the first part
* This handles branches that include additional '/' characters
* e.g. 'feature-set/feat/my-feat'
*/
branchName = parts[1..-1].join('/')
echo(branchName)
sh('npm install && ng build --aot --output-hashing none --sourcemap=false')
}
This seems to be more on shell side. Since you are planning to use shell if condition the below worked for me.
Administrator1#XXXXXXXX:
$ if [[ ${BRANCH_NAME} = feature-set* ]]; then echo "Success"; fi
Success
Remove the quotes and add an additional "[]" at the start and end respectively.
The additional "[]" works as regex

bash_profile open cv and fi error

There are few problems that need to solve.
first there is an error. -bash: /Users/jay/.bash_profile: line 7: `fi'
second, i am having trouble updating .bash_profile to install opencv.
http://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/
Here are the code below and please help.
many thanks!
# added by Anaconda2 4.2.0 installer
export PATH="/Users/jay/anaconda2/bin:$PATH"
export PATH=/usr/local/bin:$PATH
source '/Users/jay/Downloads/google-cloud-sdk/path.bash.inc'
fi
source '/Users/jay/Downloads/google-cloud-sdk/completion.bash.inc'
fi
# The next line updates PATH for the Google Cloud SDK.
if [ -f /Users/jay/Downloads/google-cloud-sdk/path.bash.inc ]; then
source '/Users/jay/Downloads/google-cloud-sdk/path.bash.inc'
fi
# The next line enables shell command completion for gcloud.
if [ -f /Users/jay/Downloads/google-cloud-sdk/completion.bash.inc ]; then
source '/Users/jay/Downloads/google-cloud-sdk/completion.bash.inc'
you have fi statements without if (fi is the 'closing' statement for an 'opening' if):
source '/Users/jay/Downloads/google-cloud-sdk/path.bash.inc'
fi
source '/Users/jay/Downloads/google-cloud-sdk/completion.bash.inc'
fi
bash syntax for if statements is e.g.
if [ -f /var/log/messages ]; then
echo "/var/log/messages exists."
fi
so for you this may be:
if [ -f '/Users/jay/Downloads/google-cloud-sdk/path.bash.inc']; then
source '/Users/jay/Downloads/google-cloud-sdk/path.bash.inc'
fi
and similar for the next line.
and there is a final fi missing at the end of your file.

autoenv printing "will run" /path/to/.env everytime I cd

My specific problem is not the fact that source /venv/bin/activate is being executed everytime I change to a sub folder. The problem is everytime I do it prints "will run" /path/to/.env
I installed autoenv through homebrew in version 0.2.0. This is my .env file:
if [ -z "$VIRTUAL_ENV" ]; then
CUR_DIR=$(pwd)
# search for the next .env
while [[ "$PWD" != "/" && "$PWD" != "$home" ]]; do
env_file="$PWD/.env"
if [[ -f "$env_file" ]]; then
BASE_DIR=$(dirname $env_file)
break
fi
builtin cd ..
done
if [ ! -z "$BASE_DIR" ]; then
echo "Activating that virtualenv"
source ${BASE_DIR}/venv/bin/activate
fi
cd $CUR_DIR
fi
The output in the terminal is something like:
MacBook-Pro:~ llamasramirez$ cd Desktop/oficios/
Will run /Users/llamas/Desktop/oficios/.env
Activating that virtualenv
Will run /Users/llamas/Desktop/oficios/.env
(venv) MacBook-Pro:oficios llamasramirez$ cd django_sites/polls/
Will run /Users/llamas/Desktop/oficios/.env
(venv) MacBook-Pro:polls llamasramirez$
Turns out the problem wasn't in the .env file. The problem was at the activate.sh file.
Opening the autoenv_init function there's a for loop that makes the annoying echo instruction:
for _file in ${_orderedfiles}; do
echo "Will run ${_file}"
autoenv_check_authz_and_run "${_file}"
done
When I comment this the echo doesn't pops up again.

How to move fossil repository subdirectory tree (to elsewhere within same repository, retaining tree levels)

I have a directory with multiple levels of subdirectories inside a fossil checkout, that I want to move to another location in a different subdirectory and retain the multiple-level directory structure.
For instance, to move a1 into a2 below, to go from having (handwritten like an abbreviated find command output):
a1/
a1/b/
a1/b/files
a1/c/
a1/c/d/
a1/c/d/more-files
a2/
I want fossil mv --hard a1 a2 to result in:
a2/a1/
a2/a1/b/
a2/a1/b/files
a2/a1/c/
a2/a1/c/d/
a2/a1/c/d/more-files
Just like the normal unix mv command would result in. Ideally with the history of the mv kept so it can be merged into another branch with any changes to files and more-files intact; as I could just fossil remove the files then re-add them as fresh files, but this is an uglier solution than I'd like.
fossil mv command (in v1.33 on Linux) loses the multiple levels and I end up with all files from lower level subdirectories moved into the top level directory of the new location.
One solution was to write a script to move each directoy individually, a level at a time, so it retained the structure. I would like to suggest this functionality to the fossil developer(s). I may post the script (below, with another dependency script included below that) to my github (user jgbreezer) sometime, but for now, this script (which I called fossilmvtree). It ignores files in the checkout not in fossil and will leave the old files/dirs where there are any (I don't believe it deletes them):
#!/bin/bash
# $1=source tree
# $2=dest. dir
# supports fossil mv options
# moves single source tree as-is to under/new dest.dir (not reducing dir levels to flat structure under dest dir)
exclude=''
usage () {
cat >&2 <<EOF
Usage: fossilmvtree [-x|--exclude= exclude_dirname] source dest"
-x option may be specified multiple times; do not specify full paths, just last
(filename/aka basename) of a directory to exclude from the move.
Command-line arguments are always included.
EOF
}
while [ -z "${1##-*}" ]
do
case "$1" in
-x|--exclude|--exclude=*)
if [[ "${1#--exclude=}" == "$1" ]]
then
# separate arg, '--exclude=' not used
shift
arg="$1"
else
arg="${1#--exclude=}"
fi
excinfo="$excinfo $arg"
# pruning is efficient
exclude="$exclude -type d -name '${arg//\'/\\\'}' -prune -o"
;;
--case-sensitive)
fossilopts="$fossilopts $1 $2"; shift;;
-*)
fossilopts="$fossilopts $1";;
esac
shift
done
echo "excluding paths: $excinfo"
echo "fossil mv options: $fossilopts"
[ $# -eq 2 ] || { usage; exit 1; }
mv="$(which fossilmvrev 2>/dev/null)" || { usage; echo "error:Missing fossilmvrev" >&2; exit 1; }
src="$1"
srcdir="$(basename "$src")"
dst="$2"
if [ -f "$dst" ]
then
# move src to new subdir of dst; otherwise we're renaming and moving
[ -d "$dst" ] || { echo "error:Destination '$dst' exists but is not a directory" >&2; exit 1; }
dst="$dst/$srcdir"
fi
#could set safe PATH (-execdir is cautious of relative/empty paths in $PATH but fossil binary might not be in std.location): PATH=/bin:/usr/bin:/usr/local/bin
eval find "$src" $exclude -type d -printf '%P\\n' | {
while read -r dir
do
[ -z "$dir" ] || [[ "$src/$dir" == "$dst/$dir" ]] && continue
echo
echo "fossil mv $src/$dir/* $dst/$dir/"
mkdir -p "$dst/$dir" || exit 1
find "$src/$dir" -maxdepth 1 \! -type d -exec "$mv" $fossilopts "$dst/$dir" '{}' +
rmdir "$src/$dir" # tidy up, as we only moved the files above (fossil doesn't really manage dirs)
# if rmdir fails due to remaining files, let user manage that (rmdir will complain to stderr if so) -
# likely to be unversioned files they might have forgotten about, shouldn't delete without user's knowledge.
done
}
It was only really tested once or twice on my specific fossil checkout, though written ready to be a re-usable script; please check the diffs (suggest do a clean checkout somewhere else and run it on that, then diff against your regular one using "diff -qr" or something before committing to check it behaved itself).
Careful if using the -x/exclude option, I wasn't sure that worked properly.
It depends on fossilmvrev script:
#!/bin/sh
# switch order of move arguments around to work with find -exec ... +
opts=''
while [ -z "${1##-*}" ]
do
case "$1" in
--case-sensitive) opts="$opts $1 $2"; shift 2;;
*) opts="$opts $1"; shift;;
esac
done
destdir="$1"
shift
fossil mv $opts "$#" $destdir
I think there is a much simpler solution
(this is under Windows but similarly for Linux)
md a2\a1
fossil mv a1 a2/a1 --hard

Vagrant VM not getting Django and others requirements

I'm using Vagrant and Chef solo to setup my django dev environment. Using Chef Solo I successfully install my packages (vim, git, apt, python, mysql) but then when I setup my project using pip to download/install my requirements (django, south, django-registration, etc), these ones are not correctly downloaded/found in my fresh VM.
I'm not sure if it's a location issue, but it's downloading and I have only warnings, never errors, but then it's not at the supposed location (I have another project setup exactly the same and it works, so maybe I'm missing something here...).
Here is my Vagrantfile:
Vagrant::Config.run do |config|
config.vm.define :djangovm do |django_config|
# Every Vagrant virtual environment requires a box to build off of.
django_config.vm.box = "lucid64"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
django_config.vm.box_url = "http://files.vagrantup.com/lucid64.box"
# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
django_config.vm.forward_port 80, 8080
django_config.vm.forward_port 8000, 8001
# Enable provisioning with chef solo, specifying a cookbooks path (relative
# to this Vagrantfile), and adding some recipes and/or roles.
django_config.vm.provision :chef_solo do |chef|
chef.json = {
python: {
install_method: 'source',
version: '2.7.5',
checksum: 'b4f01a1d0ba0b46b05c73b2ac909b1df'
},
mysql: {
server_root_password: 'root',
server_debian_password: 'root',
server_repl_password: 'root'
},
}
chef.cookbooks_path = "vagrant_resources/cookbooks"
chef.add_recipe "apt"
chef.add_recipe "build-essential"
chef.add_recipe "git"
chef.add_recipe "vim"
chef.add_recipe "openssl"
chef.add_recipe "mysql::client"
chef.add_recipe "mysql::server"
chef.add_recipe "python"
end
django_config.vm.provision :shell, :path => "vagrant_resources/vagrant_bootstrap.sh"
end
end
And here the bootstrap file to download Django and continue setting up things:
#!/usr/bin/env bash
eval vagrantfile_location="~/.vagrantfile_processed"
if [ -f $vagrantfile_location ]; then
echo "Vagrantfile already processed. Exiting..."
exit 0
fi
#==================================================================
# install dependencies
#==================================================================
/usr/bin/yes | pip install --upgrade pip
/usr/bin/yes | pip install --upgrade virtualenv
/usr/bin/yes | sudo apt-get install python-software-properties
#==================================================================
# set up the local dev environment
#==================================================================
if [ -f "/home/vagrant/.bash_profile" ]; then
echo -n "removing .bash_profile for user vagrant..."
rm /home/vagrant/.bash_profile
echo "done!"
fi
echo -n "creating new .bash_profile for user vagrant..."
ln -s /vagrant/.bash_profile /home/vagrant/.bash_profile
source /home/vagrant/.bash_profile
echo "done!"
#==================================================================
# set up virtual env
#==================================================================
cd /vagrant;
echo -n "Creating virtualenv..."
virtualenv myquivers;
echo "done!"
echo -n "Activating virtualenv..."
source /vagrant/myquivers/bin/activate
echo "done!"
echo -n "installing project dependencies via pip..."
/usr/bin/yes | pip install -r /vagrant/myquivers/myquivers/requirements/dev.txt
echo "done!"
#==================================================================
# install front-endy things
#==================================================================
echo -n "adding node.js npm repo..."
add-apt-repository ppa:chris-lea/node.js &> /dev/null || exit 1
echo "done!"
echo -n "calling apt-get update..."
apt-get update &> /dev/null || exit 1
echo "done!"
echo -n "nodejs and npm..."
apt-get install nodejs npm &> /dev/null || exit 1
echo "done!"
echo -n "installing grunt..."
npm install -g grunt-cli &> /dev/null || exit 1
echo "done!"
echo -n "installing LESS..."
npm install -g less &> /dev/null || exit 1
echo "done!"
echo -n "installing uglify.js..."
npm install -g uglify-js &> /dev/null || exit 1
echo "done!"
#==================================================================
# cleanup
#==================================================================
echo -n "marking vagrant as processed..."
touch $vagrantfile_location
echo "done!"
My requirements dev.txt looks like this:
Django==1.5.1
Fabric==1.7.0
South==0.8.2
Pillow==2.1.0
django-less==0.7.2
paramiko==1.11.0
psycopg2==2.5.1
pycrypto==2.6
wsgiref==0.1.2
django-registration==1.0
Any idea why I can't find Django and my other things in my VM?
This is a whole 'nother path, but I highly recommend using Berkshelf and doing it the Berkshelf way. There's a great guide online for rolling them this way.
That is, create a cookbook as a wrapper that will do everything your script does.
So the solution was to remove the dependency with Postgre psycopg2==2.5.1 I have in my requirements (from the setup in my other project), because here I'll be having a MySQL database instead.