Skip to content

Commit e7c9e83

Browse files
committed
add post install script to set frankenphp able to bind to port 80 for non-root users
1 parent e6510bc commit e7c9e83

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

build-packages.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ fi
5959
mkdir -p package/etc/php.d
6060
mkdir -p package/modules
6161

62-
iteration="1"
6362
cd dist
6463
glibc_version=$(ldd -v "$bin" | awk '/GLIBC_/ {gsub(/[()]/, "", $2); print $2}' | grep -v GLIBC_PRIVATE | sort -V | tail -n1)
6564
cxxabi_version=$(strings "$bin" | grep -oP 'CXXABI_\d+\.\d+(\.\d+)?' | sort -V | tail -n1)
@@ -69,6 +68,7 @@ fpm -s dir -t rpm -n frankenphp -v "${FRANKENPHP_VERSION}" \
6968
--config-files /etc/frankenphp/php.ini \
7069
--depends "libc.so.6(${glibc_version})(64bit)" \
7170
--depends "libstdc++.so.6(${cxxabi_version})(64bit)" \
71+
--after-install ../package/after_install.sh \
7272
"$bin=/usr/bin/frankenphp" \
7373
"../package/frankenphp.service=/usr/lib/systemd/system/frankenphp.service" \
7474
"../package/Caddyfile=/etc/frankenphp/Caddyfile" \
@@ -77,8 +77,22 @@ fpm -s dir -t rpm -n frankenphp -v "${FRANKENPHP_VERSION}" \
7777
"../package/content/=/usr/share/frankenphp" \
7878
"../package/modules/=/usr/lib/frankenphp/modules"
7979

80-
rpm_file="frankenphp-${FRANKENPHP_VERSION}-${iteration}.${arch}.rpm"
80+
glibc_version=$(ldd -v "$bin" | awk '/GLIBC_/ {gsub(/[()]/, "", $2); print $2}' | grep -v GLIBC_PRIVATE | sed 's/GLIBC_//' | sort -V | tail -n1)
81+
cxxabi_version=$(strings "$bin" | grep -oP 'CXXABI_\d+\.\d+(\.\d+)?' | sed 's/CXXABI_//' | sort -V | tail -n1)
8182

82-
fpm -s rpm -t deb "$rpm_file"
83+
fpm -s dir -t deb -n frankenphp -v "${FRANKENPHP_VERSION}" \
84+
--config-files /etc/frankenphp/Caddyfile \
85+
--config-files /etc/frankenphp/php.ini \
86+
--depends "libc6 (>= ${glibc_version})" \
87+
--depends "libstdc++6 (>= ${cxxabi_version})" \
88+
--deb-suggests libcap2-bin \
89+
--after-install ../package/after_install.sh \
90+
"$bin=/usr/bin/frankenphp" \
91+
"../package/frankenphp.service=/lib/systemd/system/frankenphp.service" \
92+
"../package/Caddyfile=/etc/frankenphp/Caddyfile" \
93+
"../package/etc/php.ini=/etc/frankenphp/php.ini" \
94+
"../package/etc/php.d/=/etc/frankenphp/php.d" \
95+
"../package/content/=/usr/share/frankenphp" \
96+
"../package/modules/=/usr/lib/frankenphp/modules"
8397

8498
cd ..

package/after_install.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
if command -v setcap >/dev/null 2>&1; then
4+
setcap 'cap_net_bind_service=+ep' /usr/bin/frankenphp || echo "Warning: failed to set capabilities on frankenphp"
5+
else
6+
if [ -f /etc/debian_version ]; then
7+
echo "Warning: setcap not found. Install it with: sudo apt install libcap2-bin"
8+
elif [ -f /etc/redhat-release ]; then
9+
echo "Warning: setcap not found. Install it with: sudo yum install libcap"
10+
else
11+
echo "Warning: setcap not found. Install the appropriate libcap package for your system."
12+
fi
13+
fi

0 commit comments

Comments
 (0)