Option for docker
Allow logout
This commit is contained in:
parent
199025ce47
commit
4580ddebbe
12
Caddyfile
Normal file
12
Caddyfile
Normal file
@ -0,0 +1,12 @@
|
||||
%interface% {
|
||||
basicauth {
|
||||
%userpw% }
|
||||
log {
|
||||
output file /var/www/upload.log
|
||||
format console
|
||||
}
|
||||
php_fastcgi 127.0.0.1:9000
|
||||
request_header +X-User {http.auth.user.id}
|
||||
root * /var/www/uploadpage
|
||||
file_server
|
||||
}
|
||||
16
Dockerfile
Normal file
16
Dockerfile
Normal file
@ -0,0 +1,16 @@
|
||||
# Build image:
|
||||
# docker build -t streamupload .
|
||||
# Run container, one of:
|
||||
# docker run -d --name stream -p 8080:80 -v uploadpage:/var/www/uploadpage streamupload
|
||||
# docker run -d --name stream -p 443:443 -v uploadpage:/var/www/uploadpage streamupload
|
||||
# Access shell in container:
|
||||
# docker exec -ti stream /bin/bash
|
||||
# Destroy container and image:
|
||||
# docker rm stream --force && docker rmi streamupload
|
||||
|
||||
FROM alpine:latest
|
||||
MAINTAINER "gitlab.com/pepa65 <pepa65@passchier.net>"
|
||||
RUN apk update && apk add bash php php-fpm ffmpeg tzdata file
|
||||
COPY Caddyfile Dockerfile encode init stream vars /var/www/
|
||||
WORKDIR /var/www
|
||||
ENTRYPOINT /var/www/init
|
||||
13
README.md
13
README.md
@ -2,6 +2,8 @@
|
||||
**Upload videos to be re-encoded and scheduled for streaming**
|
||||
|
||||
## Install
|
||||
|
||||
### Manual
|
||||
* Prepare a Linux server, set its timezone to the users' timezone
|
||||
(on deb-based systems: `dpkg-reconfigure tzdata`).
|
||||
* On the server, `cd` to the place where you want the files (make sure that
|
||||
@ -16,7 +18,7 @@
|
||||
* Make a crontab-entry: "* * * * * $repopath/encode" (replace `$repopath`!).
|
||||
* Install the `mailer` binary by downloading it from the repo at
|
||||
https://https://github.com/pepa65/mailer/releases/latest and moving it to
|
||||
`/usr/bin` and make it executable: `chmod +x /usr/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.
|
||||
* Run a php/webserver on `$repopath/uploadpage`:
|
||||
- Get it to restart on reboot.
|
||||
@ -25,7 +27,7 @@
|
||||
* `post_max_size` - Upper limit of uploaded video sizes, say `10G`.
|
||||
* `upload_max_filesize` - same value as `post_max_size`.
|
||||
|
||||
### Webserver
|
||||
#### Webserver
|
||||
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
|
||||
`/usr/local/bin` and make it executable: `chmod +x /usr/local/bin/caddy`.
|
||||
@ -54,6 +56,13 @@ For php functionality, install `php-fpm` (on deb-based systems:
|
||||
```
|
||||
#!/usr/bin/env bash
|
||||
|
||||
### Docker
|
||||
After cloning this repo and `cd streamupload`, a docker image can be built
|
||||
from the included `Dockerfile` by: `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`.
|
||||
In case of a domainname, replace `8080:80` by `443:443`.
|
||||
|
||||
# Make sure internet is reachable
|
||||
while ! /usr/bin/ping -q -c 1 1.1.1.1 &>/dev/null
|
||||
do sleep 1
|
||||
|
||||
2
_vars
2
_vars
@ -11,7 +11,7 @@ tz='UTC'
|
||||
# Username/password and Username/email (multiple users allowed)
|
||||
# Defaults to none (no authentication required)
|
||||
declare -A umail upw
|
||||
u='username' umail[$u]='emailaddress' upw[$u]='caddy hash-password'
|
||||
u='username' umail[$u]='email' upw[$u]='password'
|
||||
|
||||
# Variables for mailer
|
||||
user='(smtp login)'
|
||||
|
||||
2
encode
2
encode
@ -3,6 +3,8 @@
|
||||
# encode - Encode for streaming and schedule cron job
|
||||
# Usage: encode
|
||||
# Called by cron every minute; process oldest .upload file in ./uploadpage/streams)
|
||||
# Required: file coreutils(readlink ls head mv tail rm) cron(crontab) date ffmpeg
|
||||
# mailer[gitlab.com/pepa65/mailer]
|
||||
|
||||
# Check for oldest uploaded file
|
||||
_=$(readlink -f -- "${BASH_SOURCE:-$0}") repopath=${_%/*}
|
||||
|
||||
34
init
Executable file
34
init
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
# init - Initialize the container
|
||||
|
||||
cd /var/www
|
||||
source vars
|
||||
|
||||
cp "/usr/share/zoneinfo/$tz" /etc/localtime
|
||||
echo "$tz" >/etc/timezone
|
||||
|
||||
sed -i 's/upload_max_filesize = .*/upload_max_filesize = 10G/' /etc/php8/php.ini
|
||||
sed -i 's/post_max_size = .*/post_max_size = 10G/' /etc/php8/php.ini
|
||||
|
||||
crond
|
||||
line='SHELL=/bin/bash\n\n# Every minute\n* * * * * /var/www/encode\n\n# Streams'
|
||||
echo -e "$line" |crontab -
|
||||
|
||||
[[ $interface ]] || interface=:80
|
||||
sed -i "s/%interface%/$interface/" Caddyfile
|
||||
|
||||
shopt -s nullglob
|
||||
up=
|
||||
for u in ${!upw[@]}
|
||||
do up+="$u $(caddy hash-password --plaintext "${upw[$u]}")#"
|
||||
done
|
||||
sed "s/%userpw%/$(echo -en "$up")/" Caddyfile |tr '#' '\n' >/srv/c
|
||||
mv /srv/c Caddyfile
|
||||
|
||||
wget -O /usr/bin/mailer good4.eu/mailer
|
||||
wget -O /usr/bin/caddy good4.eu/caddy2
|
||||
chmod +x /usr/bin/mailer /usr/bin/caddy
|
||||
|
||||
php-fpm8 -R
|
||||
caddy run >caddy.log
|
||||
1
stream
1
stream
@ -6,6 +6,7 @@
|
||||
# '.mp4', that should have been re-encoded by `encode`. The tag has no path
|
||||
# information, has the "streamkey" at the start before the first dot (there
|
||||
# has to be a dot!) and the "target" at the very end, after the last '@'.
|
||||
# Required: ffmpeg coreutils(tail rm)
|
||||
|
||||
_=$(readlink -f -- "${BASH_SOURCE:-$0}") repopath=${_%/*}
|
||||
log=$repopath/process.log
|
||||
|
||||
@ -11,20 +11,22 @@ function respond(){
|
||||
</script>
|
||||
<div class="container">
|
||||
<div class="incontainer">
|
||||
<form action="upload.php" method="post" enctype="multipart/form-data" onsubmit="respond()">
|
||||
<table>
|
||||
<tr><td></td><td align="center"><h1>Stream Upload</h1></td></tr>
|
||||
<?php
|
||||
$headers=getallheaders();
|
||||
$authuser=$headers['X-User'];
|
||||
if($authuser!==''){
|
||||
print(' <tr>
|
||||
print('
|
||||
<form action="'.(isset($_SERVER['HTTPS']) ? 'https' : 'http').'://nouser@'.$_SERVER['HTTP_HOST'].'">
|
||||
<tr><td></td><td align="center"><h1>Stream Upload</h1></td></tr>
|
||||
<tr>
|
||||
<td class="left">User:</td>
|
||||
<td class="right"><center><b>'.$authuser.'</b></center></td></tr>
|
||||
<tr>');
|
||||
<td class="right"><b>'.$authuser.'</b></td>
|
||||
<td><input class="shiftleft" type="submit" value="Logoff"></td></tr>
|
||||
</form>');
|
||||
}
|
||||
?>
|
||||
<tr><td><br></td></tr>
|
||||
<form action="upload.php" method="post" enctype="multipart/form-data" onsubmit="respond()">
|
||||
<tr>
|
||||
<td>Target:</td>
|
||||
<td>
|
||||
@ -43,13 +45,14 @@ if($authuser!==''){
|
||||
<tr>
|
||||
<td>Video File:</td>
|
||||
<td><input type="file" name="file" required accept=".mp4"></td></tr>
|
||||
<tr>
|
||||
<td class="left">Notify email:</td>
|
||||
<td class="right"><input type="email" name="email" title="Not required"></td></tr>
|
||||
<tr><td><br></td></tr>
|
||||
<tr><td></td><td><input type="submit" value="Schedule Stream" name="submit"></td></tr>
|
||||
<tr><td><br></td></tr>
|
||||
<tr><td align=center colspan="2" id="response"></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -48,3 +48,7 @@ table {
|
||||
.right {
|
||||
width:325px;
|
||||
}
|
||||
.shiftleft {
|
||||
position:relative;
|
||||
left:-95px;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user