sync-web/sync.sh

109 行
3.4 KiB
Bash
実行ファイル

#!/bin/sh
SRV=192.168.10.103
TILDE=technicalsuwako@tilde.club
# 創作
./gostatic -v config
./gostatic -v tuifig
# 画像など
rsync -rtvzP ass ${SRV}:/var/www/htdocs/technicalsuwako.moe
# ウエブサイト
## 一般ネット
### HTTP
rsync -rtvzP www ${SRV}:/var/www/htdocs/technicalsuwako.moe
rsync -rtvzP txt ${SRV}:/var/www/htdocs/technicalsuwako.moe
### Gemini
cp www/blog.atom gemini
cp www/twtxt.txt gemini
cd gemini
find . -type f -name "blog.atom" -exec sed -i 's/https:\/\/technicalsuwako\.moe/gemini:\/\/technicalsuwako\.moe/g' {} +
find . -type f -name "blog.atom" -exec sed -i 's/\/<\/id>/\.gmi<\/id>/g' {} +
find . -type f -name "blog.atom" -exec sed -i 's/\/" rel="alt/\.gmi" rel="alt/g' {} +
find . -type f -name "twtxt.txt" -exec sed -i 's/\/*$//' {} +
find . -type f -name "twtxt.txt" -exec sed -i 's/blog\/.*/blog\/\0\.gmi/g' {} +
find . -type f -name "twtxt.txt" -exec sed -i 's/https:\/\/technicalsuwako\.moe/gemini:\/\/technicalsuwako\.moe/g' {} +
find . -type f -name "twtxt.txt" -exec sed -i 's/https:\/\/076\.moe/gemini:\/\/076\.moe/g' {} +
cd ..
rsync -rtvzP gemini/* ${IPPAN}:/var/gemini/technicalsuwako.moe
## ダークネット
rm -rf tor i2p public_html ttor ti2p
cp -r www tor
cp -r www i2p
cp -r txt ttor
cp -r txt ti2p
henko() {
local f=$1
local o=$2
local n=$3
for ex in "html" "atom" "txt"; do
case $ex in
"html") fn="*.html" ;;
"atom") fn="blog.atom" ;;
"txt") fn="twtxt.txt" ;;
esac
find "$f" -type f -name "$fn" -exec sed -i "s|$o|$n|g" {} +
done
}
kosin() {
local f=$1
local m=$2
cd "$f" || exit
while IFS= read -r line; do
henko "$f" "${line%%,*}" "${line##*,}"
done <<< "$m"
cd ..
}
tormap="https://ass.technicalsuwako.moe,http://ass.6qiatzlijtqo6giwvuhex5zgg3czzwrq5g6yick3stnn4xekw26zf7qd.onion
https://076.moe,http://7dt6irsmfvbrtgn4nuah56kky6mvr472fbwwaltuxpf26qdqkdhfvnqd.onion"
i2pmap="https://ass.technicalsuwako.moe,http://ass.technicalsuwako.i2p
https://076.moe,http://076.i2p"
dir=("tor" "ttor" "i2p" "ti2p")
for d in "${dir[@]}"; do
if [[ $d == "tor" || $d == "ttor" ]]; then
kosin "$d" "$tormap"
else
kosin "$d" "$i2pmap"
fi
done
### 両方同期
for d in "${dir[@]}"; do
rsync -rtvzP ${d} ${SRV}:/var/www/htdocs/technicalsuwako.moe
done
## ティルデHTTP
cp -r www public_html
cd public_html
find . -type f -name "*.html" -exec sed -i 's/href="\//href="\/\~technicalsuwako\//g' {} +
find . -type f -name "*.html" -exec sed -i 's/src="\//src="\/\~technicalsuwako\//g' {} +
find . -type f -name "*.css" -exec sed -i 's/static/\~technicalsuwako\/static/g' {} +
cd ..
rsync -rtvzP public_html ${TILDE}:/home/technicalsuwako
## ティルデGMI
rm -rf public_gemini
cp -r gemini public_gemini
rm -rf public_gemini/static
cd public_gemini
find . -type f -name "blog.atom" -exec sed -i 's/gemini:\/\/technicalsuwako\.moe/gemini:\/\/tilde\.club\/\~technicalsuwako/g' {} +
find . -type f -name "blog.atom" -exec sed -i 's/\/<\/id>/\.gmi<\/id>/g' {} +
find . -type f -name "blog.atom" -exec sed -i 's/\/" rel="alt/\.gmi" rel="alt/g' {} +
find . -type f -name "twtxt.txt" -exec sed -i 's/\/*$//' {} +
find . -type f -name "twtxt.txt" -exec sed -i 's/blog\/.*/blog\/\0\.gmi/g' {} +
find . -type f -name "twtxt.txt" -exec sed -i 's/gemini:\/\/technicalsuwako\.moe/gemini:\/\/tilde\.club\/\~technicalsuwako/g' {} +
find . -type f -name "*.gmi" -exec sed -i 's/=> \//=> \/\~technicalsuwako\//g' {} +
cd ..
rsync -rtvzP public_gemini ${TILDE}:/home/technicalsuwako