Compare commits

...

2 commits

Author SHA1 Message Date
leafee98 f6e18a796d update build script, add --no-upload to build.sh
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-12-13 16:50:09 +08:00
leafee98 0345418039 install dendrite to /usr/, add service and postinst 2023-12-13 16:37:27 +08:00
5 changed files with 53 additions and 16 deletions

View file

@ -18,7 +18,7 @@ steps:
--package-arch amd64
--apt-base $APT_BASE
"
--upload-to-webdav "$WEBDAV_UPLOAD_TARGET"
--webdav-url "$WEBDAV_UPLOAD_TARGET"
--webdav-user "$WEBDAV_USER"
--webdav-pass "$WEBDAV_PASS"
--package-dir packages/bin

View file

@ -10,6 +10,7 @@ maintainer="Leafee98 <me@leafee98.com>"
source=(
"dendrite::git+https://github.com/matrix-org/dendrite.git#tag=v${pkgver}"
"dendrite.service::materials/dendrite.service"
)
function build {
@ -22,8 +23,23 @@ function build {
function package {
for f in ${srcdir}/dendrite/bin/*
do
install -Dm755 -t "${pkgdir}/usr/local/lib/dendrite/" "$f";
install -Dm755 -t "${pkgdir}/usr/lib/dendrite/" "$f";
done
install -Dm644 "${srcdir}/dendrite/dendrite-sample.yaml" "${pkgdir}/etc/dendrite/dendrite-sample.yaml"
install -Dm755 "${srcdir}/dendrite.service" "${pkgdir}/usr/lib/systemd/system/dendrite.service"
}
function debian_postinst {
cat << 'EOF'
#!/usr/bin/env bash
adduser --system dendrite
systemctl daemon-reload
if systemctl is-active --quiet dendrite.service ; then
systemctl restart dendrite.service
fi
EOF
}

View file

@ -0,0 +1,18 @@
[Unit]
Description=matrix home server
After=network.target
After=postgresql.service
After=nats-server.service
[Service]
Type=simple
User=dendrite
Group=dendrite
ExecStart=/usr/lib/dendrite/dendrite -config /etc/dendrite/dendrite.yaml -http-bind-address 127.0.0.1:8008
Restart=on-failure
RestartSec=5s
LimitNOFILE=65535
MemoryMax=3072M
[Install]
WantedBy=multi-user.target

View file

@ -14,16 +14,17 @@ function msg_warn {
function usage {
echo "$_PROGRAM_NAME:"
echo " --package <dir-name> add a dir to build, can use multi times"
echo " --package-dir <dir> all dir in this directory is a package,"
echo " --package <dir-name> Add a dir to build, can be used multi times"
echo " --package-dir <dir> All dir in this directory is a package,"
echo " can use multi times"
echo " --makedeb-path <path> specify the path of makedeb"
echo " --upload-to-webdav https://webdav_host/path/dir"
echo " upload built file to a webdav server"
echo " --webdav-user <username> username of webdav server (if required)"
echo " --webdav-pass <password> password of webdav server (if required)"
echo " --makedeb-path <path> Specify the path of makedeb"
echo " --no-upload Don't upload built packages to webdav"
echo " --webdav-url https://webdav_host/path/dir"
echo " Upload built file to a webdav server"
echo " --webdav-user <username> Username of webdav server (if required)"
echo " --webdav-pass <password> Password of webdav server (if required)"
echo ' --package-exists-hook "/path/to/hook --args {}"'
echo " this program will run the hook to check"
echo " This program will run the hook to check"
echo " if specific file already built, the {} will"
echo " be replaced with the final package name,"
echo " exit with 0 means package exists"
@ -68,7 +69,8 @@ _DELIMITER="================================================================"
_PROGRAM_NAME="$0"
_PACKGES_TO_BUILD=()
MAKEDEB_PATH=""
UPLOAD_TO_WEBDAV=""
UPLOAD_TO_WEBDAV=1
WEBDAV_URL=""
WEBDAV_USER=""
WEBDAV_PASS=""
PACKAGE_DIR=()
@ -80,7 +82,8 @@ while (( "$#" >= 1 )); do
--package) _PACKGES_TO_BUILD+=("$2") ; shift ;;
--package-dir) PACKAGE_DIR+=("$2") ; shift ;;
--makedeb-path) MAKEDEB_PATH="$2" ; shift ;;
--upload-to-webdav) UPLOAD_TO_WEBDAV="$2" ; shift ;;
--no-upload) UPLOAD_TO_WEBDAV=0 ;;
--webdav-url) WEBDAV_URL="$2" ; shift ;;
--webdav-user) WEBDAV_USER="$2" ; shift ;;
--webdav-pass) WEBDAV_PASS="$2" ; shift ;;
--package-exists-hook)
@ -182,9 +185,9 @@ for package in "${_PACKGES_TO_BUILD[@]}" ; do
exit 4
fi
if [[ -n "${UPLOAD_TO_WEBDAV}" ]] ; then
msg_info "Uploading $package_name to $UPLOAD_TO_WEBDAV"
upload_to_webdav "$package_name" "$UPLOAD_TO_WEBDAV" "$WEBDAV_USER" "$WEBDAV_PASS"
if [[ -n "${WEBDAV_URL}" ]] && (( UPLOAD_TO_WEBDAV )) ; then
msg_info "Uploading $package_name to $WEBDAV_URL"
upload_to_webdav "$package_name" "$WEBDAV_URL" "$WEBDAV_USER" "$WEBDAV_PASS"
fi
) || true

View file

@ -18,7 +18,7 @@ APT_BASE=https://dufs.leafee98.com/apt
--package-dir packages/normal \
-- \
-f
# --upload-to-webdav "$WEBDAV_UPLOAD_TARGET" \
# --webdav-url "$WEBDAV_UPLOAD_TARGET" \
# --webdav-user "$WEBDAV_USER" \
# --webdav-pass "$WEBDAV_PASS" \