+ deactivate plugins helper wp script

+ ignore helper wp script for create .gitignore files in some wp-content dirs
+ nerest quick script example & readmes
* update quick scripts with use SCRIPT_DIR logic (where quick scripts placed in subfolder of root project dir)
* legacy create mysql example moved to root dir
This commit is contained in:
2022-07-10 11:57:01 +03:00
parent e612342ccc
commit cbbbe00cdb
10 changed files with 135 additions and 18 deletions

View File

@ -0,0 +1 @@
*.sh

26
wp/quick/create-config.sh Normal file
View File

@ -0,0 +1,26 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR/.."
NAME=wpstudio
wp core config --dbname=$NAME --dbuser=$NAME --dbpass=$NAME --dbhost=db
sed -i 's/<?php//' "$SCRIPT_DIR/../wp-config.php"
cat << \EOF | cat - "$SCRIPT_DIR/../wp-config.php" > /tmp/out && mv /tmp/out "$SCRIPT_DIR/../wp-config.php"
<?php
if (@$_SERVER['HTTP_HOST']) {
define('WP_SITEURL', 'http://'.$_SERVER['HTTP_HOST']);
define('WP_HOME', 'http://'.$_SERVER['HTTP_HOST']);
}
//if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'){
// $_SERVER['HTTPS'] = 'on';
// $_SERVER['SERVER_PORT'] = 443;
//}
define('FS_METHOD', 'direct');
EOF
$SCRIPT_DIR/deactivate-plugins-from-prod.sh

View File

@ -0,0 +1,5 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR/.."
#wp plugin deactivate really-simple-ssl

59
wp/quick/ignore.sh Normal file
View File

@ -0,0 +1,59 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
POSITIONAL_ARGS=()
MCLOUD=0
while [[ $# -gt 0 ]]; do
case $1 in
--mcloud)
MCLOUD=1
shift # past argument
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
echo "No support positional arguments"
exit 1
;;
esac
done
export SCRIPT_DIR
ignore() {
DIR="${SCRIPT_DIR}/../wp-content/${1}"
FILE="${DIR}/.gitignore"
if [[ ! -d $DIR ]]; then
mkdir $DIR
fi
if [[ ! -f $DIR ]]; then
echo "*" > $FILE
echo "!.gitignore" >> $FILE
fi
git add -f $FILE
}
ignore uploads
ignore upgrade
if [[ $MCLOUD -eq 1 ]]; then
ignore mcloud-reports
ignore mcloud-view-cache
fi
# Create git ignore in quick script dir
QUICK_DIR_GIT_IGNORE="${SCRIPT_DIR}/.gitignore"
if [[ ! -f $QUICK_DIR_GIT_IGNORE ]]; then
echo "/*.sh" > $QUICK_DIR_GIT_IGNORE
fi
git add -f $QUICK_DIR_GIT_IGNORE

32
wp/quick/restore-perms.sh Normal file
View File

@ -0,0 +1,32 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
WP_CONTENT_DIRS=(
plugins
upgrade
uploads
mcloud-reports
mcloud-view-cache
)
export WEB_GID=33
perms() {
sudo chown -R $UID:$WEB_GID "$1"
sudo chmod -R g+rwx "$1"
}
permsFile() {
sudo chown $UID:$WEB_GID "$1"
sudo chmod g+rw "$1"
}
for DIR in "${WP_CONTENT_DIRS[@]}"; do
DIR="$SCRIPT_DIR/../wp-content/$DIR"
if [[ -f $DIR ]]; then
permsFile "$DIR"
else
perms "$DIR"
fi
done