ai/at
1
0

fix atproto service pds, bsky, social-app for patch

This commit is contained in:
2025-12-02 21:37:41 +09:00
parent 2f5736ffde
commit b7b3c05805
22 changed files with 1011 additions and 184 deletions

View File

@@ -18,6 +18,7 @@ function at-repos-env() {
https://github.com/bluesky-social/ozone
https://github.com/bluesky-social/jetstream
)
services=( bsky plc pds jetstream bgs ozone social-app )
d=${0:a:h}
dh=${0:a:h:h}
name=${host%%.*}
@@ -73,6 +74,7 @@ function at-repos-pull() {
echo $repo
if [ -d $d/repos/${repo##*/} ];then
cd $d/repos/${repo##*/}
git stash
if ! git pull;then
rm -rf $d/repos/${repo##*/}
at-repos-clone
@@ -100,15 +102,60 @@ function at-repos-social-app-icon-origin() {
curl -sL $icon -o $d/icons/Logotype.tsx
}
function at-repos-social-app-write() {
function at-repos-social-app-avatar-write() {
did_admin=did:plc:6qyecktefllvenje24fcxnie
dt=$d/repos/social-app/src
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"
f=$dt/lib/constants.ts
sed -i "s/public.api.web/bsky/g" $f
sed -i "s#export const BSKY_SERVICE = 'https://bsky.social'#export const BSKY_SERVICE = 'https://${host}'#g" $f
sed -i "s#export const BSKY_SERVICE_DID = 'did:web:bsky.social'#export const BSKY_SERVICE_DID = 'did:web:${host}'#g" $f
sed -i "s#export const PUBLIC_BSKY_SERVICE = 'https://public.api.bsky.app'#export const PUBLIC_BSKY_SERVICE = 'https://bsky.${host}'#g" $f
sed -i "s#export const PUBLIC_APPVIEW = 'https://api.bsky.app'#export const PUBLIC_APPVIEW = 'https://bsky.${host}'#g" $f
sed -i "s#export const PUBLIC_APPVIEW_DID = 'did:web:api.bsky.app'#export const PUBLIC_APPVIEW_DID = 'did:web:bsky.${host}'#g" $f
# Disable external services (CORS fix)
f=$dt/state/geolocation/const.ts
curl -sL https://raw.githubusercontent.com/bluesky-social/social-app/refs/heads/main/src/state/geolocation/const.ts -o $f
cat > $f << 'GEOEOF'
import {type GeolocationStatus} from '#/state/geolocation/types'
import {BAPP_CONFIG_DEV_URL, IS_DEV} from '#/env'
import {type Device} from '#/storage'
export const IPCC_URL = `https://bsky.app/ipcc`
// Disabled for self-hosted environment to avoid CORS errors
export const BAPP_CONFIG_URL_PROD = null
export const BAPP_CONFIG_URL = null
export const GEOLOCATION_CONFIG_URL = BAPP_CONFIG_URL
export const DEFAULT_GEOLOCATION_CONFIG: Device['geolocation'] = {
countryCode: undefined,
regionCode: undefined,
ageRestrictedGeos: [],
ageBlockedGeos: [],
}
export const DEFAULT_GEOLOCATION_STATUS: GeolocationStatus = {
countryCode: undefined,
regionCode: undefined,
isAgeRestrictedGeo: false,
isAgeBlockedGeo: false,
}
GEOEOF
# Add null check to geolocation config.ts to prevent fetch(null) errors
f=$dt/state/geolocation/config.ts
curl -sL https://raw.githubusercontent.com/bluesky-social/social-app/refs/heads/main/src/state/geolocation/config.ts -o $f
# Add null check at the beginning of getGeolocationConfig function (after line with 'url: string,')
sed -i "s/): Promise<Device\['geolocation'\]> {/): Promise<Device['geolocation']> {\n if (!url) return undefined/" $f
# Disable Statsig (CORS fix)
f=$dt/lib/statsig/statsig.tsx
sed -i "s#api: 'https://events.bsky.app/v2'#api: '' // Disabled for self-hosted#g" $f
# Disable SDK initialization to prevent statsigapi.net connections
sed -i "s#const SDK_KEY = 'client-SXJakO39w9vIhl3D44u8UupyzFl4oZ2qPIkjwcvuPsV'#const SDK_KEY = '' // Disabled for self-hosted#g" $f
f=$dt/view/icons/Logotype.tsx
o=$d/icons/Logotype.tsx
cp -rf $o $f
@@ -123,31 +170,53 @@ function at-repos-social-app-write() {
grep -R $did_admin .|cut -d : -f 1|sort -u|xargs sed -i "s/${did_admin}/${did}/g"
}
function at-repos-bsky-patch() {
function at-repos-atproto-service-bsky-api-patch() {
# https://github.com/itaru2622/bluesky-selfhost-env/blob/master/patching/105-atproto-services-for-docker.diff
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
d_=$d/repos/atproto
p_=$d/patching/105-atproto-services-for-docker.diff
cd ${d_}
if [ ! -f ${p_} ];then
# https://github.com/itaru2622/bluesky-selfhost-env/blob/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
p_=$d/patching/4367-atproto-services-bsky-api.diff
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
function at-repos-atproto-service-pds-index-patch() {
f=$d/repos/atproto/services/pds/index.js
curl -sL https://raw.githubusercontent.com/bluesky-social/atproto/refs/heads/main/services/pds/index.js -o $f
d_=$d/repos/atproto
p_=$d/patching/4367-atproto-services-pds-index.diff
echo "applying patch: under ${f} for ${p_}"
pushd ${d_}
patch -p1 < ${p_}
popd
}
function at-repos-social-app-agent-patch() {
f=$d/repos/social-app/src/state/session/agent.ts
p_=$d/patching/8980-social-app-disable-proxy.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-social-app-disable-external-services-patch() {
f=$d/repos/social-app/src/state/geolocation/const.ts
p_=$d/patching/8980-social-app-disable-external-services.diff
d_=$d/repos/social-app
echo "applying patch: under ${f} for ${p_}"
pushd ${d_}
patch -p1 < ${p_}
popd
}
function at-repos-atproto-service-ozone-api-patch() {
f=$d/repos/atproto/services/ozone/api.js
d_=$d/repos/atproto
p_=$d/patching/130-atproto-ozone-enable-daemon.patch
echo "applying patch: under ${f} for ${p_}"
pushd ${d_}
patch -p1 < ${p_}
@@ -172,52 +241,91 @@ function at-repos-ozone-patch() {
pushd ${d_}
patch -p1 < ${p_}
popd
#cp -rf $d/repos/atproto/service/ozone/* $d/ozone/service/
}
function at-repos-docker() {
function at-repos-build-docker-atproto() {
cd $d
docker compose build
# docker compose up -d
# docker compose up -d --no-build
# docker compose up -d --pull always
docker image prune -a
if [ -z "$1" ];then
for ((i=1; i<=${#services}; i++)); do
service=${services[$i]}
docker compose build --no-cache $service
done
else
docker compose build --no-cache $1
fi
}
function at-regi-docker() {
docker run -d -p ${dport}:${dport} --name registry --restart=always registry:2
docker tag at-pds:latest localhost:${dport}/pds:latest
docker tag at-ozone-web:latest localhost:${dport}/ozone-web:latest
docker tag at-bgs:latest localhost:${dport}/bgs:latest
docker tag at-jetstream:latest localhost:${dport}/jetstream:latest
docker tag at-bsky:latest localhost:${dport}/bsky:latest
docker tag at-ozone-daemon:latest localhost:${dport}/ozone-daemon:latest
docker tag at-ozone:latest localhost:${dport}/ozone:latest
docker tag at-plc:latest localhost:${dport}/plc:latest
docker tag at-social-app:latest localhost:${dport}/social-app:latest
docker push localhost:${dport}/pds:latest
docker push localhost:${dport}/ozone-web:latest
docker push localhost:${dport}/bgs:latest
docker push localhost:${dport}/jetstream:latest
docker push localhost:${dport}/bsky:latest
docker push localhost:${dport}/ozone-daemon:latest
docker push localhost:${dport}/ozone:latest
docker push localhost:${dport}/plc:latest
docker push localhost:${dport}/social-app:latest
function at-repos-push-reset() {
docker restart registry
docker stop registry
docker rm registry
docker volume rm registry-data 2>/dev/null || true
docker run -d -p ${dport}:${dport} --name registry \
--restart=always \
-v registry-data:/var/lib/registry \
registry:2
sleep 3
docker run -d -p ${dport}:${dport} --name registry --restart=always registry:2
}
function at-repos-push-docker() {
if [ -z "$1" ];then
for ((i=1; i<=${#services}; i++)); do
service=${services[$i]}
docker tag at-${service}:latest localhost:${dport}/${service}:latest
docker push localhost:${dport}/${service}:latest
if [ "$service" = "ozone" ];then
docker tag at-${service}:latest localhost:${dport}/${service}-web:latest
docker push localhost:${dport}/${service}-web:latest
docker tag at-${service}:latest localhost:${dport}/${service}-daemon:latest
docker push localhost:${dport}/${service}-daemon:latest
fi
done
else
docker tag at-${1}:latest localhost:${dport}/${1}:latest
docker push localhost:${dport}/${1}:latest
fi
}
function at-repos-pull-docker() {
cd $d
docker image prune -a
docker compose up -d --pull always
}
function at-origin-social-app() {
cp -rf $d/social-app-custom $d/repos/social-app
}
at-repos-env
at-repos-clone
at-repos-pull
at-repos-social-app-icon
at-repos-social-app-icon-origin
at-repos-social-app-write
at-repos-bsky-patch
at-repos-social-app-patch
at-repos-ozone-patch
at-repos-docker
case "`cat /etc/hostname`" in
at)
at-repos-pull-docker
exit
;;
*)
at-repos-push-reset
at-repos-clone
at-repos-pull
at-repos-social-app-icon
at-repos-social-app-icon-origin
at-repos-social-app-avatar-write
at-repos-social-app-agent-patch
at-repos-social-app-disable-external-services-patch
at-repos-atproto-service-bsky-api-patch
at-repos-atproto-service-pds-index-patch
at-repos-atproto-service-ozone-api-patch
at-repos-ozone-patch
if [ -n "$1" ];then
at-repos-build-docker-atproto $1
at-repos-push-docker $1
exit
fi
at-repos-build-docker-atproto
at-repos-push-docker
cd $d; docker compose down
;;
esac
# at-regi-docker