add ios social-app
This commit is contained in:
147
install.zsh
147
install.zsh
@@ -1,5 +1,23 @@
|
||||
#!/bin/zsh
|
||||
|
||||
# Sed compatibility wrapper
|
||||
function sediment() {
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' "$@"
|
||||
else
|
||||
sed -i "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Patch compatibility wrapper
|
||||
function patchment() {
|
||||
# -f : Force. Do not ask questions. (Standard in GNU and BSD patch)
|
||||
# -N : Ignore patches that seem to be reversed or already applied (Forward)
|
||||
# But we control these flags in the caller.
|
||||
patch "$@"
|
||||
}
|
||||
|
||||
function at-repos-env() {
|
||||
APP_PASSWORD=xxx
|
||||
host=syu.is
|
||||
@@ -34,6 +52,12 @@ function at-repos-env() {
|
||||
name=${host%%.*}
|
||||
domain=${host##*.}
|
||||
dport=5000
|
||||
|
||||
typeset -A PINNED_COMMITS
|
||||
PINNED_COMMITS=(
|
||||
[indigo]="d49b454196351c988ceb5ce1f5e21b689487b5ab"
|
||||
[atproto]="104e6ed37b0589cc000109dc76316be35b2257e1"
|
||||
)
|
||||
}
|
||||
|
||||
# Arrays for patch management
|
||||
@@ -82,6 +106,10 @@ function at-repos-pull() {
|
||||
echo $repo
|
||||
if [ -d $d/repos/${repo##*/} ];then
|
||||
cd $d/repos/${repo##*/}
|
||||
# Clean up before pull: reset changes, remove .orig files and untracked patch-created files
|
||||
git checkout -- .
|
||||
find . -name "*.orig" -type f -delete 2>/dev/null
|
||||
git clean -fd 2>/dev/null
|
||||
git stash -u
|
||||
if ! git pull;then
|
||||
rm -rf $d/repos/${repo##*/}
|
||||
@@ -98,32 +126,24 @@ function at-repos-pull() {
|
||||
cd $d
|
||||
}
|
||||
|
||||
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#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
|
||||
|
||||
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.web.syu.is/img/avatar/plain/#g" $f
|
||||
sed -i "s#/img/avatar_thumbnail/plain/#https://bsky.${host}/img/avatar/plain/#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"
|
||||
function at-repos-checkout-pinned() {
|
||||
echo "🔒 Checking out pinned commits..."
|
||||
cd $d/repos
|
||||
for repo_name pinned_commit in ${(kv)PINNED_COMMITS}; do
|
||||
if [ -n "$pinned_commit" ] && [ -d "$d/repos/$repo_name" ]; then
|
||||
echo " 📌 $repo_name -> $pinned_commit"
|
||||
cd $d/repos/$repo_name
|
||||
git fetch origin
|
||||
git checkout $pinned_commit
|
||||
cd $d/repos
|
||||
fi
|
||||
done
|
||||
cd $d
|
||||
}
|
||||
|
||||
function at-repos-social-app-ios-patch() {
|
||||
$d/ios/setup.zsh
|
||||
}
|
||||
|
||||
# Common patch function with status detection
|
||||
function apply-patch() {
|
||||
@@ -139,7 +159,8 @@ function apply-patch() {
|
||||
pushd ${target_dir} > /dev/null
|
||||
|
||||
# Check if patch is already applied (reverse dry-run succeeds)
|
||||
if patch --dry-run -p1 -R < ${patch_file} > /dev/null 2>&1; then
|
||||
# Use -f to force dry-run to fail instead of asking questions if unapplied
|
||||
if patch -f --dry-run -p1 -R < ${patch_file} > /dev/null 2>&1; then
|
||||
echo "✅ Already applied - skipping"
|
||||
popd > /dev/null
|
||||
echo ""
|
||||
@@ -147,9 +168,9 @@ function apply-patch() {
|
||||
fi
|
||||
|
||||
# Check if patch can be applied (forward dry-run succeeds)
|
||||
if patch --dry-run -p1 < ${patch_file} > /dev/null 2>&1; then
|
||||
if patch -f --dry-run -p1 < ${patch_file} > /dev/null 2>&1; then
|
||||
echo "🔧 Applying patch..."
|
||||
if patch -p1 < ${patch_file}; then
|
||||
if patch -f -p1 < ${patch_file}; then
|
||||
echo "✅ Applied successfully"
|
||||
popd > /dev/null
|
||||
echo ""
|
||||
@@ -284,29 +305,29 @@ function at-repos-ozone-patch() {
|
||||
fi
|
||||
|
||||
# Replace process.env with env()
|
||||
sed -i 's/process\.env\.\(NEXT_PUBLIC_[A-Z_]*\)/env('\''\1'\'')/g' lib/constants.ts 2>/dev/null || true
|
||||
sed -i 's/process\.env\.NODE_ENV/env('\''NODE_ENV'\'')/g' lib/constants.ts 2>/dev/null || true
|
||||
sediment 's/process\.env\.\(NEXT_PUBLIC_[A-Z_]*\)/env('\''\1'\'')/g' lib/constants.ts 2>/dev/null || true
|
||||
sediment 's/process\.env\.NODE_ENV/env('\''NODE_ENV'\'')/g' lib/constants.ts 2>/dev/null || true
|
||||
# Add missing SOCIAL_APP_DOMAIN constant after SOCIAL_APP_URL
|
||||
sed -i '/^export const SOCIAL_APP_URL =/,/^$/{ /^$/a\
|
||||
sediment '/^export const SOCIAL_APP_URL =/,/^$/{ /^$/a\
|
||||
export const SOCIAL_APP_DOMAIN =\
|
||||
env('\''NEXT_PUBLIC_SOCIAL_APP_DOMAIN'\'') || '\''bsky.app'\''\
|
||||
|
||||
}' lib/constants.ts 2>/dev/null || true
|
||||
# Fix multiline process.env patterns
|
||||
sed -i '/^export const NEW_ACCOUNT_MARKER_THRESHOLD_IN_DAYS = process\.env$/,/^ : 7$/ {
|
||||
sediment '/^export const NEW_ACCOUNT_MARKER_THRESHOLD_IN_DAYS = process\.env$/,/^ : 7$/ {
|
||||
s/^export const NEW_ACCOUNT_MARKER_THRESHOLD_IN_DAYS = process\.env$/export const NEW_ACCOUNT_MARKER_THRESHOLD_IN_DAYS = env('\''NEXT_PUBLIC_NEW_ACCOUNT_MARKER_THRESHOLD_IN_DAYS'\'')/
|
||||
/^ \.NEXT_PUBLIC_NEW_ACCOUNT_MARKER_THRESHOLD_IN_DAYS$/d
|
||||
}' lib/constants.ts 2>/dev/null || true
|
||||
sed -i '/^export const YOUNG_ACCOUNT_MARKER_THRESHOLD_IN_DAYS = process\.env$/,/^ : 30$/ {
|
||||
sediment '/^export const YOUNG_ACCOUNT_MARKER_THRESHOLD_IN_DAYS = process\.env$/,/^ : 30$/ {
|
||||
s/^export const YOUNG_ACCOUNT_MARKER_THRESHOLD_IN_DAYS = process\.env$/export const YOUNG_ACCOUNT_MARKER_THRESHOLD_IN_DAYS = env('\''NEXT_PUBLIC_YOUNG_ACCOUNT_MARKER_THRESHOLD_IN_DAYS'\'')/
|
||||
/^ \.NEXT_PUBLIC_YOUNG_ACCOUNT_MARKER_THRESHOLD_IN_DAYS$/d
|
||||
}' lib/constants.ts 2>/dev/null || true
|
||||
sed -i '/^export const HIGH_PROFILE_FOLLOWER_THRESHOLD = process\.env$/,/^ : Infinity$/ {
|
||||
sediment '/^export const HIGH_PROFILE_FOLLOWER_THRESHOLD = process\.env$/,/^ : Infinity$/ {
|
||||
s/^export const HIGH_PROFILE_FOLLOWER_THRESHOLD = process\.env$/export const HIGH_PROFILE_FOLLOWER_THRESHOLD = env('\''NEXT_PUBLIC_HIGH_PROFILE_FOLLOWER_THRESHOLD'\'')/
|
||||
/^ \.NEXT_PUBLIC_HIGH_PROFILE_FOLLOWER_THRESHOLD$/d
|
||||
}' lib/constants.ts 2>/dev/null || true
|
||||
# Fix parseInt() to handle undefined by adding || ''
|
||||
sed -i "s/parseInt(env('\([^']*\)'))/parseInt(env('\1') || '0')/g" lib/constants.ts 2>/dev/null || true
|
||||
sediment "s/parseInt(env('\([^']*\)'))/parseInt(env('\1') || '0')/g" lib/constants.ts 2>/dev/null || true
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
@@ -317,6 +338,9 @@ function at-repos-build-docker-atproto() {
|
||||
for ((i=1; i<=${#services}; i++)); do
|
||||
service=${services[$i]}
|
||||
docker compose build --no-cache $service
|
||||
if [ "$service" = "ozone" ]; then
|
||||
docker compose build --no-cache ${service}-web
|
||||
fi
|
||||
done
|
||||
else
|
||||
docker compose build --no-cache $1
|
||||
@@ -338,12 +362,11 @@ function at-repos-push-reset() {
|
||||
}
|
||||
|
||||
function at-repos-push-docker() {
|
||||
if [ -z "$1" ];then
|
||||
for ((i=1; i<=${#services}; i++)); do
|
||||
service=${services[$i]}
|
||||
if [ -z "$1" ] || [ "$1" = "push" ]; then
|
||||
for service in "${services[@]}"; do
|
||||
docker tag at-${service}:latest localhost:${dport}/${service}:latest
|
||||
docker push localhost:${dport}/${service}:latest
|
||||
if [ "$service" == "ozone" ];then
|
||||
if [ "$service" = "ozone" ]; then
|
||||
docker tag at-${service}-web:latest localhost:${dport}/${service}-web:latest
|
||||
docker push localhost:${dport}/${service}-web:latest
|
||||
fi
|
||||
@@ -388,28 +411,55 @@ function at-repos-reset-bgs-db() {
|
||||
echo "⚙️ Updating Slurp Config..."
|
||||
docker exec -i $dp psql -U postgres -d bgs -c "UPDATE slurp_configs SET new_subs_disabled = false, new_pds_per_day_limit = 1000 WHERE id = 1;"
|
||||
|
||||
echo "🔗 Registering Trusted Domain & Resetting Repos..."
|
||||
# host=pds:3000
|
||||
echo "🔗 Registering Trusted Domain..."
|
||||
# Retry loop for addTrustedDomain as BGS might still be warming up
|
||||
for i in {1..5}; do
|
||||
if curl -f -X POST "https://bgs.${host}/admin/pds/addTrustedDomain?domain=${host}" -H "Authorization: Bearer ${BGS_ADMIN_KEY}"; then
|
||||
echo ""
|
||||
echo "✅ Trusted domain registered"
|
||||
break
|
||||
fi
|
||||
echo "Bot failed to contact BGS (attempt $i/5)... waiting 5s"
|
||||
echo "Failed to contact BGS (attempt $i/5)... waiting 5s"
|
||||
sleep 5
|
||||
done
|
||||
|
||||
echo "🔗 Requesting PDS Crawl..."
|
||||
# Request BGS to crawl the PDS - this registers the PDS and starts subscription
|
||||
for i in {1..5}; do
|
||||
result=$(curl -s -X POST "https://bgs.${host}/admin/pds/requestCrawl" \
|
||||
-H "Authorization: Bearer ${BGS_ADMIN_KEY}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"hostname\":\"{$host}\"}" \
|
||||
-w "%{http_code}" -o /dev/null)
|
||||
if [ "$result" = "200" ]; then
|
||||
echo "✅ PDS crawl requested successfully"
|
||||
break
|
||||
fi
|
||||
echo "Failed to request crawl (attempt $i/5, status: $result)... waiting 5s"
|
||||
sleep 5
|
||||
done
|
||||
|
||||
echo "⏳ Waiting 5s for BGS to connect to PDS..."
|
||||
sleep 5
|
||||
|
||||
echo "🔄 Triggering repo sync for existing users..."
|
||||
for ((i=1; i<=${#handles}; i++)); do
|
||||
handle=${handles[$i]}
|
||||
did=`curl -sL "https://${host}/xrpc/com.atproto.repo.describeRepo?repo=${handle}" |jq -r .did`
|
||||
if [ ! -z "$did" ] && [ "$did" != "null" ]; then
|
||||
echo "Resetting repo: $handle ($did)"
|
||||
curl -X POST "https://bgs.${host}/admin/repo/reset?did=${did}" \
|
||||
-H "Authorization: Bearer ${BGS_ADMIN_KEY}"
|
||||
did=$(curl -sL "https://${host}/xrpc/com.atproto.repo.describeRepo?repo=${handle}" | jq -r .did)
|
||||
if [ -n "$did" ] && [ "$did" != "null" ]; then
|
||||
echo " Syncing repo: $handle ($did)"
|
||||
# Use takedown=false to trigger a resync without actually taking down
|
||||
curl -s -X POST "https://bgs.${host}/admin/repo/takedown?did=${did}&takedown=false" \
|
||||
-H "Authorization: Bearer ${BGS_ADMIN_KEY}" || true
|
||||
else
|
||||
echo "Skipping reset for $handle (DID not found)"
|
||||
echo " Skipping $handle (DID not found)"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "✅ BGS reset complete!"
|
||||
echo " PDS should now be subscribed and syncing repos."
|
||||
}
|
||||
|
||||
function at-repos-feed-generator-start-push() {
|
||||
@@ -480,7 +530,7 @@ case "$1" in
|
||||
exit
|
||||
;;
|
||||
patch)
|
||||
at-repos-social-app-avatar-write
|
||||
at-repos-social-app-ios-patch
|
||||
at-repos-patch-apply-all
|
||||
at-repos-ozone-patch
|
||||
show-failed-patches
|
||||
@@ -520,7 +570,8 @@ case "`cat /etc/hostname`" in
|
||||
*)
|
||||
at-repos-clone
|
||||
at-repos-pull
|
||||
at-repos-social-app-avatar-write
|
||||
at-repos-checkout-pinned
|
||||
at-repos-social-app-ios-patch
|
||||
at-repos-patch-apply-all
|
||||
at-repos-ozone-patch
|
||||
show-failed-patches
|
||||
|
||||
Reference in New Issue
Block a user