Skip to content

Commit

Permalink
Call fetch at deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuichiueda committed Nov 28, 2017
1 parent b64c5be commit a83f9ac
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
16 changes: 16 additions & 0 deletions bin/fetch
Expand Up @@ -14,6 +14,12 @@ sort -u > $tmp-git-change

git pull

[ -f "$datadir/INIT" ] &&
find posts pages -type d |
grep -Eo '(posts|pages)/[^/]+' > $tmp-git-change

rm -f "$datadir/INIT"

### CREATE TIMESTAMP FILES IF NOT EXIST ###
cat $tmp-git-change |
while read d ; do
Expand Down Expand Up @@ -47,6 +53,7 @@ done
### MAKE POST/PAGE LIST ###

# SAVE OLD LIST FOR CREATING NAVIGATION LINKS
touch "$datadir/post_list"
cp "$datadir/post_list" $tmp-old-post-list

# LIST POSTS DATA
Expand Down Expand Up @@ -107,4 +114,13 @@ awk '$2~/^\*$|^#*$/{$2=""}{print}' |
awk 'NF>1' > $tmp-all
mv $tmp-all "$datadir/all_markdown"


### MAKE LATEST POST ###
page=$( tail -n 1 "$datadir/post_list" | cut -d' ' -f 3 | sed 's;s/;=;')
proto=$(awk '$1=="protocol:"{print $2}' "$contentsdir/config.yaml" | tr -d \')
host=$(awk '$1=="host:"{print $2}' "$contentsdir/config.yaml" | tr -d \')

echo $proto"//"$host"/?"$page > "$datadir/last_post"

rm -f $tmp-*

13 changes: 7 additions & 6 deletions deploy
Expand Up @@ -17,16 +17,17 @@ rnd=$(cat /dev/urandom | tr -cd 0-9a-zA-Z | head -c 32)
[ -e "/home/ueda/rnd" ] && rnd=$(cat /home/ueda/rnd )
mv "fetch" "fetch_$rnd.cgi"

### RESTORE DATADIR ###
rm -rf "$datadir/posts"
rm -rf "$datadir/pages"

### PULL DATA ###
rm -rf "${contentsdir:?}"
cd "$wwwdir"
git clone "https://github.com/$contents_owner/$contents"
touch "$datadir/INIT"
chown www-data:www-data "$datadir/INIT"
chown www-data:www-data "$contentsdir" -R
sudo -u www-data "$appdir/fetch_$rnd.cgi"

echo "call fetch_$rnd.cgi from GitHub"

### RESTORE DATADIR ###
rm -rf "$datadir/posts"
rm -rf "$datadir/pages"
#sudo -u www-data "$appdir/fetch.init"
#rm -f "$appdir/fetch.init"

0 comments on commit a83f9ac

Please sign in to comment.