8 Commits

Author SHA1 Message Date
0f850bc326 fix: place commands in if blocks
All checks were successful
Continuous Integration / lint_n_build (push) Successful in 29s
Continuous Delivery / build_n_upload (push) Successful in 29s
2026-06-25 19:13:36 +02:00
55122123c2 feat: add occ alias 2026-06-25 18:43:34 +02:00
c0920dd46f fix: add php-pgsql 2026-06-25 18:37:28 +02:00
4939f18c26 fix: replace php config var in config file 2026-06-25 16:53:44 +02:00
b4f72fa1c5 fix: add php-posix 2026-06-25 16:28:19 +02:00
edbfafd951 fix: use preun instead of postun
All checks were successful
Continuous Integration / lint_n_build (push) Successful in 35s
Continuous Delivery / build_n_upload (push) Successful in 36s
2026-06-25 14:44:51 +02:00
37a5cf94b2 fix: some bugs in rpm spec 2026-06-25 14:37:25 +02:00
d2f9e531ab feat: add php-fpm config 2026-06-25 13:01:17 +02:00
4 changed files with 57 additions and 34 deletions

View File

@@ -73,9 +73,10 @@ install: ## Install files into rpm dest (requires env var DESTDIR)
printf "[CRITICAL] Missing env var DESTDIR\n[CRITICAL] This command is designed to be called by rpmbuild only!\n" 1>&2; \
exit 1; \
fi
install --mode=755 --directory $(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d $(DESTDIR)$(RPM_SYSCONFDIR)/nextcloud
install --mode=755 --directory $(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d $(DESTDIR)$(RPM_SYSCONFDIR)/nextcloud $(DESTDIR)$(RPM_SYSCONFDIR)/php-fpm.d
install --mode=644 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d files/nginx/cloud.netoik.io.conf
install --mode=640 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/nextcloud files/nextcloud/config.php
install --mode=640 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/nextcloud files/nextcloud/config.php.tpl
install --mode=644 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/php-fpm.d files/php-fpm/nextcloud.conf
.PHONY: upload
upload: ## Upload rpm package to Gitea repository (requires env var PKG_TOKEN)

View File

@@ -1,8 +1,8 @@
<?php
$CONFIG = array (
'instanceid' => '',
'passwordsalt' => '',
'secret' => '',
'instanceid' => '$INSTANCE_ID',
'passwordsalt' => '$PASSWORD_SALT',
'secret' => '$SECRET',
'trusted_domains' => array (
0 => 'cloud.netoik.io',
),
@@ -26,7 +26,6 @@ $CONFIG = array (
),
'default_phone_region' => 'FR',
'maintenance' => false,
'maintenance_window_start' => 1,
'log_type' => 'systemd',
'loglevel' => 2,
'config_is_read_only' => true,

View File

@@ -0,0 +1,16 @@
; Configure here a php-fpm pool
; See manual at: https://www.php.net/manual/en/install.fpm.configuration.php
[nextcloud]
user = nextcloud
group = nextcloud
listen = /run/php-fpm/nextcloud.sock
listen.owner = nextcloud
listen.group = nextcloud
listen.mode = 0777
pm = dynamic
pm.max_children = 50
pm.min_spare_servers = 5
pm.max_spare_servers = 35

View File

@@ -10,7 +10,7 @@ URL: %(make url)
Source0: %(make source0)
Buildarch: %(make arch)
BuildRequires: make
Requires: netoik-rp netoik-db netoik-cache php php-cli php-gd php-mbstring php-intl php-pecl-apcu php-mysqlnd php-opcache php-json php-zip php-redis php-imagick php-fpm
Requires: netoik-rp netoik-db netoik-cache php php-cli php-gd php-mbstring php-intl php-pecl-apcu php-mysqlnd php-opcache php-json php-zip php-redis php-imagick php-fpm php-posix php-pgsql
%description
Install the cloud server called Nextcloud.
@@ -27,29 +27,22 @@ set -xe
# Create nextcloud user
if ! id nextcloud >/dev/null 2>&1; then
useradd --no-create-home --shell $SHELL --system nextcloud
useradd --base-dir %{_sharedstatedir} --create-home --shell $SHELL --system nextcloud
runuser --user=nextcloud -- mkdir --parents %{_sharedstatedir}/nextcloud/data
runuser --user=nextcloud -- printf 'alias occ="php /var/www/nextcloud/occ"\n' > %{_sharedstatedir}/nextcloud/.bash_profile
usermod --groups postgres,valkey --append nextcloud
fi
# Add nextcloud to postgres and valkey groups
usermod --groups postgres,valkey --append nextcloud
# Download nextcloud latest release
wget --output-document %{_tmppath}/nextcloud-latest.tar.bz2 https://download.nextcloud.com/server/releases/latest.tar.bz2
wget --output-document %{_tmppath}/nextcloud-latest.tar.bz2.asc https://download.nextcloud.com/server/releases/latest.tar.bz2.asc
wget --output-document %{_tmppath}/nextcloud.asc https://nextcloud.com/nextcloud.asc
gpg --import %{_tmppath}/nextcloud.asc
gpg --verify %{_tmppath}/nextcloud-latest.tar.bz2.asc %{_tmppath}/nextcloud-latest.tar.bz2
tar --extract --file=%{_tmppath}/nextcloud-latest.tar.bz2 --directory=%{_sharedstatedir}
# Change rights an owner
chown --recursive nextcloud:nextcloud %{_sharedstatedir}/nextcloud
chmod 700 %{_sharedstatedir}/nextcloud
# Create data dir
runuser --user=nextcloud -- mkdir --parents %{_sharedstatedir}/nextcloud/data
# Add link to config
runuser --user=nextcloud -- ln --symbolic --force %{_sysconfdir}/nextcloud/config.php %{_sharedstatedir}/nextcloud/config/config.php
# Create config file
if ! -f %{_sysconfdir}/nextcloud/config.php; then
export INSTANCE_ID=$(openssl rand -hex 16)
export PASSWORD_SALT=$(openssl rand -hex 16)
export SECRET=$(openssl rand -hex 16)
export CONFIG='$CONFIG'
envsubst < %{_sysconfdir}/nextcloud/config.php.tpl > %{_sysconfdir}/nextcloud/config.php
chown root:nextcloud %{_sysconfdir}/nextcloud/config.php
chmod 640 %{_sysconfdir}/nextcloud/config.php
fi
# Create postgres user and db
if ! runuser --user=postgres -- psql --quiet --tuples-only --command='\du' | grep --quiet nextcloud; then
@@ -59,21 +52,31 @@ if ! runuser --user=postgres -- psql --quiet --tuples-only --command='\l' | grep
runuser --user=postgres -- createdb --owner=nextcloud nextcloud
fi
# Download nextcloud latest release
if ! -d /var/www/nextcloud; then
wget --output-document %{_tmppath}/nextcloud-latest.tar.bz2 https://download.nextcloud.com/server/releases/latest.tar.bz2
wget --output-document %{_tmppath}/nextcloud-latest.tar.bz2.asc https://download.nextcloud.com/server/releases/latest.tar.bz2.asc
wget --output-document %{_tmppath}/nextcloud.asc https://nextcloud.com/nextcloud.asc
gpg --import %{_tmppath}/nextcloud.asc
gpg --verify %{_tmppath}/nextcloud-latest.tar.bz2.asc %{_tmppath}/nextcloud-latest.tar.bz2
tar --extract --file=%{_tmppath}/nextcloud-latest.tar.bz2 --directory=/var/www
chown --recursive nextcloud:nextcloud /var/www/nextcloud
chmod 755 /var/www/nextcloud
runuser --user=nextcloud -- ln --symbolic --force %{_sysconfdir}/nextcloud/config.php /var/www/nextcloud/config/config.php
fi
# Restart services
systemctl daemon-reload
systemctl reenable nginx.service php-fpm.service
systemctl restart nginx.service php-fpm.service
%postun
%preun
# Display commands and exit on error
set -xe
# Stop service
systemctl stop php-fpm
# If uninstalling, then delete user and db
if [ $1 == 0 ]; then
if id nextcloud; then
if id nextcloud >/dev/null 2>&1; then
userdel --force --remove nextcloud
fi
if runuser --user=postgres -- psql --quiet --tuples-only --command='\l' | grep --quiet nextcloud; then
@@ -82,13 +85,17 @@ if [ $1 == 0 ]; then
if runuser --user=postgres -- psql --quiet --tuples-only --command='\du' | grep --quiet nextcloud; then
runuser --user=postgres -- dropuser nextcloud
fi
rm --force /etc/nextcloud/config.php
rm --recursive --force /var/www/nextcloud
fi
%files
%dir %attr(755, root, root) %{_sysconfdir}/nextcloud
%attr(640, root, -) %{_sysconfdir}/nextcloud/config.php
%attr(644, root, root) %{_sysconfdir}/nextcloud/config.php.tpl
%attr(644, root, root) %{_sysconfdir}/nginx/conf.d/cloud.netoik.io.conf
%attr(644, root, root) %{_sysconfdir}/php-fpm.d/nextcloud.conf
%changelog
%autochangelog