Browse Source

+ 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
master
dimti 2 years ago
parent
commit
cbbbe00cdb
  1. 0
      create-mysql-user.sh
  2. 6
      wp/.gitignore-example
  3. 23
      wp/README.md
  4. 5
      wp/nerest-quick.sh
  5. 1
      wp/quick/.gitignore-example
  6. 12
      wp/quick/create-config.sh
  7. 5
      wp/quick/deactivate-plugins-from-prod.sh
  8. 59
      wp/quick/ignore.sh
  9. 32
      wp/quick/restore-perms.sh
  10. 10
      wp/restore-perms.sh.example

0
wp/new-user.sh → create-mysql-user.sh

6
wp/.gitignore-example

@ -15,8 +15,6 @@
/wp-content/cache /wp-content/cache
/wp-content/logs /wp-content/logs
/wp-content/updraft /wp-content/updraft
/wp-content/upgrade
/wp-content/uploads
/wp-content/wp-cache-config.php /wp-content/wp-cache-config.php
/wp-content/webp-express /wp-content/webp-express
/wp-content/wp-rocket-config /wp-content/wp-rocket-config
@ -35,7 +33,7 @@
# IDE ignores # IDE ignores
/.idea /.idea
# Bash script helpers in root dir
/*.sh
# composer root vendor dir ignore
/vendor
# Custom ignores # Custom ignores

23
wp/README.md

@ -0,0 +1,23 @@
# Quick scripts
Create `quick` dir in your root project folder.
Place `.gitignore` file in that dir with these content:
```
*.sh
```
Copy needed helper scripts in that `quick/` dir and create copies with `.example` extension for adding example-scripts to your project GIT.
You might need add worked execute script for create executable copies from examples.
Add `nerest-quick.sh` to you root project dir:
```shell
#!/bin/bash
QUICK_DIR=quick
cd $QUICK_DIR &&
find ./ -name "*.sh.example" -exec sh -c 'F={}; cp -u $F ${F%.example} && chmod +x ${F%.example}' \;
```

5
wp/nerest-quick.sh

@ -0,0 +1,5 @@
#!/bin/bash
QUICK_DIR=quick
cd $QUICK_DIR &&
find ./ -name "*.sh.example" -exec sh -c 'F={}; cp -u $F ${F%.example} && chmod +x ${F%.example}' \;

1
wp/quick/.gitignore-example

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

12
wp/create-config.sh.example → wp/quick/create-config.sh

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

5
wp/quick/deactivate-plugins-from-prod.sh

@ -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

@ -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

@ -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

10
wp/restore-perms.sh.example

@ -1,10 +0,0 @@
#!/bin/bash
DIRS=( wp-content/plugins )
export WEB_GID=33
perms() {
sudo chown -R $UID:$WEB_GID "$1"
sudo chmod -R g+rwx "$1"
}
for DIR in "${DIRS[@]}"; do
perms "$DIR"
done
Loading…
Cancel
Save