ai/at
1
0

fix install.zsh

This commit is contained in:
2025-06-26 20:44:05 +09:00
parent ded3110fce
commit fb87306653
5 changed files with 109 additions and 116 deletions

View File

@ -14,15 +14,14 @@ https://github.com/bluesky-social/atproto
## account ## account
[@ai.syu.is](https://web.syu.is/profile/ai.syu.is) [@ai.syui.ai](https://syu.is/profile/did:plc:6qyecktefllvenje24fcxnie)
- https://at.syu.is/at/yui.syui.ai
- https://plc.syu.is/did:plc:6qyecktefllvenje24fcxnie - https://plc.syu.is/did:plc:6qyecktefllvenje24fcxnie
- https://plc.directory/did:plc:ytvoptig4ddshmwdsjmhtcym - https://plc.directory/did:plc:ytvoptig4ddshmwdsjmhtcym
[@yui.syui.ai](https://bsky.app/profile/did:plc:4hqjfn7m6n5hno3doamuhgef) [@yui.syui.ai](https://bsky.app/profile/did:plc:4hqjfn7m6n5hno3doamuhgef)
- https://pds.syu.is/at://did:plc:4hqjfn7m6n5hno3doamuhgef - https://plc.directory/did:plc:4hqjfn7m6n5hno3doamuhgef
```sh ```sh
$ curl -sL syu.is/xrpc/_health $ curl -sL syu.is/xrpc/_health

View File

@ -97,17 +97,40 @@ services:
redis: redis:
condition: service_healthy condition: service_healthy
jetstream: ozone:
build:
context: ./repos/jetstream/
dockerfile: Dockerfile
ports: ports:
- 6008:6008 - 2585:3000
volumes: build:
- ./data/jetstream:/data context: ./repos/atproto/
dockerfile: services/ozone/Dockerfile
restart: always restart: always
command: node --enable-source-maps api.js
volumes:
- ./data/ozone/:/data/
- ./repos/ozone.js:/app/services/ozone/api.js:ro
env_file: env_file:
- ./envs/jetstream - ./envs/ozone
healthcheck:
test: "wget -q --spider http://localhost:3000/xrpc/_health"
interval: 5s
retries: 20
depends_on:
database:
condition: service_healthy
ozone-daemon:
build:
context: ./repos/atproto/
dockerfile: services/ozone/Dockerfile
restart: always
command: node --enable-source-maps daemon.js
env_file:
- ./envs/ozone
depends_on:
ozone:
condition: service_healthy
database:
condition: service_healthy
ozone-web: ozone-web:
build: build:
@ -123,26 +146,21 @@ services:
database: database:
condition: service_healthy condition: service_healthy
ozone: jetstream:
build: build:
context: ./repos/atproto/ context: ./repos/jetstream/
dockerfile: services/ozone/Dockerfile dockerfile: Dockerfile
ports: ports:
- 2585:3000 - 6008:6008
restart: always
command: node --enable-source-maps api.js
volumes: volumes:
- ./data/ozone/:/data/ - ./data/jetstream:/data
restart: always
env_file: env_file:
- ./envs/ozone - ./envs/jetstream
ozone-daemon: ipcc:
build: image: nginx:alpine
context: ./repos/atproto/
dockerfile: services/ozone/Dockerfile
restart: always
command: node --enable-source-maps daemon.js
volumes: volumes:
- ./data/ozone/:/data/ - ./configs/nginx/ipcc.conf:/etc/nginx/conf.d/default.conf
env_file: ports:
- ./envs/ozone - 8099:80

9
configs/nginx/ipcc.conf Normal file
View File

@ -0,0 +1,9 @@
server {
listen 80;
location / {
add_header Content-Type application/json;
add_header Access-Control-Allow-Origin *;
return 200 '{"countryCode":"JP"}';
}
}

View File

@ -1,11 +1,11 @@
#!/bin/zsh #!/bin/zsh
# ./install.zsh $HOST # ./install.zsh $pds
repos_v='{}'
function at-repos-env() { function at-repos-env() {
host=$1 pds=$1
if [ -z "$1" ];then if [ -z "$1" ];then
host=syu.is pds=syu.is
fi fi
did=did:plc:6qyecktefllvenje24fcxnie did=did:plc:6qyecktefllvenje24fcxnie
icon=https://git.syui.ai/ai/at/raw/branch/main/icons/Logotype.tsx icon=https://git.syui.ai/ai/at/raw/branch/main/icons/Logotype.tsx
@ -15,18 +15,16 @@ function at-repos-env() {
https://github.com/bluesky-social/atproto https://github.com/bluesky-social/atproto
https://github.com/bluesky-social/social-app https://github.com/bluesky-social/social-app
https://github.com/bluesky-social/feed-generator https://github.com/bluesky-social/feed-generator
https://github.com/bluesky-social/ozone
https://github.com/bluesky-social/jetstream
) )
d=${0:a:h} d=${0:a:h}
dh=${0:a:h:h} dh=${0:a:h:h}
name=${host%%.*} name=${pds%%.*}
domain=${host##*.} domain=${pds##*.}
} }
function at-repos-json() { function at-repos-json() {
f=~/.config/atproto/token.json f=~/.config/atproto/token.json
j="{ \"did\": \"did:plc:6qyecktefllvenje24fcxnie\", \"didDoc\": { \"service\": [ { \"serviceEndpoint\": \"https://syu.is\" } ] }, \"handle\": \"ai.syu.is\", \"accessJwt\": \"xxx\" }" j="{ \"did\": \"${did}\", \"didDoc\": { \"service\": [ { \"serviceEndpoint\": \"https://${pds}\" } ] }, \"handle\": \"ai.${pds}\", \"accessJwt\": \"xxx\" }"
if [ ! -f "$f" ];then if [ ! -f "$f" ];then
mkdir -p ~/.config/atproto mkdir -p ~/.config/atproto
echo $j >> $f echo $j >> $f
@ -36,28 +34,28 @@ function at-repos-json() {
function at-repos-token() { function at-repos-token() {
at-repos-json at-repos-json
if [ -z "$host" ] && [ -f $f ];then if [ -z "$pds" ] && [ -f $f ];then
host=`cat $f|jq -r ".didDoc.service.[].serviceEndpoint"` pds=`cat $f|jq -r ".didDoc.service.[].serviceEndpoint"`
handle=`cat $f|jq -r ".handle"` handle=`cat $f|jq -r ".handle"`
did=`cat $f|jq -r ".did"` did=`cat $f|jq -r ".did"`
token=`cat $f|jq -r ".token"` token=`cat $f|jq -r ".token"`
host=${host##*/} pds=${pds##*/}
fi fi
name=${host%%.*} name=${pds%%.*}
domain=${host##*.} domain=${pds##*.}
} }
function at-repos-clone() { function at-repos-clone() {
if [ ! -d $d/repos ];then mkdir -p $d/repos
mkdir -p $d/repos
fi
cd $d/repos cd $d/repos
for ((i=1; i<=${#repos}; i++)); do for ((i=1; i<=${#repos}; i++)); do
repo=${repos[$i]} repo=${repos[$i]}
echo $repo echo $repo
if [ -d $d/repos/${repo##*/} ] && [ "${repo##*/}" = "social-app" ];then
rm -rf $d/repos/${repo##*/}
fi
if [ ! -d $d/repos/${repo##*/} ];then if [ ! -d $d/repos/${repo##*/} ];then
git clone $repo git clone $repo
fi fi
done done
if [ ! -f $d/repos/feed-generator/Dockerfile ] && [ -f $d/docker/feed/Dockerfile ];then if [ ! -f $d/repos/feed-generator/Dockerfile ] && [ -f $d/docker/feed/Dockerfile ];then
@ -73,16 +71,11 @@ function at-repos-pull() {
if [ -d $d/repos/${repo##*/} ];then if [ -d $d/repos/${repo##*/} ];then
cd $d/repos/${repo##*/} cd $d/repos/${repo##*/}
if ! git pull;then if ! git pull;then
cd $d/repos
rm -rf $d/repos/${repo##*/} rm -rf $d/repos/${repo##*/}
at-repos-clone at-repos-clone
fi fi
fi fi
rv=$(echo "$repos_v" | jq -r ".[\"${repo##*/}\"]")
if [ "$rv" != "null" ];then
cd $d/repos/${repo##*/}
git reset --hard $rv
cd ..
fi
done done
cd $d cd $d
} }
@ -100,25 +93,48 @@ function at-repos-social-app-icon-origin() {
} }
function at-repos-social-app-write() { function at-repos-social-app-write() {
did_admin=did:plc:6qyecktefllvenje24fcxnie did_admin=did:plc:z72i7hdynmk6r22z27h6tvur
dt=$d/repos/social-app/src dt=$d/repos/social-app/src
cd $dt cd $dt
grep -R syu.is .|cut -d : -f 1|sort -u|xargs sed -i "s/syu.is/${host}/g"
grep -R web.syu.is .|cut -d : -f 1|sort -u|xargs sed -i "s/web.syu.is/web.${host}/g" t=(bsky.social bsky.app)
f=$dt/lib/constants.ts for tt in "${t[@]}"; do
sed -i "s/public.api.web/bsky/g" $f escaped_tt=$(echo "$tt" | sed 's/\./\\./g')
grep -R "$escaped_tt" . | cut -d : -f 1 | sort -u | xargs -r sed -i "s/${tt}/${pds}/g"
done
t=(api public.api public.api.bsky public.bsky)
for tt in "${t[@]}"; do
grep -R "${tt}\.${pds}" . | cut -d : -f 1 | sort -u | xargs -r sed -i "s/${tt}\.${pds}/bsky.${pds}/g"
done
t=(cardyb events status)
for tt in "${t[@]}"; do
grep -R "${tt}\.${pds}" . | cut -d : -f 1 | sort -u | xargs -r sed -i "s/${tt}\.${pds}/${tt}.bsky.app/g"
done
f=$dt/lib/strings/url-helpers.ts
sed -i 's#https://go.bsky.app/redirect?u=${encodeURIComponent(url)}#url#g' $f
sed -i 's#`url`#url#g' $f
f=$dt/lib/statsig/statsig.tsx
sed -i "s#api: 'https://events.bsky.app/v2'#api: 'https://syu.is/events/v2/disabled'#g" $f
sed -i "s#initTimeoutMs: 1,#initTimeoutMs: 1, disableAllLogging: true,#g" $f
## cloudflare worker -> /ipcc
#f=$dt/state/geolocation.tsx
#sed -i 's#https://syu\.is/ipcc#https://bsky\.app/ipcc#g' $f
f=$dt/view/icons/Logotype.tsx f=$dt/view/icons/Logotype.tsx
o=$d/icons/Logotype.tsx o=$d/icons/Logotype.tsx
cp -rf $o $f cp -rf $o $f
f=$dt/view/com/util/UserAvatar.tsx 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 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.web.syu.is/img/avatar/plain/#g" $f sed -i "s#/img/avatar/plain/#https://bsky.${pds}/img/avatar/plain/#g" $f
sed -i "s#/img/avatar_thumbnail/plain/#https://bsky.${host}/img/avatar/plain/#g" $f sed -i "s#/img/avatar_thumbnail/plain/#https://bsky.${pds}/img/avatar/plain/#g" $f
sed -i "s#source={{uri: avatar}}#source={{ uri: hackModifyThumbnailPath(avatar, 1 > 0), }}#g" $f sed -i "s#source={{uri: avatar}}#source={{ uri: hackModifyThumbnailPath(avatar, 1 > 0), }}#g" $f
curl -sL https://raw.githubusercontent.com/bluesky-social/social-app/refs/heads/main/src/lib/strings/url-helpers.ts -o $dt/lib/strings/url-helpers.ts
sed -i "s#https://go.web.syu.is/redirect?u=\${encodeURIComponent(url)}#\${url}#g" $dt/lib/strings/url-helpers.ts
grep -R $did_admin .|cut -d : -f 1|sort -u|xargs sed -i "s/${did_admin}/${did}/g" grep -R $did_admin .|cut -d : -f 1|sort -u|xargs sed -i "s/${did_admin}/${did}/g"
} }
@ -126,58 +142,19 @@ function at-repos-bsky-patch() {
f=$d/repos/atproto/services/bsky/api.js f=$d/repos/atproto/services/bsky/api.js
curl -sL https://raw.githubusercontent.com/bluesky-social/atproto/refs/heads/main/services/bsky/api.js -o $f curl -sL https://raw.githubusercontent.com/bluesky-social/atproto/refs/heads/main/services/bsky/api.js -o $f
d_=$d/repos/atproto d_=$d/repos/atproto
p_=$d/patching/105-atproto-services-for-docker.diff p_=$d_/105-atproto-services-for-docker.diff
cd ${d_} cd $d_
if [ ! -f ${p_} ];then # https://github.com/itaru2622/bluesky-selfhost-env/blob/master/patching/105-atproto-services-for-docker.diff
# https://github.com/itaru2622/bluesky-selfhost-env/blob/master/patching/105-atproto-services-for-docker.diff curl -sLO https://raw.githubusercontent.com/itaru2622/bluesky-selfhost-env/refs/heads/master/patching/105-atproto-services-for-docker.diff
echo download patch: https://github.com/itaru2622/bluesky-selfhost-env/blob/master/patching/105-atproto-services-for-docker.diff
curl -sL https://raw.githubusercontent.com/itaru2622/bluesky-selfhost-env/refs/heads/master/patching/105-atproto-services-for-docker.diff -o ${p_}
else
echo local patch
fi
echo "applying patch: under ${f} for ${p_}"
pushd ${d_}
patch -p1 < ${p_}
popd
}
function at-repos-social-app-patch() {
f=$d/repos/social-app/Dockerfile
p_=$d/patching/social-app-dockerfile.diff
d_=$d/repos/social-app
cd ${d_}
curl -sLO https://raw.githubusercontent.com/bluesky-social/social-app/refs/heads/main/Dockerfile
echo "applying patch: under ${f} for ${p_}"
pushd ${d_}
patch -p1 < ${p_}
popd
}
function at-repos-ozone-patch() {
#DOMAIN=syu.is
cd $d/repos
d_=$d/repos/ozone
rm -rf ${d_}
p_=$d/patching/120-ozone-runtimeEnvVars.diff
git clone https://github.com/bluesky-social/ozone
cd ${d_}
pushd ${d_}
echo "applying patch: under ${d_} for ${p_}"
patch -p1 < ${p_}
popd
p_=$d/patching/122-ozone-enable-daemon.diff
echo "applying patch: under ${d_} for ${p_}" echo "applying patch: under ${d_} for ${p_}"
pushd ${d_} pushd ${d_}
patch -p1 < ${p_} patch -p1 < ${p_}
popd popd
#cp -rf $d/repos/atproto/service/ozone/* $d/ozone/service/
} }
function at-repos-docker() { function at-repos-docker() {
cd $d cd $d
docker compose build && docker compose up -d docker compose build $1 && docker compose up -d
} }
at-repos-env at-repos-env
@ -187,15 +164,5 @@ at-repos-social-app-icon
at-repos-social-app-icon-origin at-repos-social-app-icon-origin
at-repos-social-app-write at-repos-social-app-write
at-repos-bsky-patch at-repos-bsky-patch
at-repos-social-app-patch
at-repos-ozone-patch
at-repos-docker at-repos-docker
#echo "[y]docker compose build && up"
#read key
#case $key in
# [yY])
# at-repos-docker
# ;;
#esac

View File

@ -15,7 +15,7 @@ function at-env() {
collection=`echo $at_uri|cut -d / -f 4` collection=`echo $at_uri|cut -d / -f 4`
rkey=`echo $at_uri|cut -d / -f 5` rkey=`echo $at_uri|cut -d / -f 5`
d=${0:a:h} d=${0:a:h}
f=~/.config/ai/token.json f=~/.config/syui/ai/bot/token.json
if [ -f $f ];then if [ -f $f ];then
host=`cat $f|jq -r ".didDoc.service.[].serviceEndpoint"|cut -d / -f 3` host=`cat $f|jq -r ".didDoc.service.[].serviceEndpoint"|cut -d / -f 3`
token=`cat $f|jq -r .accessJwt` token=`cat $f|jq -r .accessJwt`