blob: efad2fbadccd6749d413fc5655d324d6beae1671 (
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#!/bin/sh
set -eu
repodir="$HOME/Private/repos/THESIAH"
out="$repodir/public/diary/index.html"
out2="$repodir/public/recordings/index.html"
out3="$repodir/public/videos/index.html"
server="${THESIAH_SERVER:-root@thesiah.xyz}"
dest="/var/www/thesiah/diary/"
dest2="/var/www/thesiah/recordings/"
dest3="/var/www/thesiah/videos/"
defaults="sy after foramonth"
src="$repodir/public/diary/"
src2="$repodir/public/recordings/"
src3="$repodir/public/videos/"
bgm="$repodir/static/bgm/"
bgmd="/var/www/thesiah/bgm/"
prv="$repodir/static/previews/"
prvd="/var/www/thesiah/previews/"
cd "$repodir"
hugo --cleanDestinationDir
if [ ! -f "$out" ]; then
echo "error: not found: $out" >&2
exit 1
fi
if [ ! -f "$out2" ]; then
echo "error: not found: $out2" >&2
exit 1
fi
if [ ! -f "$out3" ]; then
echo "error: not found: $out3" >&2
exit 1
fi
ssh "$server" "mkdir -p '$dest'"
ssh "$server" "mkdir -p '$dest2'"
ssh "$server" "mkdir -p '$dest3'"
ssh "$server" "mkdir -p '$prvd'"
rsync -azv --update --itemize-changes --stats "$bgm" "$server:$bgmd"
if [ -d "$prv" ]; then
rsync -azv --update --itemize-changes --stats "$prv" "$server:$prvd"
fi
if [ -n "${THESIAH_SSH_OPTS:-}" ]; then
rsync -azv --update --itemize-changes --stats \
-e "ssh $THESIAH_SSH_OPTS" \
"$src" "$server:$dest"
else
rsync -azv --update --itemize-changes --stats \
"$src" "$server:$dest"
fi
if [ -n "${THESIAH_SSH_OPTS:-}" ]; then
rsync -azv --update --itemize-changes --stats \
-e "ssh $THESIAH_SSH_OPTS" \
"$src2" "$server:$dest2"
else
rsync -azv --update --itemize-changes --stats \
"$src2" "$server:$dest2"
fi
if [ -n "${THESIAH_SSH_OPTS:-}" ]; then
rsync -azv --update --itemize-changes --stats \
-e "ssh $THESIAH_SSH_OPTS" \
"$src3" "$server:$dest3"
else
rsync -azv --update --itemize-changes --stats \
"$src3" "$server:$dest3"
fi
if [ -n "${1-}" ]; then
new="$repodir/content/diary/$1"
if [ -f "$new" ]; then
rsync -az --update "$new" "$server:$dest"
elif [ -d "$new" ]; then
rsync -az --update "$new/" "$server:$dest$(basename "$new")/"
fi
fi
if [ -n "${1-}" ]; then
new="$repodir/content/recordings/$1"
if [ -f "$new" ]; then
rsync -az --update "$new" "$server:$dest2"
elif [ -d "$new" ]; then
rsync -az --update "$new/" "$server:$dest2$(basename "$new")/"
fi
fi
if [ -n "${1-}" ]; then
new="$repodir/content/videos/$1"
if [ -f "$new" ]; then
rsync -az --update "$new" "$server:$dest3"
elif [ -d "$new" ]; then
rsync -az --update "$new/" "$server:$dest3$(basename "$new")/"
fi
fi
ssh "$THESIAH_SERVER" "chmod 644 $dest/index.html"
ssh "$THESIAH_SERVER" "chmod 644 $dest2/index.html"
ssh "$THESIAH_SERVER" "chmod 644 $dest3/index.html"
cd - >/dev/null
|