Browse Source

Initial commit

master
dimti 1 year ago
commit
cde7488084
  1. 1
      .gitignore
  2. 49
      .gitignore-example
  3. 13
      nerest-quick.sh
  4. 1
      quick/.gitignore
  5. 25
      quick/create-config.sh.example
  6. 2
      quick/deactivate-unnecessary-plugins-on-local-env.sh.example
  7. 15
      quick/local/replace-domain.sh.example
  8. 20
      quick/restore-perms.sh.example
  9. 10
      quick/settings.sh.example
  10. 2
      wp-content/upgrade/.gitignore

1
.gitignore

@ -0,0 +1 @@
/.idea

49
.gitignore-example

@ -0,0 +1,49 @@
# Unnecessary files ignore
*.sql
*.gz
*.log
*.old
# wp config ignore
/wp-config.php
# wp-content uploads, backups and additional ignores
/wp-content/advanced-cache.php
/wp-content/aiowps_backups
/wp-content/backup-dup-lite
/wp-content/backupwordpress-*
/wp-content/backup*
/wp-content/cache
/wp-content/logs
/wp-content/updraft
/wp-content/wp-cache-config.php
/wp-content/webp-express
/wp-content/wp-rocket-config
# Letsencrypt dir ignore
/.well-known
# duplicator plugin wp-snapshots ignore
/wp-snapshots
/dup*.txt
# webmasters confirmation files
/yandex*.html
/google*.html
# IDE ignores
/.idea
# composer root vendor dir ignore
/vendor
# Apache htaccess ignore for resolve test/prod envs
/.htaccess
# Custom ignores
/*.txt
/serap*
/wp-content/gallery
/antibot8
/.tmb
/wp-config.bak.php

13
nerest-quick.sh

@ -0,0 +1,13 @@
#!/bin/bash
QUICK_DIR=quick
if [[ ! -d $QUICK_DIR ]]; then
echo "Quick dir not exists: ${QUICK_DIR}"
exit 1
fi
cd $QUICK_DIR
find ./ -name "*.sh.example" -exec sh -c 'F={}; cp -u $F ${F%.example}' \;
find ./ -name "*.sh" -exec sh -c 'F={}; chmod +x ${F}' \;

1
quick/.gitignore

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

25
quick/create-config.sh.example

@ -0,0 +1,25 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. "${SCRIPT_DIR}/settings.sh" || {
echo "no settings" && exit 1
}
wp core config --dbname=$PROJECT_NAME --dbuser=$PROJECT_NAME --dbpass=$PROJECT_NAME --dbhost=db --dbprefix=$TABLE_PREFIX
sed -i 's/<?php//' "${PROJECT_WEB_ROOT}/wp-config.php"
cat << \EOF | cat - "${PROJECT_WEB_ROOT}/wp-config.php" > /tmp/out && mv /tmp/out "${PROJECT_WEB_ROOT}/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

2
quick/deactivate-unnecessary-plugins-on-local-env.sh.example

@ -0,0 +1,2 @@
#!/bin/bash
wp plugin deactivate really-simple-ssl

15
quick/local/replace-domain.sh.example

@ -0,0 +1,15 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. "${SCRIPT_DIR}/../settings.sh" || {
echo "no settings" && exit 1
}
TABLE_WP_OPTIONS="${TABLE_PREFIX}options"
TABLE_WP_POSTS="${TABLE_PREFIX}posts"
TABLE_WP_POSTMETA="${TABLE_PREFIX}postmeta"
wp search-replace "https://${PROD_DOMAIN}" "http://${LOCAL_DOMAIN}" ${TABLE_WP_OPTIONS} ${TABLE_WP_POSTS} ${TABLE_WP_POSTMETA} --report-changed-only=true
wp search-replace "https:\/\/${PROD_DOMAIN}" "http:\/\/${LOCAL_DOMAIN}" ${TABLE_WP_OPTIONS} ${TABLE_WP_POSTS} ${TABLE_WP_POSTMETA} --report-changed-only=true
wp search-replace "${PROD_DOMAIN}" "${LOCAL_DOMAIN}" ${TABLE_WP_OPTIONS} ${TABLE_WP_POSTS} ${TABLE_WP_POSTMETA} --report-changed-only=true

20
quick/restore-perms.sh.example

@ -0,0 +1,20 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
WP_CONTENT_DIRS=(
plugins
upgrade
uploads
)
export WEB_GID=33
perms() {
sudo chown -R $UID:$WEB_GID "$1"
find "$1" -type d -exec chmod g+rwx '{}' \;
find "$1" -type f -exec chmod g+rw '{}' \;
}
for DIR in "${WP_CONTENT_DIRS[@]}"; do
perms "$SCRIPT_DIR/../wp-content/$DIR"
done

10
quick/settings.sh.example

@ -0,0 +1,10 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export PROJECT_NAME=wpstudio
export PROJECT_WEB_ROOT="${SCRIPT_DIR}/.."
export TABLE_PREFIX="wp_"
export PROD_DOMAIN=wpstudio.ru
export LOCAL_DOMAIN=wpstudio.local.wpstudio.ru

2
wp-content/upgrade/.gitignore

@ -0,0 +1,2 @@
*
!.gitignore
Loading…
Cancel
Save