#!/bin/bash # this is a script for hugo deployment # the occurrence of error will stop the script set -e
# 检查/h/backup/notes/文件夹的新文件,并加入hugo中 path='/h/backup/notes/' files=$(ls $path) # 对notes文件夹中的笔记进行遍历,获取文件名 for filename in $files do echo "------------------------------------------------------" echo $filename # 若存在新增的文件,添加到hugo中 if [ ! -f "./content/post/${filename}" ] then echo "add ${filename} to hugo" hugo new post/${filename} # 因hugo生成的文件有必要的头,所以追加内容进去 cat ${path}${filename} >> ./content/post/${filename} else echo "${filename} exists" fi done
# 删除打包文件 rm -rf public hugo -t mainroad
# 进入打包文件夹 cd public
# git operations git init git add -A msg="building sit 'data'" #$#检查执行命令时所带参数个数是否为1,参数即为commit if [ $# -eq 1 ] then msg="$1" fi git commit -m "$msg"