Compare commits
4 commits
1553e2b392
...
56310b98f5
Author | SHA1 | Date | |
---|---|---|---|
56310b98f5 | |||
7e4775208f | |||
84d54ed276 | |||
5afcd633d5 |
5 changed files with 127 additions and 2 deletions
64
README.md
Normal file
64
README.md
Normal file
|
@ -0,0 +1,64 @@
|
|||
# Piped-Alpine
|
||||
|
||||
- Patches for backend source code to make it work on Alpine
|
||||
- Simple build script and `start.sh`
|
||||
- OpenRC configs
|
||||
|
||||
Patches may outdate, so open an issue
|
||||
if you get an error while script applies them.
|
||||
|
||||
## How to build
|
||||
1. Install dependencies: `doas apk add git openjdk17 7zip`
|
||||
2. Install Rust: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
|
||||
(Note that you don't need doas or sudo here)
|
||||
3. Enter to RustUp environment: `source ~/.cargo/env`
|
||||
4. Run the script: `./build.sh`
|
||||
(`bash build.sh` if you executed previous commands from bash)
|
||||
|
||||
## How to start Piped
|
||||
1. Edit config.properties
|
||||
2. Change `/home/piped` in start.sh to directory
|
||||
where piped JAR and config are located
|
||||
3. Run the script: `./start.sh`
|
||||
|
||||
## OpenRC
|
||||
1. Change `/home/piped` in piped.init to directory
|
||||
where piped JAR and config are located
|
||||
2. Change `command_user="piped"` in piped.init to the Piped's user name
|
||||
3. Copy this init script: `doas cp piped.init /etc/init.d/piped`
|
||||
4. Add it to autostart: `doas rc-update add piped`
|
||||
5. Start the service: `doas service piped start`
|
||||
|
||||
## I also need to start a proxy, right?
|
||||
Yes.
|
||||
|
||||
This repo is dedicated only to patches for Piped's backend,
|
||||
but I've included an OpenRC config for proxy and this small explanation below.
|
||||
|
||||
### Build
|
||||
Building proxy is quite easy:
|
||||
```bash
|
||||
git clone https://github.com/TeamPiped/piped-proxy
|
||||
cd piped-proxy
|
||||
cargo build --release
|
||||
cp target/release/piped-proxy ..
|
||||
cd ..
|
||||
```
|
||||
|
||||
### Start
|
||||
Command: `UDS=1 ./piped-proxy`
|
||||
|
||||
- With UDS=1, it creates a Unix socket in `./socket/actix.sock`
|
||||
instead of listening on TCP port.
|
||||
- Without UDS=1, it listens for HTTP connections on :8080 port.
|
||||
- If you want to specify other TCP port,
|
||||
use `BIND=127.0.0.1:8080` variable (replace port and host with your own),
|
||||
and do not enable UDS.
|
||||
|
||||
Create `socket` directory before the first start if you have enabled UDS.
|
||||
Also, check if the user from which the proxy is started has write access to the `socket/`.
|
||||
|
||||
### OpenRC
|
||||
The same as in Piped backend.
|
||||
Copy `proxy.init` replacing the directory and user, replacing `UDS=1` with `BIND=...` if needed.
|
||||
I've set `nginx` as user because otherwise my reverse proxy won't have access to the socket file.
|
4
build.sh
4
build.sh
|
@ -47,8 +47,8 @@ title 'Cloning repositories...'
|
|||
[ -e reqwest4j ] || clone https://github.com/TeamPiped/reqwest4j reqwest4j
|
||||
|
||||
title 'Applying patches...'
|
||||
cd_and_exec backend try_exec git apply ../backend.patch
|
||||
cd_and_exec reqwest4j try_exec git apply ../reqwest4j.patch
|
||||
cd_and_exec backend git apply ../backend.patch
|
||||
cd_and_exec reqwest4j git apply ../reqwest4j.patch
|
||||
|
||||
|
||||
# ---
|
||||
|
|
22
piped.init
Executable file
22
piped.init
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
name=$RC_SVCNAME
|
||||
command="/bin/ash"
|
||||
command_args="/home/piped/start.sh"
|
||||
command_user="piped"
|
||||
directory="/home/piped"
|
||||
|
||||
output_log="/var/log/$RC_SVCNAME/piped.log"
|
||||
error_log="/var/log/$RC_SVCNAME/error.log"
|
||||
|
||||
pidfile="/run/$RC_SVCNAME/$RC_SVCNAME.pid"
|
||||
command_background="yes"
|
||||
|
||||
depend() {
|
||||
need net
|
||||
}
|
||||
|
||||
start_pre() {
|
||||
checkpath --directory --owner $command_user:$command_user --mode 0775 \
|
||||
/run/$RC_SVCNAME /var/log/$RC_SVCNAME
|
||||
}
|
23
proxy.init
Normal file
23
proxy.init
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
export UDS=1
|
||||
|
||||
name=$RC_SVCNAME
|
||||
command="/home/ytproxy/piped-proxy"
|
||||
command_user="nginx"
|
||||
directory="/home/ytproxy"
|
||||
|
||||
output_log="/var/log/$RC_SVCNAME/proxy.log"
|
||||
error_log="/var/log/$RC_SVCNAME/error.log"
|
||||
|
||||
pidfile="/run/$RC_SVCNAME/$RC_SVCNAME.pid"
|
||||
command_background="yes"
|
||||
|
||||
depend() {
|
||||
need net
|
||||
}
|
||||
|
||||
start_pre() {
|
||||
checkpath --directory --owner $command_user:$command_user --mode 0775 \
|
||||
/run/$RC_SVCNAME /var/log/$RC_SVCNAME
|
||||
}
|
16
start.sh
Normal file
16
start.sh
Normal file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/ash
|
||||
# shellcheck shell=dash
|
||||
|
||||
JAVA_BIN="/usr/lib/jvm/default-jvm/bin/java"
|
||||
PIPED="/home/piped/piped.jar"
|
||||
|
||||
"$JAVA_BIN" -server \
|
||||
-Xmx1G \
|
||||
-XX:+UnlockExperimentalVMOptions \
|
||||
-XX:+OptimizeStringConcat \
|
||||
-XX:+UseStringDeduplication \
|
||||
-XX:+UseCompressedOops \
|
||||
-XX:+UseNUMA \
|
||||
-XX:+UseG1GC \
|
||||
-Xshare:on \
|
||||
-jar "$PIPED"
|
Loading…
Add table
Reference in a new issue