ld-site/script/build_on_linux.sh
liding 8d07d60566 Remove deleted article files.
Delete non-existing files in the article dir from the target dir when rsync
transfers article files.
2024-06-30 09:05:48 +08:00

27 lines
762 B
Bash

#!/usr/bin/env sh
# cron
# 0 4 * * * . /etc/profile; /bin/sh /opt/ld-site/script/build_on_linux.sh >/dev/null 2>&1
export PATH=$PATH:/opt/dev_tools/node-v20.12.2-linux-x64/bin
script_path="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
original_article_home="/home/ld/Documents/ld_article"
original_article_destination="/opt/ld-site/src/content"
ld_site_dist_target="/opt/nginx_targets/ld_site_dist"
rsync -a --delete-after -f"P config.ts" \
"${original_article_home}/" \
"${original_article_destination}/"
cd "${script_path}/../"
npm run build
if [ $? -ne 0 ]; then
echo "cannot build ld_site."
exit 1
fi
mv ${ld_site_dist_target} "${ld_site_dist_target}-old"
mv dist ${ld_site_dist_target}
rm -rf "${ld_site_dist_target}-old"