blob: a6575fceb16c3ca6767df8d67b3fc8fea28de128 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#!/bin/bash
# CONFIG
LUME_DIR="/your/lume/dir"
SRC_DIR="$LUME_DIR/src"
BUILD_DIR="site"
# OPTIONAL
BLOG_URL="https://yourblog.url"
POST_URL_DIR="posts"
WEBPSH="/your/webp/convert/path"
COMMIT_COMMENT="`echo "Memory" && free -h | head -2 | awk '{print $(NF-5)"," $(NF-4)"," $(NF-3)}' | column -t -s ","`"
FEDI_CMT="y"
export DENO_INSTALL="/home/$USER/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
commands=("deno" "git" "toot" "cwebp")
for cmd in "${commands[@]}"; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "Please install: $cmd"
exit 1
fi
done
git_commit() {
cd "$SRC_DIR" || exit
ls "$SRC_DIR/.git" || git init || exit
git add . || exit
git commit -m "$COMMIT_COMMENT"
}
build() {
cd $LUME_DIR || exit
deno task lume --dest=$BUILD_DIR > /dev/null 2>&1
}
fedi_posts() {
LAST_POST=`ls -tr | tail -1`
POST_URL=`echo "$BLOG_URL/$POST_URL_DIR/$LAST_POST/" | sed "s/\.md//g"`
TITLE=`grep "^title: " "$LAST_POST" | sed "s/^title: //g"`
MSTDN_URL=`toot post "$TITLE - $POST_URL" | sed "s/Toot posted: //g" `
INS_TXT=`cat <<EOF
comments:
src: '$MSTDN_URL'
EOF`
awk -v ins="$INS_TXT" '
/^---/ {
if (++count == 2) {
print ins
}
}
{print} ' "$LAST_POST" > tmp && mv tmp "$LAST_POST"
sed -i '/comments: {}/d' "$LAST_POST"
}
git_commit
if [ $? -eq 0 ]; then
$WEBPSH
cd $SRC_DIR/$POST_URL_DIR || exit
grep "^comments:$" "$(ls -tr | tail -1)"
if [ $? -eq 0 ]; then
build
exit 0
else
if [ "$FEDI_CMT" = "y" ]; then
fedi_posts
git_commit
build
fi
fi
else
exit 1
fi
|