Skip to content

Commit a32433e

Browse files
committed
Add metasearch
1 parent 49e1f84 commit a32433e

5 files changed

Lines changed: 101 additions & 4 deletions

File tree

_do.cr

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ BROWSER_DETECTOR_VERSION = "4.1.0"
3838
HLS_VERSION = "1.5.15"
3939
MEDIA_CAPTIONS_VERSION = "1.0.4"
4040
MEDIA_ICONS_VERSION = "1.1.5"
41+
METASEARCH_VERSION = "37dc3364731f3a62c554f2d19160c22bd5f260fe"
4142
P2P_MEDIA_LOADER_VERSION = "2.0.1"
4243
RNOSTR_VERSION = "0.4.8"
4344
RUST_VERSION = "1.86.0"
@@ -54,7 +55,7 @@ OPUS_BITRATE_KBPS = 256
5455
BANDWIDTH_MB_PER_SEC = 20
5556
IGNORE_HOSTS = ["personal.tracker.com", "tracker.novage.com.ua", "www.googletagmanager.com"]
5657

57-
CERTBOT_DOMAINS = ["media.codonaft.com", "nostr.codonaft.com", "test.codonaft.com"]
58+
CERTBOT_DOMAINS = ["media", "nostr", "metasearch", "test"].map { |i| "#{i}.codonaft.com" }
5859

5960
MAIN_SITE_CONFIG = Path["_config.yml"]
6061

@@ -243,6 +244,14 @@ def build
243244
dependencies: ["g++", "openssl-dev", "openssl-libs-static"],
244245
)
245246

247+
build_rust_app(
248+
MEDIA_HOST,
249+
crate: "metasearch",
250+
branch: "master",
251+
git: URI.parse("https://github.com/mat-1/metasearch2"),
252+
version: METASEARCH_VERSION,
253+
)
254+
246255
generate_certbot_script(MEDIA_HOST)
247256
end
248257

@@ -262,7 +271,7 @@ def start
262271
end
263272
step("start")
264273
start_openrc(MIRROR_HOST, services: ["i2pd", "local", "nginx", "tor"])
265-
start_openrc(MEDIA_HOST, services: ["aquatic_ws", "broadcastr", "rnostr", "i2pd", "local", "nginx", "tor"])
274+
start_openrc(MEDIA_HOST, services: ["aquatic_ws", "broadcastr", "metasearch", "rnostr", "i2pd", "local", "nginx", "tor"])
266275
end
267276

268277
def encode_media(input : String, config : YAML::Any, language : String)
@@ -671,6 +680,8 @@ end
671680
def generate_certbot_script(host)
672681
domains = CERTBOT_DOMAINS.join(',')
673682
user = ssh(host, ["echo -n ${USER}"])
683+
raise "unexpected username" if user.empty?
684+
674685
home_dir = BUILD_DIR.join(host).join("home").join(user)
675686
cron_dir = home_dir.join(".periodic/weekly")
676687
output = cron_dir.join("certbot-prod.sh")
@@ -987,8 +998,12 @@ def build_rust_app(
987998
raise "unspecified version" if version.nil?
988999
"#{crate} --version #{version}"
9891000
else
990-
raise "either version or branch is allowed" if !version.nil? && !branch.nil?
991-
version = version.nil? ? "" : " --tag #{version}"
1001+
version =
1002+
if version.nil?
1003+
""
1004+
else
1005+
branch.nil? ? " --tag #{version}" : " --rev #{version}"
1006+
end
9921007
branch = branch.nil? ? "" : " --branch #{branch}"
9931008
"--git #{git}#{version}#{branch}"
9941009
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/sbin/openrc-run
2+
3+
name="metasearch"
4+
5+
command="/usr/local/bin/${name}"
6+
command_user="nobody:nobody"
7+
command_background="true"
8+
command_args="/etc/${name}/${name}.toml"
9+
10+
pidfile="/run/${name}.pid"
11+
output_logger="logger"
12+
error_logger="logger"
13+
14+
depend() {
15+
need net
16+
use logger
17+
}

_hosts/media.codonaft/etc/local.d/90-inotify-extra.start

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
fi
1616
done &
1717

18+
[ -f /etc/init.d/metasearch ] && inotifywait --event close_write,moved_to,create --monitor --recursive /etc/metasearch/ |
19+
while read -r directory events filename ; do
20+
if [[ "${filename}" == "metasearch.toml" ]] ; then
21+
rc-service --ifstarted metasearch restart 2>>/dev/stdout | logger
22+
fi
23+
done &
24+
1825
# rnostr relay --watch does nothing (probably under load only)
1926
[ -f /etc/init.d/rnostr ] && inotifywait --event close_write,moved_to,create --monitor --recursive /etc/rnostr/ |
2027
while read -r directory events filename ; do
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
bind = "127.0.0.1:28019"
2+
api = true
3+
4+
[ui]
5+
show_autocomplete = false
6+
favicon = "https://codonaft.com/favicon.ico"
7+
8+
[image_search]
9+
enabled = true
10+
max_download_size = 4194304
11+
12+
[engines]
13+
bing = false
14+
minecraft_wiki = false
15+
16+
[urls.replace]
17+
"medium.com" = "scribe.rip"
18+
".medium.com" = "scribe.rip"
19+
"x.com" = "xcancel.com"
20+
".x.com" = "xcancel.com"
21+
22+
[urls.weight]
23+
".zhihu.com" = 0
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
server {
2+
listen 443 ssl;
3+
listen [::]:443 ssl;
4+
#listen 443 quic;
5+
#listen [::]:443 quic;
6+
http2 on;
7+
#http3 on;
8+
9+
include /etc/nginx/allowlist.conf;
10+
11+
server_name metasearch.codonaft.com;
12+
ssl_certificate /etc/nginx/ssl/codonaft.com/fullchain.pem;
13+
ssl_certificate_key /etc/nginx/ssl/codonaft.com/privkey.pem;
14+
ssl_trusted_certificate /etc/nginx/ssl/codonaft.com/chain.pem;
15+
16+
access_log /var/log/nginx/access.log privacy;
17+
18+
location / {
19+
proxy_http_version 1.1;
20+
proxy_connect_timeout 20s;
21+
proxy_socket_keepalive on;
22+
proxy_send_timeout 20s;
23+
proxy_read_timeout 120s;
24+
25+
proxy_set_header "Host" $host;
26+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
27+
#proxy_set_header X-Forwarded-Proto $scheme;
28+
29+
#add_header Cache-Control "public, max-age=7200";
30+
#expires 2h;
31+
#default_type "text/plain";
32+
33+
proxy_pass http://127.0.0.1:28019;
34+
}
35+
}

0 commit comments

Comments
 (0)