This commit is contained in:
john smith 2023-02-03 11:33:03 +02:00 committed by ed
parent 4de61defc9
commit c4191de2e7
3 changed files with 171 additions and 32 deletions

View file

@ -1,39 +1,47 @@
# Maintainer: John Smith <devnull@need.moe>
pkgname=copyparty-git
_pkgname=copyparty
pkgver=3866e6a
# Maintainer: icxes <dev.null@need.moe>
pkgname=copyparty
pkgver="1.6.3"
pkgrel=1
pkgdesc="Portable file sharing hub"
arch=("any")
url="https://github.com/9001/copyparty"
url="https://github.com/9001/${pkgname}"
license=('MIT')
depends=("python3")
makedepends=("git" "curl" "python3")
optdepends=("python-mutagen" "python-pillow" "python-pyvips" "ffmpeg" "python-pyftpdlib" "python-pyopenssl" "impacket"==0.10.0)
conflicts=("copyparty")
source=("git+https://github.com/9001/${_pkgname}.git")
sha256sums=("SKIP")
prepare() {
cd "${srcdir}/${_pkgname}"
cp "contrib/systemd/${_pkgname}.service" "contrib/package/arch/${_pkgname}.service"
sed -i 's/\/usr\/local\/bin\/copyparty-sfx.py/\/usr\/bin\/copyparty/' "contrib/package/arch/${_pkgname}.service"
}
pkgver() {
cd "${srcdir}/${_pkgname}"
git rev-parse --short HEAD
}
build() {
cd "${srcdir}/${_pkgname}/scripts"
./make-sfx.sh gz
}
depends=("python3" "python-jinja")
optdepends=("ffmpeg: thumbnails for videos, images (slower) and audio, music tags"
"python-mutagen: music tags (alternative)"
"python-pillow: thumbnails for images"
"python-pyvips: thumbnails for images (higher quality, faster, uses more ram)"
"libkeyfinder-git: detection of musical keys"
"qm-vamp-plugins: BPM detection"
"python-pyftpdlib: ftp functionality"
"python-pyopenssl: sftp functionality"
"impacket: smb support (bad idea)"
"python-impacket-git: smb support (bad idea)"
)
source=("${url}/releases/download/v${pkgver}/${pkgname}-sfx.py"
"${pkgname}.conf"
"${pkgname}.service"
"https://raw.githubusercontent.com/9001/${pkgname}/hovudstraum/LICENSE"
)
backup=("etc/${pkgname}.conf" )
sha256sums=("56c02d43a0e6c18d71295268674454b4c6f5ff2ccef30fb95f81d58d2d1e260d"
"c19df8d0b6cd32d0b37c68e4f170d8634644e7fe7d99c9030cc6f20622ef95b5"
"2ab7598e5150facb4f63bf5433b25b60874603f7a408bb37b24186c54a331b37"
"cb2ce3d6277bf2f5a82ecf336cc44963bc6490bcf496ffbd75fc9e21abaa75f3"
)
package() {
cd "${srcdir}/${_pkgname}"
install -Dm755 "dist/copyparty-sfx-gz.py" "${pkgdir}/usr/bin/${_pkgname}"
install -Dm644 "contrib/package/arch/${_pkgname}.service" "${pkgdir}/usr/lib/systemd/system/${_pkgname}.service"
install -Dm644 "LICENSE" "${pkgdir}/usr/share/licenses/${_pkgname}/LICENSE"
echo "If this is your first time installing copyparty, you'll want to copy the systemd service file to /etc/systemd/system and edit it to suit your needs"
cd "${srcdir}/"
mkdir -p /etc/${pkgname}.d
install -Dm755 "${pkgname}-sfx.py" "${pkgdir}/usr/bin/${pkgname}"
install -Dm644 "${pkgname}.conf" "${pkgdir}/etc/${pkgname}.conf"
install -Dm644 "${pkgname}.service" "${pkgdir}/usr/lib/systemd/system/${pkgname}.service"
install -Dm644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
echo "------------"
echo "If this is your first time installing ${pkgname}, you'll want to copy the systemd service file"
echo "from /usr/lib/systemd/system/${pkgname}.service to /etc/systemd/system and edit /etc/${pkgname}.conf"
echo "to suit your needs"
echo "------------"
}

View file

@ -0,0 +1,70 @@
## load /etc/copyparty.d/*.conf
## paths are relative from the location of each included file unless the path is absolute, for example % /etc/copyparty.d, max include depth is 64
% copyparty.d
## append some arguments to the commandline;
## the first space in a line counts as a separator,
## any additional spaces are part of the value
#-e2dsa
#-e2ts
#-i 127.0.0.1
## create users:
## u username:password
#u ed:password
#u user2:password2
## leave a blank line between volumes
## (and also between users and volumes)
## create a volume:
## share "." (the current directory)
## as "/" (the webroot) for the following users:
## "r" grants read-access for anyone
## "rw ed" grants read-write to ed
#.
#/
#r
#rw ed
## custom permissions for the "priv" folder:
## user "user2" can only see/read the contents
## user "ed" gets read-write access
#./priv
#/priv
#r user2
#rw ed
## this does the same thing,
## and will cause an error on startup since /priv is already taken:
#./priv
#/priv
#r ed user2
#w ed
## share /home/ed/Music/ as /music and let anyone read it
## (this will replace any folder called "music" in the webroot)
#/home/ed/Music
#/music
#r
## and a folder where anyone can upload
## but nobody can see the contents
## and set the e2d flag to enable the uploads database
## and set the nodupe flag to reject duplicate uploads
#/home/ed/inc
#/dump
#w
#c e2d
#c nodupe
## this entire config file can be replaced with these arguments (in the systemd file or the copyparty command):
## -u ed:password -u user2:password2 -v .::r:a,ed -v priv:priv:r,user2:rw,ed -v /home/ed/Music:music:r -v /home/ed/inc:dump:w:c,e2d,nodupe
## but note that the config file always wins in case of conflicts

View file

@ -0,0 +1,61 @@
# this will start `/usr/local/bin/copyparty-sfx.py`
# and share '/mnt' with anonymous read+write
#
# installation:
# cp -pv copyparty.service /etc/systemd/system
# restorecon -vr /etc/systemd/system/copyparty.service
# firewall-cmd --permanent --add-port={80,443,3923}/tcp # --zone=libvirt
# firewall-cmd --reload
# systemctl daemon-reload && systemctl enable --now copyparty
#
# you may want to:
# change "User=cpp" and "/home/cpp/" to another user
# remove the nft lines to only listen on port 3923
# and in the ExecStart= line:
# change '/usr/bin/python3' to another interpreter
# change '/mnt::rw' to another location or permission-set
# add '-q' to disable logging on busy servers
# add '-i 127.0.0.1' to only allow local connections
# add '-e2dsa' to enable filesystem scanning + indexing
# add '-e2ts' to enable metadata indexing
#
# with `Type=notify`, copyparty will signal systemd when it is ready to
# accept connections; correctly delaying units depending on copyparty.
# But note that journalctl will get the timestamps wrong due to
# python disabling line-buffering, so messages are out-of-order:
# https://user-images.githubusercontent.com/241032/126040249-cb535cc7-c599-4931-a796-a5d9af691bad.png
#
# unless you add -q to disable logging, you may want to remove the
# following line to allow buffering (slightly better performance):
# Environment=PYTHONUNBUFFERED=x
#
# keep ExecStartPre before ExecStart, at least on rhel8
[Unit]
Description=copyparty file server
[Service]
Type=notify
SyslogIdentifier=copyparty
Environment=PYTHONUNBUFFERED=x
ExecReload=/bin/kill -s USR1 $MAINPID
# user to run as + where the TLS certificate is (if any)
User=cpp
Environment=XDG_CONFIG_HOME=/home/cpp/.config
# setup forwarding from ports 80 and 443 to port 3923
ExecStartPre=+/bin/bash -c 'nft -n -a list table nat | awk "/ to :3923 /{print\$NF}" | xargs -rL1 nft delete rule nat prerouting handle; true'
ExecStartPre=+nft add table ip nat
ExecStartPre=+nft -- add chain ip nat prerouting { type nat hook prerouting priority -100 \; }
ExecStartPre=+nft add rule ip nat prerouting tcp dport 80 redirect to :3923
ExecStartPre=+nft add rule ip nat prerouting tcp dport 443 redirect to :3923
# stop systemd-tmpfiles-clean.timer from deleting copyparty while it's running
ExecStartPre=+/bin/bash -c 'mkdir -p /run/tmpfiles.d/ && echo "x /tmp/pe-copyparty*" > /run/tmpfiles.d/copyparty.conf'
# copyparty settings
ExecStart=/usr/bin/python3 /usr/bin/copyparty -c /etc/copyparty.conf
[Install]
WantedBy=multi-user.target