Update readme

This commit is contained in:
gitlab.com/pepa65 2022-09-13 01:37:58 +07:00
parent 30f2649ae1
commit b4158dcd83
12 changed files with 42 additions and 51 deletions

View File

@ -1,12 +1,13 @@
{
email %sslmail%
}
%interface% { %interface% {
basicauth * {
%userpw% }
log { log {
output file /var/www/web.log output file /var/www/web.log
format console format console
} }
php_fastcgi 127.0.0.1:9000 php_fastcgi 127.0.0.1:9000
request_header +X-User {http.auth.user.id}
root * /var/www/uploadpage root * /var/www/uploadpage
file_server file_server
} }

View File

@ -10,10 +10,11 @@
FROM alpine:latest FROM alpine:latest
MAINTAINER "gitlab.com/pepa65 <pepa65@passchier.net>" MAINTAINER "gitlab.com/pepa65 <pepa65@passchier.net>"
RUN apk update && apk add bash php php-fpm ffmpeg tzdata file && rm -rf /lib/apk/db RUN apk update && apk add bash php php-fpm ffmpeg tzdata file
ADD https://good4.eu/mailer /usr/bin/mailer ADD https://good4.eu/mailer /usr/bin/mailer
ADD https://good4.eu/caddy /usr/bin/caddy
#ADD https://caddyserver.com/api/download?os=linux&arch=amd64&idempotency=74472262832423 /usr/bin/caddy #ADD https://caddyserver.com/api/download?os=linux&arch=amd64&idempotency=74472262832423 /usr/bin/caddy
ADD https://good4.eu/caddy /usr/bin/caddy
COPY Caddyfile Dockerfile /root/
WORKDIR /var/www WORKDIR /var/www
COPY Caddyfile Dockerfile encode init stream vars ./ COPY encode init stream vars mailhash ./
ENTRYPOINT ./init ENTRYPOINT ./init

View File

@ -6,23 +6,23 @@
### Manual ### Manual
* Prepare a Linux server, set its timezone to the users' timezone * Prepare a Linux server, set its timezone to the users' timezone
(on deb-based systems: `dpkg-reconfigure tzdata`). (on deb-based systems: `dpkg-reconfigure tzdata`).
* On the server, `cd` to the place where you want the files (make sure that
the webserver user (often `www-data`) has access to the location!). the webserver user (often `www-data`) has access to the location!).
* Make sure the packages `git php-fpm ffmpeg` are installed (on deb-based * Make sure the packages `git php-fpm ffmpeg` are installed (on deb-based
systems: `apt install git php-fpm ffmpeg`). systems: `apt install git php-fpm ffmpeg`).
* Clone repo: `git clone https://gitlab.com/pepa65/streamupload`. * Clone repo: `git clone https://gitlab.com/pepa65/streamupload`.
* `cd streamupload`. Now the output of `pwd` is the value for `$repopath`. * Move the `streamupload` directory to a place that is accessible to the web
* Copy `_vars` to `vars` and set the variables server, like: `mv streamupload /var/www` and `cd` to that place. Now the
`to`, `user`, `password`, `smtp` and `port` in it in order to output of `pwd` is the value for `$repopath`.
receive mail notifications when the encodes are finished. * Copy `_vars` to `vars` and `_mailhash` to `mailhash` and set the variables
in `vars` (webserver, SMTP-server) and `mailhash` (usernames, emails and
bcrypt-password-hashes).
* Make a crontab-entry: "* * * * * $repopath/encode" (replace `$repopath`!). * Make a crontab-entry: "* * * * * $repopath/encode" (replace `$repopath`!).
* Install the `mailer` binary by downloading it from the repo at * Install the `mailer` binary by downloading it from the repo at
https://https://github.com/pepa65/mailer/releases/latest and moving it to https://https://github.com/pepa65/mailer/releases/latest and moving it to
`/usr/local/bin` and make it executable: `chmod +x /usr/local/bin/mailer`. `/usr/local/bin` and make it executable: `chmod +x /usr/local/bin/mailer`.
If it's not installed, everything except the email will still work. If it's not installed, everything (except the emails) will still work.
* Run a php/webserver on `$repopath/uploadpage`: * Run a php/webserver on `$repopath/uploadpage`:
- Get it to restart on reboot. - Get it to restart on reboot.
- Setting up basicauth on the page is a good idea if others can get access!
- Change the relevant `php.ini` to allow large file uploads: - Change the relevant `php.ini` to allow large file uploads:
* `post_max_size` - Upper limit of uploaded video sizes, say `10G`. * `post_max_size` - Upper limit of uploaded video sizes, say `10G`.
* `upload_max_filesize` - same value as `post_max_size`. * `upload_max_filesize` - same value as `post_max_size`.
@ -31,32 +31,29 @@
If no webserver has been installed, an easy way to get going is to use Caddy If no webserver has been installed, an easy way to get going is to use Caddy
from https://caddyserver.com/download and place the `caddy` binary in from https://caddyserver.com/download and place the `caddy` binary in
`/usr/local/bin` and make it executable: `chmod +x /usr/local/bin/caddy`. `/usr/local/bin` and make it executable: `chmod +x /usr/local/bin/caddy`.
For php functionality, install `php-fpm` (on deb-based systems: Make the config file `/root/Caddyfile` like:
`apt install php-fpm`) and make the config file `/root/Caddyfile` with:
``` ```
{
email $email
}
:80 { :80 {
basicauth {
$user $hashpassword
}
log { log {
output file /var/www/web.log output file $weblogfile
} }
php_fastcgi unix//run/php/php-fpm.sock php_fastcgi unix//run/php/php-fpm.sock
request_header +X-User {http.auth.user.id}
root * $repopath/uploadpage root * $repopath/uploadpage
file_server file_server
} }
``` ```
* If the server IP has an DNS A record pointing to it, `:80` can be replaced * If the server IP has an DNS A record pointing to it, `:80` can be replaced
by the domainname with the A record. by the domainname with the A record, and it will be SSL-encrypted.
* Replace `$user` with the desired username for authentication and replace * Replace `$email` with an email for the SSL-certificates.
`$hashpassword` with the output of `caddy hash-password` which will * Replace `$weblogfile` with a path for a webserver logfile.
ask for the password to be used for authentication. Multiple users (on
separate lines) are allowed.
* Replace `$repopath` (see above in Install). * Replace `$repopath` (see above in Install).
* The value of `/run/php/php-fpm.sock` might need to be adjusted, depending * The value of `/run/php/php-fpm.sock` might need to be adjusted, depending
on the system used, it needs to be the unix socket for php. on the system used, it needs to be the unix socket for php.
* Caddy can be started at boottime by including `@reboot /root/Caddy` as a * Caddy can be started at boottime by including `@reboot /root/Caddy` as a
line in root's crontab: `crontab -e` and make the file `/root/Caddy` with: line in root's crontab: `crontab -e` and make the file `/root/Caddy` with:
``` ```
#!/usr/bin/env bash #!/usr/bin/env bash
@ -75,15 +72,17 @@ sleep 1
and make it executable: `chmod +x /root/Caddy`. and make it executable: `chmod +x /root/Caddy`.
### Docker ### Docker
After cloning this repo and `cd streamupload`, a docker image can be built After cloning this repo, `cd streamupload`, and setting the variables in `vars` and
from the included `Dockerfile` by: `docker build -t streamupload .`. `mailhash`, a docker image can be built from the included `Dockerfile` by:
In the case of running on a LAN and not having a DNS A record, start it with: `docker build -t streamupload .`. In the case of running on a LAN and not having a
DNS A record, start it with:
`docker run -d -p 8080:80 -v $PWD/uploadpage:/var/www/uploadpage streamupload`. `docker run -d -p 8080:80 -v $PWD/uploadpage:/var/www/uploadpage streamupload`.
In case of a domainname, replace `8080:80` by `443:443`. In case of a domainname, replace `8080:80` by `443:443`.
## Usage ## Usage
* Get a streamkey for the target by scheduling a stream * Get a streamkey for the target by scheduling a stream
(supported are: Restream.io, YouTube.com, Facebook.com). (supported are: Restream.io, YouTube.com, Facebook.com).
* Go to the server's IP address in the browser: `http://$ipaddress` or to the * Go to the server's URL in the browser: `http://$ipaddress:8080` or to the
domainname if available: `https://$domainname`. domainname if available: `https://$domainname`.
* Log in with the username and passwors as prepared in `mailhash`.
* Fill in the form, and click "Schedule Stream". * Fill in the form, and click "Schedule Stream".

View File

@ -1,3 +1,3 @@
# Separated by TABs: user/mail/bcrypt-hash # Separated by TABs: username / email / bcrypt-hash
# Get hash: php -r "echo password_hash('$password', PASSWORD_BCRYPT);" # Get bcrypt-hash: php -r "echo password_hash('$password', PASSWORD_BCRYPT);"
username e@ma.il $2y$10$XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX username e@ma.il $2y$10$XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

13
_vars
View File

@ -1,18 +1,15 @@
## Variables for the install script ## Variables for the install script
# All have to be filled in, except if they have a default # All have to be filled in, except if they have a default
# Timezone for local user
tz='Asia/Bangkok'
# Interface for serving the page: ':80' or 'domain.name' # Interface for serving the page: ':80' or 'domain.name'
# Defaults to ':80' # Defaults to ':80'
interface='' interface=''
# Timezone for local user # Email for registering SSL-certificate
tz='UTC' sslmail='(valid email)'
# Username / Email / Password/Hash (multiple users allowed)
# Must have at least one Username and Email with either Password or Hash
declare -A umail upw uhash
u='username' umail[$u]='email' upw[$u]='password'
u='username' umail[$u]='email' uhash[$u]='$(caddy hash-password)'
# Variables for mailer # Variables for mailer
user='(smtp login)' user='(smtp login)'

15
init
View File

@ -15,21 +15,14 @@ crond
line='SHELL=/bin/bash\n\n# Every minute\n* * * * * /var/www/encode\n\n# Streams' line='SHELL=/bin/bash\n\n# Every minute\n* * * * * /var/www/encode\n\n# Streams'
echo -e "$line" |crontab - echo -e "$line" |crontab -
sed -i "s/%sslmail%/$sslmail/" /root/Caddyfile
[[ $interface ]] || interface=:80 [[ $interface ]] || interface=:80
sed -i "s/%interface%/$interface/" Caddyfile sed -i "s/%interface%/$interface/" /root/Caddyfile
chmod +x /usr/bin/caddy /usr/bin/mailer chmod +x /usr/bin/caddy /usr/bin/mailer
up=
shopt -s nullglob
for u in "${!upw[@]}"
do hash=${uhash[$u]}
[[ $hash ]] || hash=$(caddy hash-password --plaintext "${upw["$u"]}")
up+="\t\t$u $hash#"
done
sed "s/%userpw%/$(echo -en "$up")/" Caddyfile |tr '#' '\n' >/srv/c
mv /srv/c Caddyfile
php-fpm8 -R php-fpm8 -R
caddy start >caddy.log caddy start --config /root/Caddyfile --adapter caddyfile >caddy.log
sleep 9999d sleep 9999d

0
uploadpage/check.php Normal file → Executable file
View File

0
uploadpage/favicon.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 111 KiB

0
uploadpage/index.php Normal file → Executable file
View File

0
uploadpage/login.php Normal file → Executable file
View File

0
uploadpage/page.css Normal file → Executable file
View File

0
uploadpage/upload.php Normal file → Executable file
View File