ai/at
ai/at
1
0
at/install.zsh
2025-02-24 13:38:55 +09:00

104 lines
2.8 KiB
Bash
Executable File

#!/bin/zsh
function at-repos-env() {
host=syu.is
did=did:plc:6qyecktefllvenje24fcxnie
repos=(
https://github.com/did-method-plc/did-method-plc
https://github.com/bluesky-social/indigo
https://github.com/bluesky-social/atproto
https://github.com/bluesky-social/social-app
https://github.com/bluesky-social/feed-generator
)
d=${0:a:h}
dh=${0:a:h:h}
}
function at-repos-token() {
f=~/.config/atproto/token.json
if [ -z "$host" ] && [ -f $f ];then
host=`cat $f|jq -r ".didDoc.service.[].serviceEndpoint"`
handle=`cat $f|jq -r ".handle"`
did=`cat $f|jq -r ".did"`
token=`cat $f|jq -r ".token"`
fi
name=${host%%.*}
domain=${host##*.}
}
function at-repos-clone() {
mkdir -p $d/repos
cd $d/repos
for ((i=1; i<=${#repos}; i++)); do
repo=${repos[$i]}
echo $repo
if [ ! -d $d/repos/${repo##*/} ];then
git clone $repo
fi
done
if [ ! -f $d/repos/feed-generator/Dockerfile ] && [ -f $d/docker/feed/Dockerfile ];then
cp -rf $d/docker/feed/Dockerfile $d/repos/feed-generator/
fi
}
function at-repos-pull() {
cd $d/repos
for ((i=1; i<=${#repos}; i++)); do
repo=${repos[$i]}
echo $repo
if [ -d $d/repos/${repo##*/} ];then
cd $d/repos/${repo##*/}
if ! git pull;then
cd $d/repos
rm -rf $d/repos/${repo##*/}
at-repos-clone
fi
fi
done
cd $d
echo "docker compose build && docker compose up -d"
}
function at-repos-social-app-icon() {
curl -sL https://raw.githubusercontent.com/bluesky-social/social-app/main/src/view/icons/Logotype.tsx -o $d/repos/social-app/src/view/icons/Logotype.tsx
cp -rf $d/repos/social-app/src/view/icons/Logotype.tsx $d/icons/
}
function at-repos-social-app-icon-origin() {
curl -sL https://git.syui.ai/ai/at/raw/branch/main/icons/Logotype.tsx -o $d/icons/Logotype.tsx
}
function at-repos-social-app-write() {
did_admin=did:plc:z72i7hdynmk6r22z27h6tvur
dt=$d/repos/social-app/src
cd $dt
grep -R bsky.social .|cut -d : -f 1|sort -u|xargs sed -i "s/bsky.social/${domain}/g"
grep -R bsky.app .|cut -d : -f 1|sort -u|xargs sed -i "s/bsky.app/web.${domain}/g"
sed -i "s/public.api.web/bsky/g" ./lib/constants.ts
f=$dt/view/icons/Logotype.tsx
o=$d/icons/Logotype.tsx
cp -rf $o $f
f=$dt/view/com/util/UserAvatar.tsx
curl -sL https://raw.githubusercontent.com/bluesky-social/social-app/refs/heads/main/src/view/com/util/UserAvatar.tsx -o $f
sed -i "s#/img/avatar/plain/#https://cdn.bsky.app/img/avatar/plain/#g" $f
sed -i "s#/img/avatar_thumbnail/plain/#https://bsky.${domain}/img/avatar/plain/#g" $f
sed -i "s#source={{uri: avatar}}#source={{ uri: hackModifyThumbnailPath(avatar, 1 > 0), }}#g" $f
grep -R $did_admin .|cut -d : -f 1|sort -u|xargs sed -i "s/${did_admin}/${did}/g"
}
at-repos-env
at-repos-token
at-repos-clone
at-repos-pull
at-repos-social-app-icon
case $1 in
icon|i)
at-repos-social-app-icon-origin
;;
esac
at-repos-social-app-write