slackbuilds/n/nextcloud-server/SlackBuild

129 lines
3.4 KiB
Text
Raw Normal View History

2021-06-15 10:26:26 +02:00
#!/bin/bash
CWD=$(pwd)
PRGNAM=$(basename $CWD)
RELEASE_TYPE=${RELEASE_TYPE:-releases}
2017-11-06 12:20:58 +01:00
VERSION=${VERSION:-stable}
ARCH="noarch" # hardcode ARCH
BUILD=${BUILD:-1}
2020-06-25 11:23:11 +02:00
TAG=${TAG:-gwh}
VHOST=${VHOST:-vhosts/$PRGNAM}
VHOSTROOT=/var/www/${VHOST}
DOCROOT=${DOCROOT:-/var/www/${VHOST}/htdocs}
2017-11-08 15:04:27 +01:00
DATAROOT=${DATAROOT:-/home/nextcloud/data}
PHPUSER=${PHPUSER:-apache}
PHPGROUP=${PHPGROUP:-apache}
TMP=${TMP:-/tmp/$TAG}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
set -eu
rm -rf $PKG
mkdir -p $TMP $OUTPUT $PKG/$VHOSTROOT
2017-11-06 12:20:58 +01:00
case $VERSION in
"stable")
wget -c https://download.nextcloud.com/server/${RELEASE_TYPE}/latest.tar.bz2 -O $CWD/nextcloud.tar.bz2
2017-12-15 10:18:14 +01:00
;;
"master")
wget -c https://download.nextcloud.com/server/daily/latest-master.tar.bz2 -O $CWD/nextcloud.tar.bz2
2017-11-06 12:17:11 +01:00
;;
*)
[ ! -e $CWD/nextcloud-$VERSION.tar.bz2 ] && wget -c https://download.nextcloud.com/server/${RELEASE_TYPE}/nextcloud-$VERSION.tar.bz2 -O $CWD/nextcloud.tar.bz2
2017-11-06 12:17:11 +01:00
;;
esac
2017-12-15 10:18:14 +01:00
cd $PKG/$VHOSTROOT
tar xvf $CWD/nextcloud.tar.bz2
rm $CWD/nextcloud.tar.bz2
mv nextcloud htdocs
VERSION=$(grep "Version =" htdocs/version.php | grep -o "[0-9,]*" | tr , .)
cp $CWD/nextcloud-news-updater.rb .
chmod +x nextcloud-news-updater.rb
cd $PKG/$VHOSTROOT/htdocs
chown -R root:root .
find . \
\( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 -o -perm 755 \) \
-exec chmod 750 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 -o -perm 644 \) \
-exec chmod 640 {} \;
mkdir -p $PKG/usr/doc/$PRGNAM
for i in AUTHORS CONTRIBUTING.md COPYING* README*; do
[ -e $i ] && cp -a $i $PKG/usr/doc/$PRGNAM
done
# Change ownership and perms and create a link.
chown -R $PHPUSER:$PHPGROUP $PKG/$DOCROOT
chmod 0750 $PKG/$DOCROOT
chmod 0770 $PKG/$DOCROOT/{config,apps}
2017-11-08 15:04:27 +01:00
mkdir -p $PKG/etc/logrotate.d/
cat <<EOF > $PKG/etc/logrotate.d/nextcloud.new
$DATAROOT/nextcloud.log {
monthly
rotate 6
delaycompress
compress
notifempty
missingok
}
EOF
mkdir -p $PKG/install
cat <<EOF > $PKG/install/doinst.sh
2021-06-15 10:26:26 +02:00
#!/bin/bash
2017-11-08 15:04:27 +01:00
config() {
NEW="\$1"
OLD="\$(dirname \$NEW)/\$(basename \$NEW .new)"
# If there's no config file by that name, mv it over:
if [ ! -r \$OLD ]; then
mv \$NEW \$OLD
elif [ "\$(cat \$OLD | md5sum)" = "\$(cat \$NEW | md5sum)" ]; then
# toss the redundant copy
rm \$NEW
fi
# Otherwise, we leave the .new copy for the admin to consider...
}
config etc/logrotate.d/nextcloud.new
chown -R $PHPUSER:$PHPGROUP $DOCROOT/apps
grep -q "/var/www/${VHOST}/htdocs/cron.php" /var/spool/cron/crontabs/apache || echo "*/15 * * * * php -f /var/www/${VHOST}/htdocs/cron.php" >> /var/spool/cron/crontabs/apache
grep -q "/var/www/${VHOST}/nextcloud-news-updater.rb" /var/spool/cron/crontabs/apache || echo "*/15 * * * * php -f /var/www/${VHOST}/nextcloud-news-updater.rb" >> /var/spool/cron/crontabs/apache
echo "Upgrading database and applications"
( cd /var/www/${VHOST}/htdocs/
sudo -u $PHPUSER php ./occ upgrade --quiet --no-interaction
)
echo "Post-installation process completed"
EOF
cat <<EOF > $PKG/install/slack-desc
$PRGNAM: $PRGNAM (self-hosted cloud platform)
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM: http://nextcloud.org
$PRGNAM:
EOF
cd $PKG
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
2023-08-16 12:23:26 +02:00
/sbin/makepkg --linkadd y --chown n --prepend $OUTPUT/$PRGNAM-$(echo $VERSION | tr - _)-$ARCH-$BUILD$TAG.${PKGTYPE:-txz}