Compare commits

..

1 Commits

29 changed files with 35 additions and 408 deletions

View File

@ -1,18 +0,0 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export TMP_DIR=$SCRIPT_DIR/tmp
DIRS=(
cache
logs
user/config
user/data
user/accounts
user/pages
user/themes/quark/images
tmp
backup
images
assets
)

View File

@ -1,87 +0,0 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. "${SCRIPT_DIR}/_settings.sh" || {
echo "no settings" && exit 1
}
export WEB_GID=33
export DIRS_MODE=775
export FILES_MODE=664
echo -n "Check sudo permissions... "
sudo whoami
[ ! -d "$TMP_DIR" ] && {
echo "no tmp dir" && exit 1
}
perms() {
TARGET=$1
chmodFromFile() {
MODE=$1
FILE_LIST_FILE=$2
# shellcheck disable=SC2046
# shellcheck disable=SC2006
chmod "$MODE" `cat "$FILE_LIST_FILE"`
}
export -f chmodFromFile
echo -n "Set correct ownerships for $(basename ${TARGET})... "
sudo chown -R $UID:$WEB_GID "${TARGET}"
if [[ -d "${TARGET}" ]]; then
# echo -n "and fixing permissions for these directory... "
# echo "Fetching dirs without spaces"
find "${TARGET}" -type d -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep -v ' ' > $TMP_DIR/dirs-without-spaces
# echo "Splitting dirs by 10000 lines"
split -l 10000 $TMP_DIR/dirs-without-spaces $TMP_DIR/dirs-without-spaces-part-
# echo "Fetching files without spaces"
find "${TARGET}" -type f -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep -v ' ' > $TMP_DIR/files-without-spaces
# echo "Splitting files at 10000 lines"
split -l 10000 $TMP_DIR/files-without-spaces $TMP_DIR/files-without-spaces-part-
# echo "Fetching dirs with spaces"
find "${TARGET}" -type d -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep ' ' > $TMP_DIR/dirs-with-spaces
# echo "Fetching files with spaces"
find "${TARGET}" -type f -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep ' ' > $TMP_DIR/files-with-spaces
# echo "Fixing permissions for dirs"
# shellcheck disable=SC2038
# shellcheck disable=SC2016
find $TMP_DIR/ -maxdepth 1 -type f -name "dirs-without-spaces-part-*" | xargs -I {} bash -c 'chmodFromFile $DIRS_MODE {}'
# echo "Fixing permissions for files"
# shellcheck disable=SC2038
# shellcheck disable=SC2016
find $TMP_DIR/ -maxdepth 1 -type f -name "files-without-spaces-part-*" | xargs -I {} bash -c 'chmodFromFile $FILES_MODE {}'
# echo "Fixing permissions for dirs with spaces"
cat $TMP_DIR/dirs-with-spaces | xargs -I {} chmod $DIRS_MODE "{}"
# echo "Fixing permissions for files with spaces"
cat $TMP_DIR/files-with-spaces | xargs -I {} chmod $FILES_MODE "{}"
# echo "Removing temporary files"
rm $TMP_DIR/files-*
rm $TMP_DIR/dirs-*
echo "ok"
else
echo -n "and fixing permission for this file... "
# echo "Fixing permissions"
chmod $FILES_MODE "${TARGET}"
echo "ok"
fi
}
for DIR in "${DIRS[@]}"; do
perms "$SCRIPT_DIR/../$DIR"
done

View File

@ -14,78 +14,61 @@ WP_CONTENT_DIRS=(
) )
export WEB_GID=33 export WEB_GID=33
export DIRS_MODE=775
export FILES_MODE=664
echo -n "Check sudo permissions... " echo -n "Check sudo permissions... "
sudo whoami sudo whoami
[ ! -d "$TMP_DIR" ] && {
echo "no tmp dir" && exit 1
}
perms() { perms() {
TARGET=$1 TARGET=$1
chmodFromFile() {
MODE=$1
FILE_LIST_FILE=$2
# shellcheck disable=SC2046
# shellcheck disable=SC2006
chmod "$MODE" `cat "$FILE_LIST_FILE"`
}
export -f chmodFromFile
echo -n "Set correct ownerships for $(basename ${TARGET})... " echo -n "Set correct ownerships for $(basename ${TARGET})... "
sudo chown -R $UID:$WEB_GID "${TARGET}" sudo chown -R $UID:$WEB_GID "${TARGET}"
if [[ -d "${TARGET}" ]]; then if [[ -d "${TARGET}" ]]; then
# echo -n "and fixing permissions for these directory... " echo -n "and fixing permission for this directory... "
# echo "Fetching dirs without spaces" # echo "Fetching dirs without spaces"
find "${TARGET}" -type d -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep -v ' ' > $TMP_DIR/dirs-without-spaces find "${TARGET}" -type d -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep -v ' ' > $TMP_DIR/dirs-without-spaces
# echo "Splitting dirs by 10000 lines" # echo "Splitting dirs by 10000 lines"
split -l 10000 $TMP_DIR/dirs-without-spaces $TMP_DIR/dirs-without-spaces-part- split -l 10000 $TMP_DIR/dirs-without-spaces $TMP_DIR/dirs-without-spaces-part-
# echo "Fetching files without spaces" # echo "Fetching files without spaces"
find "${TARGET}" -type f -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep -v ' ' > $TMP_DIR/files-without-spaces find "${TARGET}" -type f -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep -v ' ' > $TMP_DIR/files-without-spaces
# echo "Splitting files at 10000 lines" # echo "Splitting files at 10000 lines"
split -l 10000 $TMP_DIR/files-without-spaces $TMP_DIR/files-without-spaces-part- split -l 10000 $TMP_DIR/files-without-spaces $TMP_DIR/files-without-spaces-part-
# echo "Fetching dirs with spaces" # echo "Fetching dirs with spaces"
find "${TARGET}" -type d -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep ' ' > $TMP_DIR/dirs-with-spaces find "${TARGET}" -type d -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep ' ' > $TMP_DIR/dirs-with-spaces
# echo "Fetching files with spaces" # echo "Fetching files with spaces"
find "${TARGET}" -type f -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep ' ' > $TMP_DIR/files-with-spaces find "${TARGET}" -type f -not \( -path *${THEME}/dist* -o -path */node_modules* \) | grep ' ' > $TMP_DIR/files-with-spaces
# echo "Fixing permissions for dirs" # echo "Fixing permissions for dirs"
# shellcheck disable=SC2038 # shellcheck disable=SC2038
# shellcheck disable=SC2016 # shellcheck disable=SC2016
find $TMP_DIR/ -maxdepth 1 -type f -name "dirs-without-spaces-part-*" | xargs -I {} bash -c 'chmodFromFile $DIRS_MODE {}' find $TMP_DIR/ -maxdepth 1 -type f -name "dirs-without-spaces-part-*" | xargs -I {} bash -c 'chmod 774 `cat {}`'
# echo "Fixing permissions for files" # echo "Fixing permissions for files"
# shellcheck disable=SC2038 # shellcheck disable=SC2038
# shellcheck disable=SC2016 # shellcheck disable=SC2016
find $TMP_DIR/ -maxdepth 1 -type f -name "files-without-spaces-part-*" | xargs -I {} bash -c 'chmodFromFile $FILES_MODE {}' find $TMP_DIR/ -maxdepth 1 -type f -name "files-without-spaces-part-*" | xargs -I {} bash -c 'chmod 664 `cat {}`'
# echo "Fixing permissions for dirs with spaces" # echo "Fixing permissions for dirs with spaces"
cat $TMP_DIR/dirs-with-spaces | xargs -I {} chmod $DIRS_MODE "{}" cat $TMP_DIR/dirs-with-spaces | xargs -I {} chmod 775 "{}"
# echo "Fixing permissions for files with spaces" # echo "Fixing permissions for files with spaces"
cat $TMP_DIR/files-with-spaces | xargs -I {} chmod $FILES_MODE "{}" cat $TMP_DIR/files-with-spaces | xargs -I {} chmod 664 "{}"
# echo "Removing temporary files" # echo "Removing temporary files"
rm $TMP_DIR/files-* # rm $TMP_DIR/files-*
rm $TMP_DIR/dirs-* # rm $TMP_DIR/dirs-*
echo "ok" echo "ok"
else else
echo -n "and fixing permission for this file... " echo -n "and fixing permission for this file... "
# echo "Fixing permissions" # echo "Fixing permissions"
chmod $FILES_MODE "${TARGET}" chmod 664 "${TARGET}"
echo "ok" echo "ok"
fi fi
} }
@ -94,4 +77,4 @@ for DIR in "${WP_CONTENT_DIRS[@]}"; do
perms "$SCRIPT_DIR/../wp-content/$DIR" perms "$SCRIPT_DIR/../wp-content/$DIR"
done done
#perms "$SCRIPT_DIR/../wp-content/index.php" perms "$SCRIPT_DIR/../wp-content/index.php"

14
quick/settings.sh.example Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export TMP_DIR=$SCRIPT_DIR/tmp
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
export THEME=nicol

View File

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

View File

@ -1,4 +0,0 @@
#!/bin/bash
REMOTE_SSH_USER=site_name
REMOTE_SSH_HOST=host_name
REMOTE_SSH_PORT=22

View File

@ -1,41 +0,0 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $SCRIPT_DIR/_settings.sh || {
echo "no settings" && exit 1
}
REMOTE_FROM_DATABASE_USERNAME=some_username
REMOTE_FROM_DATABASE_PASSWORD=some_password
REMOTE_FROM_DATABASE_NAME=some_database
DATABASE_USERNAME=site_name
DATABASE_PASSWORD='password'
DATABASE_NAME=site_name
echo -n "SSH connection verify... "
ssh $REMOTE_SSH_USER@$REMOTE_SSH_HOST -p $REMOTE_SSH_PORT "whoami"
if [[ "$?" -ne 0 ]]; then
echo "That is not ok... Abort program!"
exit 1
fi
WITHOUT_DROP_LOCAL_DB=0
if [[ ! -z "$1" ]]; then
WITHOUT_DROP_LOCAL_DB=1
fi
if [[ $WITHOUT_MAKE_DUMP -ne 1 ]]; then
echo -n "Drop and recreate local database... "
mariadb -e "DROP DATABASE \`${DATABASE_NAME}\`"
mariadb -e "CREATE DATABASE \`${DATABASE_NAME}\`"
fi
echo -n "Loading database from remote server... "
ssh $REMOTE_SSH_USER@$REMOTE_SSH_HOST -p $REMOTE_SSH_PORT \
"mysqldump -u $REMOTE_FROM_DATABASE_USERNAME -p$REMOTE_FROM_DATABASE_PASSWORD $REMOTE_FROM_DATABASE_NAME | bzip2 -c" \
| pv | bzip2 -cd | mariadb -u $DATABASE_USERNAME -p''"$DATABASE_PASSWORD"'' ${DATABASE_NAME}
echo "OK"

View File

@ -1,14 +0,0 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $SCRIPT_DIR/_settings.sh || {
echo "no settings" && exit 1
}
REMOTE_FROM_DIR_PATH=some_absolute_path_without_end_slash
DESTINATION_DIR_PATH=/var/www/html/wp-content/uploads
echo -n "Upload... "
rsync -a --info=progress2 -e "ssh -p ${REMOTE_SSH_PORT}" $REMOTE_SSH_USER@$REMOTE_SSH_HOST:$REMOTE_FROM_DIR_PATH/ $DESTINATION_DIR_PATH/
echo "OK"

View File

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

View File

@ -1,8 +0,0 @@
#!/bin/bash
SETTINGS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# exporting variables dot not effect to visibility for other scripts - all variables is visible
export TMP_DIR=$SETTINGS_SCRIPT_DIR/tmp
export THEME=demo

View File

@ -1,29 +0,0 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. "$SCRIPT_DIR/_settings.sh" || {
echo "no settings" && exit 1
}
APP_DIR="${SCRIPT_DIR}/.."
PLUGINS=(winter)
THEME_DIRS=(layouts pages partials)
export WEB_GID=33
perms() {
sudo chown -R $UID:$WEB_GID "$1"
sudo chmod -R g+rwx "$1"
}
perms "${APP_DIR}/storage"
perms "${APP_DIR}/bootstrap/cache"
for DIR in "${THEME_DIRS[@]}"; do
perms "${APP_DIR}/themes/$THEME/$DIR"
done
for DIR in "${PLUGINS[@]}"; do
perms "${APP_DIR}/plugins/$DIR"
done

View File

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

View File

@ -1,50 +0,0 @@
#!/bin/bash
git fetch origin --prune
export LANG=en_US.UTF-8
LOCAL_BRANCHES_IN_DEVELOP=( $(git branch --merged develop --format "%(refname:short)") )
LOCAL_BRANCHES_WITHOUT_UPSTREAM=( $(git branch --format "%(refname:short) %(upstream) %(upstream:track)" | grep -vE "(develop|master)" | awk '{if ($3 == "[gone]" || !$2) print $1;}') )
if [ ${#LOCAL_BRANCHES_WITHOUT_UPSTREAM[@]} -eq 0 ]; then
echo "Нет веток без remote"
else
LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_MERGED_INTO_DEVELOP=()
for BRANCH_WITHOUT_UPSTREAM in "${LOCAL_BRANCHES_WITHOUT_UPSTREAM[@]}"; do
for BRANCH_MERGED_IN_DEVELOP in "${LOCAL_BRANCHES_IN_DEVELOP[@]}"; do
if [ "$BRANCH_WITHOUT_UPSTREAM" == "$BRANCH_MERGED_IN_DEVELOP" ]; then
LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_MERGED_INTO_DEVELOP+=( "$BRANCH_WITHOUT_UPSTREAM" )
fi
done
done
if [ ${#LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_MERGED_INTO_DEVELOP[@]} -ne 0 ]; then
echo "Ветки без remote и вмерженные в develop"
# echo "${LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_MERGED_INTO_DEVELOP[@]}" | tr " " "\n"
echo "${LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_MERGED_INTO_DEVELOP[@]}"
fi
LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_NOT_MERGED_INTO_DEVELOP=()
for BRANCH_WITHOUT_UPSTREAM in "${LOCAL_BRANCHES_WITHOUT_UPSTREAM[@]}"; do
BRANCH_IS_MERGED_INTO_DEVELOP=0
for BRANCH_MERGED_IN_DEVELOP in "${LOCAL_BRANCHES_IN_DEVELOP[@]}"; do
if [ "$BRANCH_WITHOUT_UPSTREAM" == "$BRANCH_MERGED_IN_DEVELOP" ] ; then
BRANCH_IS_MERGED_INTO_DEVELOP=1
fi
done
if [ $BRANCH_IS_MERGED_INTO_DEVELOP -eq 0 ]; then
LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_NOT_MERGED_INTO_DEVELOP+=( "$BRANCH_WITHOUT_UPSTREAM" )
fi
done
if [ ${#LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_NOT_MERGED_INTO_DEVELOP[@]} -ne 0 ]; then
echo "Ветки без remote, но еще не вмерженные в develop"
# echo "${LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_NOT_MERGED_INTO_DEVELOP[@]}" | tr " " "\n"
echo "${LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_NOT_MERGED_INTO_DEVELOP[@]}"
fi
fi

View File

@ -1,31 +0,0 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
WP_CONTENT_DIRS=(
plugins
upgrade
uploads
themes
)
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

View File

@ -1,24 +0,0 @@
#!/bin/bash
SETTINGS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export TMP_DIR=$SETTINGS_SCRIPT_DIR/tmp
export PROJECT_NAME=wpstudio
export PROJECT_WEB_ROOT="${SETTINGS_SCRIPT_DIR}/.."
export TABLE_PREFIX="wp_"
export PROD_DOMAIN=wpstudio.ru
export LOCAL_DOMAIN=wpstudio.local.wpstudio.ru
export THEME=nicol
export SSH_PORT=22
export SSH_PROD_USERNAME=wpstudio
export SSH_PROD_SERVER=wpstudio.ru
export PROD_DATABASE_NAME=wpstudio
export LOCAL_DATABASE_NAME=wpstudio
export REMOTE_SITE_DIR=/var/www/html

View File

@ -1,4 +0,0 @@
# Place on remote server to home dir
[client]
user = wpstudio
password = PASSWORD

View File

@ -1,24 +0,0 @@
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "${SCRIPT_DIR}/../settings.sh" || {
echo "no settings" && exit 1
}
CONTAINER=$(docker ps | grep mariadb | awk '{print $1}')
if [[ -z "${CONTAINER}" ]]; then
echo "Unable to find container: db"
exit 1
fi
MYSQL_CMD="docker exec -i ${CONTAINER} mariadb -u root -p123456"
echo -n "Drop and recreate ${LOCAL_DATABASE_NAME} database... "
bash -c "${MYSQL_CMD} -e 'DROP DATABASE \`${LOCAL_DATABASE_NAME}\`'"
bash -c "${MYSQL_CMD} -e 'CREATE DATABASE \`${LOCAL_DATABASE_NAME}\`'"
echo "OK"
echo -n "Importing prod dump data from $SSH_PROD_SERVER ... "
ssh -C ${SSH_PROD_USERNAME}@${SSH_PROD_SERVER} "mariadb-dump --defaults-extra-file=/home/${SSH_PROD_USERNAME}/.my.cnf ${PROD_DATABASE_NAME} | sed '1d'" | pv | bash -c "${MYSQL_CMD} ${LOCAL_DATABASE_NAME}"
echo "OK"

View File

@ -1,27 +0,0 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. "${SCRIPT_DIR}/../settings.sh" || {
echo "no settings" && exit 1
}
UPLOAD_DIR="wp-content/uploads"
SOURCE_UPLOADS_PATH="${REMOTE_SITE_DIR}/${UPLOAD_DIR}"
DESTINATION_UPLOADS_PATH=$(realpath "${SCRIPT_DIR}/../../${UPLOAD_DIR}")
if [ -z "$DESTINATION_UPLOADS_PATH" ]; then
echo "DESTINATION_UPLOADS_PATH is empty" && exit 1
fi
CMD="rsync -a --info=progress2 $SSH_PROD_USERNAME@$SSH_PROD_SERVER:$SOURCE_UPLOADS_PATH/ $DESTINATION_UPLOADS_PATH/"
# shellcheck disable=SC2145
echo "Execute: ${CMD}"
read -p "Are you sure? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
/bin/bash -c "${CMD}"
fi

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,2 +0,0 @@
*
!.gitignore