WP2Static

 주의 사항

 

 

 Exclude Pattern

/password/
/wikipage/
/about
/status

 

 Include Pattern

/sitemap.xml

 

 수동 복사 항목

#!/bin/bash
#

REMOTE=root@10.0.1.2
BASE=/var/www/andrwj.com/htdocs
STATIC=/var/www/andrwj.com/static

mkdir -p ${STATIC}
touch ${STATIC}/.wp2static_safety

echo "2) Prismatic js/css ..."
SRC="wp-content/plugins/prismatic/lib/prism"
mkdir -p ${STATIC}/${SRC}
cd ${BASE}/${SRC}; rsync -avr ./css ${STATIC}/${SRC}; rsync -avr ./js ${STATIC}/${SRC}
echo "3) widget-options.css"
SRC="wp-content/plugins/widget-options/assets/css"
mkdir -p ${STATIC}/${SRC}
cd ${BASE}/${SRC}; rsync -avr ./widget-options.css ${STATIC}/${SRC}
echo "4) jQuery files"
SRC="wp-includes/js"
mkdir -p ${STATIC}/${SRC}
cd ${BASE}/${SRC}; rsync -avr ./jquery ${STATIC}/${SRC}/

echo "5) footnote plugin files ... "
SRC=wp-content/plugins/footnotes
mkdir -p ${STATIC}/${SRC}
cd ${BASE}/${SRC}; rsync -avr ./js ${STATIC}/${SRC}/
rsync -avr ./css ${STATIC}/${SRC}/

echo "6) sitemap.xsl"
SRC="wp-content/plugins/google-sitemap-generator"
mkdir -p ${STATIC}/${SRC}
cd ${BASE}/${SRC}; rsync -avr ./sitemap.xsl ${STATIC}/${SRC}/

echo "7) relocating sitemap files"
${HOME}/bin/fetch-sitemap-xmls.sh

echo "8) Robots.txt"
echo "User-agent: *
Allow: /

Sitemap: http://andrwj.com/sitemap.xml
" > ${STATIC}/robots.txt

echo "9) ownership reset"
chown -R www-data:www-data ${STATIC}
echo "10) rsync with remote"
rsync -avr --delete ${STATIC}/ ${REMOTE}:/${BASE}/

echo "11) rsync only image files in uploads/2019"
rsync -avr --include="*.gif" --include="*.png" --include="*.jpg"  --exclude="*" ${BASE}/wp-content/uploads/2019/ ${REMOTE}:/${BASE}/wp-content/uploads/2019/

 

 Daynote 항목 업데이트

#!/bin/bash
DATE=${1:-empty}
STATIC_DIR=/var/www/andrwj.com/static
REMOTE_DIR=/var/www/andrwj.com/htdocs
REMOTE_USER=root
REMOTE_IP=10.0.1.2
# 입력된 날짜가 없으면 현재 날짜를 지정
if [[ "$DATE" == "empty" ]]; then
  DATE=$(TZ=Asia/Seoul date +'%Y-%m-%d')
fi
dates=(${DATE//\-/ })
YEAR=${dates[0]}
declare -a TARGET=( "daynote" "post/daynote" "post/daynote/${DATE}" "daynotes/${YEAR}" )
for t in ${TARGET[@]}; do
  echo $t
  mkdir -p ${STATIC_DIR}/${t} && chown -R www-data:www-data ${STATIC_DIR}/${t}
  cd ${STATIC_DIR}/${t} && \
        wget -q http://andrwj.com/${t}/ -O index.html && \
        perl -pi -e  's/andrwj\.net/andrwj\.com/g' index.html && \
        chown www-data:www-data index.html && \
        rsync -avr ${STATIC_DIR}/${t}/  ${REMOTE_USER}@${REMOTE_IP}:${REMOTE_DIR}/${t}/ > /dev/null
done

 

 

  단일 게시물 업데이트 


#!/bin/bash
URL=${1:-empty}
STATIC_DIR=/var/www/andrwj.com/static
REMOTE_DIR=/var/www/andrwj.com/htdocs
REMOTE_USER=root
REMOTE_IP=10.0.1.2

if [[ "$URL" == "empty" ]]; then
  echo "missing URL"
  exit 0
fi

mkdir -p ${STATIC_DIR}/${URL} && chown -R www-data:www-data ${STATIC_DIR}/${URL}
cd ${STATIC_DIR}/${URL} && \
    wget -q http://andrwj.com/${URL}/ -O index.html && \
    perl -pi -e  's/andrwj\.net/andrwj\.com/g' index.html && \
    chown www-data:www-data index.html && \
    rsync -avr ${STATIC_DIR}/${URL}/  ${REMOTE_USER}@${REMOTE_IP}:${REMOTE_DIR}/${URL}/ > /dev/null