forked from bluesky-social/atproto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.zsh
executable file
·214 lines (198 loc) · 6.34 KB
/
install.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/bin/zsh
host=syu.is
name=${host%%.*}
domain=${host##*.}
d=${0:a:h}
dh=${0:a:h:h}
git_plc=https://github.com/did-method-plc/did-method-plc
git_bgs=https://github.com/bluesky-social/indigo
git_atp=https://github.com/bluesky-social/atproto
git_web=https://github.com/bluesky-social/social-app
git_fee=https://github.com/bluesky-social/feed-generator
run_repos_dl() {
mkdir -p $d/repos
cd $d/repos
if [ ! -d $d/repos/did-method-plc ];then
git clone $git_plc
fi
if [ ! -d $d/repos/indigo ];then
git clone $git_bgs
fi
if [ ! -d $d/repos/atproto ];then
git clone $git_atp
fi
if [ ! -d $d/repos/social-app ];then
git clone $git_web
fi
if [ ! -d $d/repos/feed-generator ];then
git clone $git_fee
cp -rf $d/docker/feed/Dockerfile $d/repos/feed-generator/
fi
}
run_repos_dl
run_env() {
b="ADMIN_PASSWORD
MODERATOR_PASSWORD
TRIAGE_PASSWORD
SERVICE_SIGNING_KEY
IMG_URI_SALT
IMG_URI_KEY
OZONE_ADMIN_PASSWORD
OZONE_MODERATOR_PASSWORD
OZONE_TRIAGE_PASSWORD
OZONE_SIGNING_KEY_HEX
BGS_ADMIN_KEY
PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX
PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX"
for ((i=1;i<=`echo $b|wc -l`;i++))
do
f=`echo $b|awk "NR==$i"`
o=`openssl ecparam --name secp256k1 --genkey --noout --outform DER | tail --bytes=+8 | head --bytes=32 | xxd --plain --cols 32`
echo $f=$o
export $f=$o
done
b="PDS_JWT_SECRET
PDS_ADMIN_PASSWORD"
for ((i=1;i<=`echo $b|wc -l`;i++))
do
f=`echo $b|awk "NR==$i"`
o=`openssl rand --hex 16`
echo $f=$o
export $f=$o
done
}
run_env_write() {
echo MODERATION_PUSH_URL=https://admin:${OZONE_ADMIN_PASSWORD}@mod.${host} >> $d/.env/appview
echo MODERATION_PUSH_URL=https://admin:${OZONE_ADMIN_PASSWORD}@mod.${host} >> $d/.env/moderation
echo ADMIN_PASSWORD=$ADMIN_PASSWORD >> $d/.env/appview
echo "{\"admin_password\": \"$ADMIN_PASSWORD\"}" >> $d/config.json
echo MODERATOR_PASSWORD=$MODERATOR_PASSWORD >> $d/.env/appview
echo TRIAGE_PASSWORD=$TRIAGE_PASSWORD >> $d/.env/appview
echo SERVICE_SIGNING_KEY=$SERVICE_SIGNING_KEY >> $d/.env/appview
echo IMG_URI_SALT=$IMG_URI_SALT >> $d/.env/appview
echo IMG_URI_KEY=$IMG_URI_KEY >> $d/.env/appview
echo OZONE_ADMIN_PASSWORD=$OZONE_ADMIN_PASSWORD >> $d/.env/moderation
echo OZONE_MODERATOR_PASSWORD=$OZONE_MODERATOR_PASSWORD >> $d/.env/moderation
echo OZONE_TRIAGE_PASSWORD=$OZONE_TRIAGE_PASSWORD >> $d/.env/moderation
echo OZONE_SIGNING_KEY_HEX=$OZONE_SIGNING_KEY_HEX >> $d/.env/mod
echo BGS_ADMIN_KEY=$BGS_ADMIN_KEY >> $d/.env/bgs
echo PDS_JWT_SECRET=$PDS_JWT_SECRET >> $d/.env/pds
echo PDS_ADMIN_PASSWORD=$PDS_ADMIN_PASSWORD >> $d/.env/pds
echo PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX=$PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX >> $d/.env/pds
echo PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX=$PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX >> $d/.env/pds
}
run_web() {
cd $d/repos/social-app/src
if [ -n "`grep -R bsky.social .`" ];then
for f (`grep -R bsky.social . |cut -d : -f 1`) sed -i -e "s/bsky\.social/${name}\.${domain}/g" $f
fi
#if [ -n "`grep -R bsky.app .`" ];then
# for f (`grep -R bsky.app . |cut -d : -f 1`) sed -i -e "s/bsky\.app/web\.${name}\.${domain}/g" $f
#fi
if [ -n "`grep -R "isSandbox: false" .`" ];then
for f (`grep -R "isSandbox: false" . |cut -d : -f 1`) sed -i -e "s/isSandbox: false/isSandbox: true/g" $f
fi
if [ -n "`grep -R SANDBOX .`" ];then
for f (`grep -R SANDBOX . |cut -d : -f 1`) sed -i -e "s/SANDBOX/${name}\.${domain}/g" $f
fi
f=./view/com/modals/ServerInput.tsx
if [ -n "`grep -R Bluesky.Social $f`" ] && [ -f $f ];then
sed -i -e "s/Bluesky\.Social/${name}\.${domain}/g" $f
fi
f=./state/queries/preferences/moderation.ts
if [ -n "`grep -R 'Bluesky Social' $f`" ] && [ -f $f ];then
sed -i -e "s/Bluesky Social/${name}\.${domain}/g" $f
fi
f=./view/com/auth/create/Step1.tsx
if [ -n "`grep -R 'Bluesky' $f`" ] && [ -f $f ];then
sed -i -e "s/Bluesky/${name}\.${domain}/g" $f
fi
f=./lib/strings/url-helpers.ts
if [ -n "`grep -R 'Bluesky Social' $f`" ] && [ -f $f ];then
sed -i -e "s/Bluesky Social/${name}\.${domain}/g" $f
fi
f=./view/icons/Logotype.tsx
o=$d/icons/Logotype.tsx
if [ -n "`grep -R 'M8.478 6.252c1.503.538 2.3 1.7' $f`" ] && [ -f $f ] && [ -f $o ];then
cp -rf $o $f
fi
}
run_web_icon_dl() {
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/
}
run_web_app() {
cd $d/repos/social-app/src
f=./lib/analytics/analytics.tsx
if [ -n "`grep -R 'bsky.app' $f`" ] && [ -f $f ];then
sed -i -e "s#https://api.events.bsky.app/v1#https://api.syu.is/v1#g" $f
fi
f=./lib/analytics/analytics.web.tsx
if [ -n "`grep -R 'bsky.app' $f`" ] && [ -f $f ];then
sed -i -e "s#api.events.bsky.app/v1#api.syu.is/v1#g" $f
fi
f=./lib/notifications/notifications.ts
if [ -n "`grep -R 'bsky.app' $f`" ] && [ -f $f ];then
sed -i -e "s/bsky\.app/${name}\.${domain}/g" $f
fi
f=./lib/constants.ts
if [ -n "`grep -R 'bsky.app' $f`" ] && [ -f $f ];then
sed -i -e "s/bsky\.app/${name}\.${domain}/g" $f
fi
f=./lib/strings/url-helpers.ts
if [ -n "`grep -R 'bsky.app' $f`" ] && [ -f $f ];then
sed -i -e "s/bsky\.app/${name}\.${domain}/g" $f
fi
f=./view/com/modals/ServerInput.tsx
if [ -n "`grep -R 'bsky.app' $f`" ] && [ -f $f ];then
sed -i -e "s/bsky\.app/${name}\.${domain}/g" $f
fi
f=./view/com/modals/ContentFilteringSettings.tsx
if [ -n "`grep -R 'bsky.app' $f`" ] && [ -f $f ];then
sed -i -e "s/bsky\.app/${name}\.${domain}/g" $f
fi
f=./state/queries/index.ts
if [ -n "`grep -R 'bsky.app' $f`" ] && [ -f $f ];then
sed -i -e "s#https://public.api.bsky.app#https://api.syu.is#g" $f
fi
f=./App.native.tsx
if [ -n "`grep -R 'sentry' $f`" ] && [ -f $f ];then
sed -i -e "s#import 'lib/sentry'#//import 'lib/sentry'#g" $f
sed -i -e "s#import 'lib/sentry'#//import 'lib/sentry'#g" ./App.web.tsx
fi
}
run_update() {
cd $d/repos/did-method-plc;git pull
cd $d/repos/indigo;git pull
cd $d/repos/atproto;git pull
cd $d/repos/feed-generator;git pull
rm -rf $d/repos/social-app;
if [ ! -d $d/repos/social-app ];then
cd $d/repos
git clone $git_web
run_web
run_web_app
fi
cd $d
echo ----------------------------
echo cd $d
echo 'docker compose build && docker compose up -d'
}
case $1 in
run-env-write)
run_env
run_env_write
;;
web)
run_web
;;
web-icon-dl)
run_web_icon_dl
;;
web-app)
run_web_app
;;
update|up)
run_update
;;
esac