forked from crony/UpFast
Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a4d9291ee3 | ||
|
129101ac2e | ||
|
c3f133b211 | ||
|
4d3cac8851 | ||
|
574b7ce5f1 | ||
|
3873729ae7 | ||
|
4342fa4a56 | ||
|
aa1dff7015 | ||
|
e9563be67a | ||
|
3d1ba3bb5c | ||
|
69f19a1888 | ||
|
17c172a73d | ||
|
76963bcd88 | ||
|
1987a3fbef | ||
|
fb7b89a101 | ||
|
972f55f38d | ||
|
a5df50f43c | ||
|
b376d91e21 | ||
|
da70b22fdf | ||
|
7c593f2fc2 | ||
|
9f8afe5054 | ||
|
edc99c3481 | ||
|
8fdc68b441 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
|||||||
__pycache__
|
__pycache__
|
||||||
upload
|
upload
|
||||||
venv
|
env
|
||||||
|
87
README.md
87
README.md
@ -10,58 +10,25 @@ To run on a regular system I recommend to use a virtual environment to install t
|
|||||||
|
|
||||||
We will also be setting up an specific user to run the app as safe as possible with a systemd service file for startup
|
We will also be setting up an specific user to run the app as safe as possible with a systemd service file for startup
|
||||||
|
|
||||||
|
#### Installing
|
||||||
```bash
|
```bash
|
||||||
# Create the user (You can specify a different home-dir)
|
./install.sh
|
||||||
sudo useradd --shell /bin/bash --system \
|
|
||||||
--home-dir "/usr/local/upfast" -m upfast
|
|
||||||
|
|
||||||
# Change to upfast user and go to upfast dir
|
|
||||||
su upfast
|
|
||||||
cd
|
|
||||||
|
|
||||||
# Clone the project directly into upfast-src directory
|
|
||||||
git clone https://code.cronyakatsuki.xyz/crony/upfast .
|
|
||||||
|
|
||||||
# Create the virtual environment and load it for user on default
|
|
||||||
python3 -m venv venv
|
|
||||||
# Activate the virtual environment
|
|
||||||
source venv/bin/activate
|
|
||||||
# Install all the requirements
|
|
||||||
pip install -r requirements.txt
|
|
||||||
|
|
||||||
# Load environment by default
|
|
||||||
echo "source /usr/local/upfast/venv/bin/activate" > "/usr/local/upfast/.profile"
|
|
||||||
|
|
||||||
# create the upload directory
|
|
||||||
mkdir upload
|
|
||||||
|
|
||||||
# UpFast go brrr
|
|
||||||
uvicorn main:app --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips='*'
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Autostart with systemd
|
#### Running
|
||||||
|
|
||||||
To autostart with systemd you will need to create a systemd .service file in path `/etc/systemd/system/upfast.service` and add this content to it.
|
|
||||||
|
|
||||||
```systemd
|
|
||||||
[Unit]
|
|
||||||
Description=UpFast service
|
|
||||||
Documentation=https://code.cronyakatsuki.xyz/crony/upfast
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
User=upfast
|
|
||||||
Group=upfast
|
|
||||||
WorkingDirectory=/usr/local/upfast/
|
|
||||||
ExecStart=/usr/local/upfast/venv/bin/uvicorn main:app --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips='*'
|
|
||||||
Restart=on-failure
|
|
||||||
```
|
|
||||||
Finally run following commmands.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# refresh services
|
systemctl start upfast.service
|
||||||
sudo systemctl daemon-reload
|
```
|
||||||
# enable the service
|
|
||||||
sudo systemctl enable upfast.service
|
#### Start on boot
|
||||||
|
```bash
|
||||||
|
systemctl enable upfast.service
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Updating
|
||||||
|
To update, you only need to pull the changes
|
||||||
|
```bash
|
||||||
|
su upfast -c 'cd && git pull --no-rebase'
|
||||||
```
|
```
|
||||||
|
|
||||||
### Docker
|
### Docker
|
||||||
@ -80,24 +47,14 @@ The sample command will need an upload directory, you can replace `./upload` wit
|
|||||||
### Nginx Proxy setup
|
### Nginx Proxy setup
|
||||||
|
|
||||||
This is an example nginx proxy config for http
|
This is an example nginx proxy config for http
|
||||||
|
```bash
|
||||||
|
cp ./upfast-nginx /etc/nginx/sites-available/upfast
|
||||||
|
ln -sf /etc/nginx/sites-available/upfast /etc/nginx/sites-enabled/
|
||||||
|
```
|
||||||
|
|
||||||
```nginx
|
> Load config
|
||||||
server {
|
```bash
|
||||||
|
systemctl reload nginx
|
||||||
listen 80;
|
|
||||||
listen [::]:80;
|
|
||||||
|
|
||||||
server_name upfast.example.com ;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://127.0.0.1:8000;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
|
||||||
proxy_redirect off;
|
|
||||||
proxy_buffering off;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# Contributions
|
# Contributions
|
||||||
|
39
install.sh
Executable file
39
install.sh
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# quick install (and run) script for upfast using systemd
|
||||||
|
if [ "$(id -u)" -ne 0 ]
|
||||||
|
then
|
||||||
|
echo "Please run as root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
SIZE="5G"
|
||||||
|
|
||||||
|
UFDIR=${1:=/srv/upfast}
|
||||||
|
USER=${1:=upfast}
|
||||||
|
useradd --shell /bin/sh --system --home-dir $UFDIR $UFUSER ||
|
||||||
|
exit 1
|
||||||
|
mkdir -p "$UFDIR" || # dodge copying of skeletons
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
chown "$UFUSER:$UFUSER" "$UFDIR"
|
||||||
|
chmod 700 "$UFDIR"
|
||||||
|
|
||||||
|
su "$UFUSER" -c"
|
||||||
|
cd
|
||||||
|
git clone https://code.cronyakatsuki.xyz/tlast/upfast . ||
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
python3 -m venv env
|
||||||
|
. ./env/bin/activate ||
|
||||||
|
exit1
|
||||||
|
pip install -r requirements.txt ||
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
fallocate -l $SIZE storage
|
||||||
|
mkfs.ext4 storage
|
||||||
|
mount storage upload
|
||||||
|
rm -fd /storage/*" ||
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
cp ./upfast.service /etc/systemd/system/upfast.service
|
||||||
|
systemctl daemon-reload
|
@ -5,8 +5,7 @@ html {
|
|||||||
body {
|
body {
|
||||||
max-width: 900px;
|
max-width: 900px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
background: #303446;
|
background: #81a1c1;
|
||||||
color: #c6d0f5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
@ -16,7 +15,7 @@ h1 {
|
|||||||
|
|
||||||
hr {
|
hr {
|
||||||
margin: 40px;
|
margin: 40px;
|
||||||
color: #626880;
|
color: #2e3440;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
@ -34,9 +33,9 @@ video {
|
|||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #f2d5cf;
|
color: #ebcb8b;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-style: bold;
|
font-weight: bold;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +44,7 @@ a:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
background: #292c3c;
|
background: #2e3440;
|
||||||
font-size: 1am;
|
font-size: 1am;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
max-width: 800;
|
max-width: 800;
|
||||||
@ -54,6 +53,7 @@ pre {
|
|||||||
overflow-x: scroll;
|
overflow-x: scroll;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 1rem;
|
border-radius: 1rem;
|
||||||
|
color: #88c0d0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.file {
|
.file {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
body {
|
body {
|
||||||
max-width: 900px;
|
max-width: 900px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
background: #303446;
|
background: #81a1c1;
|
||||||
color: #c6d0f5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -12,9 +11,9 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #f2d5cf;
|
color: #ebcb8b;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-style: bold;
|
font-weight: bold;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,8 +22,9 @@ a:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
background: #414559;
|
background: #88c0d0;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
font-size: 105%;
|
font-size: 105%;
|
||||||
|
font-style: italic;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
}
|
}
|
||||||
|
15
upfast-nginx
Normal file
15
upfast-nginx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
|
||||||
|
server_name upfast.example.com ;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:8000;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_buffering off;
|
||||||
|
}
|
||||||
|
}
|
13
upfast.service
Normal file
13
upfast.service
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=UpFast service
|
||||||
|
Documentation=https://code.cronyakatsuki.xyz/crony/upfast
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=upfast
|
||||||
|
Group=upfast
|
||||||
|
WorkingDirectory=/usr/local/upfast/
|
||||||
|
ExecStart=/usr/local/upfast/env/bin/uvicorn main:app --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips='*'
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user